Skip to content

Commit

Permalink
test get all modifications (stashed or not) in one call
Browse files Browse the repository at this point in the history
Signed-off-by: jamal-khey <[email protected]>
  • Loading branch information
jamal-khey committed Oct 1, 2023
1 parent 66308ca commit 32aa89c
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ private void testNetworkModificationsCount(UUID groupUuid, int actualSize) throw
assertEquals(actualSize, modificationsTestGroupId.size());
}


@Test
public void shouldGetPosition() {
var network = networkStoreService.getNetwork(TEST_NETWORK_ID, null);
Expand Down Expand Up @@ -1326,4 +1327,50 @@ public void testDeleteStashedNetworkModifications() throws Exception {
assertEquals(0, modificationRepository.getModifications(TEST_GROUP_ID, false, true, true).size());
mockMvc.perform(delete("/v1/groups/" + UUID.randomUUID() + "/stashed-modifications").queryParam("errorOnGroupNotFound", "false")).andExpect(status().isOk());
}

@Test
public void testGetAllNetworkModifications() throws Exception {
List<EquipmentAttributeModificationInfos> loadModificationInfosList = List.of(
EquipmentAttributeModificationInfos.builder()
.equipmentType(IdentifiableType.LOAD)
.equipmentAttributeName("v1load")
.equipmentId("v1load")
.build(),
EquipmentAttributeModificationInfos.builder()
.equipmentType(IdentifiableType.LOAD)
.equipmentAttributeName("v2load")
.equipmentId("v2load")
.build());
loadModificationInfosList.stream().forEach(loadModificationInfos -> {
try {
String loadModificationInfosJson = objectWriter.writeValueAsString(loadModificationInfos);
MvcResult mvcResult = mockMvc.perform(post(URI_NETWORK_MODIF)
.content(loadModificationInfosJson)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andReturn();
assertApplicationStatusOK(mvcResult);
} catch (Exception e) {
e.printStackTrace();
}
});

List<ModificationInfos> modifications = modificationRepository.getModifications(TEST_GROUP_ID, false, true);
assertEquals(2, modifications.size());

mockMvc.perform(delete(URI_NETWORK_MODIF_BASE)
.queryParam("groupUuid", TEST_GROUP_ID.toString())
.queryParam("uuids", modifications.get(0).getUuid().toString())
.queryParam("stash", "true"))
.andExpect(status().isOk());
MvcResult mvcResult = mockMvc.perform(get("/v1/groups/{groupUuid}/modifications", TEST_GROUP_ID)).andExpectAll(
status().isOk(),
content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
String resultAsString = mvcResult.getResponse().getContentAsString();
List<ModificationInfos> bsicListResulModifInfos = mapper.readValue(resultAsString, new TypeReference<>() { });
assertEquals(2, bsicListResulModifInfos.size());
assertEquals(bsicListResulModifInfos.get(0).getStashed(), true);
assertEquals(bsicListResulModifInfos.get(1).getStashed(), false);
}
}

0 comments on commit 32aa89c

Please sign in to comment.