14
14
import it .pagopa .selfcare .onboarding .HttpResponseMessageMock ;
15
15
import it .pagopa .selfcare .onboarding .common .OnboardingStatus ;
16
16
import it .pagopa .selfcare .onboarding .common .WorkflowType ;
17
- import it .pagopa .selfcare .onboarding .entity .AggregateInstitution ;
18
17
import it .pagopa .selfcare .onboarding .entity .Institution ;
19
18
import it .pagopa .selfcare .onboarding .entity .Onboarding ;
20
19
import it .pagopa .selfcare .onboarding .exception .ResourceNotFoundException ;
21
- import it .pagopa .selfcare .onboarding .mapper .OnboardingMapper ;
22
20
import it .pagopa .selfcare .onboarding .service .CompletionService ;
23
21
import it .pagopa .selfcare .onboarding .service .NotificationEventService ;
24
22
import it .pagopa .selfcare .onboarding .service .OnboardingService ;
@@ -60,9 +58,6 @@ public class OnboardingFunctionsTest {
60
58
@ InjectMock
61
59
NotificationEventService notificationEventService ;
62
60
63
- @ Inject
64
- OnboardingMapper onboardingMapper ;
65
-
66
61
final String onboardinString = "{\" onboardingId\" :\" onboardingId\" }" ;
67
62
68
63
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 {
117
112
void onboardingsOrchestrator_throwExceptionIfOnboardingNotPresent () {
118
113
final String onboardingId = "onboardingId" ;
119
114
TaskOrchestrationContext orchestrationContext = mock (TaskOrchestrationContext .class );
120
-
115
+
121
116
when (orchestrationContext .getInput (String .class )).thenReturn (onboardingId );
122
117
when (service .getOnboarding (onboardingId )).thenReturn (Optional .empty ());
123
118
assertThrows (ResourceNotFoundException .class , () -> function .onboardingsOrchestrator (orchestrationContext , executionContext ));
@@ -171,44 +166,6 @@ void onboardingOrchestratorContractRegistrationAggregator(){
171
166
function .onboardingsOrchestrator (orchestrationContext , executionContext );
172
167
}
173
168
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
-
212
169
@ Test
213
170
void onboardingsOrchestratorNewAdminRequest () {
214
171
Onboarding onboarding = new Onboarding ();
@@ -239,7 +196,7 @@ void onboardingsOrchestratorForApprove() {
239
196
onboarding .setWorkflowType (WorkflowType .FOR_APPROVE );
240
197
241
198
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext (onboarding );
242
-
199
+
243
200
244
201
function .onboardingsOrchestrator (orchestrationContext , executionContext );
245
202
@@ -260,7 +217,7 @@ void onboardingsOrchestratorForApproveWhenToBeValidated() {
260
217
onboarding .setWorkflowType (WorkflowType .FOR_APPROVE );
261
218
262
219
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext (onboarding );
263
-
220
+
264
221
265
222
function .onboardingsOrchestrator (orchestrationContext , executionContext );
266
223
@@ -284,7 +241,7 @@ void onboardingsOrchestratorConfirmation() {
284
241
onboarding .setInstitution (new Institution ());
285
242
286
243
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext (onboarding );
287
-
244
+
288
245
289
246
function .onboardingsOrchestrator (orchestrationContext , executionContext );
290
247
@@ -489,7 +446,7 @@ void onboardingsOrchestratorRegistrationRequestApprove() {
489
446
onboarding .setWorkflowType (WorkflowType .FOR_APPROVE_PT );
490
447
491
448
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext (onboarding );
492
-
449
+
493
450
494
451
function .onboardingsOrchestrator (orchestrationContext , executionContext );
495
452
@@ -535,7 +492,6 @@ TaskOrchestrationContext mockTaskOrchestrationContext(Onboarding onboarding) {
535
492
536
493
Task task = mock (Task .class );
537
494
when (orchestrationContext .callActivity (any (),any (),any (),any ())).thenReturn (task );
538
- when (orchestrationContext .callSubOrchestrator (any (),any ())).thenReturn (task );
539
495
when (task .await ()).thenReturn ("example" );
540
496
when (orchestrationContext .allOf (anyList ())).thenReturn (task );
541
497
return orchestrationContext ;
@@ -554,7 +510,7 @@ void buildContract() {
554
510
555
511
@ Test
556
512
void saveToken () {
557
-
513
+
558
514
when (executionContext .getLogger ()).thenReturn (Logger .getGlobal ());
559
515
doNothing ().when (service ).saveTokenWithContract (any ());
560
516
@@ -566,7 +522,7 @@ void saveToken() {
566
522
567
523
@ Test
568
524
void sendMailRegistrationWithContract () {
569
-
525
+
570
526
when (executionContext .getLogger ()).thenReturn (Logger .getGlobal ());
571
527
doNothing ().when (service ).sendMailRegistrationForContract (any ());
572
528
@@ -579,7 +535,7 @@ void sendMailRegistrationWithContract() {
579
535
580
536
@ Test
581
537
void sendMailRegistration () {
582
-
538
+
583
539
when (executionContext .getLogger ()).thenReturn (Logger .getGlobal ());
584
540
doNothing ().when (service ).sendMailRegistration (any ());
585
541
@@ -591,7 +547,7 @@ void sendMailRegistration() {
591
547
592
548
@ Test
593
549
void sendMailRegistrationApprove () {
594
-
550
+
595
551
when (executionContext .getLogger ()).thenReturn (Logger .getGlobal ());
596
552
doNothing ().when (service ).sendMailRegistrationApprove (any ());
597
553
@@ -603,7 +559,7 @@ void sendMailRegistrationApprove() {
603
559
604
560
@ Test
605
561
void sendMailOnboardingApprove () {
606
-
562
+
607
563
when (executionContext .getLogger ()).thenReturn (Logger .getGlobal ());
608
564
doNothing ().when (service ).sendMailOnboardingApprove (any ());
609
565
@@ -615,7 +571,7 @@ void sendMailOnboardingApprove() {
615
571
616
572
@ Test
617
573
void sendMailRegistrationWithContractWhenApprove () {
618
-
574
+
619
575
when (executionContext .getLogger ()).thenReturn (Logger .getGlobal ());
620
576
doNothing ().when (service ).sendMailRegistrationForContractWhenApprove (any ());
621
577
@@ -635,7 +591,7 @@ void onboardingCompletionOrchestrator() {
635
591
onboarding .setInstitution (new Institution ());
636
592
637
593
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext (onboarding );
638
-
594
+
639
595
640
596
function .onboardingsOrchestrator (orchestrationContext , executionContext );
641
597
@@ -665,7 +621,7 @@ void onboardingRejectedOrchestrator() {
665
621
onboarding .setInstitution (new Institution ());
666
622
667
623
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext (onboarding );
668
-
624
+
669
625
670
626
function .onboardingsOrchestrator (orchestrationContext , executionContext );
671
627
@@ -692,7 +648,7 @@ void createInstitutionAndPersistInstitutionId() {
692
648
693
649
@ Test
694
650
void sendCompletedEmail () {
695
-
651
+
696
652
when (executionContext .getLogger ()).thenReturn (Logger .getGlobal ());
697
653
doNothing ().when (completionService ).sendCompletedEmail (any ());
698
654
@@ -704,7 +660,7 @@ void sendCompletedEmail() {
704
660
705
661
@ Test
706
662
void sendMailRejection () {
707
-
663
+
708
664
when (executionContext .getLogger ()).thenReturn (Logger .getGlobal ());
709
665
doNothing ().when (completionService ).sendMailRejection (any ());
710
666
@@ -766,4 +722,4 @@ void createDelegationForAggregation() {
766
722
verify (completionService , times (1 ))
767
723
.createDelegation (any ());
768
724
}
769
- }
725
+ }
0 commit comments