diff --git a/src/test/java/org/folio/service/pieces/PieceStorageServiceTest.java b/src/test/java/org/folio/service/pieces/PieceStorageServiceTest.java index dbcddbc92..4f99262af 100644 --- a/src/test/java/org/folio/service/pieces/PieceStorageServiceTest.java +++ b/src/test/java/org/folio/service/pieces/PieceStorageServiceTest.java @@ -21,6 +21,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -57,6 +58,9 @@ public class PieceStorageServiceTest { @Autowired PieceStorageService pieceStorageService; + @Autowired + ConsortiumConfigurationService consortiumConfigurationService; + @Autowired private RestClient restClientMock; @@ -106,6 +110,7 @@ void testPiecesShouldBeReturnedByQuery(VertxTestContext vertxTestContext) { .withTotalRecords(1); when(restClientMock.get(any(RequestEntry.class), any(), any())).thenReturn(Future.succeededFuture(pieceCollection)); + when(consortiumConfigurationService.getConsortiumConfiguration(any(RequestContext.class))).thenReturn(Future.succeededFuture(Optional.empty())); String expectedQuery = String.format("id==%s", pieceId); var future = pieceStorageService.getPieces(Integer.MAX_VALUE, 0, expectedQuery, requestContext); @@ -130,15 +135,18 @@ void testShouldDeleteItems() { private static class ContextConfiguration { - @Bean RestClient restClient() { + @Bean + RestClient restClient() { return mock(RestClient.class); } - @Bean ProtectionService protectionService() { + @Bean + ProtectionService protectionService() { return mock(ProtectionService.class); } - @Bean PieceStorageService pieceStorageService(ConsortiumConfigurationService consortiumConfigurationService, + @Bean + PieceStorageService pieceStorageService(ConsortiumConfigurationService consortiumConfigurationService, ConsortiumUserTenantsRetriever consortiumUserTenantsRetriever, RestClient restClient) { return spy(new PieceStorageService(consortiumConfigurationService, consortiumUserTenantsRetriever, restClient)); @@ -146,13 +154,14 @@ private static class ContextConfiguration { @Bean ConsortiumConfigurationService consortiumConfigurationService(RestClient restClient) { - return new ConsortiumConfigurationService(restClient); + return spy(new ConsortiumConfigurationService(restClient)); } @Bean ConsortiumUserTenantsRetriever consortiumUserTenantsRetriever(RestClient restClient) { - return new ConsortiumUserTenantsRetriever(restClient); + return spy(new ConsortiumUserTenantsRetriever(restClient)); } } + }