Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -70,4 +70,9 @@ public ResponseEntity<Void> updateNetworkModificationsMetadata(@RequestParam("uu
networkModificationService.updateNetworkModificationsMetadata(networkModificationUuids, metadata);
return ResponseEntity.ok().build();
}

@GetMapping(value = "/containers/references/exists")
public ResponseEntity<Boolean> hasModificationReferences(@RequestParam("uuids") List<UUID> containerUuids) {
return ResponseEntity.ok().body(networkModificationService.hasModificationReferences(containerUuids));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -676,4 +676,11 @@ public List<UUID> findAllChildrenUuids(List<UUID> compositeUuids) {
new ParameterizedTypeReference<List<UUID>>() { }
).getBody();
}

public boolean hasModificationReferences(List<UUID> containerUuids) {
String path = UriComponentsBuilder.fromPath("containers/references/exists")
.queryParam(UUIDS, containerUuids)
.build().toUriString();
return Boolean.TRUE.equals(restTemplate.getForObject(getNetworkModificationServerURI(false) + path, Boolean.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,17 @@ void testUpdateNetworkModificationsMetadata() throws Exception {

verify(networkModificationService).updateNetworkModificationsMetadata(List.of(firstUuid, secondUuid), metadata);
}

@Test
void testhasModificationReference() throws Exception {
UUID firstUuid = UUID.randomUUID();
UUID secondUuid = UUID.randomUUID();

mockMvc.perform(get(BASE_URL + "/containers/references/exists")
.param("uuids", firstUuid.toString(), secondUuid.toString())
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string("false"));
verify(networkModificationService).hasModificationReferences(List.of(firstUuid, secondUuid));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,13 @@

verifyNoMoreInteractions(restTemplate);
}

@Test
void testHasModificationReferences() {
UUID modificationUuid = UUID.randomUUID();
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/containers/references/exists?uuids=" + modificationUuid;

networkModificationService.hasModificationReferences(List.of(modificationUuid));
verify(restTemplate).getForObject(eq(expectedUrl), eq(Boolean.class));

Check warning on line 167 in src/test/java/org/gridsuite/study/server/service/NetworkModificationServiceTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this and every subsequent useless "eq(...)" invocation; pass the values directly.

See more on https://sonarcloud.io/project/issues?id=org.gridsuite%3Astudy-server&issues=AaCA2qdWpaoos7QIcdV0&open=AaCA2qdWpaoos7QIcdV0&pullRequest=1086
}
}
Loading