From a258b2c3a2c81d1bc30bc18a1448d537b12b9fef Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 12 Jan 2024 15:17:47 -0800 Subject: [PATCH 01/12] fix: fixing client type reading issue --- .../ca/bc/gov/app/service/legacy/LegacyPersistenceService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyPersistenceService.java index 93a3c54077..6e6d03cc13 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyPersistenceService.java @@ -23,7 +23,7 @@ public Mono> persist( Flux .fromStream(persistenceServices.stream()) .filter(service -> service.filterByType( - message.parameters().get(ApplicationConstant.SUBMISSION_TYPE).toString() + message.parameters().get(ApplicationConstant.CLIENT_TYPE_CODE).toString() ) ) .next() From 7d10a9ca47b2f982c0c62a21a7480ecbdcce71c5 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 12 Jan 2024 15:39:45 -0800 Subject: [PATCH 02/12] fix(FSADT1-1121): adding error handling and message for country load - added a load message when loading countries - added error handling for post-processing --- .../main/java/ca/bc/gov/app/service/legacy/LegacyService.java | 3 ++- .../java/ca/bc/gov/app/service/processor/ProcessorService.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java index 3628936fbd..049da93d15 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java @@ -43,7 +43,8 @@ public LegacyService( public void setUp() { countryCodeRepository.findAll().doOnNext( countryCode -> countryList.put(countryCode.getCountryCode(), countryCode.getDescription())) - .collectList().subscribe(); + .collectList() + .subscribe(list -> log.info("Loaded {} country codes", list.size())); } diff --git a/processor/src/main/java/ca/bc/gov/app/service/processor/ProcessorService.java b/processor/src/main/java/ca/bc/gov/app/service/processor/ProcessorService.java index fbda7a117d..d0d01a2012 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/processor/ProcessorService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/processor/ProcessorService.java @@ -118,6 +118,7 @@ public void processedMessages() { ) .doOnNext(submission -> log.info("Submission post processed {}, building message", submission)) + .onErrorContinue((throwable, o) -> log.error("Error processing submission {}", o, throwable)) .flatMap(submissionLoadingService::buildMailMessage) .doOnNext(message -> log.info("Email ready to be sent {}", message)) .flatMap(mailService::sendMail) From 655ab54e7f4397b10eb57e2b51b0a0225e8b83a0 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 12 Jan 2024 16:04:50 -0800 Subject: [PATCH 03/12] fix(FSADT1-1121): fixing persistence and loading --- .../main/java/ca/bc/gov/app/dto/MessagingWrapper.java | 8 ++++++++ .../legacy/LegacyAbstractPersistenceService.java | 10 ++++------ .../legacy/LegacyIndividualPersistenceService.java | 10 ++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/processor/src/main/java/ca/bc/gov/app/dto/MessagingWrapper.java b/processor/src/main/java/ca/bc/gov/app/dto/MessagingWrapper.java index 2f87e00c8c..44c49d1d89 100644 --- a/processor/src/main/java/ca/bc/gov/app/dto/MessagingWrapper.java +++ b/processor/src/main/java/ca/bc/gov/app/dto/MessagingWrapper.java @@ -2,6 +2,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Objects; public record MessagingWrapper( T payload, @@ -19,4 +20,11 @@ public MessagingWrapper withParameter(String key, Object value) { return this; } + @SuppressWarnings({"unchecked", "unused"}) + public

P getParameter(String key,Class

clazz) { + if(Objects.isNull(this.parameters.get(key))) + return null; + return (P) this.parameters.get(key); + } + } diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java index 0ca77aebfa..9c64f9dd3d 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java @@ -53,7 +53,7 @@ public Mono> loadSubmission(MessagingWrapper submission.getSubmissionId()) ) .map(submission -> - new MessagingWrapper( + new MessagingWrapper<>( message.payload(), message.parameters() ) @@ -85,16 +85,14 @@ public Mono> checkClientData(MessagingWrapper .map(contact -> contact.getFirstName() + " " + contact.getLastName()) .doOnNext(contact -> log.info( - "Loaded submission contact for persistence on oracle {} {} {}", + "Loaded submission contact for persistence on oracle {} {}", message.payload(), - contact, - submissionDetail.getClientNumber() + contact ) ) .map(contact -> new MessagingWrapper<>( - message.parameters().get(ApplicationConstant.FOREST_CLIENT_NUMBER) - .toString(), + message.getParameter(ApplicationConstant.FOREST_CLIENT_NUMBER,String.class), message.parameters() ) .withParameter(ApplicationConstant.CLIENT_TYPE_CODE, diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java index ebb1267d98..58c2a577cb 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java @@ -56,10 +56,7 @@ public Mono> generateForestClient( return getSubmissionDetailRepository() .findBySubmissionId( - (Integer) - message - .parameters() - .get(ApplicationConstant.SUBMISSION_ID) + message.getParameter(ApplicationConstant.SUBMISSION_ID, Integer.class) ) .map(detailEntity -> getBaseForestClient( @@ -81,8 +78,9 @@ public Mono> generateForestClient( .withClientIdentification( getUser(message, ApplicationConstant.CREATED_BY).replace("bcsc\\", StringUtils.EMPTY)) - .withClientNumber(message.parameters() - .get(ApplicationConstant.FOREST_CLIENT_NUMBER).toString()) + .withClientNumber( + message.getParameter(ApplicationConstant.FOREST_CLIENT_NUMBER, String.class) + ) ) .map(forestClient -> new MessagingWrapper<>(forestClient, message.parameters()) From 3cc2d88de433f02bdcba389be93728eff761592a Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 12 Jan 2024 16:32:52 -0800 Subject: [PATCH 04/12] chore: limiting the size of the userid --- .../bc/gov/app/mappers/AbstractForestClientMapper.java | 4 ++++ .../bc/gov/app/mappers/ForestClientContactMapper.java | 10 ++++++++++ .../app/mappers/ForestClientDoingBusinessAsMapper.java | 10 ++++++++++ .../bc/gov/app/mappers/ForestClientLocationMapper.java | 10 ++++++++++ 4 files changed, 34 insertions(+) diff --git a/legacy/src/main/java/ca/bc/gov/app/mappers/AbstractForestClientMapper.java b/legacy/src/main/java/ca/bc/gov/app/mappers/AbstractForestClientMapper.java index 09ac0a4284..bbbfddc2dd 100644 --- a/legacy/src/main/java/ca/bc/gov/app/mappers/AbstractForestClientMapper.java +++ b/legacy/src/main/java/ca/bc/gov/app/mappers/AbstractForestClientMapper.java @@ -13,6 +13,10 @@ public interface AbstractForestClientMapper { @InheritInverseConfiguration E toEntity(D dto); + @Named("UserIdSizeQualifier") + default String limitUserId(String origin) { + return origin.length() > 30 ? origin.substring(0, 30) : origin; + } @Named("EmptySpaceQualifier") default String defaultEmptySpace(Object origin) { diff --git a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientContactMapper.java b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientContactMapper.java index a7c405c76a..2695f92482 100644 --- a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientContactMapper.java +++ b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientContactMapper.java @@ -46,5 +46,15 @@ public interface ForestClientContactMapper extends source = "clientNumber", qualifiedByName = "InitialRevisionQualifier" ) + @Mapping( + source = "createdBy", + target = "createdBy", + qualifiedByName = "UserIdSizeQualifier" + ) + @Mapping( + source = "updatedBy", + target = "updatedBy", + qualifiedByName = "UserIdSizeQualifier" + ) ForestClientContactEntity toEntity(ForestClientContactDto dto); } diff --git a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapper.java b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapper.java index 8bca91ddb8..a4ecac15d5 100644 --- a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapper.java +++ b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapper.java @@ -46,5 +46,15 @@ public interface ForestClientDoingBusinessAsMapper extends source = "clientNumber", qualifiedByName = "InitialRevisionQualifier" ) + @Mapping( + source = "createdBy", + target = "createdBy", + qualifiedByName = "UserIdSizeQualifier" + ) + @Mapping( + source = "updatedBy", + target = "updatedBy", + qualifiedByName = "UserIdSizeQualifier" + ) ClientDoingBusinessAsEntity toEntity(ClientDoingBusinessAsDto dto); } diff --git a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientLocationMapper.java b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientLocationMapper.java index a16cf03d7d..d61e20fb1e 100644 --- a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientLocationMapper.java +++ b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientLocationMapper.java @@ -46,5 +46,15 @@ public interface ForestClientLocationMapper extends source = "clientNumber", qualifiedByName = "InitialRevisionQualifier" ) + @Mapping( + source = "createdBy", + target = "createdBy", + qualifiedByName = "UserIdSizeQualifier" + ) + @Mapping( + source = "updatedBy", + target = "updatedBy", + qualifiedByName = "UserIdSizeQualifier" + ) ForestClientLocationEntity toEntity(ForestClientLocationDto dto); } From 245513d0bb4f5df58753fe77c524095387b4720c Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 12 Jan 2024 16:48:58 -0800 Subject: [PATCH 05/12] fix(FSADT1-1121): forcing user to be automated one --- .../dto/legacy/ForestClientContactDto.java | 3 +++ .../LegacyAbstractPersistenceService.java | 4 ++-- .../gov/app/service/legacy/LegacyService.java | 22 ++++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java index 2326aa046f..24a6e4bc53 100644 --- a/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java +++ b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java @@ -1,5 +1,8 @@ package ca.bc.gov.app.dto.legacy; +import lombok.With; + +@With public record ForestClientContactDto( String clientNumber, String clientLocnCode, diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java index 9c64f9dd3d..0d3b665fda 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java @@ -258,8 +258,8 @@ public Mono> createContact(MessagingWrapper m RegExUtils.replaceAll(submissionContact.getBusinessPhoneNumber(), "\\D", StringUtils.EMPTY), submissionContact.getEmailAddress(), - getUser(message, ApplicationConstant.CREATED_BY), - getUser(message, ApplicationConstant.UPDATED_BY), + ApplicationConstant.PROCESSOR_USER_NAME, + ApplicationConstant.PROCESSOR_USER_NAME, ApplicationConstant.ORG_UNIT ) ) diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java index 049da93d15..198e43ef89 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java @@ -76,8 +76,8 @@ public Mono createLocation( null, "Y", StringUtils.EMPTY, - user, - user, + ApplicationConstant.PROCESSOR_USER_NAME, + ApplicationConstant.PROCESSOR_USER_NAME, ApplicationConstant.ORG_UNIT, ApplicationConstant.ORG_UNIT ); @@ -87,12 +87,22 @@ public Mono createLocation( } public Mono createContact(ForestClientContactDto dto) { - return postRequestToLegacy("/api/contacts", dto) + return postRequestToLegacy( + "/api/contacts", + dto + .withCreatedBy(ApplicationConstant.PROCESSOR_USER_NAME) + .withUpdatedBy(ApplicationConstant.PROCESSOR_USER_NAME) + ) .thenReturn(dto.clientNumber()); } public Mono createClient(ForestClientDto dto) { - return postRequestToLegacy("/api/clients", dto); + return postRequestToLegacy( + "/api/clients", + dto + .withCreatedBy(ApplicationConstant.PROCESSOR_USER_NAME) + .withUpdatedBy(ApplicationConstant.PROCESSOR_USER_NAME) + ); } public Mono createDoingBusinessAs( @@ -106,8 +116,8 @@ public Mono createDoingBusinessAs( new ClientDoingBusinessAsDto( clientNumber, doingBusinessAsName, - createdBy, - updatedBy, + ApplicationConstant.PROCESSOR_USER_NAME, + ApplicationConstant.PROCESSOR_USER_NAME, ApplicationConstant.ORG_UNIT ) ) From 6a7d83f38ea6f52a7e5d877fb45dadf9707bf082 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 12 Jan 2024 17:41:36 -0800 Subject: [PATCH 06/12] fix(FSADT1-1121): making CHES return string instead of void --- .../ca/bc/gov/app/controller/ches/ChesController.java | 2 +- .../java/ca/bc/gov/app/service/ches/ChesService.java | 2 +- .../java/ca/bc/gov/app/service/client/ClientService.java | 6 +++--- .../app/service/client/ClientSubmissionMailService.java | 9 +++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/ches/ChesController.java b/backend/src/main/java/ca/bc/gov/app/controller/ches/ChesController.java index bac6cf34ff..deab97128d 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/ches/ChesController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/ches/ChesController.java @@ -33,7 +33,7 @@ public class ChesController { */ @PostMapping("/email") @ResponseStatus(HttpStatus.ACCEPTED) - public Mono sendEmail(@RequestBody EmailRequestDto emailRequestDto) { + public Mono sendEmail(@RequestBody EmailRequestDto emailRequestDto) { log.info("Sending email using CHES {}", emailRequestDto); return clientService.sendEmail(emailRequestDto); } diff --git a/backend/src/main/java/ca/bc/gov/app/service/ches/ChesService.java b/backend/src/main/java/ca/bc/gov/app/service/ches/ChesService.java index b336cd2bf8..7e5ad922b1 100644 --- a/backend/src/main/java/ca/bc/gov/app/service/ches/ChesService.java +++ b/backend/src/main/java/ca/bc/gov/app/service/ches/ChesService.java @@ -126,7 +126,7 @@ public Mono sendEmail(String templateName, "", throwable.getMessage(), variables), - "Error sending email" + "Error sending email " + throwable.getMessage() ) ); } diff --git a/backend/src/main/java/ca/bc/gov/app/service/client/ClientService.java b/backend/src/main/java/ca/bc/gov/app/service/client/ClientService.java index 954eb5bc4b..c2a00a697a 100644 --- a/backend/src/main/java/ca/bc/gov/app/service/client/ClientService.java +++ b/backend/src/main/java/ca/bc/gov/app/service/client/ClientService.java @@ -253,10 +253,10 @@ public Flux findByClientNameOrIncorporation(String value) { *

Send email to a client.

* * @param emailRequestDto The request data containing client details. - * @return A {@link Mono} of {@link Void}. + * @return A {@link Mono} of {@link String}. */ - public Mono sendEmail(EmailRequestDto emailRequestDto) { - return triggerEmail(emailRequestDto).then(); + public Mono sendEmail(EmailRequestDto emailRequestDto) { + return triggerEmail(emailRequestDto); } /** diff --git a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java index b3655831ef..aae646f087 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java @@ -14,8 +14,7 @@ public class ClientSubmissionMailService { private final WebClient forestClientApi; - /*@ServiceActivator(inputChannel = ApplicationConstant.SUBMISSION_MAIL_CHANNEL)*/ - public Mono sendMail(EmailRequestDto mailMessage) { + public Mono sendMail(EmailRequestDto mailMessage) { log.info("Sending email to {} {} -> {}", mailMessage.email(), @@ -28,8 +27,10 @@ public Mono sendMail(EmailRequestDto mailMessage) { .post() .uri("/ches/email") .body(Mono.just(mailMessage), EmailRequestDto.class) - .exchangeToMono(clientResponse -> clientResponse.bodyToMono(Void.class)) - .doOnNext(source -> log.info("Email sent to {}", mailMessage.email())); + .exchangeToMono(clientResponse -> clientResponse.bodyToMono(String.class)) + .doOnNext(source -> log.info("Email sent to {}", mailMessage.email())) + .doOnError(throwable -> log.error("Error sending email to {}", mailMessage.email(), + throwable)); } From 5cee7339d08b2d4069e02e0ffb7e904af557e4b6 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 12 Jan 2024 17:57:43 -0800 Subject: [PATCH 07/12] fix(FSADT1-1121): making CHES return string instead of void --- .../gov/app/controller/ches/ChesControllerIntegrationTest.java | 3 ++- .../bc/gov/app/service/client/ClientSubmissionMailService.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/test/java/ca/bc/gov/app/controller/ches/ChesControllerIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/controller/ches/ChesControllerIntegrationTest.java index 96934b2228..3c3743c5a1 100644 --- a/backend/src/test/java/ca/bc/gov/app/controller/ches/ChesControllerIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/controller/ches/ChesControllerIntegrationTest.java @@ -74,7 +74,8 @@ void shouldSubmitRegisteredBusinessData() { .body(Mono.just(EMAIL_REQUEST), EmailRequestDto.class) .exchange() .expectStatus().isAccepted() - .expectBody().isEmpty(); + .expectBody(String.class) + .isEqualTo("Email sent successfully. Transaction ID: 00000000-0000-0000-0000-000000000000"); } } \ No newline at end of file diff --git a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java index aae646f087..a9597ffef7 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java @@ -28,7 +28,7 @@ public Mono sendMail(EmailRequestDto mailMessage) { .uri("/ches/email") .body(Mono.just(mailMessage), EmailRequestDto.class) .exchangeToMono(clientResponse -> clientResponse.bodyToMono(String.class)) - .doOnNext(source -> log.info("Email sent to {}", mailMessage.email())) + .doOnNext(source -> log.info("Email sent to {} {}", mailMessage.email(),source)) .doOnError(throwable -> log.error("Error sending email to {}", mailMessage.email(), throwable)); From bdef7f9b7dd129e50a79f2e98a54f893f13b4530 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 12 Jan 2024 18:16:03 -0800 Subject: [PATCH 08/12] fix(FSADT1-1121): making CHES return string instead of void --- processor/openshift.deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processor/openshift.deploy.yml b/processor/openshift.deploy.yml index 25df43b5ac..45509406e2 100644 --- a/processor/openshift.deploy.yml +++ b/processor/openshift.deploy.yml @@ -110,7 +110,7 @@ objects: name: ${NAME}-${ZONE} key: database-user - name: CLIENT_URI - value: https://${NAME}-${ZONE}-backend.${DOMAIN}/api + value: https://${NAME}-${URL_ZONE}-backend.${DOMAIN}/api - name: LEGACY_URI value: https://${NAME}-${URL_ZONE}-legacy.${DOMAIN} - name: TIMING From 9e45c201931c635787d10d3bf3b0c06e3f125ffd Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 15 Jan 2024 08:03:51 -0800 Subject: [PATCH 09/12] test: fixing test --- .../service/client/ClientSubmissionMailServiceTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java index e1932c9935..3051cfba56 100644 --- a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java +++ b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java @@ -2,9 +2,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.containing; import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; +import static com.github.tomakehurst.wiremock.client.WireMock.jsonResponse; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.status; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.awaitility.Awaitility.await; @@ -12,6 +12,8 @@ import ca.bc.gov.app.TestConstants; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; import java.time.Duration; +import java.util.UUID; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -37,7 +39,8 @@ class ClientSubmissionMailServiceTest { @BeforeAll public static void setUp() { wireMockExtension - .stubFor(post("/ches/email").willReturn(status(202))); + .stubFor(post("/ches/email") + .willReturn(jsonResponse(UUID.randomUUID().toString(), 200))); } @Test @@ -46,6 +49,7 @@ void shouldSendEmail() { service .sendMail(TestConstants.EMAIL_REQUEST) .as(StepVerifier::create) + .assertNext(Assertions::assertNotNull) .verifyComplete(); await() @@ -68,6 +72,7 @@ void shouldPreventReviewMails() { service .sendMail(TestConstants.EMAIL_REQUEST) .as(StepVerifier::create) + .assertNext(Assertions::assertNotNull) .verifyComplete(); await() From 40ce709347affdc43d282b5ad1e283b5f645c53b Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 15 Jan 2024 08:26:40 -0800 Subject: [PATCH 10/12] fix(FSADT1-1121): fixing some NPE --- .../app/service/legacy/LegacyClientPersistenceService.java | 2 -- .../service/legacy/LegacyIndividualPersistenceService.java | 3 --- .../legacy/LegacyRegisteredSPPersistenceService.java | 2 -- .../legacy/LegacyUnregisteredSPPersistenceService.java | 2 -- .../service/client/ClientSubmissionMailServiceTest.java | 7 ++++++- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyClientPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyClientPersistenceService.java index 049e35fd22..daa5abbafe 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyClientPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyClientPersistenceService.java @@ -77,8 +77,6 @@ public Mono> generateForestClient( .withCorpRegnNmbr( ProcessorUtil.extractNumbers(submissionDetail.getIncorporationNumber()) ) - .withClientNumber(message.parameters() - .get(ApplicationConstant.FOREST_CLIENT_NUMBER).toString()) ) .map(forestClient -> new MessagingWrapper<>( diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java index 58c2a577cb..91e321f4af 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java @@ -78,9 +78,6 @@ public Mono> generateForestClient( .withClientIdentification( getUser(message, ApplicationConstant.CREATED_BY).replace("bcsc\\", StringUtils.EMPTY)) - .withClientNumber( - message.getParameter(ApplicationConstant.FOREST_CLIENT_NUMBER, String.class) - ) ) .map(forestClient -> new MessagingWrapper<>(forestClient, message.parameters()) diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceService.java index 8c434d4cf4..08b9a67b3a 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceService.java @@ -139,8 +139,6 @@ public Mono> generateForestClient( .withClientName(contact[1]) .withClientTypeCode("I") .withClientIdTypeCode("BCRE") - .withClientNumber(message.parameters() - .get(ApplicationConstant.FOREST_CLIENT_NUMBER).toString()) ) ) .map(forestClient -> diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java index 3b0129efbe..19d36515ab 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java @@ -84,8 +84,6 @@ public Mono> generateForestClient( getUser(message, ApplicationConstant.CLIENT_SUBMITTER_NAME) + " submitted the sole proprietor with data acquired from Business BCeID") .withClientTypeCode("I") - .withClientNumber(message.parameters() - .get(ApplicationConstant.FOREST_CLIENT_NUMBER).toString()) ) .doOnNext(forestClient -> log.info("Generated forest client for USP {}", diff --git a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java index 3051cfba56..5ed4d4399c 100644 --- a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java +++ b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java @@ -40,7 +40,12 @@ class ClientSubmissionMailServiceTest { public static void setUp() { wireMockExtension .stubFor(post("/ches/email") - .willReturn(jsonResponse(UUID.randomUUID().toString(), 200))); + .willReturn(jsonResponse( + "Transaction ID: " + UUID.randomUUID(), + 200 + ) + ) + ); } @Test From f86cba33855a0c52568d1b7006c9272d9b6d8efa Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 15 Jan 2024 09:57:26 -0800 Subject: [PATCH 11/12] fix(FSADT1-1131|FSADT1-1132): fixing mail content --- backend/src/main/resources/templates/revision.html | 2 +- .../service/client/ClientSubmissionLoadingService.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/main/resources/templates/revision.html b/backend/src/main/resources/templates/revision.html index ae6e60444c..25160be2e3 100644 --- a/backend/src/main/resources/templates/revision.html +++ b/backend/src/main/resources/templates/revision.html @@ -18,7 +18,7 @@
 

- An application for a client number for ${userName} needs your review. + An application for a client number for ${business.name} needs your review.

Please review it in the Client Management System and decide if it should be accepted or rejected. diff --git a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingService.java b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingService.java index fe09b6e946..ddae54a6be 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingService.java @@ -146,17 +146,21 @@ private Map getParameter( .get(ApplicationConstant.SUBMISSION_STATUS)) { case A -> approvalParameters(username, businessName, clientNumber); case R -> rejectionParameters(username, businessName, clientNumber, reason); - default -> revisionParameters(username, submissionId); + default -> revisionParameters(username, businessName, submissionId); }; } private Map revisionParameters( String username, + String businessName, Integer submissionId ) { return Map.of( "userName", username, - "submission", submissionId + "submission", submissionId, + "business", Map.of( + "name", businessName + ) ); } From 5af11413b8d94c3380c6725e370f1eca92ff25bd Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Mon, 15 Jan 2024 09:58:00 -0800 Subject: [PATCH 12/12] fix(FSADT1-1121): fixing typeid --- .../ca/bc/gov/app/ApplicationConstant.java | 2 +- .../LegacyIndividualPersistenceService.java | 13 +++++++--- ...egacyUnregisteredSPPersistenceService.java | 10 ++++++++ .../ca/bc/gov/app/util/ProcessorUtil.java | 19 +++++++++++++- ...egacyIndividualPersistenceServiceTest.java | 10 ++------ ...acyRegisteredSPPersistenceServiceTest.java | 16 ++---------- ...yUnregisteredSPPersistenceServiceTest.java | 8 +----- .../ca/bc/gov/app/util/ProcessorUtilTest.java | 25 +++++++++++++++++++ 8 files changed, 68 insertions(+), 35 deletions(-) diff --git a/processor/src/main/java/ca/bc/gov/app/ApplicationConstant.java b/processor/src/main/java/ca/bc/gov/app/ApplicationConstant.java index 2656e8c90e..18b0a20cae 100644 --- a/processor/src/main/java/ca/bc/gov/app/ApplicationConstant.java +++ b/processor/src/main/java/ca/bc/gov/app/ApplicationConstant.java @@ -28,7 +28,7 @@ public final class ApplicationConstant { public static final String LOCATION_ID = "locationId"; public static final String TOTAL = "total"; public static final String INDEX = "index"; - public static final String PROCESSOR_USER_NAME = "IDIR\\OTTOMATED"; + public static final String PROCESSOR_USER_NAME = "idir\\ottomated"; public static final long ORG_UNIT = 70L; public static final String LOCATION_CODE = "locationCode"; public static final String CLIENT_TYPE_CODE = "CLIENT_TYPE_CODE"; diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java index 91e321f4af..5e0ee1aad4 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java @@ -73,11 +73,16 @@ public Mono> generateForestClient( " submitted the individual with data acquired from BC Services Card" ) .withClientTypeCode("I") - .withClientIdTypeCode("BCSC") - //Assuming that individuals can only be created by BCSC users + .withClientIdTypeCode( + ProcessorUtil.getClientIdTypeCode( + ProcessorUtil.splitName( + getUser(message, ApplicationConstant.CREATED_BY))[1] + ) + ) .withClientIdentification( - getUser(message, ApplicationConstant.CREATED_BY).replace("bcsc\\", - StringUtils.EMPTY)) + ProcessorUtil.splitName( + getUser(message, ApplicationConstant.CREATED_BY))[0] + ) ) .map(forestClient -> new MessagingWrapper<>(forestClient, message.parameters()) diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java index 19d36515ab..6fc65780c3 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java +++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java @@ -84,6 +84,16 @@ public Mono> generateForestClient( getUser(message, ApplicationConstant.CLIENT_SUBMITTER_NAME) + " submitted the sole proprietor with data acquired from Business BCeID") .withClientTypeCode("I") + .withClientIdTypeCode( + ProcessorUtil.getClientIdTypeCode( + ProcessorUtil.splitName( + getUser(message, ApplicationConstant.CREATED_BY))[1] + ) + ) + .withClientIdentification( + ProcessorUtil.splitName( + getUser(message, ApplicationConstant.CREATED_BY))[0] + ) ) .doOnNext(forestClient -> log.info("Generated forest client for USP {}", diff --git a/processor/src/main/java/ca/bc/gov/app/util/ProcessorUtil.java b/processor/src/main/java/ca/bc/gov/app/util/ProcessorUtil.java index d299bc1ac7..8d532d072d 100644 --- a/processor/src/main/java/ca/bc/gov/app/util/ProcessorUtil.java +++ b/processor/src/main/java/ca/bc/gov/app/util/ProcessorUtil.java @@ -38,6 +38,8 @@ public static String[] splitName(String input) { ).trim() : input; + cleanedInput = cleanedInput.replace("\\", " "); + //Split by space String[] words = cleanedInput.replace(",", StringUtils.EMPTY).split("\\s+"); @@ -59,6 +61,22 @@ public static String[] splitName(String input) { } } + public static String getClientIdTypeCode(String code){ + if (StringUtils.isBlank(code)) { + return StringUtils.EMPTY; + } + switch (code.toLowerCase()) { + case "bcsc": + return "BCSC"; + case "bceidbusiness": + return "BCEI"; + case "idir": + return "OTHR"; + default: + return StringUtils.EMPTY; + } + } + private static String getStringFromPattern(String input, Pattern pattern) { Matcher matcher = pattern.matcher(input); if (matcher.find()) { @@ -68,5 +86,4 @@ private static String getStringFromPattern(String input, Pattern pattern) { } } - } diff --git a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceServiceTest.java b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceServiceTest.java index cd94307a06..6ff1495dba 100644 --- a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceServiceTest.java +++ b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceServiceTest.java @@ -97,10 +97,9 @@ void shouldCreateForestClient() { .hasFieldOrPropertyWithValue("clientComment", "Jhon Snow submitted the individual with data acquired from BC Services Card") .hasFieldOrPropertyWithValue("clientTypeCode", "I") - .hasFieldOrPropertyWithValue("clientNumber", "00000001") - .hasFieldOrPropertyWithValue("clientIdTypeCode", "BCSC") + .hasFieldOrPropertyWithValue("clientIdTypeCode", "OTHR") .hasFieldOrPropertyWithValue("clientIdentification", - ApplicationConstant.PROCESSOR_USER_NAME); + "ottomated"); assertThat(message.parameters().get(ApplicationConstant.SUBMISSION_ID)) .isNotNull() @@ -125,11 +124,6 @@ void shouldCreateForestClient() { .isInstanceOf(String.class) .isEqualTo("not applicable"); - assertThat(message.parameters().get(ApplicationConstant.FOREST_CLIENT_NUMBER)) - .isNotNull() - .isInstanceOf(String.class) - .isEqualTo("00000001"); - }) .verifyComplete(); } diff --git a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceServiceTest.java b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceServiceTest.java index 521ed19294..cc4dca8fd1 100644 --- a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceServiceTest.java +++ b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceServiceTest.java @@ -119,8 +119,7 @@ void shouldCreateForestClient() { "BAXTER CORP" ) ) - .hasFieldOrPropertyWithValue("clientTypeCode", "I") - .hasFieldOrPropertyWithValue("clientNumber", "00000001"); + .hasFieldOrPropertyWithValue("clientTypeCode", "I"); assertThat(message.parameters().get(ApplicationConstant.SUBMISSION_ID)) .isNotNull() @@ -144,12 +143,6 @@ void shouldCreateForestClient() { .isNotNull() .isInstanceOf(String.class) .isEqualTo("FM00184546"); - - assertThat(message.parameters().get(ApplicationConstant.FOREST_CLIENT_NUMBER)) - .isNotNull() - .isInstanceOf(String.class) - .isEqualTo("00000001"); - }) .verifyComplete(); } @@ -213,8 +206,7 @@ void shouldCreateForestClientWhenNoBcRegData() { "BAXTER CORP" ) ) - .hasFieldOrPropertyWithValue("clientTypeCode", "I") - .hasFieldOrPropertyWithValue("clientNumber", "00000001"); + .hasFieldOrPropertyWithValue("clientTypeCode", "I"); assertThat(message.parameters().get(ApplicationConstant.SUBMISSION_ID)) .isNotNull() @@ -239,10 +231,6 @@ void shouldCreateForestClientWhenNoBcRegData() { .isInstanceOf(String.class) .isEqualTo("FM00184546"); - assertThat(message.parameters().get(ApplicationConstant.FOREST_CLIENT_NUMBER)) - .isNotNull() - .isInstanceOf(String.class) - .isEqualTo("00000001"); }) .verifyComplete(); diff --git a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceServiceTest.java b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceServiceTest.java index 78027ae194..95c5910b1c 100644 --- a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceServiceTest.java +++ b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceServiceTest.java @@ -98,8 +98,7 @@ void shouldCreateForestClient() { .hasFieldOrPropertyWithValue("legalMiddleName", StringUtils.EMPTY) .hasFieldOrPropertyWithValue("clientComment", "Jhon Snow submitted the sole proprietor with data acquired from Business BCeID") - .hasFieldOrPropertyWithValue("clientTypeCode", "I") - .hasFieldOrPropertyWithValue("clientNumber", "00000001"); + .hasFieldOrPropertyWithValue("clientTypeCode", "I"); assertThat(message.parameters().get(ApplicationConstant.SUBMISSION_ID)) .isNotNull() @@ -124,11 +123,6 @@ void shouldCreateForestClient() { .isInstanceOf(String.class) .isEqualTo("not applicable"); - assertThat(message.parameters().get(ApplicationConstant.FOREST_CLIENT_NUMBER)) - .isNotNull() - .isInstanceOf(String.class) - .isEqualTo("00000001"); - }) .verifyComplete(); } diff --git a/processor/src/test/java/ca/bc/gov/app/util/ProcessorUtilTest.java b/processor/src/test/java/ca/bc/gov/app/util/ProcessorUtilTest.java index 224ce304e0..140c05a492 100644 --- a/processor/src/test/java/ca/bc/gov/app/util/ProcessorUtilTest.java +++ b/processor/src/test/java/ca/bc/gov/app/util/ProcessorUtilTest.java @@ -32,6 +32,13 @@ void shouldSplitName(String input, String[] expected) { Assertions.assertArrayEquals(expected, ProcessorUtil.splitName(input)); } + @ParameterizedTest(name = "should get client id type code {0} and get {1}") + @MethodSource("clientIdTypeCode") + @DisplayName("should get client id type code") + void shouldGetClientIdTypeCode(String input, String expected) { + Assertions.assertEquals(expected, ProcessorUtil.getClientIdTypeCode(input)); + } + private static Stream extract() { return Stream.of( Arguments.of("ABC1234", "ABC", "1234"), @@ -44,6 +51,10 @@ private static Stream extract() { private static Stream splitName() { return Stream.of( + Arguments.of( + "bcsc\\123456", + new String[]{"123456", "bcsc", ""} + ), Arguments.of( "John Doe", new String[]{"Doe", "John", ""} @@ -77,4 +88,18 @@ private static Stream splitName() { ); } + private static Stream clientIdTypeCode(){ + return + Stream.of( + Arguments.of("bcsc", "BCSC"), + Arguments.of("BCSC", "BCSC"), + Arguments.of("bceidbusiness", "BCEI"), + Arguments.of("idir", "OTHR"), + Arguments.of("test", StringUtils.EMPTY), + Arguments.of(StringUtils.EMPTY, StringUtils.EMPTY), + Arguments.of(null, StringUtils.EMPTY), + Arguments.of(" ", StringUtils.EMPTY) + ); + } + }