Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor constant USER_ID (bis) #585

Open
wants to merge 2 commits into
base: refactor/const_USER_ID
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/test/java/org/gridsuite/study/server/LoadFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public class LoadFlowTest {

private static final String LOADFLOW_STATUS_JSON = "{\"status\":\"COMPLETED\"}";

private static final String USER_ID = "userId";
private static final String VARIANT_ID = "variant_1";

private static final String VARIANT_ID_2 = "variant_2";

private static final long TIMEOUT = 1000;
Expand Down Expand Up @@ -372,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(HEADER_USER_ID, "userId"))
.header(HEADER_USER_ID, USER_ID))
.andExpect(status().isForbidden());

//run a loadflow
mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run", studyNameUserIdUuid, modificationNode3Uuid)
.header(HEADER_USER_ID, "userId"))
.header(HEADER_USER_ID, USER_ID))
.andExpect(status().isOk());

checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS);
Expand Down Expand Up @@ -412,7 +412,7 @@ public void testLoadFlow() throws Exception {

// loadflow failed
mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run", studyNameUserIdUuid, modificationNode2Uuid)
.header(HEADER_USER_ID, "userId"))
.header(HEADER_USER_ID, USER_ID))
.andExpect(status().isOk());

checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_FAILED);
Expand All @@ -433,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(HEADER_USER_ID, "userId"))
.header(HEADER_USER_ID, USER_ID))
.andExpect(status().isOk())
.andReturn();

Expand Down Expand Up @@ -485,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(HEADER_USER_ID, "userId"))
.header(HEADER_USER_ID, USER_ID))
.andExpect(status().isOk())
.andReturn();

Expand All @@ -496,7 +496,7 @@ public void testInvalidateStatus() throws Exception {

// invalidate status
mockMvc.perform(put("/v1/studies/{studyUuid}/loadflow/invalidate-status", studyNameUserIdUuid)
.header(HEADER_USER_ID, "userId")).andExpect(status().isOk());
.header(HEADER_USER_ID, USER_ID)).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)));
}
Expand All @@ -521,7 +521,7 @@ public void testDeleteLoadFlowResults() throws Exception {

//run a loadflow
mockMvc.perform(put("/v1/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run", studyNameUserIdUuid, modificationNode3Uuid)
.header(HEADER_USER_ID, "userId"))
.header(HEADER_USER_ID, USER_ID))
.andExpect(status().isOk());

checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS);
Expand Down Expand Up @@ -759,7 +759,7 @@ public void testLoadFlowParameters() throws Exception {

JSONAssert.assertEquals(LOADFLOW_DEFAULT_PARAMETERS_JSON, mvcResult.getResponse().getContentAsString(), JSONCompareMode.NON_EXTENSIBLE);

createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, LOADFLOW_DEFAULT_PARAMETERS_JSON, "userId", HttpStatus.OK);
createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, LOADFLOW_DEFAULT_PARAMETERS_JSON, USER_ID, HttpStatus.OK);

//checking update is registered
mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/loadflow/parameters", studyNameUserIdUuid)).andExpectAll(
Expand All @@ -773,7 +773,7 @@ public void testLoadFlowParameters() throws Exception {

studyNameUserIdUuid = studyEntity2.getId();

createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, LOADFLOW_DEFAULT_PARAMETERS_JSON, "userId", HttpStatus.OK);
createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, LOADFLOW_DEFAULT_PARAMETERS_JSON, USER_ID, HttpStatus.OK);

//get initial loadFlow parameters
mvcResult = mockMvc.perform(get("/v1/studies/{studyUuid}/loadflow/parameters", studyNameUserIdUuid)).andExpectAll(
Expand Down Expand Up @@ -825,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(HEADER_USER_ID, "userId"))
mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header(HEADER_USER_ID, USER_ID))
.andExpect(status().isOk());
var mess = output.receive(TIMEOUT, studyUpdateDestination);
assertNotNull(mess);
Expand Down
Loading
Loading