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

Fix constants not static final #586

Open
wants to merge 1 commit into
base: main
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
8 changes: 4 additions & 4 deletions src/test/java/org/gridsuite/study/server/CaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class CaseTest {
public static final String POST = "POST";
private static final String CASE_NAME = "DefaultCaseName";

//output destinations
private static final String STUDY_UPDATE_DESTINATION = "study.update";

@Autowired
private MockMvc mockMvc;

Expand All @@ -79,9 +82,6 @@ public class CaseTest {
@Autowired
private StudyRepository studyRepository;

//output destinations
private String studyUpdateDestination = "study.update";

@Before
public void setup() throws IOException {

Expand Down Expand Up @@ -142,7 +142,7 @@ private void cleanDB() {

@After
public void tearDown() {
List<String> destinations = List.of(studyUpdateDestination);
List<String> destinations = List.of(STUDY_UPDATE_DESTINATION);

cleanDB();

Expand Down
38 changes: 19 additions & 19 deletions src/test/java/org/gridsuite/study/server/LoadFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ public class LoadFlowTest {
private static String LOADFLOW_PROFILE_PARAMETERS_JSON;

//output destinations
private final String studyUpdateDestination = "study.update";
private final String elementUpdateDestination = "element.update";
private final String loadflowResultDestination = "loadflow.result";
private final String loadflowStoppedDestination = "loadflow.stopped";
private final String loadflowFailedDestination = "loadflow.failed";
private static final String STUDY_UPDATE_DESTINATION = "study.update";
private static final String ELEMENT_UPDATE_DESTINATION = "element.update";
private static final String LOADFLOW_RESULT_DESTINATION = "loadflow.result";
private static final String LOADFLOW_STOPPED_DESTINATION = "loadflow.stopped";
private static final String LOADFLOW_FAILED_DESTINATION = "loadflow.failed";

@Autowired
private MockMvc mockMvc;
Expand Down Expand Up @@ -249,14 +249,14 @@ public MockResponse dispatch(RecordedRequest request) {
input.send(MessageBuilder.withPayload("")
.setHeader("resultUuid", LOADFLOW_RESULT_UUID)
.setHeader("receiver", "%7B%22nodeUuid%22%3A%22" + request.getPath().split("%")[5].substring(4) + "%22%2C%22userId%22%3A%22userId%22%7D")
.build(), loadflowResultDestination);
.build(), LOADFLOW_RESULT_DESTINATION);
return new MockResponse().setResponseCode(200)
.setBody(loadFlowResultUuidStr)
.addHeader("Content-Type", "application/json; charset=utf-8");
} else if (path.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID)) {
input.send(MessageBuilder.withPayload("")
.setHeader("receiver", "%7B%22nodeUuid%22%3A%22" + request.getPath().split("%")[5].substring(4) + "%22%2C%22userId%22%3A%22userId%22%7D")
.build(), loadflowFailedDestination);
.build(), LOADFLOW_FAILED_DESTINATION);
return new MockResponse().setResponseCode(200)
.setBody(loadFlowErrorResultUuidStr)
.addHeader("Content-Type", "application/json; charset=utf-8");
Expand Down Expand Up @@ -289,7 +289,7 @@ public MockResponse dispatch(RecordedRequest request) {
input.send(MessageBuilder.withPayload("")
.setHeader("resultUuid", resultUuid)
.setHeader("receiver", "%7B%22nodeUuid%22%3A%22" + request.getPath().split("%")[5].substring(4) + "%22%2C%22userId%22%3A%22userId%22%7D")
.build(), loadflowStoppedDestination);
.build(), LOADFLOW_STOPPED_DESTINATION);
return new MockResponse().setResponseCode(200)
.addHeader("Content-Type", "application/json; charset=utf-8");
} else if (path.matches("/v1/results")) {
Expand Down Expand Up @@ -552,22 +552,22 @@ public void testResetUuidResultWhenLFFailed() {

StudyService studyService = Mockito.mock(StudyService.class);
doAnswer(invocation -> {
input.send(MessageBuilder.withPayload("").setHeader(HEADER_RECEIVER, resultUuidJson).build(), loadflowFailedDestination);
input.send(MessageBuilder.withPayload("").setHeader(HEADER_RECEIVER, resultUuidJson).build(), LOADFLOW_FAILED_DESTINATION);
return resultUuid;
}).when(studyService).runLoadFlow(any(), any(), any(), any());
studyService.runLoadFlow(studyEntity.getId(), modificationNode.getId(), "", null);

// Test reset uuid result in the database
assertTrue(networkModificationTreeService.getComputationResultUuid(modificationNode.getId(), LOAD_FLOW).isEmpty());

Message<byte[]> message = output.receive(TIMEOUT, studyUpdateDestination);
Message<byte[]> message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION);
assertEquals(studyEntity.getId(), message.getHeaders().get(NotificationService.HEADER_STUDY_UUID));
String updateType = (String) message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE);
assertEquals(NotificationService.UPDATE_TYPE_LOADFLOW_FAILED, updateType);
}

private void checkUpdateModelStatusMessagesReceived(UUID studyUuid, String updateTypeToCheck, String otherUpdateTypeToCheck) {
Message<byte[]> loadFlowStatusMessage = output.receive(TIMEOUT, studyUpdateDestination);
Message<byte[]> loadFlowStatusMessage = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION);
assertEquals(studyUuid, loadFlowStatusMessage.getHeaders().get(NotificationService.HEADER_STUDY_UUID));
String updateType = (String) loadFlowStatusMessage.getHeaders().get(HEADER_UPDATE_TYPE);
if (otherUpdateTypeToCheck == null) {
Expand Down Expand Up @@ -632,19 +632,19 @@ private void createOrUpdateParametersAndDoChecks(UUID studyNameUserIdUuid, Strin
.content(parameters))
.andExpect(status().is(status.value()));

Message<byte[]> message = output.receive(TIMEOUT, studyUpdateDestination);
Message<byte[]> message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION);
assertEquals(studyNameUserIdUuid, message.getHeaders().get(NotificationService.HEADER_STUDY_UUID));
assertEquals(NotificationService.UPDATE_TYPE_LOADFLOW_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE));
message = output.receive(TIMEOUT, studyUpdateDestination);
message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION);
assertEquals(NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE));
message = output.receive(TIMEOUT, studyUpdateDestination);
message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION);
assertEquals(NotificationService.UPDATE_TYPE_SENSITIVITY_ANALYSIS_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE));
message = output.receive(TIMEOUT, studyUpdateDestination);
message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION);
assertEquals(NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE));
message = output.receive(TIMEOUT, studyUpdateDestination);
message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION);
assertEquals(NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS, message.getHeaders().get(NotificationService.HEADER_UPDATE_TYPE));

