Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Seddik Yengui <seddik.yengui_externe@rte-france.com>
  • Loading branch information
Seddik Yengui committed Dec 24, 2024
1 parent dd65d54 commit 7d34857
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.ExpectedCount;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.ResourceAccessException;

import java.io.IOException;
import java.time.ZonedDateTime;
Expand Down Expand Up @@ -336,6 +339,16 @@ public void testDeleteAll() {
.andRespond(withResourceNotFound());
PowsyblException powsyblException = assertThrows(PowsyblException.class, () -> restNetworkStoreClient.removeSubstations(networkUuid, Resource.INITIAL_VARIANT_NUM, List.of("wrongId")));
assertEquals("Fail to delete at /networks/{networkUuid}/{variantNum}/substations, status: 404 NOT_FOUND", powsyblException.getMessage());

server.reset();
server.expect(ExpectedCount.times(2), requestTo("/networks/" + networkUuid + "/" + Resource.INITIAL_VARIANT_NUM + "/substations"))
.andExpect(method(DELETE))
.andExpect(content().string("[\"wrongId2\"]"))
.andRespond((request -> {
throw new ResourceAccessException("ResourceAccessException error");
}));
ResourceAccessException httpClientErrorException = assertThrows(ResourceAccessException.class, () -> restNetworkStoreClient.removeSubstations(networkUuid, Resource.INITIAL_VARIANT_NUM, List.of("wrongId2")));
assertEquals("ResourceAccessException error", httpClientErrorException.getMessage());
server.verify();
}

Expand Down

0 comments on commit 7d34857

Please sign in to comment.