Skip to content

Commit

Permalink
Updated workflow executor
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Nov 27, 2024
1 parent da680b9 commit dbe94d5
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ public void onboardingsOrchestrator(
workflowExecutor = new WorkflowExecutorForApprove(objectMapper, optionsRetry);
case FOR_APPROVE_PT ->
workflowExecutor = new WorkflowExecutorForApprovePt(objectMapper, optionsRetry);
case FOR_APPROVE_GPU ->
workflowExecutor = new WorkflowExecutorForApproveGpu(objectMapper, optionsRetry);
case CONFIRMATION ->
workflowExecutor = new WorkflowExecutorConfirmation(objectMapper, optionsRetry);
case CONFIRMATION_AGGREGATE ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public record WorkflowExecutorForApproveGpu(ObjectMapper objectMapper, TaskOptio
@Override
public Optional<OnboardingStatus> executeRequestState(TaskOrchestrationContext ctx, OnboardingWorkflow onboardingWorkflow) {
String onboardingString = getOnboardingString(objectMapper, onboardingWorkflow.getOnboarding());
ctx.callActivity("BuildAttachmentsAndSaveTokens", onboardingString, optionsRetry, String.class).await();
ctx.callActivity(SEND_MAIL_ONBOARDING_APPROVE_ACTIVITY, onboardingString, optionsRetry, String.class).await();
return Optional.of(OnboardingStatus.TOBEVALIDATED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,74 @@ void onboardingOrchestratorUsersEaPending() {
function.onboardingsOrchestrator(orchestrationContext, executionContext);
}

@Test
void onboardingsOrchestratorForApproveGpu() {
Onboarding onboarding = new Onboarding();
onboarding.setId("onboardingId");
onboarding.setStatus(OnboardingStatus.REQUEST);
onboarding.setWorkflowType(WorkflowType.FOR_APPROVE_GPU);

TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding);

function.onboardingsOrchestrator(orchestrationContext, executionContext);

ArgumentCaptor<String> captorActivity = ArgumentCaptor.forClass(String.class);
verify(orchestrationContext, times(2))
.callActivity(captorActivity.capture(), any(), any(), any());
assertEquals("BuildAttachmentsAndSaveTokens", captorActivity.getAllValues().get(0));
assertEquals(SEND_MAIL_ONBOARDING_APPROVE_ACTIVITY, captorActivity.getAllValues().get(1));

verify(service, times(1))
.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<String> 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 onboardingsOrchestratorForApproveGpuWhenToBeValidated() {
Onboarding onboarding = new Onboarding();
onboarding.setId("onboardingId");
onboarding.setStatus(OnboardingStatus.TOBEVALIDATED);
onboarding.setWorkflowType(WorkflowType.FOR_APPROVE_GPU);

TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContext(onboarding);

function.onboardingsOrchestrator(orchestrationContext, executionContext);

ArgumentCaptor<String> captorActivity = ArgumentCaptor.forClass(String.class);
verify(orchestrationContext, times(3))
.callActivity(captorActivity.capture(), any(), any(), any());
assertEquals(BUILD_CONTRACT_ACTIVITY_NAME, captorActivity.getAllValues().get(0));
assertEquals(SAVE_TOKEN_WITH_CONTRACT_ACTIVITY_NAME, captorActivity.getAllValues().get(1));
assertEquals(SEND_MAIL_REGISTRATION_FOR_CONTRACT_WHEN_APPROVE_ACTIVITY, captorActivity.getAllValues().get(2));

verify(service, times(1))
.updateOnboardingStatus(onboarding.getId(), OnboardingStatus.PENDING);
}

private Product createDummyProduct() {
Product product = new Product();
product.setTitle("Title");
Expand Down

0 comments on commit dbe94d5

Please sign in to comment.