From 90041a71cb95c45bdd65eba5e5cd0fb5d0083c1d Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Tue, 21 Nov 2023 11:37:01 -0800 Subject: [PATCH] feat(FSADT1-999): adding dob processing to Sole Prop --- .../repository/legacy/ForestClientRepository.java | 11 ----------- .../processor/SoleProprietorProcessorMatcher.java | 5 +++-- .../SoleProprietorProcessorMatcherTest.java | 13 +++++++++---- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientRepository.java index 2acc411df6..a58b118b61 100644 --- a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientRepository.java +++ b/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientRepository.java @@ -32,17 +32,6 @@ public interface ForestClientRepository extends ReactiveCrudRepository findByIncorporationNumber(String incorporationNumber); - @Query(""" - SELECT * - FROM THE.FOREST_CLIENT - WHERE - UPPER(LEGAL_FIRST_NAME) = UPPER(:firstName) - AND UPPER(CLIENT_NAME) = UPPER(:lastName) - AND CLIENT_STATUS_CODE = 'ACT' - AND CLIENT_TYPE_CODE = 'I' - ORDER BY CLIENT_NUMBER""") - Flux findByIndividualNames(String firstName, String lastName); - @Query(""" SELECT * FROM THE.FOREST_CLIENT diff --git a/processor/src/main/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcher.java index 9e348da2da..2aa05d4d8c 100644 --- a/processor/src/main/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcher.java +++ b/processor/src/main/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcher.java @@ -37,9 +37,10 @@ public Mono matches(SubmissionInformationDto submission) { return forestClientRepository - .findByIndividualNames( + .findByIndividual( ProcessorUtil.splitName(submission.corporationName())[1], - ProcessorUtil.splitName(submission.corporationName())[0] + ProcessorUtil.splitName(submission.corporationName())[0], + submission.dateOfBirth()!= null ? submission.dateOfBirth().atStartOfDay() : null ) .doOnNext(entity -> log.info("Found a match {}", entity)) .map(ForestClientEntity::getClientNumber) diff --git a/processor/src/test/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcherTest.java b/processor/src/test/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcherTest.java index df7652a55e..3aed05a741 100644 --- a/processor/src/test/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcherTest.java +++ b/processor/src/test/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcherTest.java @@ -1,6 +1,7 @@ package ca.bc.gov.app.service.processor; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -9,6 +10,7 @@ import ca.bc.gov.app.dto.SubmissionInformationDto; import ca.bc.gov.app.entity.legacy.ForestClientEntity; import ca.bc.gov.app.repository.legacy.ForestClientRepository; +import java.time.LocalDate; import java.util.stream.Stream; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -41,7 +43,7 @@ void shouldMatchOrNot( Flux mockData ) { - when(repository.findByIndividualNames(anyString(),anyString())) + when(repository.findByIndividual(anyString(), anyString(), any())) .thenReturn(mockData); StepVerifier.FirstStep verifier = @@ -62,19 +64,22 @@ private static Stream legalName() { return Stream.of( Arguments.of( - new SubmissionInformationDto("James Frank", null, null, null, "USP"), + new SubmissionInformationDto("James Frank", LocalDate.of(2023, 4, 5), null, null, + "USP"), true, null, Flux.empty() ), Arguments.of( - new SubmissionInformationDto("Marco Polo", null, null, null, "RSP"), + new SubmissionInformationDto("Marco Polo", LocalDate.of(2023, 9, 12), null, null, + "RSP"), false, new MatcherResult("corporationName", String.join(",", "00000000")), Flux.just(new ForestClientEntity().withClientNumber("00000000")) ), Arguments.of( - new SubmissionInformationDto("Lucca DeBiaggio", null, null, null, "USP"), + new SubmissionInformationDto("Lucca DeBiaggio", LocalDate.of(2023, 10, 11), null, + null, "USP"), false, new MatcherResult("corporationName", String.join(",", "00000000", "00000001")), Flux.just(new ForestClientEntity().withClientNumber("00000000"),