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.
[SELC-5476] Feat: Added user mapping for aggregate users (#489)
- Loading branch information
1 parent
8fe35fd
commit 57cc1c3
Showing
3 changed files
with
111 additions
and
0 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
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
93 changes: 93 additions & 0 deletions
93
...nboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/OnboardingMapperTest.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,93 @@ | ||
package it.pagopa.selfcare.onboarding; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import it.pagopa.selfcare.onboarding.common.PartyRole; | ||
import it.pagopa.selfcare.onboarding.dto.OnboardingAggregateOrchestratorInput; | ||
import it.pagopa.selfcare.onboarding.entity.AggregateInstitution; | ||
import it.pagopa.selfcare.onboarding.entity.Onboarding; | ||
import it.pagopa.selfcare.onboarding.entity.User; | ||
import it.pagopa.selfcare.onboarding.mapper.OnboardingMapperImpl; | ||
import jakarta.inject.Inject; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@QuarkusTest | ||
class OnboardingMapperTest { | ||
|
||
@Inject | ||
private OnboardingMapperImpl onboardingMapper; | ||
|
||
@Test | ||
void mapToOnboardingAggregateOrchestratorInputTestWithAggregateUsers(){ | ||
Onboarding onboarding = new Onboarding(); | ||
onboarding.setId("example"); | ||
onboarding.setProductId("productId"); | ||
User user = new User(); | ||
user.setId("aggregatorUser"); | ||
user.setRole(PartyRole.MANAGER); | ||
user.setProductRole("aggregatorProductRole"); | ||
onboarding.setUsers(List.of(user)); | ||
|
||
User user2 = new User(); | ||
user2.setId("aggregateUser"); | ||
user2.setRole(PartyRole.MANAGER); | ||
user2.setProductRole("aggregateProductRole"); | ||
AggregateInstitution aggregateInstitution = new AggregateInstitution(); | ||
aggregateInstitution.setUsers(List.of(user2)); | ||
onboarding.setAggregates(List.of(aggregateInstitution)); | ||
|
||
OnboardingAggregateOrchestratorInput response = onboardingMapper.mapToOnboardingAggregateOrchestratorInput(onboarding, aggregateInstitution); | ||
Assertions.assertEquals(1, response.getUsers().size()); | ||
Assertions.assertEquals("aggregateUser", response.getUsers().get(0).getId()); | ||
Assertions.assertEquals(PartyRole.MANAGER, response.getUsers().get(0).getRole()); | ||
Assertions.assertEquals("aggregateProductRole", response.getUsers().get(0).getProductRole()); | ||
|
||
} | ||
|
||
@Test | ||
void mapToOnboardingAggregateOrchestratorInputTestWithoutAggregatesUser(){ | ||
Onboarding onboarding = new Onboarding(); | ||
onboarding.setId("example"); | ||
onboarding.setProductId("productId"); | ||
User user = new User(); | ||
user.setId("aggregatorUser"); | ||
user.setRole(PartyRole.MANAGER); | ||
user.setProductRole("aggregatorProductRole"); | ||
onboarding.setUsers(List.of(user)); | ||
|
||
AggregateInstitution aggregateInstitution = new AggregateInstitution(); | ||
aggregateInstitution.setUsers(null); | ||
onboarding.setAggregates(List.of(aggregateInstitution)); | ||
|
||
OnboardingAggregateOrchestratorInput response = onboardingMapper.mapToOnboardingAggregateOrchestratorInput(onboarding, aggregateInstitution); | ||
Assertions.assertEquals(1, response.getUsers().size()); | ||
Assertions.assertEquals("aggregatorUser", response.getUsers().get(0).getId()); | ||
Assertions.assertEquals(PartyRole.MANAGER, response.getUsers().get(0).getRole()); | ||
Assertions.assertEquals("aggregatorProductRole", response.getUsers().get(0).getProductRole()); | ||
} | ||
|
||
@Test | ||
void mapToOnboardingAggregateOrchestratorInputTestWithAggregatesUserEmptyList(){ | ||
Onboarding onboarding = new Onboarding(); | ||
onboarding.setId("example"); | ||
onboarding.setProductId("productId"); | ||
User user = new User(); | ||
user.setId("aggregatorUser"); | ||
user.setRole(PartyRole.MANAGER); | ||
user.setProductRole("aggregatorProductRole"); | ||
onboarding.setUsers(List.of(user)); | ||
|
||
AggregateInstitution aggregateInstitution = new AggregateInstitution(); | ||
aggregateInstitution.setUsers(Collections.emptyList()); | ||
onboarding.setAggregates(List.of(aggregateInstitution)); | ||
|
||
OnboardingAggregateOrchestratorInput response = onboardingMapper.mapToOnboardingAggregateOrchestratorInput(onboarding, aggregateInstitution); | ||
Assertions.assertEquals(1, response.getUsers().size()); | ||
Assertions.assertEquals("aggregatorUser", response.getUsers().get(0).getId()); | ||
Assertions.assertEquals(PartyRole.MANAGER, response.getUsers().get(0).getRole()); | ||
Assertions.assertEquals("aggregatorProductRole", response.getUsers().get(0).getProductRole()); | ||
} | ||
} |