Skip to content

Commit

Permalink
[SELC-5752] Fix: change Spy on userMapper to UserServiceTest (#197)
Browse files Browse the repository at this point in the history
Co-authored-by: manuraf <manuel.rafeli@pagopa.it>
  • Loading branch information
flaminiaScarciofolo and manuraf authored Oct 14, 2024
1 parent 2e4fd2e commit a41d07f
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import it.pagopa.selfcare.user.exception.InvalidRequestException;
import it.pagopa.selfcare.user.exception.ResourceNotFoundException;
import it.pagopa.selfcare.user.mapper.UserMapper;
import it.pagopa.selfcare.user.mapper.UserMapperImpl;
import it.pagopa.selfcare.user.model.LoggedUser;
import it.pagopa.selfcare.user.model.OnboardedProduct;
import it.pagopa.selfcare.user.model.UserNotificationToSend;
Expand Down Expand Up @@ -86,7 +87,7 @@ class UserServiceTest {
@InjectMock
private UserRegistryService userRegistryApi;

@InjectMock
@Spy
private UserMapper userMapper;

@InjectMock
Expand Down Expand Up @@ -331,7 +332,7 @@ void testRetrievePerson() {
subscriber.assertCompleted();
}

//@Test
@Test
void testRetrievePerson_workContractsIsEmpty() {
UserInstitution userInstitution = new UserInstitution();
userInstitution.setUserId("test-user");
Expand Down Expand Up @@ -1127,7 +1128,7 @@ void testRetrieveUsersData() {

// Call the method
AssertSubscriber<UserDataResponse> subscriber = userService.retrieveUsersData(institutionId, personId, roles, states, products, productRoles, userUuid)
.subscribe().withSubscriber(AssertSubscriber.create());
.subscribe().withSubscriber(AssertSubscriber.create(10));

// Verify the result
subscriber.assertCompleted().getItems().forEach(actual -> {
Expand Down Expand Up @@ -1181,13 +1182,12 @@ void testRetrieveUsersDataRemovingProductsWhenProductFilterIsPresent() {

// Call the method
AssertSubscriber<UserDataResponse> subscriber = userService.retrieveUsersData(institutionId, personId, roles, states, products, productRoles, userUuid)
.subscribe().withSubscriber(AssertSubscriber.create());
.subscribe().withSubscriber(AssertSubscriber.create(10));

// Verify the result
subscriber.assertCompleted().getItems().forEach(actual -> {
assertNotNull(actual);
assertEquals(1, actual.getProducts().size());
assertEquals("prod-io", actual.getProducts().get(0).getProductId());
assertEquals(0, actual.getProducts().size());
assertEquals(institutionId, "test-institution");
});

Expand Down Expand Up @@ -1237,13 +1237,13 @@ void testRetrieveUsersDataRemovingProductsWhenStatesFilterIsPresent() {

// Call the method
AssertSubscriber<UserDataResponse> subscriber = userService.retrieveUsersData(institutionId, personId, roles, states, products, productRoles, userUuid)
.subscribe().withSubscriber(AssertSubscriber.create());
.subscribe().withSubscriber(AssertSubscriber.create(10));

// Verify the result
subscriber.assertCompleted().getItems().forEach(actual -> {
assertNotNull(actual);
assertEquals(1, actual.getProducts().size());
assertEquals("prod-io", actual.getProducts().get(0).getProductId());
assertEquals("test", actual.getProducts().get(0).getProductId());
assertEquals(institutionId, "test-institution");
});

Expand All @@ -1261,7 +1261,7 @@ void testRetrieveUsersDataRemovingProductsWhenProductRolesFilterIsPresent() {
List<String> roles = Collections.emptyList();
List<String> states = Collections.emptyList();
List<String> products = Collections.emptyList();
List<String> productRoles = Collections.singletonList("test-productRole");
List<String> productRoles = Collections.singletonList("admin");
String userUuid = "test-userUuid";

UserInstitution userInstitution = new UserInstitution();
Expand Down Expand Up @@ -1293,13 +1293,13 @@ void testRetrieveUsersDataRemovingProductsWhenProductRolesFilterIsPresent() {

// Call the method
AssertSubscriber<UserDataResponse> subscriber = userService.retrieveUsersData(institutionId, personId, roles, states, products, productRoles, userUuid)
.subscribe().withSubscriber(AssertSubscriber.create());
.subscribe().withSubscriber(AssertSubscriber.create(10));

// Verify the result
// Verify the result
subscriber.assertCompleted().getItems().forEach(actual -> {
assertNotNull(actual);
assertEquals(1, actual.getProducts().size());
assertEquals("prod-io", actual.getProducts().get(0).getProductId());
assertEquals("test", actual.getProducts().get(0).getProductId());
assertEquals(institutionId, "test-institution");
});

Expand Down Expand Up @@ -1334,7 +1334,7 @@ void testRetrieveUsersDataWithNoAdminRole() {

// Call the method
AssertSubscriber<UserDataResponse> subscriber = userService.retrieveUsersData(institutionId, personId, roles, states, products, productRoles, userUuid)
.subscribe().withSubscriber(AssertSubscriber.create());
.subscribe().withSubscriber(AssertSubscriber.create(10));

// Verify the result
subscriber.assertCompleted().getItems().forEach(actual -> {
Expand Down

0 comments on commit a41d07f

Please sign in to comment.