diff --git a/src/main/java/org/gridsuite/study/server/StudyConstants.java b/src/main/java/org/gridsuite/study/server/StudyConstants.java index 9cbc9c661..07d776e61 100644 --- a/src/main/java/org/gridsuite/study/server/StudyConstants.java +++ b/src/main/java/org/gridsuite/study/server/StudyConstants.java @@ -63,10 +63,6 @@ private StudyConstants() { public static final String QUERY_PARAM_REPORT_UUID = "reportUuid"; public static final String QUERY_PARAM_REPORTER_ID = "reporterId"; public static final String QUERY_PARAM_REPORT_TYPE = "reportType"; - public static final String HEADER_RECEIVER = "receiver"; - public static final String HEADER_BUS_ID = "busId"; - public static final String HEADER_IMPORT_PARAMETERS = "importParameters"; - public static final String HEADER_MESSAGE = "message"; public static final String HEADER_USER_ID = "userId"; public static final String QUERY_PARAM_ONLY_STASHED = "onlyStashed"; public static final String QUERY_PARAM_STASHED = "stashed"; diff --git a/src/main/java/org/gridsuite/study/server/StudyController.java b/src/main/java/org/gridsuite/study/server/StudyController.java index abd6ac33f..30bb2f4d6 100644 --- a/src/main/java/org/gridsuite/study/server/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/StudyController.java @@ -890,7 +890,7 @@ public ResponseEntity setLoadflowProvider(@PathVariable("studyUuid") UUID @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The security analysis provider is set")}) public ResponseEntity setSecurityAnalysisProvider(@PathVariable("studyUuid") UUID studyUuid, @RequestBody(required = false) String provider, - @RequestHeader("userId") String userId) { + @RequestHeader(HEADER_USER_ID) String userId) { studyService.updateSecurityAnalysisProvider(studyUuid, provider, userId); return ResponseEntity.ok().build(); } @@ -1838,7 +1838,7 @@ public ResponseEntity setNonEvacuatedEnergyParametersInfos( @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The sensitivity analysis non evacuated energy provider is set")}) public ResponseEntity setNonEvacuatedEnergyProvider(@PathVariable("studyUuid") UUID studyUuid, @RequestBody(required = false) String provider, - @RequestHeader("userId") String userId) { + @RequestHeader(HEADER_USER_ID) String userId) { studyService.updateNonEvacuatedEnergyProvider(studyUuid, provider, userId); return ResponseEntity.ok().build(); } diff --git a/src/main/java/org/gridsuite/study/server/notification/NotificationService.java b/src/main/java/org/gridsuite/study/server/notification/NotificationService.java index 4c29b6c35..d19b596d2 100644 --- a/src/main/java/org/gridsuite/study/server/notification/NotificationService.java +++ b/src/main/java/org/gridsuite/study/server/notification/NotificationService.java @@ -97,6 +97,12 @@ public class NotificationService { public static final String HEADER_PARENT_NODE = "parentNode"; public static final String HEADER_REMOVE_CHILDREN = "removeChildren"; public static final String HEADER_INDEXATION_STATUS = "indexation_status"; + public static final String HEADER_RECEIVER = "receiver"; + public static final String HEADER_MESSAGE = "message"; + public static final String HEADER_IMPORT_PARAMETERS = "importParameters"; + public static final String HEADER_BUS_ID = "busId"; + + public static final String QUERY_PARAM_RECEIVER = "receiver"; public static final String NODE_UPDATED = "nodeUpdated"; public static final String NODE_DELETED = "nodeDeleted"; diff --git a/src/main/java/org/gridsuite/study/server/service/ConsumerService.java b/src/main/java/org/gridsuite/study/server/service/ConsumerService.java index 9a59f6a5c..e2bd9bf9f 100644 --- a/src/main/java/org/gridsuite/study/server/service/ConsumerService.java +++ b/src/main/java/org/gridsuite/study/server/service/ConsumerService.java @@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import static org.gridsuite.study.server.StudyConstants.*; +import static org.gridsuite.study.server.notification.NotificationService.*; import static org.gridsuite.study.server.dto.ComputationType.*; /** diff --git a/src/test/java/org/gridsuite/study/server/LoadFlowTest.java b/src/test/java/org/gridsuite/study/server/LoadFlowTest.java index e5f7e8bf0..13f1bc15c 100644 --- a/src/test/java/org/gridsuite/study/server/LoadFlowTest.java +++ b/src/test/java/org/gridsuite/study/server/LoadFlowTest.java @@ -66,7 +66,8 @@ import java.io.IOException; import java.util.*; -import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_RECEIVER; +import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.dto.ComputationType.LOAD_FLOW; import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; import static org.junit.Assert.*; @@ -126,8 +127,6 @@ public class LoadFlowTest { private static final long TIMEOUT = 1000; - private static final String USER_ID_HEADER = "userId"; - private static final String DEFAULT_PROVIDER = "defaultProvider"; private static final String OTHER_PROVIDER = "otherProvider"; @@ -373,12 +372,12 @@ public void testLoadFlow() throws Exception { // run a loadflow on root node (not allowed) mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run", studyNameUserIdUuid, rootNodeUuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); //run a loadflow mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run", studyNameUserIdUuid, modificationNode3Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); @@ -413,7 +412,7 @@ public void testLoadFlow() throws Exception { // loadflow failed mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run", studyNameUserIdUuid, modificationNode2Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_FAILED); @@ -434,7 +433,7 @@ public void testGetLimitViolations() throws Exception { //run a loadflow mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run?limitReduction=0.7", studyNameUserIdUuid, modificationNode1Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()) .andReturn(); @@ -486,7 +485,7 @@ public void testInvalidateStatus() throws Exception { //run a loadflow mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run?limitReduction=0.7", studyNameUserIdUuid, modificationNode1Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()) .andReturn(); @@ -497,7 +496,7 @@ public void testInvalidateStatus() throws Exception { // invalidate status mockMvc.perform(put("/v1/studies/{studyUuid}/loadflow/invalidate-status", studyNameUserIdUuid) - .header("userId", "userId")).andExpect(status().isOk()); + .header(HEADER_USER_ID, "userId")).andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/invalidate-status\\?resultUuid=" + LOADFLOW_RESULT_UUID))); } @@ -522,7 +521,7 @@ public void testDeleteLoadFlowResults() throws Exception { //run a loadflow mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run", studyNameUserIdUuid, modificationNode3Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); @@ -627,7 +626,7 @@ public void testNoResult() throws Exception { private void createOrUpdateParametersAndDoChecks(UUID studyNameUserIdUuid, String parameters, String userId, HttpStatusCode status) throws Exception { mockMvc.perform( post("/v1/studies/{studyUuid}/loadflow/parameters", studyNameUserIdUuid) - .header("userId", userId) + .header(HEADER_USER_ID, userId) .contentType(MediaType.ALL) .content(parameters)) .andExpect(status().is(status.value())); @@ -709,7 +708,7 @@ public void testResetLoadFlowParametersUserHasValidParamsInProfileButNoExistingL // the following testGetDefaultProviders tests are related to StudyTest::testGetDefaultProviders but with a user and different profile cases @Test public void testGetDefaultProvidersFromProfile() throws Exception { - mockMvc.perform(get("/v1/loadflow-default-provider").header(USER_ID_HEADER, VALID_PARAMS_IN_PROFILE_USER_ID)).andExpectAll( + mockMvc.perform(get("/v1/loadflow-default-provider").header(HEADER_USER_ID, VALID_PARAMS_IN_PROFILE_USER_ID)).andExpectAll( status().isOk(), content().string(OTHER_PROVIDER)); var requests = TestUtils.getRequestsDone(2, server); @@ -719,7 +718,7 @@ public void testGetDefaultProvidersFromProfile() throws Exception { @Test public void testGetDefaultProvidersFromProfileInvalid() throws Exception { - mockMvc.perform(get("/v1/loadflow-default-provider").header(USER_ID_HEADER, INVALID_PARAMS_IN_PROFILE_USER_ID)).andExpectAll( + mockMvc.perform(get("/v1/loadflow-default-provider").header(HEADER_USER_ID, INVALID_PARAMS_IN_PROFILE_USER_ID)).andExpectAll( status().isOk(), content().string(DEFAULT_PROVIDER)); var requests = TestUtils.getRequestsDone(3, server); @@ -730,7 +729,7 @@ public void testGetDefaultProvidersFromProfileInvalid() throws Exception { @Test public void testGetDefaultProvidersWithoutProfile() throws Exception { - mockMvc.perform(get("/v1/loadflow-default-provider").header(USER_ID_HEADER, NO_PROFILE_USER_ID)).andExpectAll( + mockMvc.perform(get("/v1/loadflow-default-provider").header(HEADER_USER_ID, NO_PROFILE_USER_ID)).andExpectAll( status().isOk(), content().string(DEFAULT_PROVIDER)); var requests = TestUtils.getRequestsDone(2, server); @@ -740,7 +739,7 @@ public void testGetDefaultProvidersWithoutProfile() throws Exception { @Test public void testGetDefaultProvidersWithoutParamInProfile() throws Exception { - mockMvc.perform(get("/v1/loadflow-default-provider").header(USER_ID_HEADER, NO_PARAMS_IN_PROFILE_USER_ID)).andExpectAll( + mockMvc.perform(get("/v1/loadflow-default-provider").header(HEADER_USER_ID, NO_PARAMS_IN_PROFILE_USER_ID)).andExpectAll( status().isOk(), content().string(DEFAULT_PROVIDER)); var requests = TestUtils.getRequestsDone(2, server); @@ -826,7 +825,7 @@ 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("userId", "userId")) + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); var mess = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(mess); diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java index 3c0ccf498..a8c9a57eb 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java @@ -71,6 +71,7 @@ import java.util.concurrent.atomic.AtomicReference; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.StudyConstants.QUERY_PARAM_RECEIVER; import static org.gridsuite.study.server.utils.ImpactUtils.createModificationResultWithElementImpact; import static org.gridsuite.study.server.utils.MatcherCreatedStudyBasicInfos.createMatcherCreatedStudyBasicInfos; @@ -132,8 +133,6 @@ public class NetworkModificationTest { private static final String TEST_FILE = "testCase.xiidm"; - private static final String USER_ID_HEADER = "userId"; - private static final long TIMEOUT = 1000; private static final String URI_NETWORK_MODIF = "/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-modifications"; @@ -505,7 +504,7 @@ public void testLocalBuildValue() throws Exception { stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(networkModificationResult)); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -523,7 +522,7 @@ public void testLocalBuildValue() throws Exception { stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(networkModificationResult)); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); @@ -570,14 +569,14 @@ public void testNetworkModificationSwitch() throws Exception { // update switch on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // update switch on first modification node UUID stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -586,7 +585,7 @@ public void testNetworkModificationSwitch() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); wireMockUtils.verifyNetworkModificationPostWithVariant(stubId, bodyJson, NETWORK_UUID_STRING, VARIANT_ID); - mvcResult = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, userId)).andExpectAll( + mvcResult = mockMvc.perform(get("/v1/studies").header(HEADER_USER_ID, userId)).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -598,7 +597,7 @@ public void testNetworkModificationSwitch() throws Exception { // update switch on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); @@ -623,7 +622,7 @@ public void testNetworkModificationSwitch() throws Exception { stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(networkModificationResult)); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); Set substationsSet = ImmutableSet.of("s3", "s1", "s2"); NetworkImpactsInfos expectedPayload = NetworkImpactsInfos.builder().impactedSubstationsIds(substationsSet).build(); @@ -668,14 +667,14 @@ public void testNetworkModificationEquipment() throws Exception { //update equipment on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); //update equipment UUID stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -683,7 +682,7 @@ public void testNetworkModificationEquipment() throws Exception { checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); wireMockUtils.verifyNetworkModificationPost(stubId, bodyJson, NETWORK_UUID_STRING); - mvcResult = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, "userId").header(USER_ID_HEADER, "userId")).andExpectAll( + mvcResult = mockMvc.perform(get("/v1/studies").header(HEADER_USER_ID, "userId").header(HEADER_USER_ID, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -696,7 +695,7 @@ public void testNetworkModificationEquipment() throws Exception { // update equipment on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid2) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid2)); @@ -739,14 +738,14 @@ public void testCreateGenerator() throws Exception { // create generator on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(bodyJsonCreate).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // create generator on first modification node UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreate).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -758,7 +757,7 @@ public void testCreateGenerator() throws Exception { // create generator on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(bodyJsonCreate).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); @@ -777,7 +776,7 @@ public void testCreateGenerator() throws Exception { String bodyJsonUpdate = mapper.writeValueAsString(body); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNode1Uuid, MODIFICATION_UUID) .content(bodyJsonUpdate).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkUpdateEquipmentCreationMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -798,7 +797,7 @@ public void testCreateGenerator() throws Exception { output.receive(TIMEOUT, studyUpdateDestination); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreateBis).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); } @@ -817,14 +816,14 @@ public void testCreateShuntsCompensator() throws Exception { // create shuntCompensator on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(createShuntCompensatorAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // create shuntCompensator on modification node child of root node UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createShuntCompensatorAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -838,7 +837,7 @@ public void testCreateShuntsCompensator() throws Exception { String shuntCompensatorAttributesUpdated = "{\"type\":\"" + ModificationType.SHUNT_COMPENSATOR_CREATION + "\",\"shuntCompensatorId\":\"shuntCompensatorId2\",\"shuntCompensatorName\":\"shuntCompensatorName2\",\"voltageLevelId\":\"idVL2\",\"busOrBusbarSectionId\":\"idBus1\"}"; mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNode1Uuid, MODIFICATION_UUID) .content(shuntCompensatorAttributesUpdated).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkUpdateEquipmentCreationMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -854,7 +853,7 @@ public void testCreateShuntsCompensator() throws Exception { // create shunt compensator on building node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createShuntCompensatorAttributes2).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); } @@ -882,14 +881,14 @@ public void testCreateLine() throws Exception { // create line on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(createLineAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // create line on first modification node UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createLineAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -901,7 +900,7 @@ public void testCreateLine() throws Exception { // create line on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(createLineAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); @@ -921,7 +920,7 @@ public void testCreateLine() throws Exception { UUID stubPutId = wireMockUtils.stubNetworkModificationPut(MODIFICATION_UUID); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNode1Uuid, MODIFICATION_UUID) .content(lineAttributesUpdated).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkUpdateEquipmentCreationMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -943,7 +942,7 @@ public void testCreateLine() throws Exception { // create line on building node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createLineAttributes2).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); } @@ -965,14 +964,14 @@ public void testCreateTwoWindingsTransformer() throws Exception { // create 2WT on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(createTwoWindingsTransformerAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // create 2WT on first modification node UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createTwoWindingsTransformerAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -984,7 +983,7 @@ public void testCreateTwoWindingsTransformer() throws Exception { // create 2WT on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(createTwoWindingsTransformerAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); @@ -998,7 +997,7 @@ public void testCreateTwoWindingsTransformer() throws Exception { UUID stubPutId = wireMockUtils.stubNetworkModificationPut(MODIFICATION_UUID); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNode1Uuid, MODIFICATION_UUID) .content(twoWindingsTransformerAttributesUpdated).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkUpdateEquipmentCreationMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -1014,7 +1013,7 @@ public void testCreateTwoWindingsTransformer() throws Exception { // create Two Windings Transformer on building node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createTwoWindingsTransformerAttributes2).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); } @@ -1033,13 +1032,13 @@ public void testChangeModificationActiveState() throws Exception { // deactivate modification on modificationNode mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network_modifications/{modificationUuid}?active=false", - studyUuid, nodeNotFoundUuid, modificationUuid).header(USER_ID_HEADER, "userId") - .header(USER_ID_HEADER, userId)) + studyUuid, nodeNotFoundUuid, modificationUuid).header(HEADER_USER_ID, "userId") + .header(HEADER_USER_ID, userId)) .andExpect(status().isNotFound()); mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network_modifications/{modificationUuid}?active=false", - studyUuid, modificationNode1.getId(), modificationUuid).header(USER_ID_HEADER, "userId") - .header(USER_ID_HEADER, userId)) + studyUuid, modificationNode1.getId(), modificationUuid).header(HEADER_USER_ID, "userId") + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); AtomicReference node = new AtomicReference<>(); @@ -1052,8 +1051,8 @@ public void testChangeModificationActiveState() throws Exception { // reactivate modification mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network_modifications/{modificationUuid}?active=true", - studyUuid, modificationNode1.getId(), modificationUuid).header(USER_ID_HEADER, "userId") - .header(USER_ID_HEADER, userId)) + studyUuid, modificationNode1.getId(), modificationUuid).header(HEADER_USER_ID, "userId") + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); node.set(networkModificationTreeService.getNode(modificationNode1.getId())); @@ -1086,7 +1085,7 @@ public void deleteModificationRequest() throws Exception { UUID studyUuid1 = UUID.randomUUID(); mockMvc.perform(delete(URI_NETWORK_MODIF, studyUuid1, modificationNode.getId()) .queryParam("uuids", node3.getId().toString()) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); checkEquipmentDeletingMessagesReceived(studyUuid1, modificationNode.getId()); checkEquipmentDeletingFinishedMessagesReceived(studyUuid1, modificationNode.getId()); @@ -1094,7 +1093,7 @@ public void deleteModificationRequest() throws Exception { UUID modificationUuid = UUID.randomUUID(); mockMvc.perform(delete(URI_NETWORK_MODIF, studyUuid, modificationNode.getId()) .queryParam("uuids", modificationUuid.toString()) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); wireMockUtils.verifyDeleteRequest(stubId, "/v1/network-modifications", false, Map.of("uuids", WireMock.equalTo(modificationUuid.toString()))); checkEquipmentDeletingMessagesReceived(studyUuid, modificationNode.getId()); @@ -1107,7 +1106,7 @@ public void deleteModificationRequest() throws Exception { ).getId(); mockMvc.perform(delete("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-modifications", studyUuid, modificationNode.getId()) .queryParam("uuids", modificationUuid.toString()) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isBadRequest()); wireMockUtils.verifyDeleteRequest(stubId, "/v1/network-modifications", false, Map.of("uuids", WireMock.equalTo(modificationUuid.toString()))); checkEquipmentDeletingMessagesReceived(studyUuid, modificationNode.getId()); @@ -1137,13 +1136,13 @@ public void testUpdateLines() throws Exception { UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(bodyJsonCreate1).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // lockout line mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreate1).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -1157,7 +1156,7 @@ public void testUpdateLines() throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPostWithError(bodyJsonCreate2); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreate2).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isBadRequest()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -1170,7 +1169,7 @@ public void testUpdateLines() throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreate3).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -1184,7 +1183,7 @@ public void testUpdateLines() throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPostWithError(bodyJsonCreate4); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreate4).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isBadRequest()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -1197,7 +1196,7 @@ public void testUpdateLines() throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreate5).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -1211,7 +1210,7 @@ public void testUpdateLines() throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPostWithError(bodyJsonCreate6); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreate6).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isBadRequest()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -1224,7 +1223,7 @@ public void testUpdateLines() throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreate7).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -1238,7 +1237,7 @@ public void testUpdateLines() throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPostWithError(bodyJsonCreate8); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJsonCreate8).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isBadRequest()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -1249,7 +1248,7 @@ public void testUpdateLines() throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(bodyJsonCreate9).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); @@ -1280,14 +1279,14 @@ public void testCreateLoad() throws Exception { // create load on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(createLoadAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // create load on first modification node UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createLoadAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -1299,7 +1298,7 @@ public void testCreateLoad() throws Exception { // create load on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(createLoadAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); @@ -1313,7 +1312,7 @@ public void testCreateLoad() throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPutWithBody(MODIFICATION_UUID, loadAttributesUpdated); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNode1Uuid, MODIFICATION_UUID) .content(loadAttributesUpdated).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkUpdateEquipmentCreationMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -1330,7 +1329,7 @@ public void testCreateLoad() throws Exception { // create load on building node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode3Uuid) .content(createLoadAttributes2).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); } @@ -1352,14 +1351,14 @@ public void testModifyLoad() throws Exception { // modify load on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(loadModificationAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // modify load on first modification node UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(loadModificationAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -1371,7 +1370,7 @@ public void testModifyLoad() throws Exception { // modify load on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid2) .content(loadModificationAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid2)); @@ -1385,7 +1384,7 @@ public void testModifyLoad() throws Exception { String loadAttributesUpdated = "{\"type\":\"" + ModificationType.LOAD_MODIFICATION + "\",\"loadId\":\"loadId1\",\"loadType\":\"FICTITIOUS\",\"activePower\":\"70.0\"}"; mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(loadAttributesUpdated).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkUpdateEquipmentModificationMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1409,14 +1408,14 @@ public void testModifyEquipment() throws Exception { String equipmentModificationAttribute = "{\"type\":\"" + ModificationType.GENERATOR_MODIFICATION + "\",\"equipmentId\":\"equipmentId\"}"; mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(equipmentModificationAttribute).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // modify generator on first modification node UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(equipmentModificationAttribute).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -1428,7 +1427,7 @@ public void testModifyEquipment() throws Exception { // modify generator on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid2) .content(equipmentModificationAttribute).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid2)); @@ -1442,7 +1441,7 @@ public void testModifyEquipment() throws Exception { UUID stubPutId = wireMockUtils.stubNetworkModificationPutWithBody(MODIFICATION_UUID, generatorAttributesUpdated); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(generatorAttributesUpdated).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkUpdateEquipmentModificationMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1469,14 +1468,14 @@ public void testCreateSubstation() throws Exception { // create substation on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(createSubstationAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // create substation on first modification node UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createSubstationAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -1488,7 +1487,7 @@ public void testCreateSubstation() throws Exception { // create substation on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(createSubstationAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); @@ -1502,7 +1501,7 @@ public void testCreateSubstation() throws Exception { String substationAttributesUpdated = "{\"type\":\"" + ModificationType.SUBSTATION_CREATION + "\",\"substationId\":\"substationId2\",\"substationName\":\"substationName2\",\"country\":\"FR\"}"; mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNode1Uuid, MODIFICATION_UUID) .content(substationAttributesUpdated).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkUpdateEquipmentCreationMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -1518,7 +1517,7 @@ public void testCreateSubstation() throws Exception { // create substation on building node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createSubstationAttributes2).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); } @@ -1540,14 +1539,14 @@ public void testCreateVoltageLevel() throws Exception { // create voltage level on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(createVoltageLevelAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // create voltage level UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createVoltageLevelAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -1559,7 +1558,7 @@ public void testCreateVoltageLevel() throws Exception { // create voltage level on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(createVoltageLevelAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); @@ -1574,7 +1573,7 @@ public void testCreateVoltageLevel() throws Exception { + ",\"nominalVoltage\":\"379.1\", \"substationId\":\"s2\"}"; mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNode1Uuid, MODIFICATION_UUID) .content(voltageLevelAttributesUpdated).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkUpdateEquipmentCreationMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -1591,7 +1590,7 @@ public void testCreateVoltageLevel() throws Exception { // create voltage level on building node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(createVoltageLevelAttributes2).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); } @@ -1621,7 +1620,7 @@ public void testLineSplitWithVoltageLevel() { UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(lineSplitWoVLasJSON).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -1633,7 +1632,7 @@ public void testLineSplitWithVoltageLevel() { UUID stubPutId = wireMockUtils.stubNetworkModificationPutWithBody(MODIFICATION_UUID, lineSplitWoVLasJSON); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(lineSplitWoVLasJSON).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkUpdateEquipmentModificationMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1646,7 +1645,7 @@ public void testLineSplitWithVoltageLevel() { stubPutId = wireMockUtils.stubNetworkModificationPutWithBodyAndError(MODIFICATION_UUID, badBody); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(badBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpectAll( status().isBadRequest(), content().string("400 BAD_REQUEST")); @@ -1654,7 +1653,7 @@ public void testLineSplitWithVoltageLevel() { checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(badBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpectAll( status().isBadRequest(), content().string("400 BAD_REQUEST")); @@ -1683,7 +1682,7 @@ public void testLineAttachToVoltageLevel() { UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(createLineAttachToVoltageLevelAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -1695,7 +1694,7 @@ public void testLineAttachToVoltageLevel() { UUID stubPutId = wireMockUtils.stubNetworkModificationPutWithBody(MODIFICATION_UUID, createLineAttachToVoltageLevelAttributes); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(createLineAttachToVoltageLevelAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkUpdateEquipmentModificationMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1718,7 +1717,7 @@ public void testLinesAttachToSplitLines() { UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(createLinesAttachToSplitLinesAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -1730,7 +1729,7 @@ public void testLinesAttachToSplitLines() { UUID stubPutId = wireMockUtils.stubNetworkModificationPutWithBody(MODIFICATION_UUID, createLinesAttachToSplitLinesAttributes); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(createLinesAttachToSplitLinesAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkUpdateEquipmentModificationMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1743,13 +1742,13 @@ public void testLinesAttachToSplitLines() { stubPutId = wireMockUtils.stubNetworkModificationPutWithBodyAndError(MODIFICATION_UUID, badBody); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(badBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isBadRequest()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(badBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isBadRequest()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1778,7 +1777,7 @@ private void checkScaling(ModificationType scalingType) throws Exception { UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(requestBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -1790,7 +1789,7 @@ private void checkScaling(ModificationType scalingType) throws Exception { UUID stubPutId = wireMockUtils.stubNetworkModificationPutWithBody(MODIFICATION_UUID, requestBody); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(requestBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkUpdateEquipmentModificationMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1802,7 +1801,7 @@ private void checkScaling(ModificationType scalingType) throws Exception { stubPostId = wireMockUtils.stubNetworkModificationPostWithBodyAndError(requestBody); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(requestBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().is4xxClientError()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1811,7 +1810,7 @@ private void checkScaling(ModificationType scalingType) throws Exception { stubPutId = wireMockUtils.stubNetworkModificationPutWithBodyAndError(MODIFICATION_UUID, requestBody); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(requestBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().is4xxClientError()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1833,7 +1832,7 @@ public void testDeleteVoltageLevelOnline() { UUID stubIdPost = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(createDeleteVoltageLevelOnlineAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -1844,7 +1843,7 @@ public void testDeleteVoltageLevelOnline() { UUID stubIdPut = wireMockUtils.stubNetworkModificationPutWithBody(MODIFICATION_UUID, createDeleteVoltageLevelOnlineAttributes); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(createDeleteVoltageLevelOnlineAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkUpdateEquipmentModificationMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1854,7 +1853,7 @@ public void testDeleteVoltageLevelOnline() { String badBody = "{\"type\":\"" + ModificationType.DELETE_VOLTAGE_LEVEL_ON_LINE + "\",\"bogus\":\"bogus\"}"; UUID stubIdPostErr = wireMockUtils.stubNetworkModificationPostWithBodyAndError(badBody); UUID stubIdPutErr = wireMockUtils.stubNetworkModificationPutWithBodyAndError(MODIFICATION_UUID, badBody); - mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid).header(USER_ID_HEADER, userId) + mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid).header(HEADER_USER_ID, userId) .content(badBody).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isBadRequest()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1862,7 +1861,7 @@ public void testDeleteVoltageLevelOnline() { wireMockUtils.verifyNetworkModificationPost(stubIdPostErr, badBody, NETWORK_UUID_STRING); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) - .header(USER_ID_HEADER, userId) + .header(HEADER_USER_ID, userId) .content(badBody).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isBadRequest()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1884,7 +1883,7 @@ public void testDeleteAttachingline() { UUID stubIdPost = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(createDeleteAttachingLineAttributes).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -1894,7 +1893,7 @@ public void testDeleteAttachingline() { UUID stubIdPut = wireMockUtils.stubNetworkModificationPutWithBody(MODIFICATION_UUID, createDeleteAttachingLineAttributes); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) - .header(USER_ID_HEADER, userId) + .header(HEADER_USER_ID, userId) .content(createDeleteAttachingLineAttributes).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1907,7 +1906,7 @@ public void testDeleteAttachingline() { UUID stubIdPutErr = wireMockUtils.stubNetworkModificationPutWithBodyAndError(MODIFICATION_UUID, badBody); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(badBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isBadRequest()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1915,7 +1914,7 @@ public void testDeleteAttachingline() { mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNodeUuid, MODIFICATION_UUID) .content(badBody).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isBadRequest()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -1944,7 +1943,7 @@ public void testReorderModification() throws Exception { // switch the 2 modifications order (modification1 is set at the end, after modification2) mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-modification/{modificationID}", - studyNameUserIdUuid, modificationNodeUuid, modification1).header(USER_ID_HEADER, "userId")) + studyNameUserIdUuid, modificationNodeUuid, modification1).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -1967,7 +1966,7 @@ public void testReorderModification() throws Exception { // switch back the 2 modifications order (modification1 is set before modification2) mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-modification/{modificationID}?beforeUuid={modificationID2}", - studyNameUserIdUuid, modificationNodeUuid, modification1, modification2).header(USER_ID_HEADER, "userId")) + studyNameUserIdUuid, modificationNodeUuid, modification1, modification2).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -2003,13 +2002,13 @@ public void testReorderModificationErrorCase() throws Exception { UUID nodeIdUuid1 = UUID.randomUUID(); mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-modification/{modificationID}?beforeUuid={modificationID2}", - studyNameUserIdUuid, nodeIdUuid1, modification1, modification2).header(USER_ID_HEADER, "userId")) + studyNameUserIdUuid, nodeIdUuid1, modification1, modification2).header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, nodeIdUuid1); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, nodeIdUuid1); mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-modification/{modificationID}?beforeUuid={modificationID2}", - studyNameUserIdUuid1, modificationNodeUuid, modification1, modification2).header(USER_ID_HEADER, "userId")) + studyNameUserIdUuid1, modificationNodeUuid, modification1, modification2).header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid1, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid1, modificationNodeUuid); @@ -2039,7 +2038,7 @@ public void testDuplicateModification() throws Exception { studyUuid, nodeUuid1) .contentType(MediaType.APPLICATION_JSON) .content(modificationUuidListBody) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid1); checkNodesBuildStatusUpdatedMessageReceived(studyUuid, List.of(nodeUuid1)); @@ -2074,7 +2073,7 @@ public void testDuplicateModification() throws Exception { studyUuid, nodeUuid1) .contentType(MediaType.APPLICATION_JSON) .content(modificationUuidListBody) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); NetworkImpactsInfos expectedPayload = NetworkImpactsInfos.builder().build(); @@ -2115,7 +2114,7 @@ public void testDuplicateModificationErrorCase() throws Exception { UUID.randomUUID(), rootNodeUuid) .contentType(MediaType.APPLICATION_JSON) .content(modificationUuidListBody) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); // Random/bad nodeId error case @@ -2123,7 +2122,7 @@ public void testDuplicateModificationErrorCase() throws Exception { studyUuid, UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON) .content(modificationUuidListBody) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); } @@ -2155,7 +2154,7 @@ public void testCutAndPasteModification() throws Exception { studyUuid, nodeUuid1, nodeUuid1) .contentType(MediaType.APPLICATION_JSON) .content(modificationUuidListBody) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid1); checkNodesBuildStatusUpdatedMessageReceived(studyUuid, List.of(nodeUuid1)); @@ -2180,7 +2179,7 @@ public void testCutAndPasteModification() throws Exception { studyUuid, nodeUuid2, nodeUuid1) .contentType(MediaType.APPLICATION_JSON) .content(modificationUuidListBody) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid2); checkEquipmentUpdatingMessagesReceived(studyUuid, nodeUuid1); @@ -2211,7 +2210,7 @@ public void testCutAndPasteModification() throws Exception { studyUuid, nodeUuid1) .contentType(MediaType.APPLICATION_JSON) .content(modificationUuidListBody) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isBadRequest()); } @@ -2236,7 +2235,7 @@ public void testCutAndPasteModificationErrorCase() throws Exception { UUID.randomUUID(), rootNodeUuid, UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON) .content(modificationUuidListBody) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); // Random/bad nodeId error case @@ -2244,7 +2243,7 @@ public void testCutAndPasteModificationErrorCase() throws Exception { studyUuid, UUID.randomUUID(), UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON) .content(modificationUuidListBody) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); } @@ -2271,14 +2270,14 @@ public void testDeleteEquipment() throws Exception { // delete equipment on root node (not allowed) mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, rootNodeUuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isForbidden()); // delete equipment on first modification node UUID stubPostId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -2290,7 +2289,7 @@ public void testDeleteEquipment() throws Exception { // delete equipment on second modification node mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); @@ -2303,7 +2302,7 @@ public void testDeleteEquipment() throws Exception { UUID stubPutId = wireMockUtils.stubNetworkModificationPut(MODIFICATION_UUID); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNode1Uuid, MODIFICATION_UUID) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkUpdateEquipmentCreationMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); @@ -2347,7 +2346,7 @@ public void testNodesInvalidation() throws Exception { UUID stubUuid = wireMockUtils.stubNetworkModificationPutWithBody(MODIFICATION_UUID, generatorAttributesUpdated); mockMvc.perform(put(URI_NETWORK_MODIF_WITH_ID, studyNameUserIdUuid, modificationNode1Uuid, MODIFICATION_UUID) .content(generatorAttributesUpdated).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentUpdatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid, modificationNode2Uuid, modificationNode3Uuid)); @@ -2377,7 +2376,7 @@ public void testNodesInvalidation() throws Exception { stubUuid = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode2Uuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid, modificationNode3Uuid)); @@ -2427,7 +2426,7 @@ public void testRemoveLoadFlowComputationReport() throws Exception { UUID stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNode1Uuid) .content(bodyJson).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); @@ -2466,7 +2465,7 @@ public void testUpdateOfBuildStatus() { UUID stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -2489,7 +2488,7 @@ public void testUpdateOfBuildStatus() { stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(networkModificationResult)); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); NetworkImpactsInfos expectedPayload = NetworkImpactsInfos.builder().impactedSubstationsIds(ImmutableSet.of("s1")).deletedEquipments(ImmutableSet.of()).build(); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -2506,7 +2505,7 @@ public void testUpdateOfBuildStatus() { stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(networkModificationResult)); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2523,7 +2522,7 @@ public void testUpdateOfBuildStatus() { stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(networkModificationResult)); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2817,7 +2816,7 @@ private NetworkModificationNode createNetworkModificationNode(UUID studyUuid, UU jsonObject.put("modificationGroupUuid", modificationGroupUuid); mnBodyJson = jsonObject.toString(); - mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).header(USER_ID_HEADER, userId).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON)) + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).header(HEADER_USER_ID, userId).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); var mess = output.receive(TIMEOUT, studyUpdateDestination); @@ -2845,7 +2844,7 @@ public void testCreateModificationWithErrors() { UUID stubId = wireMockUtils.stubNetworkModificationPost(mapper.writeValueAsString(Optional.empty())); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); @@ -2859,7 +2858,7 @@ public void testCreateModificationWithErrors() { stubId = wireMockUtils.stubNetworkModificationPostWithError(jsonCreateLoadInfos); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpectAll(status().isBadRequest(), content().string(errorMessage)); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -2869,7 +2868,7 @@ public void testCreateModificationWithErrors() { stubId = wireMockUtils.stubNetworkModificationPostWithError(jsonCreateLoadInfos, String.format("{\"message\" : \"%s\"}", errorMessage)); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpectAll(status().isBadRequest(), content().string(errorMessage)); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); @@ -2880,7 +2879,7 @@ public void testCreateModificationWithErrors() { stubId = wireMockUtils.stubNetworkModificationPostWithError(jsonCreateLoadInfos, errorMessage); mockMvc.perform(post(URI_NETWORK_MODIF, studyNameUserIdUuid, modificationNodeUuid) .content(jsonCreateLoadInfos).contentType(MediaType.APPLICATION_JSON) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpectAll(status().isBadRequest(), content().string(errorMessage)); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java index 40738596f..a2251617d 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java @@ -179,7 +179,6 @@ public class NetworkModificationTreeTest { private static final String MODIFICATION1_UUID_STRING = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; private static final String MODIFICATION2_UUID_STRING = "38400000-8cf0-11bd-b23e-10b96e4ef111"; private static final String MODIFICATION_GROUP_UUID_STRING = "38400000-8cf0-11bd-b23e-10b96e4ef222"; - private static final String USER_ID_HEADER = "userId"; @MockBean private Network network; @@ -347,7 +346,7 @@ public void testGetRoot() throws Exception { mockMvc.perform(get("/v1/studies/{studyUuid}/tree", study.getId())) .andExpect(status().isOk()); - mockMvc.perform(delete("/v1/studies/{studyUuid}/tree/nodes/{id}?deleteChildren={delete}", study.getId(), root.getId(), false).header(USER_ID_HEADER, "userId")) + mockMvc.perform(delete("/v1/studies/{studyUuid}/tree/nodes/{id}?deleteChildren={delete}", study.getId(), root.getId(), false).header(HEADER_USER_ID, "userId")) .andExpect(status().is4xxClientError()); } @@ -465,7 +464,7 @@ public void testNodeStashAndRestore() throws Exception { assertNotNull(stashedNode4.getStashDate()); var result = mockMvc.perform(get("/v1/studies/{studyUuid}/tree/nodes/stash", root.getStudyId()) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()) .andReturn(); @@ -499,7 +498,7 @@ public void testNodeStashAndRestore() throws Exception { assertNull(restoredNode4.getStashDate()); result = mockMvc.perform(get("/v1/studies/{studyUuid}/tree/nodes/stash", root.getStudyId()) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()) .andReturn(); //Only the first level nodes should appear @@ -674,7 +673,7 @@ public void testNodeManipulation() throws Exception { mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", root.getStudyId(), UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON) .content(objectWriter.writeValueAsString(node1)) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); } @@ -690,7 +689,7 @@ private void deleteNode(UUID studyUuid, List child, boolean delete .toList(); String deleteNodeUuid = child.stream().map(AbstractNode::getId).map(UUID::toString).reduce("", (a1, a2) -> a1 + "," + a2).substring(1); - mockMvc.perform(delete("/v1/studies/{studyUuid}/tree/nodes?deleteChildren={delete}", studyUuid, deleteChildren).header(USER_ID_HEADER, "userId") + mockMvc.perform(delete("/v1/studies/{studyUuid}/tree/nodes?deleteChildren={delete}", studyUuid, deleteChildren).header(HEADER_USER_ID, "userId") .queryParam("ids", deleteNodeUuid)) .andExpect(status().isOk()); @@ -718,7 +717,7 @@ private void deleteNode(UUID studyUuid, List child, boolean delete } private void stashNode(UUID studyUuid, AbstractNode child, boolean stashChildren, Set expectedStash, String userId) throws Exception { - mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}/stash?stashChildren={stash}", studyUuid, child.getId(), stashChildren).header(USER_ID_HEADER, "userId")) + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}/stash?stashChildren={stash}", studyUuid, child.getId(), stashChildren).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); @@ -738,7 +737,7 @@ private void restoreNode(UUID studyUuid, List nodeId, UUID anchorNodeId, S String param = nodeId.stream().map(UUID::toString).reduce("", (a1, a2) -> a1 + "," + a2).substring(1); - mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/restore?anchorNodeId={anchorNodeId}", studyUuid, anchorNodeId).header(USER_ID_HEADER, "userId") + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/restore?anchorNodeId={anchorNodeId}", studyUuid, anchorNodeId).header(HEADER_USER_ID, "userId") .queryParam("ids", param)) .andExpect(status().isOk()); @@ -770,7 +769,7 @@ public void testNodeInsertion() throws Exception { mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}?mode=BEFORE", root.getStudyId(), root.getId()) .contentType(MediaType.APPLICATION_JSON) .content(objectWriter.writeValueAsString(networkModification1)) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().is4xxClientError()); createNode(root.getStudyId(), root, networkModification1, userId); @@ -797,7 +796,7 @@ public void testNodeInsertion() throws Exception { mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", root.getStudyId(), UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON) .content(objectWriter.writeValueAsString(networkModification1)) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); } @@ -842,7 +841,7 @@ public void testNodeUpdate() throws Exception { mockMvc.perform(put("/v1/studies/{studyUuid}/tree/nodes", root.getStudyId()) .contentType(MediaType.APPLICATION_JSON) .content(objectWriter.writeValueAsString(node1)) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkElementUpdatedMessageSent(root.getStudyId(), userId); @@ -866,7 +865,7 @@ public void testNodeUpdate() throws Exception { mockMvc.perform(put("/v1/studies/{studyUuid}/tree/nodes", root.getStudyId()) .contentType(MediaType.APPLICATION_JSON) .content(objectWriter.writeValueAsString(justANameUpdate)) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); assertEquals(NODE_RENAMED, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(HEADER_UPDATE_TYPE)); checkElementUpdatedMessageSent(root.getStudyId(), userId); @@ -879,7 +878,7 @@ public void testNodeUpdate() throws Exception { mockMvc.perform(put("/v1/studies/{studyUuid}/tree/nodes", root.getStudyId()) .contentType(MediaType.APPLICATION_JSON) .content(objectWriter.writeValueAsString(node1)) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); } @@ -899,7 +898,7 @@ public void testNodeDescriptionUpdate() throws Exception { mockMvc.perform(put("/v1/studies/{studyUuid}/tree/nodes", root.getStudyId()) .contentType(MediaType.APPLICATION_JSON) .content(objectWriter.writeValueAsString(nodeDescriptionUpdate)) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); assertEquals(NODE_UPDATED, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(HEADER_UPDATE_TYPE)); checkElementUpdatedMessageSent(root.getStudyId(), userId); @@ -995,7 +994,7 @@ private void createNode(UUID studyUuid, AbstractNode parentNode, NetworkModifica mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNode.getId()) .contentType(MediaType.APPLICATION_JSON) .content(newNodeBodyJson) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); var mess = output.receive(TIMEOUT, studyUpdateDestination); @@ -1019,7 +1018,7 @@ private void insertNode(UUID studyUuid, AbstractNode parentNode, NetworkModifica mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}?mode={mode}", studyUuid, parentNode.getId(), mode) .contentType(MediaType.APPLICATION_JSON) .content(newNodeBodyJson) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); @@ -1116,7 +1115,7 @@ private void createNodeFail(UUID studyUuid, AbstractNode parentNode, AbstractNod mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNode.getId()) .contentType(MediaType.APPLICATION_JSON) .content(objectWriter.writeValueAsString(newNode)) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); } @@ -1172,7 +1171,7 @@ public void testGetNetworkModificationsToRestoreByNode() throws Exception { node = buildNetworkModificationNode("modification node 3", "", UUID.fromString(MODIFICATION_GROUP_UUID_STRING), VARIANT_ID, null, null, null, null, null, null, BuildStatus.BUILT); createNode(root.getStudyId(), root, node, userId); mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-modifications?uuids={modificationID1}&stashed=false", root.getStudyId(), node.getId(), MODIFICATION1_UUID_STRING) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); @@ -1209,7 +1208,7 @@ public void testGetNetworkModificationsToStashByNode() throws Exception { node = buildNetworkModificationNode("modification node 3", "", UUID.fromString(MODIFICATION_GROUP_UUID_STRING), VARIANT_ID, null, null, null, null, null, null, BuildStatus.BUILT); createNode(root.getStudyId(), root, node, userId); mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/network-modifications?uuids={modificationID1}&stashed=true", root.getStudyId(), node.getId(), MODIFICATION1_UUID_STRING) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); diff --git a/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java b/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java index ab8f43d47..edcbd04f0 100644 --- a/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java +++ b/src/test/java/org/gridsuite/study/server/NonEvacuatedEnergyTest.java @@ -69,7 +69,7 @@ import java.util.*; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_RECEIVER; import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; import static org.junit.Assert.*; diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index c84d4dc70..63124f79f 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -64,7 +64,7 @@ import java.io.IOException; import java.util.*; -import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_RECEIVER; import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.dto.ComputationType.SECURITY_ANALYSIS; import static org.gridsuite.study.server.dto.ComputationType.LOAD_FLOW; @@ -551,7 +551,7 @@ private void testSecurityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, UUI assertTrue(TestUtils.getRequestsDone(1, server).contains(String.format("/v1/results/%s/status", resultUuid))); // stop security analysis - mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/stop", studyUuid, nodeUuid).header("userId", "userId")).andExpect(status().isOk()); + mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/stop", studyUuid, nodeUuid).header(HEADER_USER_ID, "userId")).andExpect(status().isOk()); securityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, securityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); @@ -620,7 +620,7 @@ 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("userId", "userId")) + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); var mess = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(mess); @@ -649,7 +649,7 @@ public void testSecurityAnalysisParameters() throws Exception { //update the parameters mockMvc.perform( post("/v1/studies/{studyUuid}/security-analysis/parameters", studyNameUserIdUuid) - .header("userId", "userId") + .header(HEADER_USER_ID, "userId") .contentType(MediaType.APPLICATION_JSON) .content(mnBodyJson)).andExpect( status().isOk()); @@ -665,7 +665,7 @@ public void testSecurityAnalysisParameters() throws Exception { //same with set parameters mockMvc.perform( post("/v1/studies/{studyUuid}/security-analysis/parameters", studyNameUserIdUuid) - .header("userId", "userId") + .header(HEADER_USER_ID, "userId") .contentType(MediaType.APPLICATION_JSON) .content(mnBodyJson)).andExpect( status().isOk()); @@ -683,7 +683,7 @@ public void testCreateSecurityAnalysisParameters() throws Exception { //test update parameters without having already created parameters -> should call create instead of update mockMvc.perform(post("/v1/studies/{studyUuid}/security-analysis/parameters", studyUuid) - .header("userId", "userId") + .header(HEADER_USER_ID, "userId") .contentType(MediaType.APPLICATION_JSON) .content(mnBodyJson)) .andExpect(status().isOk()); diff --git a/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java index 4a9aec36e..ea752302b 100644 --- a/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java @@ -69,7 +69,7 @@ import java.util.*; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_RECEIVER; import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.dto.ComputationType.SENSITIVITY_ANALYSIS; import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; @@ -297,8 +297,7 @@ private void testSensitivityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, // run sensitivity analysis mockMvc.perform(post("/v1/studies/{studyUuid}/nodes/{nodeUuid}/sensitivity-analysis/run", studyUuid, nodeUuid) - .header("userId", "userId") - .header(HEADER_USER_ID, "testUserId")).andExpect(status().isOk()); + .header(HEADER_USER_ID, "userId")).andExpect(status().isOk()); Message sensitivityAnalysisStatusMessage = output.receive(TIMEOUT, studyUpdateDestination); assertEquals(studyUuid, sensitivityAnalysisStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID)); @@ -344,13 +343,13 @@ private void testSensitivityAnalysisWithNodeUuid(UUID studyUuid, UUID nodeUuid, mockMvc.perform(post("/v1/studies/{studyUuid}/nodes/{nodeUuid}/sensitivity-analysis/result/csv", studyUuid, UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON) - .header("userId", "userId") + .header(HEADER_USER_ID, "userId") .content(content)) .andExpectAll(status().isNotFound(), content().string("\"SENSITIVITY_ANALYSIS_NOT_FOUND\"")); mockMvc.perform(post("/v1/studies/{studyUuid}/nodes/{nodeUuid}/sensitivity-analysis/result/csv", studyUuid, nodeUuid) .contentType(MediaType.APPLICATION_JSON) - .header("userId", "userId") + .header(HEADER_USER_ID, "userId") .content(content)) .andExpectAll(status().isOk(), content().bytes(SENSITIVITY_RESULTS_AS_CSV)); @@ -604,7 +603,7 @@ 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("userId", "userId")) + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); var mess = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(mess); @@ -702,7 +701,7 @@ public void testGetSensitivityAnalysisFactorsCount() throws Exception { MockHttpServletRequestBuilder requestBuilder = get("/v1/studies/{studyUuid}/sensitivity-analysis/factors-count", studyNameUserIdUuid); IDS.getIds().forEach((key, list) -> requestBuilder.queryParam(String.format("ids[%s]", key), list.stream().map(UUID::toString).toArray(String[]::new))); - String resultAsString = mockMvc.perform(requestBuilder.header("userId", "userId")) + String resultAsString = mockMvc.perform(requestBuilder.header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()) .andReturn() .getResponse() @@ -715,7 +714,7 @@ public void testGetSensitivityAnalysisFactorsCount() throws Exception { private void setParametersAndDoChecks(UUID studyNameUserIdUuid, String parameters) throws Exception { mockMvc.perform( post("/v1/studies/{studyUuid}/sensitivity-analysis/parameters", studyNameUserIdUuid) - .header("userId", "userId") + .header(HEADER_USER_ID, "userId") .contentType(MediaType.APPLICATION_JSON) .content(parameters)).andExpect( status().isOk()); diff --git a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java index 5fff2d40f..e7983c730 100644 --- a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java +++ b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java @@ -66,7 +66,7 @@ import java.util.Objects; import java.util.UUID; -import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_RECEIVER; import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; import static org.gridsuite.study.server.utils.TestUtils.getBinaryAsBuffer; @@ -352,12 +352,12 @@ public void testAllBusesShortCircuit() throws Exception { // run a short circuit analysis on root node (not allowed) mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, rootNodeUuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); //run an all-buses short circuit analysis mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, modificationNode3Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); @@ -455,11 +455,11 @@ public void testGetShortCircuitAnalysisCsvResultNotFound() throws Exception { UUID modificationNode4Uuid = modificationNode4.getId(); mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, rootNodeUuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, modificationNode4Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); @@ -562,13 +562,13 @@ public void testOneBusShortCircuit() throws Exception { // run a one bus short circuit analysis on root node (not allowed) mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, rootNodeUuid) .param("busId", "BUS_TEST_ID") - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); //run a one bus short circuit analysis mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, modificationNode3Uuid) .param("busId", "BUS_TEST_ID") - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); @@ -726,7 +726,7 @@ public void testInvalidateShortCircuitStatus() throws Exception { //run a short circuit analysis mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, modificationNode3Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()) .andReturn(); @@ -740,7 +740,7 @@ public void testInvalidateShortCircuitStatus() throws Exception { //run a one bus short circuit analysis mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, modificationNode3Uuid) .param("busId", "BUS_TEST_ID") - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()) .andReturn(); @@ -754,7 +754,7 @@ public void testInvalidateShortCircuitStatus() throws Exception { // invalidate status mockMvc.perform(put("/v1/studies/{studyUuid}/short-circuit/invalidate-status", studyNameUserIdUuid) - .header("userId", "userId")).andExpect(status().isOk()); + .header(HEADER_USER_ID, "userId")).andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/invalidate-status\\?resultUuid=" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "&resultUuid=" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID))); @@ -800,7 +800,7 @@ 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("userId", "userId")) + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); var mess = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(mess); diff --git a/src/test/java/org/gridsuite/study/server/SingleLineDiagramTest.java b/src/test/java/org/gridsuite/study/server/SingleLineDiagramTest.java index 3ed1d4c41..4af05ae40 100644 --- a/src/test/java/org/gridsuite/study/server/SingleLineDiagramTest.java +++ b/src/test/java/org/gridsuite/study/server/SingleLineDiagramTest.java @@ -576,7 +576,7 @@ 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("userId", "userId")) + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); var mess = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(mess); diff --git a/src/test/java/org/gridsuite/study/server/StudyControllerDynamicSimulationTest.java b/src/test/java/org/gridsuite/study/server/StudyControllerDynamicSimulationTest.java index 63b7aa934..c47a172b0 100644 --- a/src/test/java/org/gridsuite/study/server/StudyControllerDynamicSimulationTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyControllerDynamicSimulationTest.java @@ -65,6 +65,7 @@ import java.util.*; import static org.assertj.core.api.Assertions.assertThat; +import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.mockito.BDDMockito.any; import static org.mockito.BDDMockito.eq; import static org.mockito.Mockito.when; @@ -96,7 +97,6 @@ public class StudyControllerDynamicSimulationTest { private static final String STUDY_DYNAMIC_SIMULATION_END_POINT_EVENTS = "{studyUuid}/nodes/{nodeUuid}/dynamic-simulation/events"; - private static final String HEADER_USER_ID_NAME = "userId"; private static final String HEADER_USER_ID_VALUE = "userId"; private static final String MAPPING_NAME_01 = "_01"; @@ -244,7 +244,7 @@ private NetworkModificationNode createNetworkModificationNode(UUID studyUuid, UU jsonObject.put("modificationGroupUuid", modificationGroupUuid); mnBodyJson = jsonObject.toString(); - studyClient.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header("userId", "userId")) + studyClient.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); var mess = output.receive(TIMEOUT, studyUpdateDestination); assertThat(mess).isNotNull(); @@ -270,7 +270,7 @@ public void testRunDynamicSimulationGivenRegularNodeAndFailed() throws Exception // run on a regular node which allows a run studyClient.perform(post(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_RUN, studyUuid, modificationNode1Uuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON) .content(PARAMETERS)) .andExpect(status().isOk()); @@ -316,7 +316,7 @@ public void testRunDynamicSimulationGivenRootNode() throws Exception { // run on root node => forbidden studyClient.perform(post(UrlUtil.buildEndPointUrl("", API_VERSION, STUDY_END_POINT) + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_RUN + "?mappingName={mappingName}", studyUuid, rootNodeUuid, MAPPING_NAME_01) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE)) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE)) .andExpect(status().isForbidden()); } @@ -338,7 +338,7 @@ public void testRunDynamicSimulationGivenRegularNode() throws Exception { // run on a regular node which allows a run studyClient.perform(post(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_RUN, studyUuid, modificationNode1Uuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON) .content(PARAMETERS)) .andExpect(status().isOk()); @@ -413,7 +413,7 @@ public void testRunDynamicSimulationGivenRegularNodeAndStopped() throws Exceptio // run on a regular node which allows a run studyClient.perform(post(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_RUN, studyUuid, modificationNode1Uuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON) .content(PARAMETERS)) .andExpect(status().isOk()); @@ -455,7 +455,7 @@ public void testGetDynamicSimulationTimeSeriesResultGivenNodeNotDone() throws Ex // get result from a node not yet done studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_RESULT + DELIMITER + "timeseries", STUDY_UUID, NODE_NOT_DONE_UUID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE)) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE)) .andExpect(status().isNoContent()); } @@ -475,7 +475,7 @@ public void testGetDynamicSimulationTimeSeriesResult() throws Exception { // get result from a node done MvcResult result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_RESULT + DELIMITER + "timeseries", STUDY_UUID, NODE_UUID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE)) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE)) .andExpect(status().isOk()).andReturn(); String timeSeriesResultJson = result.getResponse().getContentAsString(); @@ -497,7 +497,7 @@ public void testGetDynamicSimulationTimelineResultGivenNodeNotDone() throws Exce // get result from a node not yet done studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_RESULT + DELIMITER + "timeline", STUDY_UUID, NODE_NOT_DONE_UUID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE)) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE)) .andExpect(status().isNoContent()); } @@ -517,7 +517,7 @@ public void testGetDynamicSimulationTimelineResult() throws Exception { // get result from a node done MvcResult result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_RESULT + DELIMITER + "timeline", STUDY_UUID, NODE_UUID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE)) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE)) .andExpect(status().isOk()).andReturn(); List timelineEventInfosListResult = objectMapper.readValue(result.getResponse().getContentAsString(), new TypeReference<>() { }); @@ -536,7 +536,7 @@ public void testGetDynamicSimulationStatusResultGivenNodeNotRun() throws Excepti // get result from a node not yet run studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_STATUS, STUDY_UUID, NODE_NOT_RUN_UUID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE)) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE)) .andExpect(status().isNoContent()); } @@ -552,7 +552,7 @@ public void testGetDynamicSimulationTimeSeriesMetadata() throws Exception { // get timeseries metadata from a node done MvcResult result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_RESULT + DELIMITER + "timeseries/metadata", STUDY_UUID, NODE_UUID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE)) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE)) .andExpect(status().isOk()).andReturn(); List resultTimeSeriesMetadataInfosList = objectMapper.readValue(result.getResponse().getContentAsString(), new TypeReference<>() { }); @@ -573,7 +573,7 @@ public void testGetDynamicSimulationStatus() throws Exception { // get status from a node done MvcResult result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_STATUS, STUDY_UUID, NODE_UUID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE)) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE)) .andExpect(status().isOk()).andReturn(); DynamicSimulationStatus statusResult = objectMapper.readValue(result.getResponse().getContentAsString(), DynamicSimulationStatus.class); @@ -592,7 +592,7 @@ public void testGetDynamicSimulationMappings() throws Exception { // --- call endpoint to be tested --- // // get all mapping infos MvcResult result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_MAPPINGS, STUDY_UUID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE)) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE)) .andExpect(status().isOk()).andReturn(); String content = result.getResponse().getContentAsString(); @@ -622,7 +622,7 @@ public void testSetAndGetDynamicSimulationParameters() throws Exception { // --- call endpoint to be tested --- // // set parameters studyClient.perform(post(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_PARAMETERS, studyUuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(defaultDynamicSimulationParameters))) .andExpect(status().isOk()).andReturn(); @@ -633,7 +633,7 @@ public void testSetAndGetDynamicSimulationParameters() throws Exception { // get parameters result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_PARAMETERS, studyUuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn(); @@ -666,7 +666,7 @@ public void testGetDynamicSimulationModels() throws Exception { // set parameters studyClient.perform(post(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_PARAMETERS, studyUuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(defaultDynamicSimulationParameters))) .andExpect(status().isOk()).andReturn(); @@ -677,7 +677,7 @@ public void testGetDynamicSimulationModels() throws Exception { MvcResult result; // --- call endpoint to be tested --- // result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_MODELS, studyUuid, modificationNode1Uuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn(); @@ -707,7 +707,7 @@ public void testGetDynamicSimulationModelsGivenEmptyMapping() throws Exception { // set parameters studyClient.perform(post(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_PARAMETERS, studyUuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(defaultDynamicSimulationParameters))) .andExpect(status().isOk()).andReturn(); @@ -718,7 +718,7 @@ public void testGetDynamicSimulationModelsGivenEmptyMapping() throws Exception { // --- call endpoint to be tested --- // // must be no content status studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_MODELS, studyUuid, modificationNode1Uuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isNoContent()).andReturn(); @@ -775,7 +775,7 @@ public void testCrudDynamicSimulationEvents() throws Exception { // --- call endpoint to be tested --- // // --- Post an event --- // studyClient.perform(post(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_EVENTS, studyUuid, modificationNode1Uuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(EVENT))) .andExpect(status().isOk()).andReturn(); @@ -784,7 +784,7 @@ public void testCrudDynamicSimulationEvents() throws Exception { // --- Get the event --- // result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_EVENTS, studyUuid, modificationNode1Uuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn(); @@ -797,7 +797,7 @@ public void testCrudDynamicSimulationEvents() throws Exception { // --- Get event by node id and equipment id --- // result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_EVENTS, studyUuid, modificationNode1Uuid) .param("equipmentId", EQUIPMENT_ID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn(); @@ -811,7 +811,7 @@ public void testCrudDynamicSimulationEvents() throws Exception { // call update API studyClient.perform(put(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_EVENTS, studyUuid, modificationNode1Uuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(eventInfosResult))) .andExpect(status().isOk()).andReturn(); @@ -821,7 +821,7 @@ public void testCrudDynamicSimulationEvents() throws Exception { // check updated event result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_EVENTS, studyUuid, modificationNode1Uuid) .param("equipmentId", EQUIPMENT_ID) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn(); EventInfos eventInfosUpdatedResult = objectMapper.readValue(result.getResponse().getContentAsString(), EventInfos.class); @@ -831,7 +831,7 @@ public void testCrudDynamicSimulationEvents() throws Exception { // --- Delete an event --- // studyClient.perform(delete(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_EVENTS, studyUuid, modificationNode1Uuid) .param("eventUuids", eventInfosUpdatedResult.getId().toString()) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn(); @@ -839,7 +839,7 @@ public void testCrudDynamicSimulationEvents() throws Exception { // check result => must empty result = studyClient.perform(get(STUDY_BASE_URL + DELIMITER + STUDY_DYNAMIC_SIMULATION_END_POINT_EVENTS, studyUuid, modificationNode1Uuid) - .header(HEADER_USER_ID_NAME, HEADER_USER_ID_VALUE) + .header(HEADER_USER_ID, HEADER_USER_ID_VALUE) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn(); diff --git a/src/test/java/org/gridsuite/study/server/StudyServiceTest.java b/src/test/java/org/gridsuite/study/server/StudyServiceTest.java index 48fac3ce1..ea6d23de3 100644 --- a/src/test/java/org/gridsuite/study/server/StudyServiceTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyServiceTest.java @@ -13,7 +13,6 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.commons.exceptions.UncheckedInterruptedException; import com.powsybl.network.store.client.NetworkStoreService; - import org.gridsuite.study.server.dto.BasicStudyInfos; import org.gridsuite.study.server.notification.NotificationService; import org.gridsuite.study.server.repository.StudyRepository; @@ -51,12 +50,14 @@ import java.util.concurrent.CountDownLatch; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static org.gridsuite.study.server.StudyConstants.HEADER_IMPORT_PARAMETERS; import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_IMPORT_PARAMETERS; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.head; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringRunner.class) @@ -96,8 +97,6 @@ public class StudyServiceTest { private static final String CASE_FORMAT_PARAM = "caseFormat"; private static final String NETWORK_UUID_STRING = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; private static final UUID NETWORK_UUID = UUID.fromString(NETWORK_UUID_STRING); - private static final String USER_ID_HEADER = "userId"; - private static final String HEADER_UPDATE_TYPE = "updateType"; private static final UUID LOADFLOW_PARAMETERS_UUID = UUID.fromString("0c0f1efd-bd22-4a75-83d3-9e530245c7f4"); @Autowired @@ -138,7 +137,7 @@ public void testCheckNetworkExistenceReturnsOk() throws Exception { UUID studyUuid = createStudy(userId, CASE_UUID, importParameters); mockMvc.perform(head("/v1/studies/{studyUuid}/network", studyUuid) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); } @@ -154,7 +153,7 @@ public void testCheckNetworkExistenceReturnsNotContent() throws Exception { when(networkStoreService.getNetwork(NETWORK_UUID)).thenThrow(new PowsyblException("Network '" + NETWORK_UUID + "' not found")); mockMvc.perform(head("/v1/studies/{studyUuid}/network", studyUuid) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isNoContent()); } @@ -174,7 +173,7 @@ public void testRecreateStudyNetworkWithStudyCaseAndImportParameters() throws Ex UUID disableCaseExpirationStubId = wireMockUtils.stubDisableCaseExpiration(CASE_UUID.toString()); mockMvc.perform(post("/v1/studies/{studyUuid}/network", studyUuid) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); countDownLatch.await(); @@ -201,7 +200,7 @@ public void testRecreateStudyNetworkWithMissingStudyCase() throws Exception { UUID caseExistsStubId = wireMockUtils.stubCaseExists(CASE_UUID.toString(), false); mockMvc.perform(post("/v1/studies/{studyUuid}/network", studyUuid) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isFailedDependency()); wireMockUtils.verifyCaseExists(caseExistsStubId, CASE_UUID.toString()); @@ -225,7 +224,7 @@ public void testRecreateStudyNetworkFromExistingCase() throws Exception { mockMvc.perform(post("/v1/studies/{studyUuid}/network", studyUuid) .param(HEADER_IMPORT_PARAMETERS, objectWriter.writeValueAsString(newImportParameters)) .param("caseUuid", CASE_UUID_STRING) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpectAll(status().isOk()); countDownLatch.await(); @@ -258,7 +257,7 @@ public void testRecreateStudyNetworkFromUnexistingCase() throws Exception { mockMvc.perform(post("/v1/studies/{studyUuid}/network", studyUuid) .param(HEADER_IMPORT_PARAMETERS, objectWriter.writeValueAsString(newImportParameters)) .param("caseUuid", CASE_UUID_STRING) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpectAll(status().isFailedDependency()); wireMockUtils.verifyCaseExists(caseExistsStubId, CASE_UUID.toString()); @@ -278,7 +277,7 @@ private UUID createStudy(String userId, UUID caseUuid, Map impor when(loadFlowService.createDefaultLoadFlowParameters()).thenReturn(LOADFLOW_PARAMETERS_UUID); MvcResult result = mockMvc.perform(post("/v1/studies/cases/{caseUuid}", caseUuid) - .header("userId", userId) + .header(HEADER_USER_ID, userId) .param(CASE_FORMAT_PARAM, "UCTE")) .andExpect(status().isOk()) .andReturn(); diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index 21a90cc04..61d81b922 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -93,6 +93,7 @@ import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.StudyException.Type.STUDY_NOT_FOUND; import static org.gridsuite.study.server.notification.NotificationService.DEFAULT_ERROR_MESSAGE; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; import static org.gridsuite.study.server.utils.MatcherBasicStudyInfos.createMatcherStudyBasicInfos; import static org.gridsuite.study.server.utils.MatcherCreatedStudyBasicInfos.createMatcherCreatedStudyBasicInfos; import static org.gridsuite.study.server.utils.MatcherStudyInfos.createMatcherStudyInfos; @@ -138,8 +139,6 @@ public class StudyTest { private static final String DUPLICATED_STUDY_UUID = "11888888-0000-0000-0000-111111111111"; private static final String NOT_EXISTING_CASE_UUID = "00000000-0000-0000-0000-000000000000"; private static final String NOT_EXISTING_NETWORK_CASE_UUID_STRING = "00000000-0000-0000-0000-000000000001"; - private static final String HEADER_UPDATE_TYPE = "updateType"; - private static final String USER_ID_HEADER = "userId"; private static final UUID NETWORK_UUID = UUID.fromString(NETWORK_UUID_STRING); private static final UUID NOT_EXISTING_NETWORK_UUID = UUID.randomUUID(); private static final UUID CASE_UUID = UUID.fromString(CASE_UUID_STRING); @@ -694,7 +693,7 @@ public void testSearch() throws Exception { UUID rootNodeId = getRootNodeUuid(studyUuid); mvcResult = mockMvc - .perform(get("/v1/search?q={request}", String.format("userId:%s", "userId")).header(USER_ID_HEADER, "userId")) + .perform(get("/v1/search?q={request}", String.format("userId:%s", "userId")).header(HEADER_USER_ID, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); List createdStudyBasicInfosList = mapper.readValue(resultAsString, @@ -704,7 +703,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, "userId")) + studyUuid, rootNodeId, "B").header(HEADER_USER_ID, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); List equipmentInfos = mapper.readValue(resultAsString, @@ -714,7 +713,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, "userId")) + studyUuid, rootNodeId, "B").header(HEADER_USER_ID, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); 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=ID", - studyUuid, rootNodeId, "B").header(USER_ID_HEADER, "userId")) + studyUuid, rootNodeId, "B").header(HEADER_USER_ID, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = mvcResult.getResponse().getContentAsString(); equipmentInfos = mapper.readValue(resultAsString, new TypeReference>() { @@ -731,7 +730,7 @@ public void testSearch() throws Exception { 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, "userId")) + studyUuid, rootNodeId, "B").header(HEADER_USER_ID, "userId")) .andExpectAll(status().isBadRequest(), content().string("Enum unknown entry 'bogus' should be among NAME, ID")) .andReturn(); @@ -744,18 +743,18 @@ public void test() throws Exception { String userId = "userId"; //empty list - mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, "userId")).andExpectAll(status().isOk(), + mockMvc.perform(get("/v1/studies").header(HEADER_USER_ID, "userId")).andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON), content().string("[]")); //empty list - mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, "userId")).andExpectAll(status().isOk(), + mockMvc.perform(get("/v1/study_creation_requests").header(HEADER_USER_ID, "userId")).andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON), content().string("[]")); //insert a study UUID studyUuid = createStudy("userId", CASE_UUID); // check the study - result = mockMvc.perform(get("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, "userId")) + result = mockMvc.perform(get("/v1/studies/{studyUuid}", studyUuid).header(HEADER_USER_ID, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = result.getResponse().getContentAsString(); @@ -765,14 +764,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, "userId").param(CASE_FORMAT, "XIIDM")) + NOT_EXISTING_CASE_UUID, "false").header(HEADER_USER_ID, "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, "userId")) + result = mockMvc.perform(get("/v1/studies").header(HEADER_USER_ID, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = result.getResponse().getContentAsString(); @@ -786,7 +785,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("userId", "userId2")) + resultAsString = mockMvc.perform(get("/v1/studies").header(HEADER_USER_ID, "userId2")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse().getContentAsString(); createdStudyBasicInfosList = mapper.readValue(resultAsString, @@ -798,7 +797,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, "userId")) + mockMvc.perform(get("/v1/studies/{studyUuid}", randomUuid).header(HEADER_USER_ID, "userId")) .andExpectAll(status().isNotFound(), content().contentType(MediaType.APPLICATION_JSON), jsonPath("$").value(STUDY_NOT_FOUND.name())); @@ -807,7 +806,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("userId", "a")) + result = mockMvc.perform(get("/v1/studies").header(HEADER_USER_ID, "a")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); resultAsString = result.getResponse().getContentAsString(); @@ -876,7 +875,7 @@ public void testDeleteStudy() throws Exception { studyRepository.save(studyEntity); UUID stubUuid = wireMockUtils.stubNetworkModificationDeleteGroup(); - mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, "userId")) + mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); assertTrue(studyRepository.findById(studyUuid).isEmpty()); @@ -908,7 +907,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, "userId")) + mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(HEADER_USER_ID, "userId")) .andExpectAll(status().isInternalServerError(), content().string(InterruptedException.class.getName())); wireMockUtils.verifyNetworkModificationDeleteGroup(stubUuid); @@ -931,7 +930,7 @@ public void testDeleteStudyWithNonExistingCase() throws Exception { studyEntity.setCaseUuid(nonExistingCaseUuid); studyRepository.save(studyEntity); - mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(USER_ID_HEADER, "userId")) + mockMvc.perform(delete("/v1/studies/{studyUuid}", studyUuid).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); assertTrue(studyRepository.findById(studyUuid).isEmpty()); @@ -955,7 +954,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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpectAll(status().isOk(), content().contentType(MediaType.APPLICATION_JSON)).andReturn(); String resultAsString = mvcResult.getResponse().getContentAsString(); List createdStudyBasicInfosList = mapper.readValue(resultAsString, @@ -977,12 +976,12 @@ 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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkStudyMetadataUpdatedMessagesReceived(); mockMvc.perform(post("/v1/studies/{studyUuid}/notification?type=NOT_EXISTING_TYPE", UUID.randomUUID()) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isBadRequest()); } @@ -991,7 +990,7 @@ public void testLogsReport() throws Exception { 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, "userId")) + MvcResult mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/parent-nodes-report?reportType=NETWORK_MODIFICATION", studyUuid, rootNodeUuid).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()).andReturn(); String resultAsString = mvcResult.getResponse().getContentAsString(); List reporterModel = mapper.readValue(resultAsString, new TypeReference>() { }); @@ -1024,7 +1023,7 @@ 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)) + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); var mess = output.receive(TIMEOUT, studyUpdateDestination); @@ -1040,7 +1039,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("userId", userId) + .header(HEADER_USER_ID, userId) .param(CASE_FORMAT, "UCTE")) .andExpect(status().isOk()) .andReturn(); @@ -1070,7 +1069,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("userId", userId).contentType(MediaType.APPLICATION_JSON) + .header(HEADER_USER_ID, userId).contentType(MediaType.APPLICATION_JSON) .param(CASE_FORMAT, caseFormat) .content(mapper.writeValueAsString(importParameters))) .andExpect(status().isOk()) @@ -1098,7 +1097,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("userId", userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()) .andReturn(); String resultAsString = result.getResponse().getContentAsString(); @@ -1154,7 +1153,7 @@ public void testGetNullNetwork() { public void testCreateStudyWithErrorDuringCaseImport() throws Exception { String userId = "userId"; mockMvc.perform(post("/v1/studies/cases/{caseUuid}", CASE_UUID_CAUSING_IMPORT_ERROR) - .header("userId", userId) + .header(HEADER_USER_ID, userId) .param(CASE_FORMAT, "UCTE")) .andExpect(status().is5xxServerError()); @@ -1165,7 +1164,7 @@ public void testCreateStudyWithErrorDuringCaseImport() throws Exception { 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, "userId")).andExpectAll( + MvcResult mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(HEADER_USER_ID, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1184,7 +1183,7 @@ public void testCreateStudyWithErrorDuringCaseImport() throws Exception { public void testCreateStudyCreationFailedWithoutErrorMessage() throws Exception { String userId = "userId"; mockMvc.perform(post("/v1/studies/cases/{caseUuid}", CASE_UUID_CAUSING_CONVERSION_ERROR) - .header("userId", userId) + .header(HEADER_USER_ID, userId) .param(CASE_FORMAT, "XIIDM")) .andExpect(status().isOk()); @@ -1208,7 +1207,7 @@ public void testCreateStudyCreationFailedWithoutErrorMessage() throws Exception public void testCreateStudyWithErrorDuringStudyCreation() throws Exception { String userId = "userId"; mockMvc.perform(post("/v1/studies/cases/{caseUuid}", CASE_UUID_CAUSING_STUDY_CREATION_ERROR) - .header("userId", userId) + .header(HEADER_USER_ID, userId) .param(CASE_FORMAT, "UCTE")) .andExpect(status().isOk()); @@ -1236,7 +1235,7 @@ public void testGetStudyCreationRequests() throws Exception { String resultAsString; countDownLatch = new CountDownLatch(1); - mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, "userId")).andExpectAll( + mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(HEADER_USER_ID, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1255,7 +1254,7 @@ public void testGetStudyCreationRequests() throws Exception { // drop the broker message for study creation request (deletion) output.receive(TIMEOUT, studyUpdateDestination); - mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(USER_ID_HEADER, "userId")).andExpectAll( + mvcResult = mockMvc.perform(get("/v1/study_creation_requests").header(HEADER_USER_ID, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1265,7 +1264,7 @@ public void testGetStudyCreationRequests() throws Exception { assertEquals(List.of(), bsiListResult); - mvcResult = mockMvc.perform(get("/v1/studies").header(USER_ID_HEADER, "userId")).andExpectAll( + mvcResult = mockMvc.perform(get("/v1/studies").header(HEADER_USER_ID, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1277,7 +1276,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, "userId") + .header(HEADER_USER_ID, "userId") .param(CASE_FORMAT, "XIIDM")) .andExpect(status().isOk()) .andReturn(); @@ -1288,7 +1287,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, "userId")).andExpectAll( + .header(HEADER_USER_ID, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1308,7 +1307,7 @@ public void testGetStudyCreationRequests() throws Exception { output.receive(TIMEOUT, studyUpdateDestination); mvcResult = mockMvc.perform(get("/v1/study_creation_requests") - .header(USER_ID_HEADER, "userId")).andExpectAll( + .header(HEADER_USER_ID, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1319,7 +1318,7 @@ public void testGetStudyCreationRequests() throws Exception { assertEquals(List.of(), bsiListResult); mvcResult = mockMvc.perform(get("/v1/studies") - .header(USER_ID_HEADER, "userId")).andExpectAll( + .header(HEADER_USER_ID, "userId")).andExpectAll( status().isOk(), content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); @@ -1450,7 +1449,7 @@ 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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); @@ -1466,7 +1465,7 @@ 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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); @@ -1492,7 +1491,7 @@ 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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); } @@ -1531,7 +1530,7 @@ public void testDuplicateStudyWithErrorDuringCaseDuplication() throws Exception String response = mockMvc.perform(post(STUDIES_URL + "?duplicateFrom={studyUuid}", studyUuid) .param(CASE_FORMAT, "XIIDM") - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); ObjectMapper mapper = new ObjectMapper(); @@ -1544,7 +1543,7 @@ public void testDuplicateStudyWithErrorDuringCaseDuplication() throws Exception private StudyEntity duplicateStudy(UUID studyUuid, String userId, String caseFormat) throws Exception { UUID stubUuid = wireMockUtils.stubDuplicateModificationGroup(); String response = mockMvc.perform(post(STUDIES_URL + "?duplicateFrom={studyUuid}", studyUuid) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); ObjectMapper mapper = new ObjectMapper(); String newUuid = mapper.readValue(response, String.class); @@ -1655,7 +1654,7 @@ 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, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); @@ -1670,7 +1669,7 @@ public void testCutAndPasteNode() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createLoadAttributes) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); @@ -1798,7 +1797,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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, node1.getModificationGroupUuid().toString()); @@ -1806,7 +1805,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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, node1.getModificationGroupUuid().toString()); @@ -1814,7 +1813,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.CHILD) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, node1.getModificationGroupUuid().toString()); } @@ -1873,14 +1872,14 @@ public void testCutAndPastErrors() throws Exception { 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, "userId")) + .header(HEADER_USER_ID, "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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); //try to cut and paste to before the root node and expect forbidden @@ -1888,7 +1887,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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); wireMockUtils.verifyNetworkModificationCountsGet(stubUuid, node1.getModificationGroupUuid().toString()); @@ -1908,13 +1907,13 @@ public void testCutAndPasteSubtree() throws Exception { mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/subtrees?subtreeToCutParentNodeUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}", study1Uuid, emptyNode.getId(), emptyNodeChild.getId()) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, 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, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(emptyNode.getId(), emptyNodeChild.getId())); @@ -1949,12 +1948,12 @@ public void testCutAndPasteSubtree() throws Exception { mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, emptyNode.getId()) - .header(USER_ID_HEADER, "userId")).andExpect(status().isOk()); + .header(HEADER_USER_ID, "userId")).andExpect(status().isOk()); mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, UUID.randomUUID()) - .header(USER_ID_HEADER, "userId")).andExpect(status().isNotFound()); + .header(HEADER_USER_ID, "userId")).andExpect(status().isNotFound()); } @Test @@ -1974,7 +1973,7 @@ public void testDuplicateNode() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createTwoWindingsTransformerAttributes) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); @@ -1989,7 +1988,7 @@ public void testDuplicateNode() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createLoadAttributes) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); @@ -2045,21 +2044,21 @@ 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, "userId")) + .header(HEADER_USER_ID, "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, "userId")) + .header(HEADER_USER_ID, "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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); // Test Built status when duplicating an empty node @@ -2094,7 +2093,7 @@ public void testDuplicateSubtree() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createTwoWindingsTransformerAttributes) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId(), node3.getId())); @@ -2114,7 +2113,7 @@ public void testDuplicateSubtree() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createLoadAttributes) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); @@ -2141,7 +2140,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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); List nodesAfterDuplication = networkModificationTreeService.getAllNodes(study1Uuid).stream().map(NodeEntity::getIdNode).collect(Collectors.toList()); @@ -2167,12 +2166,12 @@ public void testDuplicateSubtree() throws Exception { mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, nodesAfterDuplication.get(0)) - .header(USER_ID_HEADER, "userId")).andExpect(status().isOk()); + .header(HEADER_USER_ID, "userId")).andExpect(status().isOk()); mockMvc.perform(get(STUDIES_URL + "/{studyUuid}/subtree?parentNodeUuid={parentSubtreeNode}", study1Uuid, UUID.randomUUID()) - .header(USER_ID_HEADER, "userId")).andExpect(status().isNotFound()); + .header(HEADER_USER_ID, "userId")).andExpect(status().isNotFound()); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); @@ -2199,14 +2198,14 @@ 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, "userId")) + .header(HEADER_USER_ID, "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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isNotFound()); } @@ -2230,7 +2229,7 @@ public void testDuplicateNodeBetweenStudies() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node1.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createTwoWindingsTransformerAttributes) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); @@ -2245,7 +2244,7 @@ public void testDuplicateNodeBetweenStudies() throws Exception { mockMvc.perform(post(URI_NETWORK_MODIF, study1Uuid, node2.getId()) .contentType(MediaType.APPLICATION_JSON) .content(createLoadAttributes) - .header(USER_ID_HEADER, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); @@ -2276,7 +2275,7 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, mockMvc.perform(post(STUDIES_URL + "/{studyUuid}/tree/nodes?nodeToCutUuid={nodeUuid}&referenceNodeUuid={referenceNodeUuid}&insertMode={insertMode}", studyUuid, nodeToCopy.getId(), referenceNodeUuid, insertMode) - .header(USER_ID_HEADER, userId)) + .header(HEADER_USER_ID, userId)) .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); wireMockUtils.verifyNetworkModificationCountsGet(stubUuid, nodeToCopy.getModificationGroupUuid().toString()); @@ -2359,13 +2358,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, "userId")) + .header(HEADER_USER_ID, "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, "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); } @@ -2493,7 +2492,7 @@ public void reindexStudyTest() throws Exception { @Test public void providerTest() throws Exception { - UUID studyUuid = createStudy(USER_ID_HEADER, CASE_UUID); + UUID studyUuid = createStudy(HEADER_USER_ID, CASE_UUID); assertNotNull(studyUuid); mockMvc.perform(get("/v1/studies/{studyUuid}/non-evacuated-energy/provider", studyUuid)) .andExpectAll(status().isOk(), @@ -2502,7 +2501,7 @@ public void providerTest() throws Exception { mockMvc.perform(post("/v1/studies/{studyUuid}/loadflow/provider", studyUuid) .content("SuperLF") .contentType(MediaType.TEXT_PLAIN) - .header(USER_ID_HEADER, USER_ID_HEADER)) + .header(HEADER_USER_ID, HEADER_USER_ID)) .andExpect(status().isOk()); Message message = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(message); @@ -2512,7 +2511,7 @@ public void providerTest() throws Exception { mockMvc.perform(post("/v1/studies/{studyUuid}/security-analysis/provider", studyUuid) .content("SuperSA") .contentType(MediaType.TEXT_PLAIN) - .header(USER_ID_HEADER, USER_ID_HEADER)) + .header(HEADER_USER_ID, HEADER_USER_ID)) .andExpect(status().isOk()); message = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(message); @@ -2522,7 +2521,7 @@ public void providerTest() throws Exception { mockMvc.perform(post("/v1/studies/{studyUuid}/non-evacuated-energy/provider", studyUuid) .content("SuperNEE") .contentType(MediaType.TEXT_PLAIN) - .header(USER_ID_HEADER, USER_ID_HEADER)) + .header(HEADER_USER_ID, HEADER_USER_ID)) .andExpect(status().isOk()); message = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(message); diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index 0fa7b83f6..72ebc824e 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -69,7 +69,8 @@ import java.util.*; import java.util.stream.IntStream; -import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_RECEIVER; +import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; import static org.gridsuite.study.server.dto.ComputationType.VOLTAGE_INITIALIZATION; import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; import static org.gridsuite.study.server.notification.NotificationService.STUDY_ALERT; @@ -326,7 +327,7 @@ private void initMockBeans(Network network) { private void createOrUpdateParametersAndDoChecks(UUID studyNameUserIdUuid, StudyVoltageInitParameters parameters) throws Exception { mockMvc.perform( post("/v1/studies/{studyUuid}/voltage-init/parameters", studyNameUserIdUuid) - .header("userId", "userId") + .header(HEADER_USER_ID, "userId") .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(parameters))).andExpect( status().isOk()); @@ -390,7 +391,7 @@ public void testUpdatingParametersWithSameComputationParametersDoesNotInvalidate mockMvc.perform( post("/v1/studies/{studyUuid}/voltage-init/parameters", studyEntity.getId()) - .header("userId", "userId") + .header(HEADER_USER_ID, "userId") .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(studyVoltageInitParameters))).andExpect( status().isOk()); @@ -413,9 +414,8 @@ public void testApplyModificationsWhenParameterIsActivated() throws Exception { NetworkModificationNode modificationNode1 = createNetworkModificationNode(studyUuid, rootNodeUuid, UUID.randomUUID(), VARIANT_ID_2, "node 1"); //run a voltage init analysis - mockMvc.perform( - put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/run", studyEntity.getId(), modificationNode1.getId()).header("userId", "userId") - ) + mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/run", studyEntity.getId(), modificationNode1.getId()) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); // Running the computation @@ -453,12 +453,12 @@ public void testVoltageInit() throws Exception { // run a voltage init on root node (not allowed) mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/run", studyNameUserIdUuid, rootNodeUuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isForbidden()); //run a voltage init analysis mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/run", studyNameUserIdUuid, modificationNode3Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); @@ -486,7 +486,7 @@ public void testVoltageInit() throws Exception { mockMvc.perform( post("/v1/studies/{studyUuid}/voltage-init/parameters", studyNameUserIdUuid) - .header("userId", "userId") + .header(HEADER_USER_ID, "userId") .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(createStudyVoltageInitParameters(false, VOLTAGE_INIT_PARAMETERS_INFOS_2)))).andExpect( status().isOk()); @@ -507,7 +507,7 @@ public void testVoltageInit() throws Exception { assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/stop\\?receiver=.*nodeUuid.*"))); mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/run", studyNameUserIdUuid, modificationNode2Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_FAILED); @@ -537,7 +537,7 @@ public void testCopyVoltageInitModifications() throws Exception { // run a voltage init analysis mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/run", studyNameUserIdUuid, modificationNode3Uuid) - .header("userId", "userId")) + .header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_VOLTAGE_INIT_STATUS); @@ -548,7 +548,7 @@ public void testCopyVoltageInitModifications() throws Exception { // just retrieve modifications list from modificationNode3Uuid mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/modifications", studyNameUserIdUuid, modificationNode3Uuid) - .header("userId", "userId")).andExpect(status().isOk()); + .header(HEADER_USER_ID, "userId")).andExpect(status().isOk()); assertTrue(TestUtils.getRequestsDone(2, server).stream().allMatch(r -> r.matches("/v1/groups/" + MODIFICATIONS_GROUP_UUID + "/network-modifications\\?errorOnGroupNotFound=false&onlyStashed=false&onlyMetadata=false") || r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/modifications-group-uuid") @@ -556,7 +556,7 @@ public void testCopyVoltageInitModifications() throws Exception { // clone and copy modifications to modificationNode3Uuid mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/modifications", studyNameUserIdUuid, modificationNode3Uuid) - .header("userId", "userId")).andExpect(status().isOk()); + .header(HEADER_USER_ID, "userId")).andExpect(status().isOk()); assertTrue(TestUtils.getRequestsDone(4, server).stream().allMatch(r -> r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/modifications-group-uuid") || r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/status") || @@ -750,7 +750,7 @@ 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("userId", "userId")) + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(HEADER_USER_ID, "userId")) .andExpect(status().isOk()); var mess = output.receive(TIMEOUT, studyUpdateDestination); assertNotNull(mess); diff --git a/src/test/java/org/gridsuite/study/server/utils/SendInput.java b/src/test/java/org/gridsuite/study/server/utils/SendInput.java index f22571122..b05d7ea63 100644 --- a/src/test/java/org/gridsuite/study/server/utils/SendInput.java +++ b/src/test/java/org/gridsuite/study/server/utils/SendInput.java @@ -17,8 +17,8 @@ import java.util.List; import java.util.concurrent.CountDownLatch; -import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; -import static org.gridsuite.study.server.StudyConstants.QUERY_PARAM_RECEIVER; +import static org.gridsuite.study.server.notification.NotificationService.HEADER_RECEIVER; +import static org.gridsuite.study.server.notification.NotificationService.QUERY_PARAM_RECEIVER; /** * Class that implements an action we want to execute after mocking an API call