Skip to content

Commit 6e9eda1

Browse files
committed
add Unit tests
Signed-off-by: basseche <[email protected]>
1 parent 4e7f9d8 commit 6e9eda1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/test/java/org/gridsuite/filter/server/FilterEntityControllerTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,33 @@ private void checkIdentifiableAttributes(List<IdentifiableAttributes> identifiab
421421
}
422422
}
423423

424+
@Test
425+
public void testEvaluateFilters() throws Exception {
426+
UUID filterId = UUID.randomUUID();
427+
ArrayList<AbstractExpertRule> rules = new ArrayList<>();
428+
EnumExpertRule country1Filter = EnumExpertRule.builder().field(FieldType.COUNTRY_1).operator(OperatorType.IN)
429+
.values(new TreeSet<>(Set.of("FR"))).build();
430+
rules.add(country1Filter);
431+
CombinatorExpertRule parentRule = CombinatorExpertRule.builder().combinator(CombinatorType.AND).rules(rules).build();
432+
ExpertFilter lineFilter = new ExpertFilter(filterId, new Date(), EquipmentType.LINE, parentRule);
433+
insertFilter(filterId, lineFilter);
434+
435+
// Apply filter by calling endPoint
436+
List<String> filterIds = List.of(filterId.toString());
437+
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
438+
params.addAll("ids", filterIds);
439+
params.add("networkUuid", NETWORK_UUID.toString());
440+
List<IdentifiableAttributes> result = objectMapper.readValue(mvc.perform(get(URL_TEMPLATE + "/evaluate/identifiables")
441+
.params(params).contentType(APPLICATION_JSON)).andExpect(status().isOk())
442+
.andReturn().getResponse().getContentAsString(), new TypeReference<>() { });
443+
444+
List<IdentifiableAttributes> expected = new ArrayList<>();
445+
expected.add(new IdentifiableAttributes("NHV1_NHV2_1", IdentifiableType.LINE, null));
446+
expected.add(new IdentifiableAttributes("NHV1_NHV2_2", IdentifiableType.LINE, null));
447+
448+
assertTrue(expected.size() == result.size() && result.containsAll(expected) && expected.containsAll(result));
449+
}
450+
424451
@Test
425452
public void testExportFilters() throws Exception {
426453
UUID filterId = UUID.randomUUID();

0 commit comments

Comments
 (0)