Skip to content

Commit

Permalink
Fixed report generator (finos#834)
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo Hills <[email protected]>
  • Loading branch information
SimonCockx and hugohills-regnosys authored Sep 11, 2024
1 parent 7b89343 commit 5249565
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public boolean isMeta() {

@Override
public int hashCode() {
return Objects.hash(definition, cardinality, metaAnnotations, name, rType);
return Objects.hash(definition, cardinality, metaAnnotations, name, rType, origin);
}

@Override
Expand All @@ -113,7 +113,8 @@ public boolean equals(Object obj) {
RAttribute other = (RAttribute) obj;
return Objects.equals(definition, other.definition) && Objects.equals(cardinality, other.cardinality)
&& Objects.equals(metaAnnotations, other.metaAnnotations) && Objects.equals(name, other.name)
&& Objects.equals(rType, other.rType);
&& Objects.equals(rType, other.rType)
&& Objects.equals(origin, other.origin);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,59 @@ class ReportingTest {
@Inject extension GeneratedJavaClassService
@Inject extension TabulatorTestUtil

@Test
def void generateTabulatorWithOverlappingAttributeNamesInSubreports() {
val model = '''
body Authority Body
corpus Act Corpus
report Body Corpus in real-time
from string
when Foo
with type Report
eligibility rule Foo from string:
True
type Report:
subreport1 Subreport1 (1..1)
subreport2 Subreport2 (1..1)
type Subreport1:
value string (1..1)
[ruleReference Bar]
type Subreport2:
value string (1..1)
[ruleReference Bar]
reporting rule Bar from string:
item
'''
val code = model.generateCode

val reportId = new ModelReportId(DottedPath.splitOnDots("com.rosetta.test.model"), "Body", "Corpus")
val reportFunctionClass = reportId.toJavaReportFunction
val tabulatorClass = reportId.toJavaReportTabulator

val classes = code.compileToClasses
val reportFunction = classes.<ReportFunction<Object, RosettaModelObject>>createInstance(reportFunctionClass)
val tabulator = classes.<Tabulator<RosettaModelObject>>createInstance(tabulatorClass)

val report = reportFunction.evaluate("input")

val flatReport = tabulator.tabulate(report)
val expectedValues =
'''
subreport1:
value: input
subreport2:
value: input
'''
assertFieldValuesEqual(expectedValues, flatReport)
}

@Test
def void generateTabulatorForHeroModel() {
val model = '''
Expand Down

0 comments on commit 5249565

Please sign in to comment.