diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index 7efe743a6..be835d405 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -175,7 +175,6 @@ public class StudyTest { private static final String VALID_PARAMS_IN_PROFILE_USER_ID = "validParamInProfileUser"; private static final String PROFILE_LOADFLOW_VALID_PARAMETERS_UUID_STRING = "1cec4a7b-ab7e-4d78-9dd7-ce73c5ef11d9"; private static final String USER_PROFILE_VALID_PARAMS_JSON = "{\"id\":\"97bb1890-a90c-43c3-a004-e631246d42d6\",\"name\":\"Profile with valid params\",\"loadFlowParameterId\":\"" + PROFILE_LOADFLOW_VALID_PARAMETERS_UUID_STRING + "\",\"allParametersLinksValid\":true}"; - private static final String USER_ID = NO_PARAMS_IN_PROFILE_USER_ID; //"userId"; private static final String PROFILE_LOADFLOW_DUPLICATED_PARAMETERS_UUID_STRING = "a4ce25e1-59a7-401d-abb1-04425fe24587"; private static final String DUPLICATED_PARAMS_JSON = "\"" + PROFILE_LOADFLOW_DUPLICATED_PARAMETERS_UUID_STRING + "\""; @@ -290,7 +289,7 @@ private void initMockBeans(Network network) { CreatedStudyBasicInfos.builder().id(UUID.fromString("11888888-0000-0000-0000-111111111112")).userId("userId1").caseFormat("UCTE").build() ); - when(studyInfosService.search(String.format("userId:%s", USER_ID))) + when(studyInfosService.search(String.format("userId:%s", "userId"))) .then((Answer>) invocation -> studiesInfos); when(equipmentInfosService.searchEquipments(any(), any(), any(), any(), any())).thenCallRealMethod(); @@ -703,11 +702,11 @@ private UUID getRootNodeUuid(UUID studyUuid) { public void testSearch() throws Exception { MvcResult mvcResult; String resultAsString; - UUID studyUuid = createStudy(USER_ID, CASE_UUID); + UUID studyUuid = createStudy("userId", 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)) + .perform(get("/v1/search?q={request}", String.format("userId:%s", "userId")).header(USER_ID_HEADER, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); List createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -715,7 +714,7 @@ public void testSearch() throws Exception { mvcResult = mockMvc .perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME", - studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) + studyUuid, rootNodeId, "B").header(USER_ID_HEADER, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); List equipmentInfos = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -723,7 +722,7 @@ public void testSearch() throws Exception { mvcResult = mockMvc .perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=NAME", - studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) + studyUuid, rootNodeId, "B").header(USER_ID_HEADER, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); equipmentInfos = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -731,14 +730,14 @@ public void testSearch() throws Exception { mvcResult = mockMvc .perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/search?userInput={request}&fieldSelector=ID", - studyUuid, rootNodeId, "B").header(USER_ID_HEADER, USER_ID)) + studyUuid, rootNodeId, "B").header(USER_ID_HEADER, "userId")) .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)) + studyUuid, rootNodeId, "B").header(USER_ID_HEADER, "userId")) .andExpectAll(status().isBadRequest(), content().string("Enum unknown entry 'bogus' should be among NAME, ID")) .andReturn(); @@ -748,20 +747,21 @@ public void testSearch() throws Exception { public void test() throws Exception { MvcResult result; String resultAsString; + String userId = "userId"; //empty list - mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, USER_ID)).andExpectAll(status().isOk(), + mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, "userId")).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(), + mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, "userId")).andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON), content().string("[]")); //insert a study - UUID studyUuid = createStudy(USER_ID, CASE_UUID); + UUID studyUuid = createStudy("userId", CASE_UUID); // check the study - result = mockMvc.perform(get("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, USER_ID)) + result = mockMvc.perform(get("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = result.getResponse().getContentAsString(); @@ -771,14 +771,14 @@ public void test() throws Exception { //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")) + NOT_EXISTING_CASE_UUID, "false").header(USER_ID_HEADER, "userId").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))); - result = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, USER_ID)) + result = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = result.getResponse().getContentAsString(); @@ -790,7 +790,7 @@ public void test() throws Exception { //even with the same name should work studyUuid = createStudy("userId2", CASE_UUID); - resultAsString = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, "userId2")) + resultAsString = mockMvc.perform(get("/v1/studies").header("userId", "userId2")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse().getContentAsString(); createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -800,7 +800,7 @@ 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)) + mockMvc.perform(get("/v1/studies/{studyUuid}", randomUuid).header(USER_ID_HEADER, "userId")) .andExpectAll(status().isNotFound(), content().contentType(MediaType.APPLICATION_JSON), jsonPath("$").value(STUDY_NOT_FOUND.name())); @@ -809,7 +809,7 @@ public void test() throws Exception { // 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")) + result = mockMvc.perform(get("/v1/studies").header("userId", "a")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = result.getResponse().getContentAsString(); @@ -833,16 +833,16 @@ public void test() throws Exception { .andExpect(status().isOk()); TestUtils.getRequestsDone(1, server); // just consume it - NetworkModificationNode modificationNode1 = createNetworkModificationNode(studyNameUserIdUuid, rootNodeUuid, UUID.randomUUID(), VARIANT_ID, "node 3", USER_ID); + NetworkModificationNode modificationNode1 = createNetworkModificationNode(studyNameUserIdUuid, rootNodeUuid, UUID.randomUUID(), VARIANT_ID, "node 3", userId); UUID modificationNode1Uuid = modificationNode1.getId(); mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/export-network/{format}", studyNameUserIdUuid, modificationNode1Uuid, "XIIDM")) .andExpect(status().isInternalServerError()); modificationNode1.setNodeBuildStatus(NodeBuildStatus.from(BuildStatus.BUILT)); - networkModificationTreeService.updateNode(studyNameUserIdUuid, modificationNode1, USER_ID); + networkModificationTreeService.updateNode(studyNameUserIdUuid, modificationNode1, userId); output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); - checkElementUpdatedMessageSent(studyNameUserIdUuid, USER_ID); + checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/export-network/{format}", studyNameUserIdUuid, modificationNode1Uuid, "XIIDM")) .andExpect(status().isOk()); @@ -852,25 +852,25 @@ public void test() throws Exception { @Test public void testCreateStudyWithImportParameters() throws Exception { - UUID studyUuid = createStudyWithImportParameters(USER_ID, CASE_UUID, "UCTE", Map.of("param1", List.of("paramValue1", "paramValue2"))); + UUID studyUuid = createStudyWithImportParameters("userId", CASE_UUID, "UCTE", Map.of("param1", List.of("paramValue1", "paramValue2"))); StudyEntity studyEntity = studyRepository.findById(studyUuid).get(); assertEquals(studyUuid, studyEntity.getId()); } @Test public void testCreateStudyWithDuplicateCase() throws Exception { - createStudyWithDuplicateCase(USER_ID, CASE_UUID); + createStudyWithDuplicateCase("userId", CASE_UUID); } @Test public void testDeleteStudy() throws Exception { - UUID studyUuid = createStudy(USER_ID, CASE_UUID); + UUID studyUuid = createStudy("userId", CASE_UUID); StudyEntity studyEntity = studyRepository.findById(studyUuid).orElseThrow(); studyEntity.setVoltageInitParametersUuid(UUID.randomUUID()); // does not have default params studyRepository.save(studyEntity); UUID stubUuid = wireMockUtils.stubNetworkModificationDeleteGroup(); - mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, USER_ID)) + mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); assertTrue(studyRepository.findById(studyUuid).isEmpty()); @@ -889,7 +889,7 @@ public void testDeleteStudy() throws Exception { @Test public void testDeleteStudyWithError() throws Exception { - UUID studyUuid = createStudy(USER_ID, CASE_UUID); + UUID studyUuid = createStudy("userId", CASE_UUID); StudyEntity studyEntity = studyRepository.findById(studyUuid).orElseThrow(); studyEntity.setLoadFlowParametersUuid(null); studyEntity.setSecurityAnalysisParametersUuid(null); @@ -902,7 +902,7 @@ public void testDeleteStudyWithError() throws Exception { }).when(caseService).deleteCase(any()); UUID stubUuid = wireMockUtils.stubNetworkModificationDeleteGroup(); - mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, USER_ID)) + mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, "userId")) .andExpectAll(status().isInternalServerError(), content().string(InterruptedException.class.getName())); wireMockUtils.verifyNetworkModificationDeleteGroup(stubUuid); @@ -914,7 +914,7 @@ public void testDeleteStudyWithError() throws Exception { @Test public void testDeleteStudyWithNonExistingCase() throws Exception { - UUID studyUuid = createStudy(USER_ID, CASE_UUID); + UUID studyUuid = createStudy("userId", CASE_UUID); UUID stubUuid = wireMockUtils.stubNetworkModificationDeleteGroup(); @@ -925,7 +925,7 @@ public void testDeleteStudyWithNonExistingCase() throws Exception { studyEntity.setCaseUuid(nonExistingCaseUuid); studyRepository.save(studyEntity); - mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, USER_ID)) + mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); assertTrue(studyRepository.findById(studyUuid).isEmpty()); @@ -941,7 +941,7 @@ public void testDeleteStudyWithNonExistingCase() throws Exception { @Test public void testMetadata() throws Exception { - UUID studyUuid = createStudy(USER_ID, CASE_UUID); + UUID studyUuid = createStudy("userId", CASE_UUID); UUID oldStudyUuid = studyUuid; studyUuid = createStudy("userId2", CASE_UUID); @@ -949,7 +949,7 @@ public void testMetadata() throws Exception { 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)) + .header(USER_ID_HEADER, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); String resultAsString = mvcResult.getResponse().getContentAsString(); List createdStudyBasicInfosList = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -969,21 +969,21 @@ 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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkStudyMetadataUpdatedMessagesReceived(); mockMvc.perform(post("/v1/studies/{studyUuid}/notification?type=NOT_EXISTING_TYPE", UUID.randomUUID()) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isBadRequest()); } @Test public void testLogsReport() throws Exception { - UUID studyUuid = createStudy(USER_ID, CASE_UUID); + UUID studyUuid = createStudy("userId", 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)) + MvcResult mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/parent-nodes-report?reportType=NETWORK_MODIFICATION", studyUuid, rootNodeUuid).header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()).andReturn(); String resultAsString = mvcResult.getResponse().getContentAsString(); List reporterModel = mapper.readValue(resultAsString, new TypeReference<>() { }); @@ -1032,7 +1032,7 @@ 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) + .header("userId", userId) .param(CASE_FORMAT, "UCTE")) .andExpect(status().isOk()) .andReturn(); @@ -1062,7 +1062,7 @@ 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) + .header("userId", userId).contentType(MediaType.APPLICATION_JSON) .param(CASE_FORMAT, caseFormat) .content(mapper.writeValueAsString(importParameters))) .andExpect(status().isOk()) @@ -1092,7 +1092,7 @@ private UUID createStudyWithDuplicateCase(String userId, UUID caseUuid) throws E MvcResult result = mockMvc.perform(post("/v1/studies/cases/{caseUuid}", caseUuid) .param("duplicateCase", "true") .param(CASE_FORMAT, "UCTE") - .header(USER_ID_HEADER, userId)) + .header("userId", userId)) .andExpect(status().isOk()) .andReturn(); String resultAsString = result.getResponse().getContentAsString(); @@ -1146,8 +1146,9 @@ public void testGetNullNetwork() { @Test public void testCreateStudyWithErrorDuringCaseImport() throws Exception { + String userId = "userId"; mockMvc.perform(post("/v1/studies/cases/{caseUuid}", CASE_UUID_CAUSING_IMPORT_ERROR) - .header(USER_ID_HEADER, USER_ID) + .header("userId", userId) .param(CASE_FORMAT, "UCTE")) .andExpect(status().is5xxServerError()); @@ -1155,10 +1156,10 @@ public void testCreateStudyWithErrorDuringCaseImport() throws Exception { Message message = output.receive(TIMEOUT, "study.update"); MessageHeaders headers = message.getHeaders(); - assertEquals(USER_ID, headers.get(HEADER_USER_ID)); + assertEquals(userId, 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( + MvcResult mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1199,21 +1200,22 @@ public void testCreateStudyCreationFailedWithoutErrorMessage() throws Exception @Test public void testCreateStudyWithErrorDuringStudyCreation() throws Exception { + String userId = "userId"; mockMvc.perform(post("/v1/studies/cases/{caseUuid}", CASE_UUID_CAUSING_STUDY_CREATION_ERROR) - .header(USER_ID_HEADER, USER_ID) + .header("userId", userId) .param(CASE_FORMAT, "UCTE")) .andExpect(status().isOk()); // assert that the broker message has been sent a study creation request message Message message = output.receive(TIMEOUT, "study.update"); MessageHeaders headers = message.getHeaders(); - assertEquals(USER_ID, headers.get(HEADER_USER_ID)); + assertEquals(userId, headers.get(HEADER_USER_ID)); assertEquals(NotificationService.UPDATE_TYPE_STUDIES, headers.get(HEADER_UPDATE_TYPE)); // study error message message = output.receive(TIMEOUT, "study.update"); headers = message.getHeaders(); - assertEquals(USER_ID, headers.get(HEADER_USER_ID)); + assertEquals(userId, headers.get(HEADER_USER_ID)); assertEquals(NotificationService.UPDATE_TYPE_STUDIES, headers.get(HEADER_UPDATE_TYPE)); assertEquals(STUDY_CREATION_ERROR_MESSAGE, headers.get(NotificationService.HEADER_ERROR)); @@ -1228,7 +1230,7 @@ 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( + mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1247,7 +1249,7 @@ 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( + mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1257,7 +1259,7 @@ public void testGetStudyCreationRequests() throws Exception { assertEquals(List.of(), bsiListResult); - mvcResult = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, USER_ID)).andExpectAll( + mvcResult = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1269,7 +1271,7 @@ 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) + .header(USER_ID_HEADER, "userId") .param(CASE_FORMAT, "XIIDM")) .andExpect(status().isOk()) .andReturn(); @@ -1280,7 +1282,7 @@ 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( + .header(USER_ID_HEADER, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1300,7 +1302,7 @@ public void testGetStudyCreationRequests() throws Exception { output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); mvcResult = mockMvc.perform(get("/v1/study_creation_requests") - .header(USER_ID_HEADER, USER_ID)).andExpectAll( + .header(USER_ID_HEADER, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1311,7 +1313,7 @@ public void testGetStudyCreationRequests() throws Exception { assertEquals(List.of(), bsiListResult); mvcResult = mockMvc.perform(get("/v1/studies") - .header(USER_ID_HEADER, USER_ID)).andExpectAll( + .header(USER_ID_HEADER, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1324,7 +1326,7 @@ public void testGetStudyCreationRequests() throws Exception { assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/networks\\?caseUuid=" + NEW_STUDY_CASE_UUID + "&variantId=" + FIRST_VARIANT_ID + "&reportUuid=.*"))); assertTrue(requests.contains(String.format("/v1/cases/%s/disableExpiration", NEW_STUDY_CASE_UUID))); assertTrue(requests.contains("/v1/parameters/default")); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + USER_ID + "/profile"))); + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/userId/profile"))); } private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, UUID nodeUuid, String updateType) { @@ -1389,7 +1391,7 @@ private void checkStudyMetadataUpdatedMessagesReceived() { @Test public void testCreateStudyWithDefaultLoadflow() throws Exception { - createStudy(USER_ID, CASE_UUID); + createStudy("userId", CASE_UUID); StudyEntity study = studyRepository.findAll().get(0); assertEquals(study.getNonEvacuatedEnergyProvider(), defaultNonEvacuatedEnergyProvider); } @@ -1410,10 +1412,11 @@ public void testCreateStudyWithDefaultLoadflowUserHasValidParamsInProfile() thro } private void testDuplicateStudy(UUID study1Uuid) throws Exception { + String userId = "userId"; RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", USER_ID); - NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID_2, "node2", USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", userId); + NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID_2, "node2", userId); // add modification on node "node1" 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\"}"; @@ -1422,13 +1425,13 @@ private void testDuplicateStudy(UUID study1Uuid) throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createTwoWindingsTransformerAttributes) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPostWithVariant(stubPostId, createTwoWindingsTransformerAttributes, NETWORK_UUID_STRING, VARIANT_ID); // add modification on node "node2" @@ -1438,13 +1441,13 @@ private void testDuplicateStudy(UUID study1Uuid) throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createLoadAttributes) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPostWithVariant(stubPostId, createLoadAttributes, NETWORK_UUID_STRING, VARIANT_ID_2); node2.setSecurityAnalysisResultUuid(UUID.randomUUID()); @@ -1454,9 +1457,9 @@ private void testDuplicateStudy(UUID study1Uuid) throws Exception { node2.setDynamicSimulationResultUuid(UUID.randomUUID()); node2.setVoltageInitResultUuid(UUID.randomUUID()); node2.setSecurityAnalysisResultUuid(UUID.randomUUID()); - networkModificationTreeService.updateNode(study1Uuid, node2, USER_ID); + networkModificationTreeService.updateNode(study1Uuid, node2, userId); output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); // duplicate the study StudyEntity duplicatedStudy = duplicateStudy(study1Uuid); @@ -1464,13 +1467,13 @@ private void testDuplicateStudy(UUID study1Uuid) throws Exception { //Test duplication from a non existing source study mockMvc.perform(post(STUDIES_URL + "?duplicateFrom={studyUuid}", UUID.randomUUID()) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isNotFound()); } @Test public void testDuplicateStudyWithParametersUuid() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + UUID study1Uuid = createStudy("userId", CASE_UUID); StudyEntity studyEntity = studyRepository.findById(study1Uuid).orElseThrow(); studyEntity.setLoadFlowParametersUuid(UUID.randomUUID()); studyEntity.setSecurityAnalysisParametersUuid(UUID.randomUUID()); @@ -1482,7 +1485,7 @@ public void testDuplicateStudyWithParametersUuid() throws Exception { @Test public void testDuplicateStudyWithoutParametersUuid() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + UUID study1Uuid = createStudy("userId", CASE_UUID); StudyEntity studyEntity = studyRepository.findById(study1Uuid).orElseThrow(); studyEntity.setLoadFlowParametersUuid(null); studyEntity.setSecurityAnalysisParametersUuid(null); @@ -1493,7 +1496,7 @@ public void testDuplicateStudyWithoutParametersUuid() throws Exception { @Test public void testDuplicateStudyWithErrorDuringCaseDuplication() throws Exception { - UUID studyUuid = createStudy(USER_ID, CASE_UUID); + UUID studyUuid = createStudy("userId", CASE_UUID); StudyEntity studyEntity = studyRepository.findById(studyUuid).orElseThrow(); studyRepository.save(studyEntity); @@ -1503,7 +1506,7 @@ public void testDuplicateStudyWithErrorDuringCaseDuplication() throws Exception String response = mockMvc.perform(post(STUDIES_URL + "?duplicateFrom={studyUuid}", studyUuid) .param(CASE_FORMAT, "XIIDM") - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); String duplicatedStudyUuid = mapper.readValue(response, String.class); @@ -1515,7 +1518,7 @@ 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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); String newUuid = mapper.readValue(response, String.class); StudyEntity sourceStudy = studyRepository.findById(studyUuid).orElseThrow(); @@ -1612,12 +1615,13 @@ private StudyEntity duplicateStudy(UUID studyUuid) throws Exception { @Test public void testCutAndPasteNode() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + String userId = "userId"; + UUID study1Uuid = createStudy("userId", CASE_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", USER_ID); - NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID_2, "node2", USER_ID); - NetworkModificationNode emptyNode = createNetworkModificationNode(study1Uuid, rootNode.getId(), EMPTY_MODIFICATION_GROUP_UUID, VARIANT_ID_2, "emptyNode", USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", userId); + NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID_2, "node2", userId); + NetworkModificationNode emptyNode = createNetworkModificationNode(study1Uuid, rootNode.getId(), EMPTY_MODIFICATION_GROUP_UUID, VARIANT_ID_2, "emptyNode", userId); /* * rootNode @@ -1633,13 +1637,13 @@ public void testCutAndPasteNode() throws Exception { 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)) + .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPost(stubUuid, createTwoWindingsTransformerAttributes, NETWORK_UUID_STRING); // add modification on node "node2" @@ -1648,27 +1652,27 @@ public void testCutAndPasteNode() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createLoadAttributes) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPost(stubUuid, createLoadAttributes, NETWORK_UUID_STRING); node2.setLoadFlowResultUuid(UUID.randomUUID()); node2.setSecurityAnalysisResultUuid(UUID.randomUUID()); - networkModificationTreeService.updateNode(study1Uuid, node2, USER_ID); + networkModificationTreeService.updateNode(study1Uuid, node2, userId); output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); // node2 should not have any child List allNodes = networkModificationTreeService.getAllNodes(study1Uuid); assertEquals(0, allNodes.stream().filter(nodeEntity -> nodeEntity.getParentNode() != null && nodeEntity.getParentNode().getIdNode().equals(node2.getId())).count()); // cut the node1 and paste it after node2 - cutAndPasteNode(study1Uuid, node1, node2.getId(), InsertMode.AFTER, 0, USER_ID); + cutAndPasteNode(study1Uuid, node1, node2.getId(), InsertMode.AFTER, 0, userId); /* * rootNode @@ -1698,7 +1702,7 @@ public void testCutAndPasteNode() throws Exception { .toList()); // cut and paste the node2 before emptyNode - cutAndPasteNode(study1Uuid, node2, emptyNode.getId(), InsertMode.BEFORE, 1, USER_ID); + cutAndPasteNode(study1Uuid, node2, emptyNode.getId(), InsertMode.BEFORE, 1, userId); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); /* @@ -1734,7 +1738,7 @@ public void testCutAndPasteNode() throws Exception { .toList()); //cut and paste node2 in a new branch starting from modificationNode - cutAndPasteNode(study1Uuid, node2, modificationNodeUuid, InsertMode.CHILD, 1, USER_ID); + cutAndPasteNode(study1Uuid, node2, modificationNodeUuid, InsertMode.CHILD, 1, userId); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); /* @@ -1764,10 +1768,11 @@ public void testCutAndPasteNode() throws Exception { @Test public void testCutAndPasteNodeAroundItself() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + String userId = "userId"; + UUID study1Uuid = createStudy(userId, CASE_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", userId); UUID stubGetCountUuid = wireMockUtils.stubNetworkModificationCountGet(node1.getModificationGroupUuid().toString(), 0); @@ -1775,7 +1780,7 @@ public void testCutAndPasteNodeAroundItself() throws Exception { 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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, node1.getModificationGroupUuid().toString()); @@ -1783,7 +1788,7 @@ public void testCutAndPasteNodeAroundItself() throws Exception { 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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, node1.getModificationGroupUuid().toString()); @@ -1791,22 +1796,23 @@ public void testCutAndPasteNodeAroundItself() throws Exception { 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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, node1.getModificationGroupUuid().toString()); } @Test public void testCutAndPasteNodeWithoutModification() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + String userId = "userId"; + UUID study1Uuid = createStudy(userId, CASE_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, UUID.randomUUID(), VARIANT_ID, "node1", BuildStatus.BUILT, USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, UUID.randomUUID(), VARIANT_ID, "node1", BuildStatus.BUILT, userId); - 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); + NetworkModificationNode emptyNode = createNetworkModificationNode(study1Uuid, rootNode.getId(), EMPTY_MODIFICATION_GROUP_UUID, VARIANT_ID_2, "emptyNode", BuildStatus.BUILT, userId); + NetworkModificationNode emptyNodeChild = createNetworkModificationNode(study1Uuid, emptyNode.getId(), UUID.randomUUID(), VARIANT_ID_3, "emptyNodeChild", BuildStatus.BUILT, userId); - cutAndPasteNode(study1Uuid, emptyNode, node1.getId(), InsertMode.BEFORE, 1, USER_ID); + cutAndPasteNode(study1Uuid, emptyNode, node1.getId(), InsertMode.BEFORE, 1, userId); Set request = TestUtils.getRequestsDone(1, server); assertTrue(request.stream().allMatch(r -> r.matches("/v1/reports/.*"))); @@ -1818,15 +1824,16 @@ public void testCutAndPasteNodeWithoutModification() throws Exception { @Test public void testCutAndPasteNodeWithModification() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + String userId = "userId"; + UUID study1Uuid = createStudy(userId, CASE_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, UUID.randomUUID(), VARIANT_ID, "node1", BuildStatus.BUILT, USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, UUID.randomUUID(), VARIANT_ID, "node1", BuildStatus.BUILT, userId); - NetworkModificationNode notEmptyNode = createNetworkModificationNode(study1Uuid, rootNode.getId(), UUID.randomUUID(), VARIANT_ID_2, "notEmptyNode", BuildStatus.BUILT, USER_ID); - NetworkModificationNode notEmptyNodeChild = createNetworkModificationNode(study1Uuid, notEmptyNode.getId(), UUID.randomUUID(), VARIANT_ID_3, "notEmptyNodeChild", BuildStatus.BUILT, USER_ID); + NetworkModificationNode notEmptyNode = createNetworkModificationNode(study1Uuid, rootNode.getId(), UUID.randomUUID(), VARIANT_ID_2, "notEmptyNode", BuildStatus.BUILT, userId); + NetworkModificationNode notEmptyNodeChild = createNetworkModificationNode(study1Uuid, notEmptyNode.getId(), UUID.randomUUID(), VARIANT_ID_3, "notEmptyNodeChild", BuildStatus.BUILT, userId); - cutAndPasteNode(study1Uuid, notEmptyNode, node1.getId(), InsertMode.BEFORE, 1, USER_ID); + cutAndPasteNode(study1Uuid, notEmptyNode, node1.getId(), InsertMode.BEFORE, 1, userId); Set request = TestUtils.getRequestsDone(3, server); assertTrue(request.stream().allMatch(r -> r.matches("/v1/reports/.*"))); @@ -1838,23 +1845,24 @@ public void testCutAndPasteNodeWithModification() throws Exception { @Test public void testCutAndPastErrors() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + String userId = "userId"; + UUID study1Uuid = createStudy("userId", CASE_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", userId); //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)) + .header(USER_ID_HEADER, "userId")) .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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isNotFound()); //try to cut and paste to before the root node and expect forbidden @@ -1862,7 +1870,7 @@ public void testCutAndPastErrors() throws Exception { 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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubUuid, node1.getModificationGroupUuid().toString()); @@ -1870,24 +1878,25 @@ public void testCutAndPastErrors() throws Exception { @Test public void testCutAndPasteSubtree() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + String userId = "userId"; + UUID study1Uuid = createStudy(userId, CASE_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, UUID.randomUUID(), VARIANT_ID, "node1", BuildStatus.BUILT, USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, UUID.randomUUID(), VARIANT_ID, "node1", BuildStatus.BUILT, userId); - 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); + NetworkModificationNode emptyNode = createNetworkModificationNode(study1Uuid, rootNode.getId(), EMPTY_MODIFICATION_GROUP_UUID, VARIANT_ID_2, "emptyNode", BuildStatus.BUILT, userId); + NetworkModificationNode emptyNodeChild = createNetworkModificationNode(study1Uuid, emptyNode.getId(), UUID.randomUUID(), VARIANT_ID_3, "emptyNodeChild", BuildStatus.BUILT, userId); mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/subtrees?subtreeToCutParentNodeUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}", study1Uuid, emptyNode.getId(), emptyNodeChild.getId()) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, userId)) .andExpect(status().isForbidden()); mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/subtrees?subtreeToCutParentNodeUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}", study1Uuid, emptyNode.getId(), node1.getId()) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(emptyNode.getId(), emptyNodeChild.getId())); @@ -1910,7 +1919,7 @@ public void testCutAndPasteSubtree() throws Exception { assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); checkSubtreeMovedMessageSent(study1Uuid, emptyNode.getId(), node1.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); var request = TestUtils.getRequestsDone(2, server); assertTrue(request.stream().allMatch(r -> r.matches("/v1/reports/.*"))); @@ -1922,23 +1931,24 @@ public void testCutAndPasteSubtree() throws Exception { mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, emptyNode.getId()) - .header(USER_ID_HEADER, USER_ID)).andExpect(status().isOk()); + .header(USER_ID_HEADER, "userId")).andExpect(status().isOk()); mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, UUID.randomUUID()) - .header(USER_ID_HEADER, USER_ID)).andExpect(status().isNotFound()); + .header(USER_ID_HEADER, "userId")).andExpect(status().isNotFound()); } @Test public void testDuplicateNode() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + String userId = "userId"; + UUID study1Uuid = createStudy(userId, CASE_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", USER_ID); - NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID_2, "node2", USER_ID); - NetworkModificationNode node3 = createNetworkModificationNode(study1Uuid, rootNode.getId(), UUID.randomUUID(), VARIANT_ID, "node3", BuildStatus.BUILT, USER_ID); - NetworkModificationNode emptyNode = createNetworkModificationNode(study1Uuid, rootNode.getId(), EMPTY_MODIFICATION_GROUP_UUID, VARIANT_ID_2, "emptyNode", USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", userId); + NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID_2, "node2", userId); + NetworkModificationNode node3 = createNetworkModificationNode(study1Uuid, rootNode.getId(), UUID.randomUUID(), VARIANT_ID, "node3", BuildStatus.BUILT, userId); + NetworkModificationNode emptyNode = createNetworkModificationNode(study1Uuid, rootNode.getId(), EMPTY_MODIFICATION_GROUP_UUID, VARIANT_ID_2, "emptyNode", userId); // add modification on node "node1" 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\"}"; @@ -1946,13 +1956,13 @@ public void testDuplicateNode() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createTwoWindingsTransformerAttributes) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPostWithVariant(stubUuid, createTwoWindingsTransformerAttributes, NETWORK_UUID_STRING, VARIANT_ID); // add modification on node "node2" @@ -1961,27 +1971,27 @@ public void testDuplicateNode() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createLoadAttributes) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPostWithVariant(stubUuid, createLoadAttributes, NETWORK_UUID_STRING, VARIANT_ID_2); node2.setLoadFlowResultUuid(UUID.randomUUID()); node2.setSecurityAnalysisResultUuid(UUID.randomUUID()); - networkModificationTreeService.updateNode(study1Uuid, node2, USER_ID); + networkModificationTreeService.updateNode(study1Uuid, node2, userId); output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); //node2 should not have any child List allNodes = networkModificationTreeService.getAllNodes(study1Uuid); assertEquals(0, allNodes.stream().filter(nodeEntity -> nodeEntity.getParentNode() != null && nodeEntity.getParentNode().getIdNode().equals(node2.getId())).count()); // duplicate the node1 after node2 - UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study1Uuid, node1, node2.getId(), InsertMode.AFTER, USER_ID); + UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study1Uuid, node1, node2.getId(), InsertMode.AFTER, userId); //node2 should now have 1 child allNodes = networkModificationTreeService.getAllNodes(study1Uuid); @@ -1992,7 +2002,7 @@ public void testDuplicateNode() throws Exception { .count()); // duplicate the node2 before node1 - UUID duplicatedNodeUuid2 = duplicateNode(study1Uuid, study1Uuid, node2, node1.getId(), InsertMode.BEFORE, USER_ID); + UUID duplicatedNodeUuid2 = duplicateNode(study1Uuid, study1Uuid, node2, node1.getId(), InsertMode.BEFORE, userId); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); assertEquals(1, allNodes.stream() .filter(nodeEntity -> nodeEntity.getParentNode() != null @@ -2002,7 +2012,7 @@ public void testDuplicateNode() throws Exception { //now the tree looks like root -> modificationNode -> duplicatedNode2 -> node1 -> node2 -> duplicatedNode1 //duplicate node1 in a new branch starting from duplicatedNode2 - UUID duplicatedNodeUuid3 = duplicateNode(study1Uuid, study1Uuid, node1, duplicatedNodeUuid2, InsertMode.CHILD, USER_ID); + UUID duplicatedNodeUuid3 = duplicateNode(study1Uuid, study1Uuid, node1, duplicatedNodeUuid2, InsertMode.CHILD, userId); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); //expect to have modificationNode as a parent assertEquals(1, allNodes.stream() @@ -2017,38 +2027,39 @@ public void testDuplicateNode() throws Exception { 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)) + .header(USER_ID_HEADER, "userId")) .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)) + .header(USER_ID_HEADER, "userId")) .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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isForbidden()); // Test Built status when duplicating an empty node assertEquals(BuildStatus.BUILT, networkModificationTreeService.getNodeBuildStatus(node3.getId()).getGlobalBuildStatus()); - duplicateNode(study1Uuid, study1Uuid, emptyNode, node3.getId(), InsertMode.BEFORE, USER_ID); + duplicateNode(study1Uuid, study1Uuid, emptyNode, node3.getId(), InsertMode.BEFORE, userId); assertEquals(BuildStatus.BUILT, networkModificationTreeService.getNodeBuildStatus(node3.getId()).getGlobalBuildStatus()); } @Test public void testDuplicateSubtree() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + String userId = "userId"; + UUID study1Uuid = createStudy(userId, CASE_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", USER_ID); - NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, node1.getId(), VARIANT_ID_2, "node2", USER_ID); - NetworkModificationNode node3 = createNetworkModificationNode(study1Uuid, node2.getId(), UUID.randomUUID(), VARIANT_ID, "node3", BuildStatus.BUILT, USER_ID); - NetworkModificationNode node4 = createNetworkModificationNode(study1Uuid, rootNode.getId(), EMPTY_MODIFICATION_GROUP_UUID, VARIANT_ID_2, "emptyNode", USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", userId); + NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, node1.getId(), VARIANT_ID_2, "node2", userId); + NetworkModificationNode node3 = createNetworkModificationNode(study1Uuid, node2.getId(), UUID.randomUUID(), VARIANT_ID, "node3", BuildStatus.BUILT, userId); + NetworkModificationNode node4 = createNetworkModificationNode(study1Uuid, rootNode.getId(), EMPTY_MODIFICATION_GROUP_UUID, VARIANT_ID_2, "emptyNode", userId); /*tree state root @@ -2065,13 +2076,13 @@ public void testDuplicateSubtree() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createTwoWindingsTransformerAttributes) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId(), node3.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPostWithVariant(stubUuid, createTwoWindingsTransformerAttributes, NETWORK_UUID_STRING, VARIANT_ID); // Invalidation node 3 @@ -2085,21 +2096,21 @@ public void testDuplicateSubtree() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createLoadAttributes) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPostWithVariant(stubUuid, createLoadAttributes, NETWORK_UUID_STRING, VARIANT_ID_2); node2.setNodeBuildStatus(NodeBuildStatus.from(BuildStatus.BUILT)); node2.setLoadFlowResultUuid(UUID.randomUUID()); node2.setSecurityAnalysisResultUuid(UUID.randomUUID()); - networkModificationTreeService.updateNode(study1Uuid, node2, USER_ID); + networkModificationTreeService.updateNode(study1Uuid, node2, userId); output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); //node 4 should not have any children List allNodes = networkModificationTreeService.getAllNodes(study1Uuid); @@ -2112,7 +2123,7 @@ public void testDuplicateSubtree() throws Exception { 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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); List nodesAfterDuplication = networkModificationTreeService.getAllNodes(study1Uuid).stream().map(NodeEntity::getIdNode) @@ -2120,7 +2131,7 @@ public void testDuplicateSubtree() throws Exception { assertEquals(3, nodesAfterDuplication.size()); checkSubtreeCreatedMessageSent(study1Uuid, nodesAfterDuplication.get(0), node4.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyDuplicateModificationGroup(stubDuplicateUuid, 3); /*tree state @@ -2138,12 +2149,12 @@ public void testDuplicateSubtree() throws Exception { mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, nodesAfterDuplication.get(0)) - .header(USER_ID_HEADER, USER_ID)).andExpect(status().isOk()); + .header(USER_ID_HEADER, "userId")).andExpect(status().isOk()); mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, UUID.randomUUID()) - .header(USER_ID_HEADER, USER_ID)).andExpect(status().isNotFound()); + .header(USER_ID_HEADER, "userId")).andExpect(status().isNotFound()); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); @@ -2170,29 +2181,30 @@ public void testDuplicateSubtree() throws Exception { 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)) + .header(USER_ID_HEADER, "userId")) .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) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isNotFound()); } @Test public void testDuplicateNodeBetweenStudies() throws Exception { - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + String userId = "userId"; + UUID study1Uuid = createStudy(userId, CASE_UUID); RootNode rootNode = networkModificationTreeService.getStudyTree(study1Uuid); UUID modificationNodeUuid = rootNode.getChildren().get(0).getId(); - NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", USER_ID); - NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID_2, "node2", USER_ID); + NetworkModificationNode node1 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID, "node1", userId); + NetworkModificationNode node2 = createNetworkModificationNode(study1Uuid, modificationNodeUuid, VARIANT_ID_2, "node2", userId); - UUID study2Uuid = createStudy(USER_ID, CASE_UUID); + UUID study2Uuid = createStudy(userId, CASE_UUID); RootNode study2RootNode = networkModificationTreeService.getStudyTree(study2Uuid); UUID study2ModificationNodeUuid = study2RootNode.getChildren().get(0).getId(); - NetworkModificationNode study2Node2 = createNetworkModificationNode(study2Uuid, study2ModificationNodeUuid, VARIANT_ID_2, "node2", USER_ID); + NetworkModificationNode study2Node2 = createNetworkModificationNode(study2Uuid, study2ModificationNodeUuid, VARIANT_ID_2, "node2", userId); // add modification on study 1 node "node1" UUID stubUuid = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); @@ -2200,13 +2212,13 @@ public void testDuplicateNodeBetweenStudies() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createTwoWindingsTransformerAttributes) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPostWithVariant(stubUuid, createTwoWindingsTransformerAttributes, NETWORK_UUID_STRING, VARIANT_ID); // add modification on node "node2" @@ -2215,13 +2227,13 @@ public void testDuplicateNodeBetweenStudies() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createLoadAttributes) - .header(USER_ID_HEADER, USER_ID)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); - checkElementUpdatedMessageSent(study1Uuid, USER_ID); + checkElementUpdatedMessageSent(study1Uuid, userId); wireMockUtils.verifyNetworkModificationPostWithVariant(stubUuid, createLoadAttributes, NETWORK_UUID_STRING, VARIANT_ID_2); //study 2 node2 should not have any child @@ -2229,7 +2241,7 @@ public void testDuplicateNodeBetweenStudies() throws Exception { assertEquals(0, allNodes.stream().filter(nodeEntity -> nodeEntity.getParentNode() != null && nodeEntity.getParentNode().getIdNode().equals(study2Node2.getId())).count()); // duplicate the node1 from study 1 after node2 from study 2 - UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study2Uuid, node1, study2Node2.getId(), InsertMode.AFTER, USER_ID); + UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study2Uuid, node1, study2Node2.getId(), InsertMode.AFTER, userId); //node2 should now have 1 child allNodes = networkModificationTreeService.getAllNodes(study2Uuid); @@ -2329,13 +2341,13 @@ private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkMo 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)) + .header(USER_ID_HEADER, "userId")) .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)) + .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); } @@ -2408,7 +2420,7 @@ public void reindexStudyTest() throws Exception { mockMvc.perform(get("/v1/studies/{studyUuid}/indexation/status", UUID.randomUUID())) .andExpectAll(status().isNotFound()); - UUID notExistingNetworkStudyUuid = createStudy(USER_ID, NOT_EXISTING_NETWORK_CASE_UUID); + UUID notExistingNetworkStudyUuid = createStudy("userId", NOT_EXISTING_NETWORK_CASE_UUID); mockMvc.perform(post("/v1/studies/{studyUuid}/reindex-all", notExistingNetworkStudyUuid)) .andExpect(status().isInternalServerError()); @@ -2424,7 +2436,7 @@ public void reindexStudyTest() throws Exception { requests = TestUtils.getRequestsWithBodyDone(1, server); assertEquals(1, requests.stream().filter(r -> r.getPath().contains("/v1/networks/" + NOT_EXISTING_NETWORK_UUID + "/indexed-equipments")).count()); - UUID study1Uuid = createStudy(USER_ID, CASE_UUID); + UUID study1Uuid = createStudy("userId", CASE_UUID); mockMvc.perform(get("/v1/studies/{studyUuid}/indexation/status", study1Uuid)) .andExpectAll(status().isOk(), @@ -2510,7 +2522,7 @@ public void providerTest() throws Exception { @Test public void testSupervision() throws Exception { MvcResult mvcResult; - UUID studyUuid = createStudy(USER_ID, CASE_UUID); + UUID studyUuid = createStudy("userId", CASE_UUID); mockMvc.perform(post("/v1/studies/{studyUuid}/reindex-all", studyUuid)) .andExpect(status().isOk());