Skip to content

Commit

Permalink
[MODORDERS-1174] Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Sep 12, 2024
1 parent fabdc67 commit 6772de2
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,6 +58,9 @@ public class PieceStorageServiceTest {
@Autowired
PieceStorageService pieceStorageService;

@Autowired
ConsortiumConfigurationService consortiumConfigurationService;

@Autowired
private RestClient restClientMock;

Expand Down Expand Up @@ -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);
Expand All @@ -130,29 +135,33 @@ 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));
}

@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));
}

}

}

0 comments on commit 6772de2

Please sign in to comment.