Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ghazwarhili committed Dec 5, 2023
1 parent 5fd4ae2 commit 8b95765
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public ResponseEntity<List<IdentifiableAttributes>> exportFilter(@PathVariable("
@PostMapping(value = "/filters/complexity", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Calculate filters complexity by given ids")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The complexity")})
public ResponseEntity<Integer> exportFilter(@RequestBody Map<Integer, List<Map<String, List<UUID>>>> containerIdsMap,
public ResponseEntity<Integer> computeFiltersComplexity(@RequestBody Map<Integer, List<Map<String, List<UUID>>>> containerIdsMap,
@RequestParam(value = "networkUuid") UUID networkUuid,
@RequestParam(value = "variantId", required = false) String variantId) {
Integer count = service.countComplexity(containerIdsMap, networkUuid, variantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,25 @@ public void testExportFilters() throws Exception {

}

@Test
public void testComputeFiltersComplexity() throws Exception {
final var json = "{\"3\":[{\"injections\":[\"cf399ef3-7f14-4884-8c82-1c90300da321\"],\"contingencies\":[\"cf399ef3-7f14-4884-8c82-1c90300da323\"],\"monitoredBranchs\":[\"cf399ef3-7f14-4884-8c82-1c90300da322\"]}],\"2\":[{\"injections\":[\"cf399ef3-7f14-4884-8c82-1c90300da322\"],\"contingencies\":[\"cf399ef3-7f14-4884-8c82-1c90300da323\"],\"monitoredBranchs\":[\"cf399ef3-7f14-4884-8c82-1c90300da321\"]}],\"1\":[{\"injections\":[\"cf399ef3-7f14-4884-8c82-1c90300da322\"],\"contingencies\":[\"cf399ef3-7f14-4884-8c82-1c90300da323\"],\"monitoredBranchs\":[\"cf399ef3-7f14-4884-8c82-1c90300da321\"]}],\"0\":[{\"injections\":[\"cf399ef3-7f14-4884-8c82-1c90300da321\"],\"contingencies\":[\"cf399ef3-7f14-4884-8c82-1c90300da323\"],\"monitoredBranchs\":[\"cf399ef3-7f14-4884-8c82-1c90300da322\"]}]}";
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("networkUuid", NETWORK_UUID.toString());
params.add("variantId", VARIANT_ID_1);

Integer filtersComplexityCount = objectMapper.readValue(
mvc.perform(post("/" + FilterApi.API_VERSION + "/filters/complexity")
.params(params)
.content(json)
.contentType(APPLICATION_JSON))
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString(),
new TypeReference<>() {
});
assertEquals(Optional.of(4), Optional.ofNullable(filtersComplexityCount));
}

private void checkFilterEquipments(List<FilterEquipments> filterEquipments1, List<FilterEquipments> filterEquipments2) {
assertEquals(CollectionUtils.isEmpty(filterEquipments1), CollectionUtils.isEmpty(filterEquipments2));
assertEquals(filterEquipments1.size(), filterEquipments2.size());
Expand Down

0 comments on commit 8b95765

Please sign in to comment.