diff --git a/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/functions/OnboardingFunctionsTest.java b/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/functions/OnboardingFunctionsTest.java index cee377ff0..1d5301aa1 100644 --- a/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/functions/OnboardingFunctionsTest.java +++ b/apps/onboarding-functions/src/test/java/it/pagopa/selfcare/onboarding/functions/OnboardingFunctionsTest.java @@ -318,6 +318,31 @@ void onboardingsOrchestratorForApproveGpu() { .updateOnboardingStatus(onboarding.getId(), OnboardingStatus.TOBEVALIDATED); } + @Test + void onboardingsOrchestratorForApproveGpuWhenIsPending() { + Onboarding onboarding = new Onboarding(); + onboarding.setId("onboardingId"); + onboarding.setStatus(OnboardingStatus.PENDING); + onboarding.setInstitution(new Institution()); + onboarding.setWorkflowType(WorkflowType.FOR_APPROVE_GPU); + + TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding); + + function.onboardingsOrchestrator(orchestrationContext, executionContext); + + ArgumentCaptor captorActivity = ArgumentCaptor.forClass(String.class); + verify(orchestrationContext, times(5)) + .callActivity(captorActivity.capture(), any(), any(), any()); + assertEquals(CREATE_INSTITUTION_ACTIVITY, captorActivity.getAllValues().get(0)); + assertEquals(CREATE_ONBOARDING_ACTIVITY, captorActivity.getAllValues().get(1)); + assertEquals(CREATE_USERS_ACTIVITY, captorActivity.getAllValues().get(2)); + assertEquals(STORE_ONBOARDING_ACTIVATEDAT, captorActivity.getAllValues().get(3)); + assertEquals(SEND_MAIL_COMPLETION_ACTIVITY, captorActivity.getAllValues().get(4)); + + verify(service, times(1)) + .updateOnboardingStatus(onboarding.getId(), OnboardingStatus.COMPLETED); + } + @Test void onboardingsOrchestratorForApproveWhenToBeValidated() { Onboarding onboarding = new Onboarding();