From 3d9a01030d4775ef2ee813cef335749d39feb67e Mon Sep 17 00:00:00 2001 From: Maria Martinez <77364706+mamartinezmejia@users.noreply.github.com> Date: Tue, 30 Jul 2024 09:36:34 -0700 Subject: [PATCH] fix(be:FSADT1-1419): Client ID is not being saved (#1054) * fix(be:FSADT1-1419): Client ID is not being saved --- .../service/legacy/LegacyIndividualPersistenceService.java | 6 ++++-- .../java/ca/bc/gov/app/service/legacy/LegacyService.java | 7 ++++--- .../legacy/LegacyIndividualPersistenceServiceTest.java | 7 +++++-- 3 files changed, 13 insertions(+), 7 deletions(-) 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 6acdecb80e..1c89f16444 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 @@ -110,18 +110,20 @@ public Mono> generateForestClient( ) ) .withClientIdentification( - Objects.toString( + null == detailEntity.getIdentificationCode() + ? Objects.toString( detailEntity.getIdentificationCode(), ProcessorUtil.splitName( getUser(message, ApplicationConstant.CREATED_BY) )[0] ) + : detailEntity.getClientIdentification() ) .withClientNumber(message.payload()) .withAcronym(detailEntity.getClientAcronym()) ) .doOnNext(forestClient -> log.info("forest client generated for individual {}", - forestClient.clientIdTypeCode() + forestClient.clientIdentification())) + forestClient.clientIdTypeCode() + " " + forestClient.clientIdentification())) .map(forestClient -> new MessagingWrapper<>(forestClient, message.parameters()) .withParameter(ApplicationConstant.FOREST_CLIENT_NAME, 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 c3b8aa2e7a..3eee50a0ec 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 @@ -7,6 +7,7 @@ import ca.bc.gov.app.dto.legacy.ForestClientLocationDto; import ca.bc.gov.app.entity.SubmissionLocationEntity; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @@ -46,10 +47,10 @@ public Mono createLocation( detail.getProvinceCode().toUpperCase(), detail.getPostalCode(), detail.getCountryCode().toUpperCase(), - StringUtils.defaultString(detail.getBusinessPhoneNumber().replaceAll("\\D", "")), + RegExUtils.replaceAll(detail.getBusinessPhoneNumber(), "\\D", StringUtils.EMPTY), StringUtils.EMPTY, - StringUtils.defaultString(detail.getSecondaryPhoneNumber().replaceAll("\\D", "")), - StringUtils.defaultString(detail.getFaxNumber().replaceAll("\\D", "")), + RegExUtils.replaceAll(detail.getSecondaryPhoneNumber(), "\\D", StringUtils.EMPTY), + RegExUtils.replaceAll(detail.getFaxNumber(), "\\D", StringUtils.EMPTY), StringUtils.defaultString(detail.getEmailAddress()), "N", null, 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 956ed53642..c4e5c59d16 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 @@ -63,9 +63,13 @@ void shouldCreateForestClient() { .submissionId(2) .submissionDetailId(2) .organizationName("James Baxter") + .firstName("James") + .lastName("Baxter") .businessTypeCode("U") .clientTypeCode("I") .goodStandingInd("Y") + .identificationTypeCode("OTHR") + .clientIdentification("ABC:123") .build(); when(submissionDetailRepository.findBySubmissionId(eq(2))) @@ -98,8 +102,7 @@ void shouldCreateForestClient() { "Jhon Snow submitted the individual with data acquired from BC Services Card") .hasFieldOrPropertyWithValue("clientTypeCode", "I") .hasFieldOrPropertyWithValue("clientIdTypeCode", "OTHR") - .hasFieldOrPropertyWithValue("clientIdentification", - "ottomated"); + .hasFieldOrPropertyWithValue("clientIdentification", "ABC:123"); assertThat(message.parameters().get(ApplicationConstant.SUBMISSION_ID)) .isNotNull()