message = output.receive(TIMEOUT, elementUpdateDestination);
message = output.receive(TIMEOUT, ELEMENT_UPDATE_DESTINATION);
assertEquals(studyNameUserIdUuid, message.getHeaders().get(NotificationService.HEADER_ELEMENT_UUID));
}

Expand Down Expand Up @@ -828,7 +828,7 @@ private NetworkModificationNode createNetworkModificationNode(UUID studyUuid, UU

mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}", studyUuid, parentNodeUuid).content(mnBodyJson).contentType(MediaType.APPLICATION_JSON).header("userId", "userId"))
.andExpect(status().isOk());
var mess = output.receive(TIMEOUT, studyUpdateDestination);
var mess = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION);
assertNotNull(mess);
modificationNode.setId(UUID.fromString(String.valueOf(mess.getHeaders().get(NotificationService.HEADER_NEW_NODE))));
assertEquals(InsertMode.CHILD.name(), mess.getHeaders().get(NotificationService.HEADER_INSERT_MODE));
Expand All @@ -842,7 +842,7 @@ private void cleanDB() {

@After
public void tearDown() {
List<String> destinations = List.of(studyUpdateDestination, loadflowResultDestination, loadflowStoppedDestination, loadflowFailedDestination);
List<String> destinations = List.of(STUDY_UPDATE_DESTINATION, LOADFLOW_RESULT_DESTINATION, LOADFLOW_STOPPED_DESTINATION, LOADFLOW_FAILED_DESTINATION);

cleanDB();

Expand Down
Loading
Loading