generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...boarding-sdk-product/src/test/java/it/pagopa/selfcare/product/utils/ProductUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package it.pagopa.selfcare.product.utils; | ||
|
||
import it.pagopa.selfcare.onboarding.common.PartyRole; | ||
import it.pagopa.selfcare.product.entity.PHASE_ADDITION_ALLOWED; | ||
import it.pagopa.selfcare.product.entity.Product; | ||
import it.pagopa.selfcare.product.entity.ProductRole; | ||
import it.pagopa.selfcare.product.entity.ProductRoleInfo; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ProductUtilsTest { | ||
|
||
private final static String productRoleManager = "admin"; | ||
|
||
@Test | ||
void validRoles() { | ||
Product product = dummyProduct(); | ||
List<PartyRole> partyRoles = ProductUtils.validRoles(product, PHASE_ADDITION_ALLOWED.ONBOARDING); | ||
assertEquals(1, partyRoles.size()); | ||
assertEquals(PartyRole.MANAGER, partyRoles.get(0)); | ||
} | ||
|
||
@Test | ||
void validRolesByProductRole() { | ||
Product product = dummyProduct(); | ||
List<PartyRole> partyRoles = ProductUtils.validRolesByProductRole(product, PHASE_ADDITION_ALLOWED.ONBOARDING, productRoleManager); | ||
assertEquals(1, partyRoles.size()); | ||
assertEquals(PartyRole.MANAGER, partyRoles.get(0)); | ||
} | ||
|
||
Product dummyProduct() { | ||
|
||
ProductRole productRole = new ProductRole(); | ||
productRole.setCode(productRoleManager); | ||
ProductRoleInfo productRoleInfo = new ProductRoleInfo(); | ||
productRoleInfo.setRoles(List.of(productRole)); | ||
productRoleInfo.setPhasesAdditionAllowed(List.of(PHASE_ADDITION_ALLOWED.ONBOARDING.value)); | ||
|
||
ProductRole productRoleOperator = new ProductRole(); | ||
productRoleOperator.setCode("operator"); | ||
ProductRoleInfo productRoleInfoOperator = new ProductRoleInfo(); | ||
productRoleInfoOperator.setRoles(List.of(productRoleOperator)); | ||
productRoleInfoOperator.setPhasesAdditionAllowed(List.of(PHASE_ADDITION_ALLOWED.DASHBOARD.value)); | ||
|
||
Map<PartyRole, ProductRoleInfo> roleMapping = new HashMap<>(); | ||
roleMapping.put(PartyRole.MANAGER, productRoleInfo); | ||
roleMapping.put(PartyRole.OPERATOR, productRoleInfoOperator); | ||
|
||
Product productResource = new Product(); | ||
productResource.setId("productId"); | ||
productResource.setRoleMappings(roleMapping); | ||
return productResource; | ||
} | ||
} |