Skip to content

Commit 665b8b8

Browse files
committed
refacto test
1 parent c7beced commit 665b8b8

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/test/java/org/gridsuite/securityanalysis/server/SecurityAnalysisControllerTest.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ void testDeterministicResults() throws Exception {
416416
assertEquals(expectedResultInOrder, result);
417417
}
418418

419-
private static String buildFilterUrl() throws JsonProcessingException {
419+
private static String buildFilterNUrl() throws JsonProcessingException {
420420
List<ResourceFilterDTO> filters = List.of(new ResourceFilterDTO(ResourceFilterDTO.DataType.TEXT, ResourceFilterDTO.Type.STARTS_WITH, "vl1", AbstractLimitViolationEntity.Fields.subjectLimitViolation + SpecificationUtils.FIELD_SEPARATOR + SubjectLimitViolationEntity.Fields.subjectId),
421421
new ResourceFilterDTO(ResourceFilterDTO.DataType.TEXT, ResourceFilterDTO.Type.EQUALS, new String[]{"HIGH_VOLTAGE"}, AbstractLimitViolationEntity.Fields.limitType),
422422
new ResourceFilterDTO(ResourceFilterDTO.DataType.NUMBER, ResourceFilterDTO.Type.GREATER_THAN_OR_EQUAL, "399", AbstractLimitViolationEntity.Fields.limit),
@@ -434,20 +434,7 @@ private static String buildFilterUrl() throws JsonProcessingException {
434434
"&globalFilters=" + URLEncoder.encode(jsonGlobalFilters, StandardCharsets.UTF_8) + "&networkUuid=" + NETWORK_UUID + "&variantId=" + "initialState";
435435
}
436436

437-
private static String buildFilterNmkContingenciesUrl() throws JsonProcessingException {
438-
List<ResourceFilterDTO> filters = List.of();
439-
GlobalFilter globalFilter = GlobalFilter.builder()
440-
.genericFilter(List.of(LIST_FILTER_ID))
441-
.nominalV(List.of("400.0"))
442-
.countryCode(List.of(Country.FR))
443-
.build();
444-
String jsonFilters = new ObjectMapper().writeValueAsString(filters);
445-
String jsonGlobalFilters = new ObjectMapper().writeValueAsString(globalFilter);
446-
return "filters=" + URLEncoder.encode(jsonFilters, StandardCharsets.UTF_8) +
447-
"&globalFilters=" + URLEncoder.encode(jsonGlobalFilters, StandardCharsets.UTF_8) + "&networkUuid=" + NETWORK_UUID + "&variantId=" + "initialState";
448-
}
449-
450-
private static String buildFilterNmkConstraintsUrl() throws JsonProcessingException {
437+
private static String buildFilterNmkUrl() throws JsonProcessingException {
451438
List<ResourceFilterDTO> filters = List.of();
452439
GlobalFilter globalFilter = GlobalFilter.builder()
453440
.genericFilter(List.of(LIST_FILTER_ID))
@@ -469,7 +456,7 @@ private void assertFiltredResultN() throws Exception {
469456
when(networkStoreService.getNetwork(NETWORK_UUID, PreloadingStrategy.COLLECTION)).thenReturn(network);
470457

471458
// test - n-result endpoint
472-
MvcResult mvcResult = mockMvc.perform(get("/" + VERSION + "/results/" + RESULT_UUID + "/n-result?" + buildFilterUrl()))
459+
MvcResult mvcResult = mockMvc.perform(get("/" + VERSION + "/results/" + RESULT_UUID + "/n-result?" + buildFilterNUrl()))
473460
.andExpectAll(status().isOk()).andReturn();
474461
String resultAsString = mvcResult.getResponse().getContentAsString();
475462
List<PreContingencyLimitViolationResultDTO> preContingencyResult = mapper.readValue(resultAsString, new TypeReference<>() { });
@@ -486,7 +473,7 @@ private void assertFiltredResultNmkConstraints() throws Exception {
486473
when(networkStoreService.getNetwork(NETWORK_UUID, PreloadingStrategy.COLLECTION)).thenReturn(network);
487474

488475
// test - nmk-constraints-result/paged endpoint
489-
MvcResult mvcResult = mockMvc.perform(get("/" + VERSION + "/results/" + RESULT_UUID + "/nmk-constraints-result/paged?" + buildFilterNmkConstraintsUrl()))
476+
MvcResult mvcResult = mockMvc.perform(get("/" + VERSION + "/results/" + RESULT_UUID + "/nmk-constraints-result/paged?" + buildFilterNmkUrl()))
490477
.andExpectAll(status().isOk()).andReturn();
491478
String resultAsString = mvcResult.getResponse().getContentAsString();
492479
assertNotNull(resultAsString);
@@ -501,7 +488,7 @@ private void assertFiltredResultNmkContingencies() throws Exception {
501488
when(networkStoreService.getNetwork(NETWORK_UUID, PreloadingStrategy.COLLECTION)).thenReturn(network);
502489

503490
// test - nmk-contingencies-result/paged endpoint
504-
MvcResult mvcResult = mockMvc.perform(get("/" + VERSION + "/results/" + RESULT_UUID + "/nmk-contingencies-result/paged?" + buildFilterNmkContingenciesUrl()))
491+
MvcResult mvcResult = mockMvc.perform(get("/" + VERSION + "/results/" + RESULT_UUID + "/nmk-contingencies-result/paged?" + buildFilterNmkUrl()))
505492
.andExpectAll(status().isOk()).andReturn();
506493
String resultAsString = mvcResult.getResponse().getContentAsString();
507494
assertNotNull(resultAsString);

0 commit comments

Comments
 (0)