Skip to content

Commit

Permalink
[SELC-5844] Feat: Removed SEND_MAIL_COMPLETION_AGGREGATE_ACTIVITY fun…
Browse files Browse the repository at this point in the history
…ction and related callActivity (#587)
  • Loading branch information
flaminiaScarciofolo authored Nov 4, 2024
1 parent 8faf8ec commit 7ebe547
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,6 @@ public void createOnboardedUsers(@DurableActivityTrigger(name = "onboardingStrin
completionService.persistUsers(readOnboardingValue(objectMapper, onboardingString));
}

@FunctionName(SEND_MAIL_COMPLETION_AGGREGATE_ACTIVITY)
public void sendMailCompletionAggregate(@DurableActivityTrigger(name = "onboardingString") String onboardingString, final ExecutionContext context) {
context.getLogger().info(() -> String.format(FORMAT_LOGGER_ONBOARDING_STRING, SEND_MAIL_COMPLETION_AGGREGATE_ACTIVITY, onboardingString));
completionService.sendCompletedEmailAggregate(readOnboardingValue(objectMapper, onboardingString));
}

@FunctionName(CREATE_AGGREGATE_ONBOARDING_REQUEST_ACTIVITY)
public String createAggregateOnboardingRequest(@DurableActivityTrigger(name = "onboardingString") String onboardingAggregateOrchestratorInputString, final ExecutionContext context) {
context.getLogger().info(() -> String.format(FORMAT_LOGGER_ONBOARDING_STRING, CREATE_AGGREGATE_ONBOARDING_REQUEST_ACTIVITY, onboardingAggregateOrchestratorInputString));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class ActivityName {
public static final String CREATE_USERS_ACTIVITY = "CreateUsers";
public static final String SEND_ONBOARDING_NOTIFICATION = "SendOnboardingNotification";
public static final String CREATE_AGGREGATE_ONBOARDING_REQUEST_ACTIVITY = "CreateAggregateOnboardingRequest";
public static final String SEND_MAIL_COMPLETION_AGGREGATE_ACTIVITY = "SendMailCompletionAggregate";
public static final String CREATE_DELEGATION_ACTIVITY = "CreateDelegation";
public static final String ONBOARDINGS_AGGREGATE_ORCHESTRATOR = "OnboardingsAggregate";
public static final String RESEND_NOTIFICATIONS_ACTIVITY = "ResendNotificationsActivity";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public Optional<OnboardingStatus> executePendingState(TaskOrchestrationContext c

createTestEnvironmentsOnboarding(ctx, onboarding, onboardingWithInstitutionIdString);

ctx.callActivity(SEND_MAIL_COMPLETION_AGGREGATE_ACTIVITY, onboardingWithDelegationIdString, optionsRetry, String.class).await();
return Optional.of(OnboardingStatus.COMPLETED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class OnboardingFunctionsTest {

@Test
void startAndWaitOrchestration_failedOrchestration() throws Exception {
// Setup
@SuppressWarnings("unchecked") final HttpRequestMessage<Optional<String>> req = mock(HttpRequestMessage.class);

final Map<String, String> queryParams = new HashMap<>();
Expand All @@ -97,10 +96,9 @@ void startAndWaitOrchestration_failedOrchestration() throws Exception {
doReturn(client).when(durableContext).getClient();
doReturn(scheduleNewOrchestrationInstance).when(client).scheduleNewOrchestrationInstance("Onboardings", onboardingId);

// Invoke
HttpResponseMessage responseMessage = function.startOrchestration(req, durableContext, context);

// Verify

verify(client, times(1))
.waitForInstanceCompletion(anyString(), any(), anyBoolean());
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR.value(), responseMessage.getStatusCode());
Expand Down Expand Up @@ -193,7 +191,6 @@ void onboardingOrchestratorContractRegistrationAggregator_Pending() {
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(REJECT_OUTDATED_ONBOARDINGS, captorActivity.getAllValues().get(4));
assertEquals(SEND_MAIL_COMPLETION_ACTIVITY, captorActivity.getAllValues().get(4));

Mockito.verify(orchestrationContext, times(3))
Expand Down Expand Up @@ -229,6 +226,19 @@ void onboardingOrchestratorIncrementRegistrationAggregator_Pending_delgationAlre

@Test
void onboardingOrchestratorIncrementRegistrationAggregator_Pending_delgationNotExists() {
Onboarding onboarding = getOnboarding();
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContextForIncrementAggregator(onboarding, "false");

function.onboardingsOrchestrator(orchestrationContext, executionContext);

Mockito.verify(orchestrationContext, times(2))
.callSubOrchestrator(eq(ONBOARDINGS_AGGREGATE_ORCHESTRATOR), any(), any());

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

private static Onboarding getOnboarding() {
Onboarding onboarding = new Onboarding();
onboarding.setId("onboardingId");
onboarding.setStatus(OnboardingStatus.PENDING);
Expand All @@ -241,15 +251,7 @@ void onboardingOrchestratorIncrementRegistrationAggregator_Pending_delgationNotE
institution.setId("id");
onboarding.setInstitution(institution);
onboarding.setWorkflowType(WorkflowType.INCREMENT_REGISTRATION_AGGREGATOR);
TaskOrchestrationContext orchestrationContext = mockTaskOrchestrationContextForIncrementAggregator(onboarding, "false");

function.onboardingsOrchestrator(orchestrationContext, executionContext);

Mockito.verify(orchestrationContext, times(2))
.callSubOrchestrator(eq(ONBOARDINGS_AGGREGATE_ORCHESTRATOR), any(), any());

Mockito.verify(service, times(1))
.updateOnboardingStatus(onboarding.getId(), OnboardingStatus.COMPLETED);
return onboarding;
}


Expand Down Expand Up @@ -338,7 +340,6 @@ void onboardingsOrchestratorConfirmation() {
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(REJECT_OUTDATED_ONBOARDINGS, captorActivity.getAllValues().get(4));
assertEquals(SEND_MAIL_COMPLETION_ACTIVITY, captorActivity.getAllValues().get(4));

verify(service, times(1))
Expand All @@ -365,7 +366,6 @@ void onboardingsOrchestratorConfirmationWithTestProductIds() {
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(REJECT_OUTDATED_ONBOARDINGS, captorActivity.getAllValues().get(4));
assertEquals(CREATE_ONBOARDING_ACTIVITY, captorActivity.getAllValues().get(4));
assertEquals(CREATE_USERS_ACTIVITY, captorActivity.getAllValues().get(5));
assertEquals(SEND_MAIL_COMPLETION_ACTIVITY, captorActivity.getAllValues().get(6));
Expand All @@ -388,17 +388,17 @@ void onboardingOrchestratorConfirmAggregate() {
function.onboardingsOrchestrator(orchestrationContext, executionContext);

ArgumentCaptor<String> captorActivity = ArgumentCaptor.forClass(String.class);
Mockito.verify(orchestrationContext, times(6))
Mockito.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_DELEGATION_ACTIVITY, captorActivity.getAllValues().get(2));
assertEquals(CREATE_USERS_ACTIVITY, captorActivity.getAllValues().get(3));
assertEquals(STORE_ONBOARDING_ACTIVATEDAT, captorActivity.getAllValues().get(4));
assertEquals(SEND_MAIL_COMPLETION_AGGREGATE_ACTIVITY, captorActivity.getAllValues().get(5));

Mockito.verify(service, times(1))
.updateOnboardingStatus(onboarding.getId(), OnboardingStatus.COMPLETED);
Mockito.verify(completionService,times(0)).sendCompletedEmailAggregate(any());

function.onboardingsOrchestrator(orchestrationContext, executionContext);
}
Expand Down Expand Up @@ -499,8 +499,6 @@ void onboardingsOrchestratorImport() {
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(REJECT_OUTDATED_ONBOARDINGS, captorActivity.getAllValues().get(3));

verify(service, times(1))
.updateOnboardingStatus(onboarding.getId(), OnboardingStatus.COMPLETED);
Expand Down Expand Up @@ -570,7 +568,6 @@ void onboardingsOrchestratorForApprovePtWhenToBeValidated() {
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(REJECT_OUTDATED_ONBOARDINGS, captorActivity.getAllValues().get(4));
assertEquals(SEND_MAIL_COMPLETION_ACTIVITY, captorActivity.getAllValues().get(4));

verify(service, times(1))
Expand Down Expand Up @@ -721,7 +718,6 @@ void onboardingCompletionOrchestrator() {
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(REJECT_OUTDATED_ONBOARDINGS, captorActivity.getAllValues().get(4));
assertEquals(SEND_MAIL_COMPLETION_ACTIVITY, captorActivity.getAllValues().get(4));

verify(service, times(1))
Expand Down Expand Up @@ -849,18 +845,6 @@ void sendMailRejection() {
.sendMailRejection(any(), any());
}

@Test
void sendCompletedEmailAggregate() {

when(executionContext.getLogger()).thenReturn(Logger.getGlobal());
doNothing().when(completionService).sendCompletedEmailAggregate(any());

function.sendMailCompletionAggregate(onboardinString, executionContext);

verify(completionService, times(1))
.sendCompletedEmailAggregate(any());
}


@Test
void createUsersOnboarding() {
Expand Down

0 comments on commit 7ebe547

Please sign in to comment.