Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SELC-4644] fix: setting productRole when creating an user #411

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ private List<CreateUserDto.Role> retrieveRole(String productId, Set<String> prod
return productRoles.stream().map(productRole -> {
EnumMap<PartyRole, ProductRoleInfo> roleMappings = product.getRoleMappings();
CreateUserDto.Role role = new CreateUserDto.Role();
role.setProductRole(productRole);
role.setLabel(Product.getLabel(productRole, roleMappings).orElse(null));
Optional<PartyRole> partyRole = Product.getPartyRole(productRole, roleMappings, PARTY_ROLE_WHITE_LIST);
role.setPartyRole(partyRole.orElseThrow(() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.function.Executable;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
Expand Down Expand Up @@ -294,9 +295,10 @@ void createUsersByFiscalCode() {
// given
final String institutionId = "institutionId";
final String productId = "productId";
final String productRole = "operator";
UserToCreate userToCreate = new UserToCreate();
HashSet<String> productRoles = new HashSet<>();
productRoles.add("operator");
productRoles.add(productRole);
userToCreate.setProductRoles(productRoles);

Product product = getProduct();
Expand All @@ -318,8 +320,10 @@ void createUsersByFiscalCode() {

// then
assertNotNull(userId);
ArgumentCaptor<List<CreateUserDto.Role>> captorRoles = ArgumentCaptor.forClass(List.class);
verify(userApiConnector, times(1))
.createOrUpdateUserByFiscalCode(eq(institutionId), eq(productId), eq(userToCreate), anyList());
.createOrUpdateUserByFiscalCode(eq(institutionId), eq(productId), eq(userToCreate), captorRoles.capture());
assertEquals(captorRoles.getValue().get(0).getProductRole(), productRole);
verifyNoMoreInteractions(userApiConnector);
}

Expand Down
Loading