Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ private StudyConstants() {
public static final String REPORT_UUID = "reportUuid";
public static final String UUIDS = "uuids";
public static final String IDS = "ids";
public static final String QUERY_PARAM_ERROR_ON_GROUP_NOT_FOUND = "errorOnGroupNotFound";
public static final String QUERY_PARAM_REPORT_DEFAULT_NAME = "defaultName";
public static final String QUERY_PARAM_REPORT_SEVERITY_LEVEL = "severityLevels";
public static final String QUERY_PARAM_MESSAGE_FILTER = "message";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class NetworkModificationService {
private static final String COMPOSITE_PATH = "network-composite-modifications" + DELIMITER;
private static final String GROUPS = "groups";
private static final String GROUP_PATH = GROUPS + DELIMITER + "{groupUuid}";
private static final String CONTAINERS = "containers";
private static final String CONTAINER_PATH = CONTAINERS + DELIMITER + "{containerUuid}";
private static final String NETWORK_MODIFICATIONS_PATH = "network-modifications";
private static final String NETWORK_MODIFICATIONS_COUNT_PATH = "network-modifications-count";
private static final String QUERY_PARAM_ACTION = "action";
Expand Down Expand Up @@ -108,7 +110,7 @@ public String getLineTypeWithLimits(UUID lineTypeUuid, String area, String tempe
}

public String getNetworkModificationsFromComposite(List<UUID> compositeModificationUuids, boolean onlyMetadata) {
String path = UriComponentsBuilder.fromPath(COMPOSITE_PATH + NETWORK_MODIFICATIONS_PATH)
String path = UriComponentsBuilder.fromPath(CONTAINERS + DELIMITER + NETWORK_MODIFICATIONS_PATH)
.queryParam(UUIDS, compositeModificationUuids)
.queryParam("onlyMetadata", onlyMetadata)
.build().toUriString();
Expand Down Expand Up @@ -148,8 +150,7 @@ public void updateNetworkModificationsMetadata(List<UUID> networkModificationUui

public String getModifications(UUID groupUUid, boolean stashedModifications, boolean onlyMetadata) {
Objects.requireNonNull(groupUUid);
var path = UriComponentsBuilder.fromPath(GROUP_PATH + DELIMITER + NETWORK_MODIFICATIONS_PATH)
.queryParam(QUERY_PARAM_ERROR_ON_GROUP_NOT_FOUND, false)
var path = UriComponentsBuilder.fromPath(CONTAINER_PATH + DELIMITER + NETWORK_MODIFICATIONS_PATH)
.queryParam(QUERY_PARAM_ONLY_STASHED, stashedModifications)
.queryParam("onlyMetadata", onlyMetadata)
.buildAndExpand(groupUUid)
Expand All @@ -160,8 +161,7 @@ public String getModifications(UUID groupUUid, boolean stashedModifications, boo

public String getModificationsToExport(UUID groupUUid) {
Objects.requireNonNull(groupUUid);
var path = UriComponentsBuilder.fromPath(GROUP_PATH + DELIMITER + NETWORK_MODIFICATIONS_PATH + DELIMITER + "export")
.queryParam(QUERY_PARAM_ERROR_ON_GROUP_NOT_FOUND, false)
var path = UriComponentsBuilder.fromPath(CONTAINER_PATH + DELIMITER + NETWORK_MODIFICATIONS_PATH + DELIMITER + "export")
.buildAndExpand(groupUUid)
.toUriString();

Expand All @@ -170,7 +170,7 @@ public String getModificationsToExport(UUID groupUUid) {

public Integer getModificationsCount(UUID groupUUid, boolean stashedModifications) {
Objects.requireNonNull(groupUUid);
var path = UriComponentsBuilder.fromPath(GROUP_PATH + DELIMITER + NETWORK_MODIFICATIONS_COUNT_PATH)
var path = UriComponentsBuilder.fromPath(CONTAINER_PATH + DELIMITER + NETWORK_MODIFICATIONS_COUNT_PATH)
.queryParam(QUERY_PARAM_STASHED, stashedModifications)
.buildAndExpand(groupUUid)
.toUriString();
Expand All @@ -181,7 +181,6 @@ public Integer getModificationsCount(UUID groupUUid, boolean stashedModification
public void deleteModifications(UUID groupUUid) {
Objects.requireNonNull(groupUUid);
var path = UriComponentsBuilder.fromPath(GROUP_PATH)
.queryParam(QUERY_PARAM_ERROR_ON_GROUP_NOT_FOUND, false)
.buildAndExpand(groupUUid)
.toUriString();

Expand All @@ -197,7 +196,6 @@ public void deleteModificationsGroups(List<UUID> groupUuids) {
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> httpEntity = new HttpEntity<>(toJson(groupUuids), headers);
var path = UriComponentsBuilder.fromPath(GROUPS)
.queryParam(QUERY_PARAM_ERROR_ON_GROUP_NOT_FOUND, false)
.toUriString();

restTemplate.exchange(getNetworkModificationServerURI(false) + path,
Expand Down Expand Up @@ -363,7 +361,7 @@ public Map<UUID, UUID> findParentComposites(List<UUID> modificationsUuids) {

public List<ModificationReference> getModificationReferences(UUID groupUuid) {
Objects.requireNonNull(groupUuid);
var path = UriComponentsBuilder.fromPath(GROUP_PATH + DELIMITER + "references");
var path = UriComponentsBuilder.fromPath(CONTAINER_PATH + DELIMITER + "references");

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Expand Down Expand Up @@ -628,7 +626,6 @@ public void deleteStashedModificationsFromGroups(List<UUID> groupUuids, String u
headers.set(HEADER_USER_ID, userId);
HttpEntity<String> httpEntity = new HttpEntity<>(toJson(groupUuids), headers);
var path = UriComponentsBuilder.fromPath(GROUPS + "/stashed-modifications")
.queryParam(QUERY_PARAM_ERROR_ON_GROUP_NOT_FOUND, false)
.toUriString();

restTemplate.exchange(getNetworkModificationServerURI(false) + path,
Expand All @@ -640,7 +637,6 @@ public void deleteStashedModificationsFromGroups(List<UUID> groupUuids, String u
public void restoreElementReferences(UUID groupUUid, UUID studyUuid, UUID newNodeUuid, String userId) {
Objects.requireNonNull(groupUUid);
var path = UriComponentsBuilder.fromPath(GROUP_PATH + "/references")
.queryParam(QUERY_PARAM_ERROR_ON_GROUP_NOT_FOUND, false)
.queryParam(QUERY_PARAM_NODE_CONTAINER_UUID, newNodeUuid)
.queryParam(QUERY_PARAM_STUDY_ROOT_CONTAINER_UUID, studyUuid)
.buildAndExpand(groupUUid)
Expand All @@ -655,7 +651,7 @@ public void restoreElementReferences(UUID groupUUid, UUID studyUuid, UUID newNod
}

public void verifyModifications(UUID groupUuid, Set<UUID> modificationUuids) {
var path = UriComponentsBuilder.fromPath(GROUP_PATH + DELIMITER + NETWORK_MODIFICATIONS_PATH + DELIMITER + "verify")
var path = UriComponentsBuilder.fromPath(CONTAINER_PATH + DELIMITER + NETWORK_MODIFICATIONS_PATH + DELIMITER + "verify")
.queryParam("uuids", modificationUuids)
.buildAndExpand(groupUuid)
.toUriString();
Expand Down Expand Up @@ -724,7 +720,7 @@ public List<UUID> findAllChildrenUuids(List<UUID> compositeUuids) {
}

public boolean hasModificationReferences(List<UUID> containerUuids) {
String path = UriComponentsBuilder.fromPath("containers/references/exists")
String path = UriComponentsBuilder.fromPath(CONTAINERS + DELIMITER + "references/exists")
.queryParam(UUIDS, containerUuids)
.build().toUriString();
return Boolean.TRUE.equals(restTemplate.getForObject(getNetworkModificationServerURI(false) + path, Boolean.class));
Expand All @@ -738,7 +734,7 @@ public void assertReferencedModificationsAreWritable(List<UUID> containerUuids,
if (containerUuids.isEmpty()) {
return;
}
String path = UriComponentsBuilder.fromPath("containers/references/authorized")
String path = UriComponentsBuilder.fromPath(CONTAINERS + DELIMITER + "references/authorized")
.queryParam(UUIDS, containerUuids)
.build().toUriString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3618,7 +3618,7 @@ void testUpdateNetworkModificationsActivationOnReference() throws Exception {

// Stub verifyModifications
wireMockServer.stubFor(WireMock.get(WireMock.urlPathEqualTo(
"/v1/groups/" + node.getModificationGroupUuid() + "/network-modifications/verify"))
"/v1/containers/" + node.getModificationGroupUuid() + "/network-modifications/verify"))
.willReturn(WireMock.ok()));

// Stub the references lookup (network-modification-server wire names): the modification is a reference, so a
Expand Down Expand Up @@ -3650,7 +3650,7 @@ void testUpdateNetworkModificationsActivationOnReference() throws Exception {

// Verify that verifyModifications was called with the composite UUID
WireMockUtilsCriteria.verifyGetRequest(wireMockServer,
"/v1/groups/" + node.getModificationGroupUuid() + "/network-modifications/verify",
"/v1/containers/" + node.getModificationGroupUuid() + "/network-modifications/verify",
Map.of("uuids", equalTo(compositeUuid.toString())));

// the references are looked up to check the rights on the shared modifications, if any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,28 +300,28 @@ public MockResponse dispatch(RecordedRequest request) {
Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE),
"{}"
);
} else if (path.matches("/v1/groups/.*/references") && Objects.equals(request.getMethod(), "GET")) {
} else if (path.matches("/v1/containers/.*/references") && Objects.equals(request.getMethod(), "GET")) {
return new MockResponse(
HttpStatus.OK.value(),
Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE),
objectMapper.writeValueAsString(List.of())
);
} else if (path.matches("/v1/network-modifications.*")) {
return new MockResponse(HttpStatus.OK.value());
} else if (path.matches("/v1/groups/" + MODIFICATION_GROUP_UUID + "/network-modifications-count.*") && request.getMethod().equals("GET")) {
} else if (path.matches("/v1/containers/" + MODIFICATION_GROUP_UUID + "/network-modifications-count.*") && request.getMethod().equals("GET")) {
return new MockResponse(HttpStatus.OK.value(), Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(0));
} else if (path.matches("/v1/groups/" + MODIFICATION_GROUP_UUID_2 + "/network-modifications-count.*") && request.getMethod().equals("GET")) {
} else if (path.matches("/v1/containers/" + MODIFICATION_GROUP_UUID_2 + "/network-modifications-count.*") && request.getMethod().equals("GET")) {
return new MockResponse(HttpStatus.OK.value(), Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(2));
} else if (path.matches("/v1/groups/" + MODIFICATION_GROUP_UUID_3 + "/network-modifications-count.*") && request.getMethod().equals("GET")) {
} else if (path.matches("/v1/containers/" + MODIFICATION_GROUP_UUID_3 + "/network-modifications-count.*") && request.getMethod().equals("GET")) {
return new MockResponse(HttpStatus.OK.value(), Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(0));
} else if (path.startsWith("/v1/groups/") && path.contains("/network-modifications-count") && Objects.equals(request.getMethod(), "GET")) {
} else if (path.startsWith("/v1/containers/") && path.contains("/network-modifications-count") && Objects.equals(request.getMethod(), "GET")) {
// by default nodes contain no modifications
return new MockResponse(HttpStatus.OK.value(), Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(0));
} else if (path.matches("/v1/groups/" + MODIFICATION_GROUP_UUID + "/.*") && request.getMethod().equals("GET")) {
} else if (path.matches("/v1/containers/" + MODIFICATION_GROUP_UUID + "/.*") && request.getMethod().equals("GET")) {
return new MockResponse(HttpStatus.OK.value(), Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(List.of()));
} else if (path.matches("/v1/groups/" + MODIFICATION_GROUP_UUID_2 + "/.*") && request.getMethod().equals("GET")) {
} else if (path.matches("/v1/containers/" + MODIFICATION_GROUP_UUID_2 + "/.*") && request.getMethod().equals("GET")) {
return new MockResponse(HttpStatus.OK.value(), Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(List.of("S1", "S2")));
} else if (path.matches("/v1/groups/" + MODIFICATION_GROUP_UUID_3 + "/.*") && request.getMethod().equals("GET")) {
} else if (path.matches("/v1/containers/" + MODIFICATION_GROUP_UUID_3 + "/.*") && request.getMethod().equals("GET")) {
return new MockResponse(HttpStatus.OK.value(), Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(List.of()));
} else if (path.matches("/v1/groups/.*") && request.getMethod().equals("DELETE")) {
return new MockResponse(HttpStatus.OK.value());
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/gridsuite/study/server/VoltageInitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public MockResponse dispatch(RecordedRequest request) {
IdentifiableType.GENERATOR, "genId", Set.of("s1"));
return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE),
objectMapper.writeValueAsString(new NetworkModificationsResult(List.of(VOLTAGE_INIT_MODIFICATION_UUID), List.of(networkModificationResult))));
} else if (path.matches("/v1/groups/" + MODIFICATIONS_GROUP_UUID + "/network-modifications\\?errorOnGroupNotFound=false&onlyStashed=false&onlyMetadata=.*")) {
} else if (path.matches("/v1/containers/" + MODIFICATIONS_GROUP_UUID + "/network-modifications\\?onlyStashed=false&onlyMetadata=.*")) {
return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), objectMapper.writeValueAsString(VOLTAGE_INIT_PREVIEW_MODIFICATION_LIST));
} else if (path.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/stop.*")
|| path.matches("/v1/results/" + VOLTAGE_INIT_OTHER_NODE_RESULT_UUID + "/stop.*")) {
Expand Down Expand Up @@ -884,7 +884,7 @@ private void runVoltageInit(UUID studyUuid, UUID nodeUuuid, UUID rootNetworkUuid
mockMvc.perform(get("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/network-modifications/voltage-init", studyUuid, rootNetworkUuid, nodeUuuid)
.header("userId", "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/containers/" + MODIFICATIONS_GROUP_UUID + "/network-modifications\\?onlyStashed=false&onlyMetadata=false") ||
r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/modifications-group-uuid")
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void testGetLineTypeWithLimits() {
void testGetNetworkModificationsFromComposite() {
UUID firstUuid = UUID.randomUUID();
UUID secondUuid = UUID.randomUUID();
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/network-composite-modifications/network-modifications?uuids=" + firstUuid + "&uuids=" + secondUuid + "&onlyMetadata=false";
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/containers/network-modifications?uuids=" + firstUuid + "&uuids=" + secondUuid + "&onlyMetadata=false";
when(restTemplate.getForObject(expectedUrl, String.class)).thenReturn(RESPONSE);

assertThat(networkModificationService.getNetworkModificationsFromComposite(List.of(firstUuid, secondUuid), false)).isEqualTo(RESPONSE);
Expand Down Expand Up @@ -135,7 +135,7 @@ void testUpdateNetworkModificationsMetadata() {
void testDeleteModificationsGroups() {
UUID firstUuid = UUID.randomUUID();
UUID secondUuid = UUID.randomUUID();
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/groups?errorOnGroupNotFound=false";
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/groups";

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Expand All @@ -148,7 +148,7 @@ void testDeleteModificationsGroups() {
void testDeleteStashedModificationsGroups() {
UUID firstUuid = UUID.randomUUID();
UUID secondUuid = UUID.randomUUID();
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/groups/stashed-modifications?errorOnGroupNotFound=false";
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/groups/stashed-modifications";

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Expand Down Expand Up @@ -194,7 +194,7 @@ void testFindParentComposites() {
@Test
void testGetReferencesFromGroup() {
UUID groupUuid = UUID.randomUUID();
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/groups/" + groupUuid + "/references";
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/containers/" + groupUuid + "/references";
List<ModificationReference> expected = List.of(new ModificationReference(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()));
when(restTemplate.exchange(
eq(expectedUrl),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void testDeleteStudy() throws Exception {
assertTrue(studyRepository.findById(studyUuid).isEmpty());

wireMockStubs.verifyGetReferencesDataFromGroup(stubReferencesUuid);
wireMockStubs.verifyNetworkModificationDeleteGroup(stubUuid, false);
wireMockStubs.verifyNetworkModificationDeleteGroup(stubUuid);
wireMockStubs.caseServer.verifyDeleteCase(stubDeleteCaseId, CASE_UUID_STRING);
deleteStudyStubs.verify(wireMockStubs, computationServerStubs, 10); // voltageInit, loadFlow, securityAnalysis, sensitivityAnalysis, stateEstimation, pccMin, dynamic, shortCircuit
}
Expand Down Expand Up @@ -289,7 +289,7 @@ void testDeleteStudyWithError(final CapturedOutput capturedOutput) throws Except
assertTrue(capturedOutput.getOut().contains(StudyServerExecutionService.class.getName() + " - " + CompletionException.class.getName() + ": " + InterruptedException.class.getName()));

wireMockStubs.verifyGetReferencesDataFromGroup(stubReferencesUuid);
wireMockStubs.verifyNetworkModificationDeleteGroup(stubUuid, false);
wireMockStubs.verifyNetworkModificationDeleteGroup(stubUuid);
deleteStudyStubs.verify(wireMockStubs, computationServerStubs, 3); // loadflow, security, sensitivity, stateEstimation, shortCircuit, pccMin
}

Expand Down Expand Up @@ -317,7 +317,7 @@ void testDeleteStudyWithNonExistingCase() throws Exception {
assertTrue(studyRepository.findById(studyUuid).isEmpty());

wireMockStubs.verifyGetReferencesDataFromGroup(stubReferencesUuid);
wireMockStubs.verifyNetworkModificationDeleteGroup(stubUuid, false);
wireMockStubs.verifyNetworkModificationDeleteGroup(stubUuid);
wireMockStubs.caseServer.verifyDeleteCase(stubDeleteCaseId, nonExistingCaseUuid.toString());
deleteStudyStubs.verify(wireMockStubs, computationServerStubs, 10);
}
Expand Down
Loading
Loading