Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into feature/SELC-6170
  • Loading branch information
pierpaolo.didato@emeal.nttdata.com authored and pierpaolo.didato@emeal.nttdata.com committed Dec 11, 2024
2 parents 8113a4a + 9f3a0ff commit 759a6e4
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public Uni<OnboardingResponse> onboardingPspCompletion(@Valid OnboardingPspReque
public Uni<OnboardingResponse> onboardingPgCompletion(@Valid OnboardingPgRequest onboardingRequest, @Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
.onboardingPgCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
}

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Uni<OnboardingResponse> onboardingImport(
Uni<OnboardingResponse> onboardingCompletion(
Onboarding onboarding, List<UserRequest> userRequests);

Uni<OnboardingResponse> onboardingPgCompletion(
Onboarding onboarding, List<UserRequest> userRequests);

Uni<OnboardingResponse> onboardingAggregationCompletion(
Onboarding onboarding,
List<UserRequest> userRequests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ public Uni<OnboardingResponse> onboardingCompletion(
onboarding, userRequests, null, TIMEOUT_ORCHESTRATION_RESPONSE, false);
}

@Override
public Uni<OnboardingResponse> onboardingPgCompletion(
Onboarding onboarding, List<UserRequest> userRequests) {
onboarding.setWorkflowType(WorkflowType.CONFIRMATION);
onboarding.setStatus(OnboardingStatus.PENDING);

return fillUsersAndOnboarding(
onboarding, userRequests, null, TIMEOUT_ORCHESTRATION_RESPONSE, false);
}

@Override
public Uni<OnboardingResponse> onboardingAggregationCompletion(
Onboarding onboarding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ void onboardingCompletePg() {
onboardingPgRequest.setDigitalAddress("digital@address.it");
onboardingPgRequest.setOrigin(Origin.INFOCAMERE);

Mockito.when(onboardingService.onboardingCompletion(any(), any()))
Mockito.when(onboardingService.onboardingPgCompletion(any(), any()))
.thenReturn(Uni.createFrom().item(new OnboardingResponse()));

given()
Expand All @@ -691,7 +691,7 @@ void onboardingCompletePg() {
.statusCode(200);

ArgumentCaptor<Onboarding> captor = ArgumentCaptor.forClass(Onboarding.class);
Mockito.verify(onboardingService, times(1)).onboardingCompletion(captor.capture(), any());
Mockito.verify(onboardingService, times(1)).onboardingPgCompletion(captor.capture(), any());
assertEquals(InstitutionType.PG, captor.getValue().getInstitution().getInstitutionType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,47 @@ void onboardingCompletion(UniAsserter asserter) {
});
}

@Test
@RunOnVertxContext
void onboardingPgCompletion(UniAsserter asserter) {
Onboarding request = new Onboarding();
Product product = createDummyProduct(PROD_PN.getValue(), false);
List<UserRequest> users = List.of(manager);
request.setProductId(PROD_PN.getValue());
Institution institutionBaseRequest = new Institution();
institutionBaseRequest.setTaxCode("taxCode");
institutionBaseRequest.setInstitutionType(InstitutionType.PG);
institutionBaseRequest.setOrigin(Origin.INFOCAMERE);
request.setInstitution(institutionBaseRequest);

mockPersistOnboarding(asserter);
mockPersistToken(asserter);

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

asserter.execute(() -> when(productService.getProduct(any())).thenReturn(product));

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

InstitutionResource institutionResource = new InstitutionResource();
institutionResource.setCategory("L37");
asserter.execute(() -> when(institutionRegistryProxyApi.findInstitutionUsingGET(institutionBaseRequest.getTaxCode(), null, null))
.thenReturn(Uni.createFrom().item(institutionResource)));

asserter.assertThat(() -> onboardingService.onboardingPgCompletion(request, users), Assertions::assertNotNull);

asserter.execute(() -> {
PanacheMock.verify(Onboarding.class).persist(any(Onboarding.class), any());
PanacheMock.verify(Onboarding.class).persistOrUpdate(any(List.class));
PanacheMock.verify(Onboarding.class).find(any(Document.class));
PanacheMock.verifyNoMoreInteractions(Onboarding.class);
});
}

@Test
@RunOnVertxContext
void onboardingUsers(UniAsserter asserter) {
Expand Down

0 comments on commit 759a6e4

Please sign in to comment.