Skip to content

Commit faa536e

Browse files
alexanderkielLucas0T
authored andcommitted
Simplify AnnotatedAttributeGroupTest
Removed attribute that was only needed for resource type calculation. However the resource type is known anyway. So also removed it's calculation.
1 parent 3406e08 commit faa536e

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/main/java/de/medizininformatikinitiative/torch/model/crtdl/annotated/AnnotatedAttributeGroup.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ public AnnotatedAttributeGroup setCompiledFilter(Predicate<Resource> compiledFil
9696
return new AnnotatedAttributeGroup(name, id, resourceType, groupReference, attributes, filter, compiledFilter, includeReferenceOnly);
9797
}
9898

99-
public String resourceType() {
100-
return attributes.getFirst().attributeRef().split("\\.")[0];
101-
}
102-
10399
public boolean hasMustHave() {
104100
return attributes.stream().anyMatch(AnnotatedAttribute::mustHave);
105101
}
@@ -110,4 +106,3 @@ public List<AnnotatedAttribute> refAttributes() {
110106
}
111107

112108
}
113-

src/test/java/de/medizininformatikinitiative/torch/model/crtdl/annotated/AnnotatedAttributeGroupTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
@ExtendWith(MockitoExtension.class)
2727
class AnnotatedAttributeGroupTest {
28+
2829
static final LocalDate DATE_START = LocalDate.parse("2023-01-01");
2930
static final LocalDate DATE_END = LocalDate.parse("2023-12-31");
3031
static final Code CODE1 = new Code("system1", "code1");
@@ -40,12 +41,12 @@ class Queries {
4041
void oneCode() {
4142
when(mappingTreeBase.expand("system1", "code1")).thenReturn(Stream.of("code1"));
4243
var tokenFilter = new Filter("token", "code", List.of(CODE1));
43-
var attributeGroup = new AnnotatedAttributeGroup("test", "Observation", "groupRef", List.of(new AnnotatedAttribute("Observation.name", "Observation.name", "Observation.name", false)), List.of(tokenFilter), null);
44+
var attributeGroup = new AnnotatedAttributeGroup("test", "Observation", "groupRef", List.of(), List.of(tokenFilter), null);
4445

4546
var result = attributeGroup.queries(mappingTreeBase, "Observation");
4647

4748
assertThat(result).containsExactly(
48-
new Query("Observation", QueryParams.of("code", codeValue(CODE1)).appendParam("_profile:below", stringValue("groupRef")))
49+
Query.of("Observation", QueryParams.of("code", codeValue(CODE1)).appendParam("_profile:below", stringValue("groupRef")))
4950
);
5051
}
5152

@@ -54,32 +55,32 @@ void twoCodes() {
5455
when(mappingTreeBase.expand("system1", "code1")).thenReturn(Stream.of("code1"));
5556
when(mappingTreeBase.expand("system2", "code2")).thenReturn(Stream.of("code2"));
5657
var tokenFilter = new Filter("token", "code", List.of(CODE1, CODE2));
57-
var attributeGroup = new AnnotatedAttributeGroup("test", "Observation", "groupRef", List.of(new AnnotatedAttribute("Observation.name", "Observation.name", "Observation.name", false)), List.of(tokenFilter), null);
58+
var attributeGroup = new AnnotatedAttributeGroup("test", "Observation", "groupRef", List.of(), List.of(tokenFilter), null);
5859

5960
var result = attributeGroup.queries(mappingTreeBase, "Observation");
6061

6162
assertThat(result).containsExactly(
62-
new Query("Observation", QueryParams.of("code", codeValue(CODE1)).appendParam("_profile:below", stringValue("groupRef"))),
63-
new Query("Observation", QueryParams.of("code", codeValue(CODE2)).appendParam("_profile:below", stringValue("groupRef")))
63+
Query.of("Observation", QueryParams.of("code", codeValue(CODE1)).appendParam("_profile:below", stringValue("groupRef"))),
64+
Query.of("Observation", QueryParams.of("code", codeValue(CODE2)).appendParam("_profile:below", stringValue("groupRef")))
6465
);
6566
}
6667

6768
@Test
6869
void dateFilter() {
6970
var dateFilter = new Filter("date", "date", DATE_START, DATE_END);
70-
var attributeGroup = new AnnotatedAttributeGroup("test", "Observation", "groupRef", List.of(new AnnotatedAttribute("Observation.name", "Observation.name", "Observation.name", false)), List.of(dateFilter), null);
71+
var attributeGroup = new AnnotatedAttributeGroup("test", "Observation", "groupRef", List.of(), List.of(dateFilter), null);
7172

7273
var result = attributeGroup.queries(mappingTreeBase, "Observation");
7374

7475
assertThat(result).containsExactly(
75-
new Query("Observation", QueryParams.of("date", dateValue(GREATER_EQUAL, DATE_START)).appendParam("date", dateValue(LESS_EQUAL, DATE_END)).appendParam("_profile:below", stringValue("groupRef")))
76+
Query.of("Observation", QueryParams.of("date", dateValue(GREATER_EQUAL, DATE_START)).appendParam("date", dateValue(LESS_EQUAL, DATE_END)).appendParam("_profile:below", stringValue("groupRef")))
7677
);
7778
}
7879

7980
@Test
8081
void filtersIgnoredForPatient() {
8182
var dateFilter = new Filter("date", "date", DATE_START, DATE_END);
82-
var attributeGroup = new AnnotatedAttributeGroup("test", "Observation", "groupRef", List.of(new AnnotatedAttribute("Patient.name", "Patient.name", "Patient.name", false)), List.of(dateFilter), null);
83+
var attributeGroup = new AnnotatedAttributeGroup("test", "Observation", "groupRef", List.of(), List.of(dateFilter), null);
8384

8485
var result = attributeGroup.queries(mappingTreeBase, "Patient");
8586

0 commit comments

Comments
 (0)