Skip to content

Commit

Permalink
[SELC-6232] feat: added workflowType CONFIRMATION to customValidation (
Browse files Browse the repository at this point in the history
  • Loading branch information
gianmarcoplutino authored Dec 19, 2024
1 parent 5ae63f1 commit 404ccda
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ protected boolean isWorkflowTypeAllowed(WorkflowType workflowType) {
return workflowType == WorkflowType.FOR_APPROVE ||
workflowType == WorkflowType.IMPORT ||
workflowType == WorkflowType.FOR_APPROVE_PT ||
workflowType == WorkflowType.FOR_APPROVE_GPU;
workflowType == WorkflowType.FOR_APPROVE_GPU ||
workflowType == WorkflowType.CONFIRMATION;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void customValidation_shouldReturnOnboarding_whenWorkflowTypeAllowed(WorkflowTyp

@Test
void customValidation_shouldThrowInvalidRequestException_whenWorkflowTypeNotAllowed() {
when(onboarding.getWorkflowType()).thenReturn(WorkflowType.CONFIRMATION);
when(onboarding.getWorkflowType()).thenReturn(WorkflowType.CONTRACT_REGISTRATION);

Uni<Onboarding> result = registryManagerSELC.customValidation(mock(Product.class));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ void onboarding_PRV(UniAsserter asserter) {

@Test
@RunOnVertxContext
void onboarding_SELC_Forbidden_WorkflowType(UniAsserter asserter) {
void onboarding_SELC_WorkflowType_CONFIRMATION(UniAsserter asserter) {
Onboarding request = new Onboarding();
List<UserRequest> users = List.of(manager);
request.setProductId(PROD_PAGOPA.getValue());
Expand All @@ -825,8 +825,35 @@ void onboarding_SELC_Forbidden_WorkflowType(UniAsserter asserter) {
mockVerifyOnboardingNotFound();
mockVerifyAllowedMap(request.getInstitution().getTaxCode(), request.getProductId(), asserter);

// onboardingCompletion will set the workflowType to COMPLETION, which is not allowed for GSP
asserter.assertFailedWith(() -> onboardingService.onboardingCompletion(request, users), InvalidRequestException.class);
// onboardingCompletion will set the workflowType to CONFIRMATION, which is allowed for GSP
asserter.assertThat(() -> onboardingService.onboardingCompletion(request, users), Assertions::assertNotNull);
}

@Test
@RunOnVertxContext
void onboarding_SELC_Forbidden_WorkflowType(UniAsserter asserter) {
Onboarding request = new Onboarding();
List<UserRequest> users = List.of(manager);
request.setProductId(PROD_INTEROP.getValue());
Institution institutionBaseRequest = new Institution();
institutionBaseRequest.setDescription("name");
institutionBaseRequest.setDigitalAddress("pec");
institutionBaseRequest.setInstitutionType(InstitutionType.GSP);
institutionBaseRequest.setTaxCode("taxCode");
request.setInstitution(institutionBaseRequest);
mockPersistOnboarding(asserter);

asserter.execute(() -> when(userRegistryApi.updateUsingPATCH(any(), any()))
.thenReturn(Uni.createFrom().item(Response.noContent().build())));


mockSimpleSearchPOSTAndPersist(asserter);
mockSimpleProductValidAssert(request.getProductId(), false, asserter);
mockVerifyOnboardingNotFound();
mockVerifyAllowedMap(request.getInstitution().getTaxCode(), request.getProductId(), asserter);

// onboarding will set the workflowType to CONTRACT_REGISTRATION when institutionType is GSP and product is interop, which is not allowed for GSP with origin SELC
asserter.assertFailedWith(() -> onboardingService.onboarding(request, users, null), InvalidRequestException.class);
}

@Test
Expand Down

0 comments on commit 404ccda

Please sign in to comment.