From b38e397e04e8ec4189415176ed0e5d9cc0e601e3 Mon Sep 17 00:00:00 2001 From: Tristan Chuine Date: Mon, 10 Jun 2024 20:05:25 +0200 Subject: [PATCH] Revert PR #576 --- .../org/gridsuite/study/server/StudyTest.java | 543 ++++++++++-------- 1 file changed, 289 insertions(+), 254 deletions(-) diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index 4ed39e614..7efe743a6 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -706,42 +706,42 @@ public void testSearch() throws Exception { UUID studyUuid = createStudy(USER_ID, CASE_UUID); UUID rootNodeId = getRootNodeUuid(studyUuid); - mvcResult = mockMvc.perform(get("/v1/search?q={request}", String.format("userId:%s", USER_ID)) - .header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + mvcResult = mockMvc + .perform(get("/v1/search?q={request}", String.format("userId:%s", USER_ID)).header(USER_ID_HEADER, USER_ID)) + .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); List createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { }); assertThat(createdStudyBasicInfosList, new MatcherJson<>(mapper, studiesInfos)); - mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME", - studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + mvcResult = mockMvc + .perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME", + studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) + .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); List equipmentInfos = mapper.readValue(resultAsString, new TypeReference<>() { }); assertThat(equipmentInfos, new MatcherJson<>(mapper, linesInfos)); - mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME", - studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + mvcResult = mockMvc + .perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME", + studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) + .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); equipmentInfos = mapper.readValue(resultAsString, new TypeReference<>() { }); assertThat(equipmentInfos, new MatcherJson<>(mapper, linesInfos)); - mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=ID", - studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + mvcResult = mockMvc + .perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=ID", + studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) + .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); equipmentInfos = mapper.readValue(resultAsString, new TypeReference<>() { }); assertThat(equipmentInfos, new MatcherJson<>(mapper, linesInfos)); mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=bogus", studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isBadRequest(), content().string("Enum unknown entry 'bogus' should be among NAME, ID")) - .andReturn(); + .andExpectAll(status().isBadRequest(), + content().string("Enum unknown entry 'bogus' should be among NAME, ID")) + .andReturn(); } @Test @@ -750,20 +750,19 @@ public void test() throws Exception { String resultAsString; //empty list - mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON), content().string("[]")); + mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, USER_ID)).andExpectAll(status().isOk(), + content().contentType(MediaType.APPLICATION_JSON), content().string("[]")); //empty list - mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON), content().string("[]")); + mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, USER_ID)).andExpectAll(status().isOk(), + content().contentType(MediaType.APPLICATION_JSON), content().string("[]")); //insert a study UUID studyUuid = createStudy(USER_ID, CASE_UUID); // check the study result = mockMvc.perform(get("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = result.getResponse().getContentAsString(); StudyInfos infos = mapper.readValue(resultAsString, StudyInfos.class); @@ -771,17 +770,16 @@ public void test() throws Exception { assertThat(infos, createMatcherStudyInfos(studyUuid, "UCTE")); //insert a study with a non existing case and except exception - result = mockMvc.perform(post("/v1/studies/cases/{caseUuid}", NOT_EXISTING_CASE_UUID, "false") - .header(USER_ID_HEADER, USER_ID) - .param(CASE_FORMAT, "XIIDM")) - .andExpectAll(status().isFailedDependency(), content().contentType(MediaType.valueOf("text/plain;charset=UTF-8"))) - .andReturn(); + result = mockMvc.perform(post("/v1/studies/cases/{caseUuid}", + NOT_EXISTING_CASE_UUID, "false").header(USER_ID_HEADER, USER_ID).param(CASE_FORMAT, "XIIDM")) + .andExpectAll(status().isFailedDependency(), content().contentType(MediaType.valueOf("text/plain;charset=UTF-8"))).andReturn(); assertEquals("The case '" + NOT_EXISTING_CASE_UUID + "' does not exist", result.getResponse().getContentAsString()); - assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/cases/%s/exists", NOT_EXISTING_CASE_UUID))); + assertTrue(TestUtils.getRequestsDone(1, server) + .contains(String.format("/v1/cases/%s/exists", NOT_EXISTING_CASE_UUID))); result = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); + .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = result.getResponse().getContentAsString(); List createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -793,10 +791,7 @@ public void test() throws Exception { studyUuid = createStudy("userId2", CASE_UUID); resultAsString = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, "userId2")) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn() - .getResponse() - .getContentAsString(); + .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse().getContentAsString(); createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -806,42 +801,43 @@ public void test() throws Exception { UUID randomUuid = UUID.randomUUID(); //get a non existing study -> 404 not found mockMvc.perform(get("/v1/studies/{studyUuid}", randomUuid).header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isNotFound(), content().contentType(MediaType.APPLICATION_JSON), - jsonPath("$").value(STUDY_NOT_FOUND.name())); + .andExpectAll(status().isNotFound(), + content().contentType(MediaType.APPLICATION_JSON), + jsonPath("$").value(STUDY_NOT_FOUND.name())); UUID studyNameUserIdUuid = studyRepository.findAll().get(0).getId(); // expect only 1 study (public one) since the other is private and we use // another userId result = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, "a")) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); + .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = result.getResponse().getContentAsString(); createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { }); assertEquals(2, createdStudyBasicInfosList.size()); //get available export format - mockMvc.perform(get("/v1/export-network-formats")) - .andExpectAll(status().isOk(), content().string("[\"CGMES\",\"UCTE\",\"XIIDM\"]")); + mockMvc.perform(get("/v1/export-network-formats")).andExpectAll(status().isOk(), + content().string("[\"CGMES\",\"UCTE\",\"XIIDM\"]")); assertTrue(TestUtils.getRequestsDone(1, server).contains("/v1/export/formats")); //export a network UUID rootNodeUuid = getRootNodeUuid(studyNameUserIdUuid); mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/export-network/{format}", studyNameUserIdUuid, rootNodeUuid, "XIIDM")) - .andExpect(status().isOk()); + .andExpect(status().isOk()); assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/networks/%s/export/XIIDM", NETWORK_UUID_STRING))); mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/export-network/{format}?formatParameters=%7B%22iidm.export.xml.indent%22%3Afalse%7D", studyNameUserIdUuid, rootNodeUuid, "XIIDM")) - .andExpect(status().isOk()); + .andExpect(status().isOk()); TestUtils.getRequestsDone(1, server); // just consume it NetworkModificationNode modificationNode1 = createNetworkModificationNode(studyNameUserIdUuid, rootNodeUuid, UUID.randomUUID(), VARIANT_ID, "node 3", USER_ID); UUID modificationNode1Uuid = modificationNode1.getId(); mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/export-network/{format}", studyNameUserIdUuid, modificationNode1Uuid, "XIIDM")) - .andExpect(status().isInternalServerError()); + .andExpect(status().isInternalServerError()); modificationNode1.setNodeBuildStatus(NodeBuildStatus.from(BuildStatus.BUILT)); networkModificationTreeService.updateNode(studyNameUserIdUuid, modificationNode1, USER_ID); @@ -849,7 +845,7 @@ public void test() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, USER_ID); mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/export-network/{format}", studyNameUserIdUuid, modificationNode1Uuid, "XIIDM")) - .andExpect(status().isOk()); + .andExpect(status().isOk()); assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/networks/%s/export/XIIDM?variantId=%s", NETWORK_UUID_STRING, VARIANT_ID))); } @@ -875,7 +871,7 @@ public void testDeleteStudy() throws Exception { UUID stubUuid = wireMockUtils.stubNetworkModificationDeleteGroup(); mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); assertTrue(studyRepository.findById(studyUuid).isEmpty()); @@ -907,7 +903,7 @@ public void testDeleteStudyWithError() throws Exception { UUID stubUuid = wireMockUtils.stubNetworkModificationDeleteGroup(); mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isInternalServerError(), content().string(InterruptedException.class.getName())); + .andExpectAll(status().isInternalServerError(), content().string(InterruptedException.class.getName())); wireMockUtils.verifyNetworkModificationDeleteGroup(stubUuid); @@ -930,7 +926,7 @@ public void testDeleteStudyWithNonExistingCase() throws Exception { studyRepository.save(studyEntity); mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); assertTrue(studyRepository.findById(studyUuid).isEmpty()); @@ -950,11 +946,11 @@ public void testMetadata() throws Exception { studyUuid = createStudy("userId2", CASE_UUID); - MvcResult mvcResult = mockMvc.perform(get("/v1/studies/metadata?ids=" + MvcResult mvcResult = mockMvc + .perform(get("/v1/studies/metadata?ids=" + Stream.of(oldStudyUuid, studyUuid).map(Object::toString).collect(Collectors.joining(","))) .header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); String resultAsString = mvcResult.getResponse().getContentAsString(); List createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -973,13 +969,13 @@ public void testMetadata() throws Exception { public void testNotifyStudyMetadataUpdated() throws Exception { UUID studyUuid = UUID.randomUUID(); mockMvc.perform(post("/v1/studies/{studyUuid}/notification?type=metadata_updated", studyUuid) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); checkStudyMetadataUpdatedMessagesReceived(); mockMvc.perform(post("/v1/studies/{studyUuid}/notification?type=NOT_EXISTING_TYPE", UUID.randomUUID()) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isBadRequest()); + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isBadRequest()); } @Test @@ -987,10 +983,8 @@ public void testLogsReport() throws Exception { UUID studyUuid = createStudy(USER_ID, CASE_UUID); UUID rootNodeUuid = getRootNodeUuid(studyUuid); - MvcResult mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/parent-nodes-report?reportType=NETWORK_MODIFICATION", studyUuid, rootNodeUuid) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()) - .andReturn(); + MvcResult mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/parent-nodes-report?reportType=NETWORK_MODIFICATION", studyUuid, rootNodeUuid).header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()).andReturn(); String resultAsString = mvcResult.getResponse().getContentAsString(); List reporterModel = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -1022,10 +1016,8 @@ private NetworkModificationNode createNetworkModificationNode(UUID studyUuid, UU jsonObject.put("modificationGroupUuid", modificationGroupUuid); mnBodyJson = jsonObject.toString(); - mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid) - .content(mnBodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) - .andExpect(status().isOk()); + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(USER_ID_HEADER, userId)) + .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); var mess = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); assertNotNull(mess); @@ -1040,10 +1032,10 @@ private UUID createStudy(String userId, UUID caseUuid) throws Exception { private UUID createStudy(String userId, UUID caseUuid, String parameterDuplicatedUuid, boolean parameterDuplicationSuccess) throws Exception { MvcResult result = mockMvc.perform(post("/v1/studies/cases/{caseUuid}", caseUuid) - .header(USER_ID_HEADER, userId) - .param(CASE_FORMAT, "UCTE")) - .andExpect(status().isOk()) - .andReturn(); + .header(USER_ID_HEADER, userId) + .param(CASE_FORMAT, "UCTE")) + .andExpect(status().isOk()) + .andReturn(); String resultAsString = result.getResponse().getContentAsString(); BasicStudyInfos infos = mapper.readValue(resultAsString, BasicStudyInfos.class); UUID studyUuid = infos.getId(); @@ -1070,11 +1062,11 @@ private UUID createStudy(String userId, UUID caseUuid, String parameterDuplicate protected UUID createStudyWithImportParameters(String userId, UUID caseUuid, String caseFormat, Map importParameters) throws Exception { MvcResult result = mockMvc.perform(post("/v1/studies/cases/{caseUuid}", caseUuid) - .header(USER_ID_HEADER, userId).contentType(MediaType.APPLICATION_JSON) - .param(CASE_FORMAT, caseFormat) - .content(mapper.writeValueAsString(importParameters))) - .andExpect(status().isOk()) - .andReturn(); + .header(USER_ID_HEADER, userId).contentType(MediaType.APPLICATION_JSON) + .param(CASE_FORMAT, caseFormat) + .content(mapper.writeValueAsString(importParameters))) + .andExpect(status().isOk()) + .andReturn(); String resultAsString = result.getResponse().getContentAsString(); BasicStudyInfos infos = mapper.readValue(resultAsString, BasicStudyInfos.class); UUID studyUuid = infos.getId(); @@ -1098,11 +1090,11 @@ protected UUID createStudyWithImportParameters(String userId, UUID caseUuid, Str private UUID createStudyWithDuplicateCase(String userId, UUID caseUuid) throws Exception { MvcResult result = mockMvc.perform(post("/v1/studies/cases/{caseUuid}", caseUuid) - .param("duplicateCase", "true") - .param(CASE_FORMAT, "UCTE") - .header(USER_ID_HEADER, userId)) - .andExpect(status().isOk()) - .andReturn(); + .param("duplicateCase", "true") + .param(CASE_FORMAT, "UCTE") + .header(USER_ID_HEADER, userId)) + .andExpect(status().isOk()) + .andReturn(); String resultAsString = result.getResponse().getContentAsString(); BasicStudyInfos infos = mapper.readValue(resultAsString, BasicStudyInfos.class); UUID studyUuid = infos.getId(); @@ -1157,7 +1149,7 @@ public void testCreateStudyWithErrorDuringCaseImport() throws Exception { mockMvc.perform(post("/v1/studies/cases/{caseUuid}", CASE_UUID_CAUSING_IMPORT_ERROR) .header(USER_ID_HEADER, USER_ID) .param(CASE_FORMAT, "UCTE")) - .andExpect(status().is5xxServerError()); + .andExpect(status().is5xxServerError()); // assert that the broker message has been sent a study creation request message Message message = output.receive(TIMEOUT, "study.update"); @@ -1166,9 +1158,10 @@ public void testCreateStudyWithErrorDuringCaseImport() throws Exception { assertEquals(USER_ID, headers.get(HEADER_USER_ID)); assertEquals(NotificationService.UPDATE_TYPE_STUDIES, headers.get(HEADER_UPDATE_TYPE)); - MvcResult mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + MvcResult mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, USER_ID)).andExpectAll( + status().isOk(), + content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); String resultAsString = mvcResult.getResponse().getContentAsString(); List bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -1209,7 +1202,7 @@ public void testCreateStudyWithErrorDuringStudyCreation() throws Exception { mockMvc.perform(post("/v1/studies/cases/{caseUuid}", CASE_UUID_CAUSING_STUDY_CREATION_ERROR) .header(USER_ID_HEADER, USER_ID) .param(CASE_FORMAT, "UCTE")) - .andExpect(status().isOk()); + .andExpect(status().isOk()); // assert that the broker message has been sent a study creation request message Message message = output.receive(TIMEOUT, "study.update"); @@ -1235,9 +1228,10 @@ public void testGetStudyCreationRequests() throws Exception { String resultAsString; countDownLatch = new CountDownLatch(1); - mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, USER_ID)).andExpectAll( + status().isOk(), + content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); List bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -1253,18 +1247,20 @@ public void testGetStudyCreationRequests() throws Exception { // drop the broker message for study creation request (deletion) output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); - mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, USER_ID)).andExpectAll( + status().isOk(), + content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { }); assertEquals(List.of(), bsiListResult); - mvcResult = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + mvcResult = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, USER_ID)).andExpectAll( + status().isOk(), + content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); List csbiListResponse = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -1274,9 +1270,9 @@ public void testGetStudyCreationRequests() throws Exception { //insert a study mvcResult = mockMvc.perform(post("/v1/studies/cases/{caseUuid}", NEW_STUDY_CASE_UUID, "false") .header(USER_ID_HEADER, USER_ID) - .param(CASE_FORMAT, "XIIDM")) - .andExpect(status().isOk()) - .andReturn(); + .param(CASE_FORMAT, "XIIDM")) + .andExpect(status().isOk()) + .andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); BasicStudyInfos bsiResult = mapper.readValue(resultAsString, BasicStudyInfos.class); @@ -1284,9 +1280,10 @@ public void testGetStudyCreationRequests() throws Exception { assertThat(bsiResult, createMatcherStudyBasicInfos(studyCreationRequestRepository.findAll().get(0).getId())); mvcResult = mockMvc.perform(get("/v1/study_creation_requests", NEW_STUDY_CASE_UUID, "false") - .header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + .header(USER_ID_HEADER, USER_ID)).andExpectAll( + status().isOk(), + content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -1302,18 +1299,22 @@ public void testGetStudyCreationRequests() throws Exception { // drop the broker message for study creation request (deletion) output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); - mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + mvcResult = mockMvc.perform(get("/v1/study_creation_requests") + .header(USER_ID_HEADER, USER_ID)).andExpectAll( + status().isOk(), + content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); bsiListResult = mapper.readValue(resultAsString, new TypeReference<>() { }); assertEquals(List.of(), bsiListResult); - mvcResult = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, USER_ID)) - .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) - .andReturn(); + mvcResult = mockMvc.perform(get("/v1/studies") + .header(USER_ID_HEADER, USER_ID)).andExpectAll( + status().isOk(), + content().contentType(MediaType.APPLICATION_JSON)) + .andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); csbiListResponse = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -1419,10 +1420,10 @@ private void testDuplicateStudy(UUID study1Uuid) throws Exception { UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) - .contentType(MediaType.APPLICATION_JSON) - .content(createTwoWindingsTransformerAttributes) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_JSON) + .content(createTwoWindingsTransformerAttributes) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); @@ -1435,10 +1436,10 @@ private void testDuplicateStudy(UUID study1Uuid) throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) - .contentType(MediaType.APPLICATION_JSON) - .content(createLoadAttributes) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_JSON) + .content(createLoadAttributes) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); @@ -1462,8 +1463,9 @@ private void testDuplicateStudy(UUID study1Uuid) throws Exception { assertNotEquals(study1Uuid, duplicatedStudy.getId()); //Test duplication from a non existing source study - mockMvc.perform(post(STUDIES_URL + "?duplicateFrom={studyUuid}", UUID.randomUUID()).header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isNotFound()); + mockMvc.perform(post(STUDIES_URL + "?duplicateFrom={studyUuid}", UUID.randomUUID()) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isNotFound()); } @Test @@ -1500,12 +1502,9 @@ public void testDuplicateStudyWithErrorDuringCaseDuplication() throws Exception }).when(caseService).duplicateCase(any(), any()); String response = mockMvc.perform(post(STUDIES_URL + "?duplicateFrom={studyUuid}", studyUuid) - .param(CASE_FORMAT, "XIIDM") - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()) - .andReturn() - .getResponse() - .getContentAsString(); + .param(CASE_FORMAT, "XIIDM") + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); String duplicatedStudyUuid = mapper.readValue(response, String.class); assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); @@ -1516,11 +1515,8 @@ public void testDuplicateStudyWithErrorDuringCaseDuplication() throws Exception private StudyEntity duplicateStudy(UUID studyUuid) throws Exception { UUID stubUuid = wireMockUtils.stubDuplicateModificationGroup(); String response = mockMvc.perform(post(STUDIES_URL + "?duplicateFrom={studyUuid}", studyUuid) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()) - .andReturn() - .getResponse() - .getContentAsString(); + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); String newUuid = mapper.readValue(response, String.class); StudyEntity sourceStudy = studyRepository.findById(studyUuid).orElseThrow(); assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); @@ -1650,9 +1646,10 @@ public void testCutAndPasteNode() throws Exception { String createLoadAttributes = "{\"type\":\"" + ModificationType.LOAD_CREATION + "\",\"loadId\":\"loadId1\",\"loadName\":\"loadName1\",\"loadType\":\"UNDEFINED\",\"activePower\":\"100.0\",\"reactivePower\":\"50.0\",\"voltageLevelId\":\"idVL1\",\"busId\":\"idBus1\"}"; stubUuid = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) - .content(createLoadAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_JSON) + .content(createLoadAttributes) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); @@ -1775,24 +1772,27 @@ public void testCutAndPasteNodeAroundItself() throws Exception { UUID stubGetCountUuid = wireMockUtils.stubNetworkModificationCountGet(node1.getModificationGroupUuid().toString(), 0); //try to cut and paste a node before itself and expect forbidden - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", - study1Uuid, node1.getId(), node1.getId(), InsertMode.BEFORE) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isForbidden()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", + study1Uuid, node1.getId(), node1.getId(), InsertMode.BEFORE) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, node1.getModificationGroupUuid().toString()); //try to cut and paste a node after itself and expect forbidden - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", - study1Uuid, node1.getId(), node1.getId(), InsertMode.AFTER) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isForbidden()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", + study1Uuid, node1.getId(), node1.getId(), InsertMode.AFTER) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, node1.getModificationGroupUuid().toString()); //try to cut and paste a node in a new branch after itself and expect forbidden - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", - study1Uuid, node1.getId(), node1.getId(), InsertMode.CHILD) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isForbidden()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", + study1Uuid, node1.getId(), node1.getId(), InsertMode.CHILD) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, node1.getModificationGroupUuid().toString()); } @@ -1844,23 +1844,26 @@ public void testCutAndPastErrors() throws Exception { NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", USER_ID); //try cut non existing node and expect not found - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", - study1Uuid, UUID.randomUUID(), node1.getId(), InsertMode.AFTER) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isNotFound()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", + study1Uuid, UUID.randomUUID(), node1.getId(), InsertMode.AFTER) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isNotFound()); //try to cut to a non existing position and expect not found - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", - study1Uuid, node1.getId(), UUID.randomUUID(), InsertMode.AFTER) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isNotFound()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", + study1Uuid, node1.getId(), UUID.randomUUID(), InsertMode.AFTER) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isNotFound()); //try to cut and paste to before the root node and expect forbidden UUID stubUuid = wireMockUtils.stubNetworkModificationCountGet(node1.getModificationGroupUuid().toString(), 0); - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", - study1Uuid, node1.getId(), rootNode.getId(), InsertMode.BEFORE) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isForbidden()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", + study1Uuid, node1.getId(), rootNode.getId(), InsertMode.BEFORE) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubUuid, node1.getModificationGroupUuid().toString()); } @@ -1875,15 +1878,17 @@ public void testCutAndPasteSubtree() throws Exception { NetworkModificationNode emptyNode = createNetworkModificationNode(study1Uuid, rootNode.getId(), EMPTY_MODIFICATION_GROUP_UUID, VARIANT_ID_2, "emptyNode", BuildStatus.BUILT, USER_ID); NetworkModificationNode emptyNodeChild = createNetworkModificationNode(study1Uuid, emptyNode.getId(), UUID.randomUUID(), VARIANT_ID_3, "emptyNodeChild", BuildStatus.BUILT, USER_ID); - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/subtrees?subtreeToCutParentNodeUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}", - study1Uuid, emptyNode.getId(), emptyNodeChild.getId()) + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/subtrees?subtreeToCutParentNodeUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}", + study1Uuid, emptyNode.getId(), emptyNodeChild.getId()) .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isForbidden()); + .andExpect(status().isForbidden()); - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/subtrees?subtreeToCutParentNodeUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}", - study1Uuid, emptyNode.getId(), node1.getId()) + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/subtrees?subtreeToCutParentNodeUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}", + study1Uuid, emptyNode.getId(), node1.getId()) .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(emptyNode.getId(), emptyNodeChild.getId())); @@ -1914,13 +1919,15 @@ public void testCutAndPasteSubtree() throws Exception { assertEquals(BuildStatus.NOT_BUILT, networkModificationTreeService.getNodeBuildStatus(emptyNode.getId()).getGlobalBuildStatus()); assertEquals(BuildStatus.NOT_BUILT, networkModificationTreeService.getNodeBuildStatus(emptyNodeChild.getId()).getGlobalBuildStatus()); - mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, emptyNode.getId()) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + mockMvc.perform(get(STUDIES_URL + + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", + study1Uuid, emptyNode.getId()) + .header(USER_ID_HEADER, USER_ID)).andExpect(status().isOk()); - mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, UUID.randomUUID()) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isNotFound()); + mockMvc.perform(get(STUDIES_URL + + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", + study1Uuid, UUID.randomUUID()) + .header(USER_ID_HEADER, USER_ID)).andExpect(status().isNotFound()); } @Test @@ -1937,9 +1944,10 @@ public void testDuplicateNode() throws Exception { String createTwoWindingsTransformerAttributes = "{\"type\":\"" + ModificationType.TWO_WINDINGS_TRANSFORMER_CREATION + "\",\"equipmentId\":\"2wtId\",\"equipmentName\":\"2wtName\",\"seriesResistance\":\"10\",\"seriesReactance\":\"10\",\"magnetizingConductance\":\"100\",\"magnetizingSusceptance\":\"100\",\"ratedVoltage1\":\"480\",\"ratedVoltage2\":\"380\",\"voltageLevelId1\":\"CHOO5P6\",\"busOrBusbarSectionId1\":\"CHOO5P6_1\",\"voltageLevelId2\":\"CHOO5P6\",\"busOrBusbarSectionId2\":\"CHOO5P6_1\"}"; UUID stubUuid = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) - .content(createTwoWindingsTransformerAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_JSON) + .content(createTwoWindingsTransformerAttributes) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); @@ -1951,9 +1959,10 @@ public void testDuplicateNode() throws Exception { String createLoadAttributes = "{\"type\":\"" + ModificationType.LOAD_CREATION + "\",\"loadId\":\"loadId1\",\"loadName\":\"loadName1\",\"loadType\":\"UNDEFINED\",\"activePower\":\"100.0\",\"reactivePower\":\"50.0\",\"voltageLevelId\":\"idVL1\",\"busId\":\"idBus1\"}"; stubUuid = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) - .content(createLoadAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_JSON) + .content(createLoadAttributes) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); @@ -2005,22 +2014,25 @@ public void testDuplicateNode() throws Exception { assertEquals(0, allNodes.stream().filter(nodeEntity -> nodeEntity.getParentNode() != null && nodeEntity.getParentNode().getIdNode().equals(duplicatedNodeUuid3)).count()); //try copy non existing node and expect not found - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}&sourceStudyUuid={sourceStudyUuid}", - study1Uuid, UUID.randomUUID(), node1.getId(), InsertMode.AFTER, study1Uuid) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isNotFound()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}&sourceStudyUuid={sourceStudyUuid}", + study1Uuid, UUID.randomUUID(), node1.getId(), InsertMode.AFTER, study1Uuid) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isNotFound()); //try to copy to a non existing position and expect not found - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}&sourceStudyUuid={sourceStudyUuid}", - study1Uuid, node1.getId(), UUID.randomUUID(), InsertMode.AFTER, study1Uuid) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isNotFound()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}&sourceStudyUuid={sourceStudyUuid}", + study1Uuid, node1.getId(), UUID.randomUUID(), InsertMode.AFTER, study1Uuid) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isNotFound()); //try to copy to before the root node and expect forbidden - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}&sourceStudyUuid={sourceStudyUuid}", - study1Uuid, node1.getId(), rootNode.getId(), InsertMode.BEFORE, study1Uuid) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isForbidden()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}&sourceStudyUuid={sourceStudyUuid}", + study1Uuid, node1.getId(), rootNode.getId(), InsertMode.BEFORE, study1Uuid) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isForbidden()); // Test Built status when duplicating an empty node assertEquals(BuildStatus.BUILT, networkModificationTreeService.getNodeBuildStatus(node3.getId()).getGlobalBuildStatus()); @@ -2051,9 +2063,10 @@ public void testDuplicateSubtree() throws Exception { String createTwoWindingsTransformerAttributes = "{\"type\":\"" + ModificationType.TWO_WINDINGS_TRANSFORMER_CREATION + "\",\"equipmentId\":\"2wtId\",\"equipmentName\":\"2wtName\",\"seriesResistance\":\"10\",\"seriesReactance\":\"10\",\"magnetizingConductance\":\"100\",\"magnetizingSusceptance\":\"100\",\"ratedVoltage1\":\"480\",\"ratedVoltage2\":\"380\",\"voltageLevelId1\":\"CHOO5P6\",\"busOrBusbarSectionId1\":\"CHOO5P6_1\",\"voltageLevelId2\":\"CHOO5P6\",\"busOrBusbarSectionId2\":\"CHOO5P6_1\"}"; UUID stubUuid = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) - .content(createTwoWindingsTransformerAttributes).contentType(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON) + .content(createTwoWindingsTransformerAttributes) .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId(), node3.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); @@ -2070,9 +2083,10 @@ public void testDuplicateSubtree() throws Exception { String createLoadAttributes = "{\"type\":\"" + ModificationType.LOAD_CREATION + "\",\"loadId\":\"loadId1\",\"loadName\":\"loadName1\",\"loadType\":\"UNDEFINED\",\"activePower\":\"100.0\",\"reactivePower\":\"50.0\",\"voltageLevelId\":\"idVL1\",\"busId\":\"idBus1\"}"; stubUuid = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) - .content(createLoadAttributes).contentType(MediaType.APPLICATION_JSON) + .contentType(MediaType.APPLICATION_JSON) + .content(createLoadAttributes) .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); @@ -2095,10 +2109,11 @@ public void testDuplicateSubtree() throws Exception { List allNodesBeforeDuplication = networkModificationTreeService.getAllNodes(study1Uuid).stream().map(NodeEntity::getIdNode).toList(); UUID stubDuplicateUuid = wireMockUtils.stubDuplicateModificationGroup(); - mockMvc.perform(post(STUDIES_URL + "/{study1Uuid}/tree/subtrees?subtreeToCopyParentNodeUuid={parentNodeToCopy}&referenceNodeUuid={referenceNodeUuid}&sourceStudyUuid={sourceStudyUuid}", - study1Uuid, node1.getId(), node4.getId(), study1Uuid) + mockMvc.perform(post(STUDIES_URL + + "/{study1Uuid}/tree/subtrees?subtreeToCopyParentNodeUuid={parentNodeToCopy}&referenceNodeUuid={referenceNodeUuid}&sourceStudyUuid={sourceStudyUuid}", + study1Uuid, node1.getId(), node4.getId(), study1Uuid) .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); List nodesAfterDuplication = networkModificationTreeService.getAllNodes(study1Uuid).stream().map(NodeEntity::getIdNode) .filter(Predicate.not(allNodesBeforeDuplication::contains)).toList(); @@ -2120,13 +2135,15 @@ public void testDuplicateSubtree() throws Exception { └── node 3 duplicated */ - mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, nodesAfterDuplication.get(0)) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + mockMvc.perform(get(STUDIES_URL + + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", + study1Uuid, nodesAfterDuplication.get(0)) + .header(USER_ID_HEADER, USER_ID)).andExpect(status().isOk()); - mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, UUID.randomUUID()) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isNotFound()); + mockMvc.perform(get(STUDIES_URL + + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", + study1Uuid, UUID.randomUUID()) + .header(USER_ID_HEADER, USER_ID)).andExpect(status().isNotFound()); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); @@ -2150,16 +2167,18 @@ public void testDuplicateSubtree() throws Exception { assertEquals(BuildStatus.NOT_BUILT, networkModificationTreeService.getNodeBuildStatus(nodesAfterDuplication.get(1)).getGlobalBuildStatus()); //try copy non existing node and expect not found - mockMvc.perform(post(STUDIES_URL + "/{targetStudyUuid}/tree/subtrees?subtreeToCopyParentNodeUuid={parentNodeToCopy}&referenceNodeUuid={referenceNodeUuid}&sourceStudyUuid={sourceStudyUuid}", - study1Uuid, UUID.randomUUID(), node1.getId(), study1Uuid) + mockMvc.perform(post(STUDIES_URL + + "/{targetStudyUuid}/tree/subtrees?subtreeToCopyParentNodeUuid={parentNodeToCopy}&referenceNodeUuid={referenceNodeUuid}&sourceStudyUuid={sourceStudyUuid}", + study1Uuid, UUID.randomUUID(), node1.getId(), study1Uuid) .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isNotFound()); + .andExpect(status().isNotFound()); //try to copy to a non existing position and expect not found - mockMvc.perform(post(STUDIES_URL + "/{targetStudyUuid}/tree/subtrees?subtreeToCopyParentNodeUuid={parentNodeToCopy}&referenceNodeUuid={referenceNodeUuid}&sourceStudyUuid={sourceStudyUuid}", - study1Uuid, node1.getId(), UUID.randomUUID(), study1Uuid) + mockMvc.perform(post(STUDIES_URL + + "/{targetStudyUuid}/tree/subtrees?subtreeToCopyParentNodeUuid={parentNodeToCopy}&referenceNodeUuid={referenceNodeUuid}&sourceStudyUuid={sourceStudyUuid}", + study1Uuid, node1.getId(), UUID.randomUUID(), study1Uuid) .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isNotFound()); + .andExpect(status().isNotFound()); } @Test @@ -2179,9 +2198,10 @@ public void testDuplicateNodeBetweenStudies() throws Exception { UUID stubUuid = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); String createTwoWindingsTransformerAttributes = "{\"type\":\"" + ModificationType.TWO_WINDINGS_TRANSFORMER_CREATION + "\",\"equipmentId\":\"2wtId\",\"equipmentName\":\"2wtName\",\"seriesResistance\":\"10\",\"seriesReactance\":\"10\",\"magnetizingConductance\":\"100\",\"magnetizingSusceptance\":\"100\",\"ratedVoltage1\":\"480\",\"ratedVoltage2\":\"380\",\"voltageLevelId1\":\"CHOO5P6\",\"busOrBusbarSectionId1\":\"CHOO5P6_1\",\"voltageLevelId2\":\"CHOO5P6\",\"busOrBusbarSectionId2\":\"CHOO5P6_1\"}"; mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) - .content(createTwoWindingsTransformerAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_JSON) + .content(createTwoWindingsTransformerAttributes) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); @@ -2193,9 +2213,10 @@ public void testDuplicateNodeBetweenStudies() throws Exception { stubUuid = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); String createLoadAttributes = "{\"type\":\"" + ModificationType.LOAD_CREATION + "\",\"loadId\":\"loadId1\",\"loadName\":\"loadName1\",\"loadType\":\"UNDEFINED\",\"activePower\":\"100.0\",\"reactivePower\":\"50.0\",\"voltageLevelId\":\"idVL1\",\"busId\":\"idBus1\"}"; mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) - .content(createLoadAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_JSON) + .content(createLoadAttributes) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); @@ -2222,10 +2243,11 @@ public void testDuplicateNodeBetweenStudies() throws Exception { private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, UUID referenceNodeUuid, InsertMode insertMode, int childCount, String userId) throws Exception { UUID stubUuid = wireMockUtils.stubNetworkModificationCountGet(nodeToCopy.getModificationGroupUuid().toString(), EMPTY_MODIFICATION_GROUP_UUID.equals(nodeToCopy.getModificationGroupUuid()) ? 0 : 1); - mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", - studyUuid, nodeToCopy.getId(), referenceNodeUuid, insertMode) - .header(USER_ID_HEADER, userId)) - .andExpect(status().isOk()); + mockMvc.perform(post(STUDIES_URL + + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", + studyUuid, nodeToCopy.getId(), referenceNodeUuid, insertMode) + .header(USER_ID_HEADER, userId)) + .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); wireMockUtils.verifyNetworkModificationCountsGet(stubUuid, nodeToCopy.getModificationGroupUuid().toString()); @@ -2304,15 +2326,17 @@ private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkMo UUID stubDuplicateUuid = wireMockUtils.stubDuplicateModificationGroup(); if (sourceStudyUuid.equals(targetStudyUuid)) { //if source and target are the same no need to pass sourceStudy param - mockMvc.perform(post(STUDIES_URL + "/{targetStudyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", - targetStudyUuid, nodeToCopy.getId(), referenceNodeUuid, insertMode) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + mockMvc.perform(post(STUDIES_URL + + "/{targetStudyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", + targetStudyUuid, nodeToCopy.getId(), referenceNodeUuid, insertMode) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); } else { - mockMvc.perform(post(STUDIES_URL + "/{targetStudyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}&sourceStudyUuid={sourceStudyUuid}", - targetStudyUuid, nodeToCopy.getId(), referenceNodeUuid, insertMode, sourceStudyUuid) - .header(USER_ID_HEADER, USER_ID)) - .andExpect(status().isOk()); + mockMvc.perform(post(STUDIES_URL + + "/{targetStudyUuid}/tree/nodes?nodeToCopyUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}&sourceStudyUuid={sourceStudyUuid}", + targetStudyUuid, nodeToCopy.getId(), referenceNodeUuid, insertMode, sourceStudyUuid) + .header(USER_ID_HEADER, USER_ID)) + .andExpect(status().isOk()); } List nodesAfterDuplication = networkModificationTreeService.getAllNodes(targetStudyUuid).stream().map(NodeEntity::getIdNode) @@ -2335,17 +2359,21 @@ private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkMo @Test public void testGetDefaultProviders() throws Exception { // related to LoadFlowTest::testGetDefaultProvidersFromProfile but without a user, so it doesn't use profiles - mockMvc.perform(get("/v1/loadflow-default-provider")) - .andExpectAll(status().isOk(), content().string(DEFAULT_PROVIDER)); - mockMvc.perform(get("/v1/security-analysis-default-provider")) - .andExpectAll(status().isOk(), content().string(DEFAULT_PROVIDER)); - mockMvc.perform(get("/v1/sensitivity-analysis-default-provider")) - .andExpectAll(status().isOk(), content().string(DEFAULT_PROVIDER)); + mockMvc.perform(get("/v1/loadflow-default-provider")).andExpectAll( + status().isOk(), + content().string(DEFAULT_PROVIDER)); + mockMvc.perform(get("/v1/security-analysis-default-provider")).andExpectAll( + status().isOk(), + content().string(DEFAULT_PROVIDER)); + mockMvc.perform(get("/v1/sensitivity-analysis-default-provider")).andExpectAll( + status().isOk(), + content().string(DEFAULT_PROVIDER)); var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().allMatch(r -> r.matches("/v1/default-provider"))); - mockMvc.perform(get("/v1/non-evacuated-energy-default-provider")) - .andExpectAll(status().isOk(), content().string(defaultNonEvacuatedEnergyProvider)); + mockMvc.perform(get("/v1/non-evacuated-energy-default-provider")).andExpectAll( + status().isOk(), + content().string(defaultNonEvacuatedEnergyProvider)); } private void checkSubtreeMovedMessageSent(UUID studyUuid, UUID movedNodeUuid, UUID referenceNodeUuid) { @@ -2375,15 +2403,15 @@ private void checkElementUpdatedMessageSent(UUID elementUuid, String userId) { @Test public void reindexStudyTest() throws Exception { mockMvc.perform(post("/v1/studies/{studyUuid}/reindex-all", UUID.randomUUID())) - .andExpect(status().isNotFound()); + .andExpect(status().isNotFound()); mockMvc.perform(get("/v1/studies/{studyUuid}/indexation/status", UUID.randomUUID())) - .andExpectAll(status().isNotFound()); + .andExpectAll(status().isNotFound()); UUID notExistingNetworkStudyUuid = createStudy(USER_ID, NOT_EXISTING_NETWORK_CASE_UUID); mockMvc.perform(post("/v1/studies/{studyUuid}/reindex-all", notExistingNetworkStudyUuid)) - .andExpect(status().isInternalServerError()); + .andExpect(status().isInternalServerError()); Message indexationStatusMessageOnGoing = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); Message indexationStatusMessageNotIndexed = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); @@ -2391,7 +2419,7 @@ public void reindexStudyTest() throws Exception { assertTrue(requests.stream().anyMatch(r -> r.getPath().contains("/v1/networks/" + NOT_EXISTING_NETWORK_UUID + "/reindex-all"))); mockMvc.perform(get("/v1/studies/{studyUuid}/indexation/status", notExistingNetworkStudyUuid)) - .andExpectAll(status().isInternalServerError()); + .andExpectAll(status().isInternalServerError()); requests = TestUtils.getRequestsWithBodyDone(1, server); assertEquals(1, requests.stream().filter(r -> r.getPath().contains("/v1/networks/" + NOT_EXISTING_NETWORK_UUID + "/indexed-equipments")).count()); @@ -2399,11 +2427,12 @@ public void reindexStudyTest() throws Exception { UUID study1Uuid = createStudy(USER_ID, CASE_UUID); mockMvc.perform(get("/v1/studies/{studyUuid}/indexation/status", study1Uuid)) - .andExpectAll(status().isOk(), content().string("NOT_INDEXED")); + .andExpectAll(status().isOk(), + content().string("NOT_INDEXED")); indexationStatusMessageNotIndexed = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); mockMvc.perform(post("/v1/studies/{studyUuid}/reindex-all", study1Uuid)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); indexationStatusMessageOnGoing = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); Message indexationStatusMessageDone = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); @@ -2411,7 +2440,8 @@ public void reindexStudyTest() throws Exception { assertEquals(NotificationService.UPDATE_TYPE_INDEXATION_STATUS, indexationStatusMessageDone.getHeaders().get(HEADER_UPDATE_TYPE)); mockMvc.perform(get("/v1/studies/{studyUuid}/indexation/status", study1Uuid)) - .andExpectAll(status().isOk(), content().string("INDEXED")); + .andExpectAll(status().isOk(), + content().string("INDEXED")); requests = TestUtils.getRequestsWithBodyDone(4, server); assertTrue(requests.stream().anyMatch(r -> r.getPath().contains("/v1/networks/" + NETWORK_UUID_STRING + "/reindex-all"))); @@ -2423,7 +2453,7 @@ public void reindexStudyTest() throws Exception { assertEquals(NotificationService.NODE_BUILD_STATUS_UPDATED, buildStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE)); mockMvc.perform(post("/v1/studies/{studyUuid}/reindex-all", study1Uuid)) - .andExpect(status().is5xxServerError()); + .andExpect(status().is5xxServerError()); indexationStatusMessageOnGoing = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); indexationStatusMessageNotIndexed = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); @@ -2436,13 +2466,14 @@ public void providerTest() throws Exception { UUID studyUuid = createStudy(USER_ID_HEADER, CASE_UUID); assertNotNull(studyUuid); mockMvc.perform(get("/v1/studies/{studyUuid}/non-evacuated-energy/provider", studyUuid)) - .andExpectAll(status().isOk(), content().string(defaultNonEvacuatedEnergyProvider)); + .andExpectAll(status().isOk(), + content().string(defaultNonEvacuatedEnergyProvider)); mockMvc.perform(post("/v1/studies/{studyUuid}/loadflow/provider", studyUuid) .content("SuperLF") .contentType(MediaType.TEXT_PLAIN) .header(USER_ID_HEADER, USER_ID_HEADER)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); Message message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); assertNotNull(message); assertEquals(NotificationService.UPDATE_TYPE_LOADFLOW_STATUS, message.getHeaders().get(HEADER_UPDATE_TYPE)); @@ -2452,23 +2483,25 @@ public void providerTest() throws Exception { .content("SuperSA") .contentType(MediaType.TEXT_PLAIN) .header(USER_ID_HEADER, USER_ID_HEADER)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); assertNotNull(message); assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, message.getHeaders().get(HEADER_UPDATE_TYPE)); assertNotNull(output.receive(TIMEOUT, ELEMENT_UPDATE_DESTINATION)); mockMvc.perform(post("/v1/studies/{studyUuid}/non-evacuated-energy/provider", studyUuid) - .content("SuperNEE").contentType(MediaType.TEXT_PLAIN) - .header(USER_ID_HEADER, USER_ID_HEADER)) - .andExpect(status().isOk()); + .content("SuperNEE") + .contentType(MediaType.TEXT_PLAIN) + .header(USER_ID_HEADER, USER_ID_HEADER)) + .andExpect(status().isOk()); message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); assertNotNull(message); assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, message.getHeaders().get(HEADER_UPDATE_TYPE)); assertNotNull(output.receive(TIMEOUT, ELEMENT_UPDATE_DESTINATION)); mockMvc.perform(get("/v1/studies/{studyUuid}/non-evacuated-energy/provider", studyUuid)) - .andExpectAll(status().isOk(), content().string("SuperNEE")); + .andExpectAll(status().isOk(), + content().string("SuperNEE")); var requests = TestUtils.getRequestsDone(2, server); assertTrue(requests.stream().allMatch(r -> r.matches("/v1/parameters/.*/provider"))); @@ -2480,7 +2513,7 @@ public void testSupervision() throws Exception { UUID studyUuid = createStudy(USER_ID, CASE_UUID); mockMvc.perform(post("/v1/studies/{studyUuid}/reindex-all", studyUuid)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); Message indexationStatusMessageOnGoing = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); Message indexationStatusMessageDone = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); @@ -2488,7 +2521,8 @@ public void testSupervision() throws Exception { assertEquals(NotificationService.UPDATE_TYPE_INDEXATION_STATUS, indexationStatusMessageDone.getHeaders().get(HEADER_UPDATE_TYPE)); mockMvc.perform(get("/v1/studies/{studyUuid}/indexation/status", studyUuid)) - .andExpectAll(status().isOk(), content().string("INDEXED")); + .andExpectAll(status().isOk(), + content().string("INDEXED")); Message buildStatusMessage = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); assertEquals(studyUuid, buildStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); @@ -2496,21 +2530,21 @@ public void testSupervision() throws Exception { // Test get elasticsearch host mvcResult = mockMvc.perform(get("/v1/supervision/elasticsearch-host")) - .andExpect(status().isOk()) - .andReturn(); + .andExpect(status().isOk()) + .andReturn(); assertEquals("localhost:9200", mvcResult.getResponse().getContentAsString()); // Test get indexed equipments index name mvcResult = mockMvc.perform(get("/v1/supervision/indexed-equipments-index-name")) - .andExpect(status().isOk()) - .andReturn(); + .andExpect(status().isOk()) + .andReturn(); assertEquals("equipments", mvcResult.getResponse().getContentAsString()); mvcResult = mockMvc.perform(get("/v1/supervision/indexed-tombstoned-equipments-index-name")) - .andExpect(status().isOk()) - .andReturn(); + .andExpect(status().isOk()) + .andReturn(); assertEquals("tombstoned-equipments", mvcResult.getResponse().getContentAsString()); @@ -2522,22 +2556,23 @@ public void testSupervision() throws Exception { assertEquals(32, Long.parseLong(mvcResult.getResponse().getContentAsString())); mvcResult = mockMvc.perform(get("/v1/supervision/indexed-tombstoned-equipments-count")) - .andExpect(status().isOk()) - .andReturn(); + .andExpect(status().isOk()) + .andReturn(); assertEquals(8, Long.parseLong(mvcResult.getResponse().getContentAsString())); // Test indexed equipments deletion mvcResult = mockMvc.perform(delete("/v1/supervision/studies/{studyUuid}/indexed-equipments", studyUuid)) - .andExpect(status().isOk()) - .andReturn(); + .andExpect(status().isOk()) + .andReturn(); assertEquals(20, Long.parseLong(mvcResult.getResponse().getContentAsString())); Message indexationStatusMessageNotIndexed = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); mockMvc.perform(get("/v1/studies/{studyUuid}/indexation/status", studyUuid)) - .andExpectAll(status().isOk(), content().string("NOT_INDEXED")); + .andExpectAll(status().isOk(), + content().string("NOT_INDEXED")); var requests = TestUtils.getRequestsWithBodyDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.getPath().contains("/v1/networks/" + NETWORK_UUID_STRING + "/reindex-all"))); @@ -2545,7 +2580,7 @@ public void testSupervision() throws Exception { assertEquals(1, requests.stream().filter(r -> r.getPath().matches("/v1/reports/.*")).count()); mockMvc.perform(delete("/v1/supervision/studies/{studyUuid}/nodes/builds", studyUuid)) - .andExpect(status().isOk()); + .andExpect(status().isOk()); buildStatusMessage = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); assertEquals(studyUuid, buildStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID));