Skip to content

Commit e9f1b23

Browse files
pierpaolo.didato@emeal.nttdata.compierpaolo.didato@emeal.nttdata.com
pierpaolo.didato@emeal.nttdata.com
authored and
pierpaolo.didato@emeal.nttdata.com
committed
Update test
1 parent f8e9c2f commit e9f1b23

File tree

1 file changed

+16
-60
lines changed

1 file changed

+16
-60
lines changed

apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/functions/OnboardingFunctionsTest.java

+16-60
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
import it.pagopa.selfcare.onboarding.HttpResponseMessageMock;
1515
import it.pagopa.selfcare.onboarding.common.OnboardingStatus;
1616
import it.pagopa.selfcare.onboarding.common.WorkflowType;
17-
import it.pagopa.selfcare.onboarding.entity.AggregateInstitution;
1817
import it.pagopa.selfcare.onboarding.entity.Institution;
1918
import it.pagopa.selfcare.onboarding.entity.Onboarding;
2019
import it.pagopa.selfcare.onboarding.exception.ResourceNotFoundException;
21-
import it.pagopa.selfcare.onboarding.mapper.OnboardingMapper;
2220
import it.pagopa.selfcare.onboarding.service.CompletionService;
2321
import it.pagopa.selfcare.onboarding.service.NotificationEventService;
2422
import it.pagopa.selfcare.onboarding.service.OnboardingService;
@@ -60,9 +58,6 @@ public class OnboardingFunctionsTest {
6058
@InjectMock
6159
NotificationEventService notificationEventService;
6260

63-
@Inject
64-
OnboardingMapper onboardingMapper;
65-
6661
final String onboardinString = "{\"onboardingId\":\"onboardingId\"}";
6762

6863
final String onboardingWorkflowString = "{\"type\":\"INSTITUTION\",\"onboarding\":{\"id\":\"id\",\"productId\":null,\"testEnvProductIds\":null,\"workflowType\":null,\"institution\":null,\"users\":null,\"aggregates\":null,\"pricingPlan\":null,\"billing\":null,\"signContract\":null,\"expiringDate\":null,\"status\":null,\"userRequestUid\":null,\"workflowInstanceId\":null,\"createdAt\":null,\"updatedAt\":null,\"activatedAt\":null,\"deletedAt\":null,\"reasonForReject\":null,\"isAggregator\":null}}";
@@ -117,7 +112,7 @@ public void startAndWaitOrchestration_failedOrchestration() throws Exception {
117112
void onboardingsOrchestrator_throwExceptionIfOnboardingNotPresent() {
118113
final String onboardingId = "onboardingId";
119114
TaskOrchestrationContext orchestrationContext = mock(TaskOrchestrationContext.class);
120-
115+
121116
when(orchestrationContext.getInput(String.class)).thenReturn(onboardingId);
122117
when(service.getOnboarding(onboardingId)).thenReturn(Optional.empty());
123118
assertThrows(ResourceNotFoundException.class, () -> function.onboardingsOrchestrator(orchestrationContext, executionContext));
@@ -171,44 +166,6 @@ void onboardingOrchestratorContractRegistrationAggregator(){
171166
function.onboardingsOrchestrator(orchestrationContext, executionContext);
172167
}
173168

174-
@Test
175-
void onboardingOrchestratorContractRegistrationAggregator_Pending(){
176-
Onboarding onboarding = new Onboarding();
177-
onboarding.setId("onboardingId");
178-
onboarding.setStatus(OnboardingStatus.PENDING);
179-
AggregateInstitution aggregate1 = new AggregateInstitution();
180-
aggregate1.setTaxCode("code1");
181-
AggregateInstitution aggregate2 = new AggregateInstitution();
182-
aggregate1.setTaxCode("code2");
183-
AggregateInstitution aggregate3 = new AggregateInstitution();
184-
aggregate1.setTaxCode("code3");
185-
onboarding.setAggregates(List.of(aggregate1, aggregate2, aggregate3));
186-
Institution institution = new Institution();
187-
institution.setId("id");
188-
onboarding.setInstitution(institution);
189-
onboarding.setWorkflowType(WorkflowType.CONTRACT_REGISTRATION_AGGREGATOR);
190-
191-
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding);
192-
function.onboardingsOrchestrator(orchestrationContext, executionContext);
193-
194-
ArgumentCaptor<String> captorActivity = ArgumentCaptor.forClass(String.class);
195-
Mockito.verify(orchestrationContext, times(5))
196-
.callActivity(captorActivity.capture(), any(), any(),any());
197-
assertEquals(CREATE_INSTITUTION_ACTIVITY, captorActivity.getAllValues().get(0));
198-
assertEquals(CREATE_ONBOARDING_ACTIVITY, captorActivity.getAllValues().get(1));
199-
assertEquals(CREATE_USERS_ACTIVITY, captorActivity.getAllValues().get(2));
200-
assertEquals(STORE_ONBOARDING_ACTIVATEDAT, captorActivity.getAllValues().get(3));
201-
assertEquals(SEND_MAIL_COMPLETION_ACTIVITY, captorActivity.getAllValues().get(4));
202-
203-
Mockito.verify(orchestrationContext, times(3))
204-
.callSubOrchestrator(eq(ONBOARDINGS_AGGREGATE_ORCHESTRATOR), any(), any());
205-
206-
Mockito.verify(service, times(1))
207-
.updateOnboardingStatus(onboarding.getId(), OnboardingStatus.COMPLETED);
208-
209-
function.onboardingsOrchestrator(orchestrationContext, executionContext);
210-
}
211-
212169
@Test
213170
void onboardingsOrchestratorNewAdminRequest() {
214171
Onboarding onboarding = new Onboarding();
@@ -239,7 +196,7 @@ void onboardingsOrchestratorForApprove() {
239196
onboarding.setWorkflowType(WorkflowType.FOR_APPROVE);
240197

241198
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding);
242-
199+
243200

244201
function.onboardingsOrchestrator(orchestrationContext, executionContext);
245202

@@ -260,7 +217,7 @@ void onboardingsOrchestratorForApproveWhenToBeValidated() {
260217
onboarding.setWorkflowType(WorkflowType.FOR_APPROVE);
261218

262219
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding);
263-
220+
264221

265222
function.onboardingsOrchestrator(orchestrationContext, executionContext);
266223

@@ -284,7 +241,7 @@ void onboardingsOrchestratorConfirmation() {
284241
onboarding.setInstitution(new Institution());
285242

286243
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding);
287-
244+
288245

289246
function.onboardingsOrchestrator(orchestrationContext, executionContext);
290247

@@ -489,7 +446,7 @@ void onboardingsOrchestratorRegistrationRequestApprove() {
489446
onboarding.setWorkflowType(WorkflowType.FOR_APPROVE_PT);
490447

491448
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding);
492-
449+
493450

494451
function.onboardingsOrchestrator(orchestrationContext, executionContext);
495452

@@ -535,7 +492,6 @@ TaskOrchestrationContext mockTaskOrchestrationContext(Onboarding onboarding) {
535492

536493
Task task = mock(Task.class);
537494
when(orchestrationContext.callActivity(any(),any(),any(),any())).thenReturn(task);
538-
when(orchestrationContext.callSubOrchestrator(any(),any())).thenReturn(task);
539495
when(task.await()).thenReturn("example");
540496
when(orchestrationContext.allOf(anyList())).thenReturn(task);
541497
return orchestrationContext;
@@ -554,7 +510,7 @@ void buildContract() {
554510

555511
@Test
556512
void saveToken() {
557-
513+
558514
when(executionContext.getLogger()).thenReturn(Logger.getGlobal());
559515
doNothing().when(service).saveTokenWithContract(any());
560516

@@ -566,7 +522,7 @@ void saveToken() {
566522

567523
@Test
568524
void sendMailRegistrationWithContract() {
569-
525+
570526
when(executionContext.getLogger()).thenReturn(Logger.getGlobal());
571527
doNothing().when(service).sendMailRegistrationForContract(any());
572528

@@ -579,7 +535,7 @@ void sendMailRegistrationWithContract() {
579535

580536
@Test
581537
void sendMailRegistration() {
582-
538+
583539
when(executionContext.getLogger()).thenReturn(Logger.getGlobal());
584540
doNothing().when(service).sendMailRegistration(any());
585541

@@ -591,7 +547,7 @@ void sendMailRegistration() {
591547

592548
@Test
593549
void sendMailRegistrationApprove() {
594-
550+
595551
when(executionContext.getLogger()).thenReturn(Logger.getGlobal());
596552
doNothing().when(service).sendMailRegistrationApprove(any());
597553

@@ -603,7 +559,7 @@ void sendMailRegistrationApprove() {
603559

604560
@Test
605561
void sendMailOnboardingApprove() {
606-
562+
607563
when(executionContext.getLogger()).thenReturn(Logger.getGlobal());
608564
doNothing().when(service).sendMailOnboardingApprove(any());
609565

@@ -615,7 +571,7 @@ void sendMailOnboardingApprove() {
615571

616572
@Test
617573
void sendMailRegistrationWithContractWhenApprove() {
618-
574+
619575
when(executionContext.getLogger()).thenReturn(Logger.getGlobal());
620576
doNothing().when(service).sendMailRegistrationForContractWhenApprove(any());
621577

@@ -635,7 +591,7 @@ void onboardingCompletionOrchestrator() {
635591
onboarding.setInstitution(new Institution());
636592

637593
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding);
638-
594+
639595

640596
function.onboardingsOrchestrator(orchestrationContext, executionContext);
641597

@@ -665,7 +621,7 @@ void onboardingRejectedOrchestrator() {
665621
onboarding.setInstitution(new Institution());
666622

667623
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding);
668-
624+
669625

670626
function.onboardingsOrchestrator(orchestrationContext, executionContext);
671627

@@ -692,7 +648,7 @@ void createInstitutionAndPersistInstitutionId() {
692648

693649
@Test
694650
void sendCompletedEmail() {
695-
651+
696652
when(executionContext.getLogger()).thenReturn(Logger.getGlobal());
697653
doNothing().when(completionService).sendCompletedEmail(any());
698654

@@ -704,7 +660,7 @@ void sendCompletedEmail() {
704660

705661
@Test
706662
void sendMailRejection() {
707-
663+
708664
when(executionContext.getLogger()).thenReturn(Logger.getGlobal());
709665
doNothing().when(completionService).sendMailRejection(any());
710666

@@ -766,4 +722,4 @@ void createDelegationForAggregation() {
766722
verify(completionService, times(1))
767723
.createDelegation(any());
768724
}
769-
}
725+
}

0 commit comments

Comments
 (0)