From f13340b298c9e24971f02b9347d0df8b4b2a68e9 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 19 Nov 2024 15:17:24 -0800 Subject: [PATCH 01/37] feat(be:FSADT1-1575): First draft --- .../controller/client/ClientController.java | 21 +++++++++++++++-- .../service/client/ClientLegacyService.java | 23 +++++++++++++++++++ .../gov/app/service/client/ClientService.java | 12 +++++++++- .../controller/ClientSearchController.java | 9 ++++++++ .../gov/app/service/ClientSearchService.java | 16 +++++++++++++ 5 files changed, 78 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index 0735350f0b..27e0bd24d7 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -4,6 +4,7 @@ import ca.bc.gov.app.dto.bcregistry.ClientDetailsDto; import ca.bc.gov.app.dto.client.ClientListDto; import ca.bc.gov.app.dto.client.ClientLookUpDto; +import ca.bc.gov.app.dto.legacy.ForestClientDto; import ca.bc.gov.app.exception.NoClientDataFound; import ca.bc.gov.app.service.client.ClientLegacyService; import ca.bc.gov.app.service.client.ClientService; @@ -36,7 +37,7 @@ public class ClientController { private final ClientLegacyService clientLegacyService; @GetMapping("/{clientNumber}") - public Mono getClientDetails( + public Mono getClientDetailsByIncorporationNumber( @PathVariable String clientNumber, JwtAuthenticationToken principal ) { @@ -45,7 +46,7 @@ public Mono getClientDetails( JwtPrincipalUtil.getUserId(principal) ); return clientService - .getClientDetails( + .getClientDetailsByIncorporationNumber( clientNumber, JwtPrincipalUtil.getUserId(principal), JwtPrincipalUtil.getBusinessId(principal), @@ -53,6 +54,22 @@ public Mono getClientDetails( ); } + @GetMapping("/details/{clientNumber}") + public Mono getClientDetailsByClientNumber( + @PathVariable String clientNumber, + JwtAuthenticationToken principal + ) { + log.info("Requesting client details for client number {} from the client service. {}", + clientNumber, + JwtPrincipalUtil.getUserId(principal) + ); + return clientService.getClientDetailsByClientNumber( + clientNumber, + JwtPrincipalUtil.getUserId(principal), + JwtPrincipalUtil.getBusinessId(principal), + JwtPrincipalUtil.getProvider(principal)); + } + @GetMapping("/search") public Flux fullSearch( @RequestParam(required = false, defaultValue = "0") int page, diff --git a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java index c56903e793..49eb7753e1 100644 --- a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java +++ b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java @@ -18,6 +18,7 @@ import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; /** * This class is responsible for interacting with the legacy API to fetch client data. It uses the @@ -87,6 +88,28 @@ public Flux searchLegacy( registrationNumber, companyName, dto.clientNumber())); } + public Mono searchByClientNumber( + String clientNumber + ) { + log.info("Searching for client number {} in legacy", clientNumber); + + return + legacyApi + .get() + .uri(builder -> + builder + .path("/api/search/clientNumber") + .queryParam("clientNumber", clientNumber) + .build(Map.of()) + ) + .exchangeToMono(response -> response.bodyToMono(ForestClientDto.class)) + .doOnNext( + dto -> log.info( + "Found Legacy data for in legacy with client number {}", + dto.clientNumber()) + ); + } + /** * This method is used to search for a client in the legacy system using the client's ID and last * name. 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 0766b36644..1d7505afc7 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 @@ -58,7 +58,7 @@ public class ClientService { * @param clientNumber the client number for which to retrieve details * @return a Mono that emits a ClientDetailsDto object representing the details of the client */ - public Mono getClientDetails( + public Mono getClientDetailsByIncorporationNumber( String clientNumber, String userId, String businessId, @@ -141,6 +141,16 @@ public Mono getClientDetails( "Unable to process request. This sole proprietor is not owned by a person" ))); } + + public Mono getClientDetailsByClientNumber( + String clientNumber, + String userId, + String businessId, + String provider + ) { + log.info("Loading details for {} {} {} {}", clientNumber, userId, businessId, provider); + return legacyService.searchByClientNumber(clientNumber); + } /** * Searches the BC Registry API for {@link BcRegistryFacetSearchResultEntryDto} instances matching diff --git a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java index 1617ab7c04..8f7b80a3ff 100644 --- a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java +++ b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java @@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; @RestController @Slf4j @@ -73,6 +74,14 @@ public Flux findByIdAndLastName( log.info("Receiving request to search by ID {} and Last Name {}", clientId, lastName); return service.findByIdAndLastName(clientId, lastName); } + + @GetMapping("/clientNumber") + public Mono findByClientNumber( + @RequestParam String clientNumber + ) { + log.info("Receiving request to search by ID {} and Last Name", clientNumber); + return service.findByClientNumber(clientNumber); + } @GetMapping("/id/{idType}/{identification}") public Flux findByIdentification( diff --git a/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java b/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java index 3107023a12..6f15000547 100644 --- a/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java +++ b/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java @@ -536,6 +536,22 @@ public Flux findByClientName(String clientName) { dto.clientNumber(), dto.clientName()) ); } + + public Mono findByClientNumber(String clientNumber) { + log.info("Searching for client with number {}", clientNumber); + + if (StringUtils.isBlank(clientNumber)) { + return Mono.error(new MissingRequiredParameterException("clientNumber")); + } + + return forestClientRepository.findByClientNumber(clientNumber) + .map(forestClientMapper::toDto) + .doOnNext( + dto -> log.info("Found client with client number {}", + clientNumber, + dto.clientNumber()) + ); + } public Flux> complexSearch(String value, Pageable page) { // This condition is for predictive search, and we will stop here if no query param is provided From 0d67ebd4e2f5ddc9509b94093c4072935028183e Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Thu, 21 Nov 2024 11:43:53 -0800 Subject: [PATCH 02/37] no message --- .../controller/client/ClientController.java | 4 +-- .../dto/legacy/ForestClientContactDto.java | 17 ++++++++++ .../dto/legacy/ForestClientDetailsDto.java | 24 ++++++++++++++ .../dto/legacy/ForestClientLocationDto.java | 33 +++++++++++++++++++ .../service/client/ClientLegacyService.java | 5 +-- .../gov/app/service/client/ClientService.java | 3 +- 6 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java create mode 100644 backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java create mode 100644 backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index 27e0bd24d7..96c3017b17 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -4,7 +4,7 @@ import ca.bc.gov.app.dto.bcregistry.ClientDetailsDto; import ca.bc.gov.app.dto.client.ClientListDto; import ca.bc.gov.app.dto.client.ClientLookUpDto; -import ca.bc.gov.app.dto.legacy.ForestClientDto; +import ca.bc.gov.app.dto.legacy.ForestClientDetailsDto; import ca.bc.gov.app.exception.NoClientDataFound; import ca.bc.gov.app.service.client.ClientLegacyService; import ca.bc.gov.app.service.client.ClientService; @@ -55,7 +55,7 @@ public Mono getClientDetailsByIncorporationNumber( } @GetMapping("/details/{clientNumber}") - public Mono getClientDetailsByClientNumber( + public Mono getClientDetailsByClientNumber( @PathVariable String clientNumber, JwtAuthenticationToken principal ) { diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java new file mode 100644 index 0000000000..b7eda00585 --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java @@ -0,0 +1,17 @@ +package ca.bc.gov.app.dto.legacy; + +public record ForestClientContactDto( + String clientNumber, + String clientLocnCode, + String contactCode, + String contactName, + String businessPhone, + String secondaryPhone, + String faxNumber, + String emailAddress, + String createdBy, + String updatedBy, + Long orgUnit +) { + +} diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java new file mode 100644 index 0000000000..7b0c175acc --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java @@ -0,0 +1,24 @@ +package ca.bc.gov.app.dto.legacy; + +import java.util.List; + +public record ForestClientDetailsDto ( + String clientNumber, + String clientName, + String legalFirstName, + String legalMiddleName, + String clientStatusCode, + String clientTypeCode, + String clientIdTypeCode, + String clientIdentification, + String registryCompanyTypeCode, + String corpRegnNmbr, + String clientAcronym, + String wcbFirmNumber, + String ocgSupplierNmbr, + String clientComment, + List addresses, + List contacts +) { + +} diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java new file mode 100644 index 0000000000..a396f4afc6 --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java @@ -0,0 +1,33 @@ +package ca.bc.gov.app.dto.legacy; + +import java.time.LocalDate; +import lombok.With; + +@With +public record ForestClientLocationDto( + String clientNumber, + String clientLocnCode, + String clientLocnName, + String addressOne, + String addressTwo, + String addressThree, + String city, + String province, + String postalCode, + String country, + String businessPhone, + String homePhone, + String cellPhone, + String faxNumber, + String emailAddress, + String locnExpiredInd, + LocalDate returnedMailDate, + String trustLocationInd, + String cliLocnComment, + String createdBy, + String updatedBy, + Long orgUnit +) { + +} + diff --git a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java index 49eb7753e1..352c84c5cd 100644 --- a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java +++ b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java @@ -3,6 +3,7 @@ import ca.bc.gov.app.dto.client.ClientListDto; import ca.bc.gov.app.dto.legacy.AddressSearchDto; import ca.bc.gov.app.dto.legacy.ContactSearchDto; +import ca.bc.gov.app.dto.legacy.ForestClientDetailsDto; import ca.bc.gov.app.dto.legacy.ForestClientDto; import io.micrometer.observation.annotation.Observed; import java.time.LocalDate; @@ -88,7 +89,7 @@ public Flux searchLegacy( registrationNumber, companyName, dto.clientNumber())); } - public Mono searchByClientNumber( + public Mono searchByClientNumber( String clientNumber ) { log.info("Searching for client number {} in legacy", clientNumber); @@ -102,7 +103,7 @@ public Mono searchByClientNumber( .queryParam("clientNumber", clientNumber) .build(Map.of()) ) - .exchangeToMono(response -> response.bodyToMono(ForestClientDto.class)) + .exchangeToMono(response -> response.bodyToMono(ForestClientDetailsDto.class)) .doOnNext( dto -> log.info( "Found Legacy data for in legacy with client number {}", 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 1d7505afc7..c712ac18f0 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 @@ -13,6 +13,7 @@ import ca.bc.gov.app.dto.client.ClientValueTextDto; import ca.bc.gov.app.dto.client.EmailRequestDto; import ca.bc.gov.app.dto.client.LegalTypeEnum; +import ca.bc.gov.app.dto.legacy.ForestClientDetailsDto; import ca.bc.gov.app.dto.legacy.ForestClientDto; import ca.bc.gov.app.exception.ClientAlreadyExistException; import ca.bc.gov.app.exception.InvalidAccessTokenException; @@ -142,7 +143,7 @@ public Mono getClientDetailsByIncorporationNumber( ))); } - public Mono getClientDetailsByClientNumber( + public Mono getClientDetailsByClientNumber( String clientNumber, String userId, String businessId, From 08876638d60571229969eecbba2a47dd59dd79d0 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 25 Nov 2024 10:59:45 -0800 Subject: [PATCH 03/37] Added missing field in dto --- .../java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java index 7b0c175acc..9621b37453 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java @@ -17,6 +17,7 @@ public record ForestClientDetailsDto ( String wcbFirmNumber, String ocgSupplierNmbr, String clientComment, + String goodStandingInd, List addresses, List contacts ) { From cab7aa1dce069d23943b975e88a4983e3b4972fd Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 25 Nov 2024 12:31:39 -0800 Subject: [PATCH 04/37] Added missing field in dto --- .../ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java index 9621b37453..a40776306a 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java @@ -1,5 +1,6 @@ package ca.bc.gov.app.dto.legacy; +import java.time.LocalDate; import java.util.List; public record ForestClientDetailsDto ( @@ -17,7 +18,11 @@ public record ForestClientDetailsDto ( String wcbFirmNumber, String ocgSupplierNmbr, String clientComment, + LocalDate clientCommentUpdateDate, + String clientCommentUpdateUser, String goodStandingInd, + LocalDate birthdate, + List addresses, List contacts ) { From 7b321085498ff0dbf29d7ff85e242d78d44f5d99 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 25 Nov 2024 16:14:33 -0800 Subject: [PATCH 05/37] feat(be:feat/be/FSADT1-1575): Populated good standing indicator --- .../gov/app/service/client/ClientService.java | 64 ++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) 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 c712ac18f0..d14639018b 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 @@ -149,10 +149,70 @@ public Mono getClientDetailsByClientNumber( String businessId, String provider ) { - log.info("Loading details for {} {} {} {}", clientNumber, userId, businessId, provider); - return legacyService.searchByClientNumber(clientNumber); + log.info("Loading details for {} {} {} {}", clientNumber, userId, businessId, provider); + + return legacyService + .searchByClientNumber(clientNumber) + .flatMap(forestClientDetailsDto -> { + String corpRegnNmbr = forestClientDetailsDto.corpRegnNmbr(); + + if (corpRegnNmbr == null || corpRegnNmbr.isEmpty()) { + log.info("Corporation registration number not provided. Returning legacy details."); + return Mono.just(forestClientDetailsDto); + } + + log.info("Retrieved corporation registration number: {}", corpRegnNmbr); + + Mono documentMono = bcRegistryService + .requestDocumentData(corpRegnNmbr) + .next(); + return populateGoodStandingInd(forestClientDetailsDto, documentMono); + }); } + private Mono populateGoodStandingInd( + ForestClientDetailsDto forestClientDetailsDto, + Mono documentMono + ) { + return documentMono + .map(document -> { + Boolean goodStandingInd = document.business().goodStanding(); + String goodStanding; + + if (goodStandingInd == null) { + goodStanding = ""; + } else { + goodStanding = goodStandingInd ? "Y" : "N"; + } + log.info("Setting goodStandingInd for client: {} to {}", + forestClientDetailsDto.clientNumber(), goodStanding); + + return new ForestClientDetailsDto( + forestClientDetailsDto.clientNumber(), + forestClientDetailsDto.clientName(), + forestClientDetailsDto.legalFirstName(), + forestClientDetailsDto.legalMiddleName(), + forestClientDetailsDto.clientStatusCode(), + forestClientDetailsDto.clientTypeCode(), + forestClientDetailsDto.clientIdTypeCode(), + forestClientDetailsDto.clientIdentification(), + forestClientDetailsDto.registryCompanyTypeCode(), + forestClientDetailsDto.corpRegnNmbr(), + forestClientDetailsDto.clientAcronym(), + forestClientDetailsDto.wcbFirmNumber(), + forestClientDetailsDto.ocgSupplierNmbr(), + forestClientDetailsDto.clientComment(), + forestClientDetailsDto.clientCommentUpdateDate(), + forestClientDetailsDto.clientCommentUpdateUser(), + goodStanding, + forestClientDetailsDto.birthdate(), + forestClientDetailsDto.addresses(), + forestClientDetailsDto.contacts() + ); + }); + } + + /** * Searches the BC Registry API for {@link BcRegistryFacetSearchResultEntryDto} instances matching * the given value and maps them to {@link ClientLookUpDto} instances. From 66fef15e4de3118513c70a718e2e6a17e7fc39df Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 26 Nov 2024 09:40:43 -0800 Subject: [PATCH 06/37] Added descriptions --- .../java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java | 4 ++++ .../main/java/ca/bc/gov/app/service/client/ClientService.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java index a40776306a..a60c1175c0 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java @@ -9,10 +9,14 @@ public record ForestClientDetailsDto ( String legalFirstName, String legalMiddleName, String clientStatusCode, + String clientStatusDesc, String clientTypeCode, + String clientTypeDesc, String clientIdTypeCode, + String clientIdTypeDesc, String clientIdentification, String registryCompanyTypeCode, + String registryCompanyTypeDesc, String corpRegnNmbr, String clientAcronym, String wcbFirmNumber, 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 d14639018b..9d5b854c5e 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 @@ -193,10 +193,14 @@ private Mono populateGoodStandingInd( forestClientDetailsDto.legalFirstName(), forestClientDetailsDto.legalMiddleName(), forestClientDetailsDto.clientStatusCode(), + forestClientDetailsDto.clientStatusDesc(), forestClientDetailsDto.clientTypeCode(), + forestClientDetailsDto.clientTypeDesc(), forestClientDetailsDto.clientIdTypeCode(), + forestClientDetailsDto.clientIdTypeDesc(), forestClientDetailsDto.clientIdentification(), forestClientDetailsDto.registryCompanyTypeCode(), + forestClientDetailsDto.registryCompanyTypeDesc(), forestClientDetailsDto.corpRegnNmbr(), forestClientDetailsDto.clientAcronym(), forestClientDetailsDto.wcbFirmNumber(), From ac31f73765609bc88ee98f6c05995b17ab07ec25 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 26 Nov 2024 09:46:42 -0800 Subject: [PATCH 07/37] no message --- .../java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java | 1 - .../main/java/ca/bc/gov/app/service/client/ClientService.java | 1 - 2 files changed, 2 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java index a60c1175c0..a7a4a28ca7 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java @@ -16,7 +16,6 @@ public record ForestClientDetailsDto ( String clientIdTypeDesc, String clientIdentification, String registryCompanyTypeCode, - String registryCompanyTypeDesc, String corpRegnNmbr, String clientAcronym, String wcbFirmNumber, 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 9d5b854c5e..7e26e38183 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 @@ -200,7 +200,6 @@ private Mono populateGoodStandingInd( forestClientDetailsDto.clientIdTypeDesc(), forestClientDetailsDto.clientIdentification(), forestClientDetailsDto.registryCompanyTypeCode(), - forestClientDetailsDto.registryCompanyTypeDesc(), forestClientDetailsDto.corpRegnNmbr(), forestClientDetailsDto.clientAcronym(), forestClientDetailsDto.wcbFirmNumber(), From 52637352b5a046bd8e029c50f314e15d51e226ad Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 26 Nov 2024 15:45:58 -0800 Subject: [PATCH 08/37] feat(be:FSADT1-1575): Passed groups to legacy --- .../controller/client/ClientController.java | 6 ++-- .../service/client/ClientLegacyService.java | 4 ++- .../gov/app/service/client/ClientService.java | 8 ++--- .../ca/bc/gov/app/util/JwtPrincipalUtil.java | 33 +++++++++++++++++++ .../controller/ClientSearchController.java | 7 ++-- 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index 96c3017b17..c1f46f6fe1 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -58,16 +58,14 @@ public Mono getClientDetailsByIncorporationNumber( public Mono getClientDetailsByClientNumber( @PathVariable String clientNumber, JwtAuthenticationToken principal - ) { + ) { log.info("Requesting client details for client number {} from the client service. {}", clientNumber, JwtPrincipalUtil.getUserId(principal) ); return clientService.getClientDetailsByClientNumber( clientNumber, - JwtPrincipalUtil.getUserId(principal), - JwtPrincipalUtil.getBusinessId(principal), - JwtPrincipalUtil.getProvider(principal)); + JwtPrincipalUtil.getGroups(principal)); } @GetMapping("/search") diff --git a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java index 352c84c5cd..19e9398d10 100644 --- a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java +++ b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java @@ -90,7 +90,8 @@ public Flux searchLegacy( } public Mono searchByClientNumber( - String clientNumber + String clientNumber, + List groups ) { log.info("Searching for client number {} in legacy", clientNumber); @@ -101,6 +102,7 @@ public Mono searchByClientNumber( builder .path("/api/search/clientNumber") .queryParam("clientNumber", clientNumber) + .queryParam("groups", groups) .build(Map.of()) ) .exchangeToMono(response -> response.bodyToMono(ForestClientDetailsDto.class)) 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 7e26e38183..8512372f89 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 @@ -145,14 +145,12 @@ public Mono getClientDetailsByIncorporationNumber( public Mono getClientDetailsByClientNumber( String clientNumber, - String userId, - String businessId, - String provider + List groups ) { - log.info("Loading details for {} {} {} {}", clientNumber, userId, businessId, provider); + log.info("Loading details for {} for user role {}", clientNumber, groups.toString()); return legacyService - .searchByClientNumber(clientNumber) + .searchByClientNumber(clientNumber, groups) .flatMap(forestClientDetailsDto -> { String corpRegnNmbr = forestClientDetailsDto.corpRegnNmbr(); diff --git a/backend/src/main/java/ca/bc/gov/app/util/JwtPrincipalUtil.java b/backend/src/main/java/ca/bc/gov/app/util/JwtPrincipalUtil.java index b9d98c9a14..b759131056 100644 --- a/backend/src/main/java/ca/bc/gov/app/util/JwtPrincipalUtil.java +++ b/backend/src/main/java/ca/bc/gov/app/util/JwtPrincipalUtil.java @@ -1,7 +1,10 @@ package ca.bc.gov.app.util; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Stream; import lombok.NoArgsConstructor; import org.apache.commons.lang3.StringUtils; @@ -379,5 +382,35 @@ private static String getLastNameValue(Map claims) { private static String getNameValue(Map claims) { return processName(claims).get("fullName"); } + + /** + * Retrieves a list of groups from the given JwtPrincipal. + * + * This method extracts the token attributes from the provided {@link JwtPrincipal}, then looks for the key "cognito:groups" + * in the token attributes. If the value associated with this key is a {@link List}, the method filters the elements to only + * include non-null values of type {@link String}. The resulting list of strings is returned. + * + * @param jwtPrincipal The {@link JwtPrincipal} containing the token attributes. It must have the "cognito:groups" key. + * If the key does not exist or the value is not a list of strings, an empty list is returned. + * @return A list of group names, or an empty list if the key is missing or the value is not a list of strings. + */ + public static List getGroups(JwtAuthenticationToken jwtPrincipal) { + if (jwtPrincipal == null || jwtPrincipal.getTokenAttributes() == null) { + return Collections.emptyList(); + } + + Map tokenAttributes = jwtPrincipal.getTokenAttributes(); + Object groups = tokenAttributes.get("cognito:groups"); + + if (groups instanceof List) { + return ((List) groups).stream() + .filter(Objects::nonNull) + .filter(String.class::isInstance) + .map(String.class::cast) + .toList(); + } + + return Collections.emptyList(); + } } diff --git a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java index 8f7b80a3ff..d91fbe4765 100644 --- a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java +++ b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java @@ -77,9 +77,12 @@ public Flux findByIdAndLastName( @GetMapping("/clientNumber") public Mono findByClientNumber( - @RequestParam String clientNumber + @RequestParam String clientNumber, + @RequestParam List groups ) { - log.info("Receiving request to search by ID {} and Last Name", clientNumber); + log.info("Receiving request to search by ID {} and groups {}", + clientNumber, + groups); return service.findByClientNumber(clientNumber); } From e1f2aac680a6cbdbf74f759647886ead15343045 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 26 Nov 2024 16:05:49 -0800 Subject: [PATCH 09/37] feat(be:FSADT1-1575): Passed groups to legacy --- .../ca/bc/gov/app/controller/ClientSearchController.java | 2 +- .../java/ca/bc/gov/app/service/ClientSearchService.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java index d91fbe4765..64061c702c 100644 --- a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java +++ b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java @@ -83,7 +83,7 @@ public Mono findByClientNumber( log.info("Receiving request to search by ID {} and groups {}", clientNumber, groups); - return service.findByClientNumber(clientNumber); + return service.findByClientNumber(clientNumber, groups); } @GetMapping("/id/{idType}/{identification}") diff --git a/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java b/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java index 6f15000547..e5af48ecd6 100644 --- a/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java +++ b/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java @@ -22,6 +22,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Comparator; +import java.util.List; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -36,6 +37,7 @@ import org.springframework.data.relational.core.query.Criteria; import org.springframework.data.relational.core.query.Query; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -537,12 +539,16 @@ public Flux findByClientName(String clientName) { ); } - public Mono findByClientNumber(String clientNumber) { + public Mono findByClientNumber(String clientNumber, List groups) { log.info("Searching for client with number {}", clientNumber); if (StringUtils.isBlank(clientNumber)) { return Mono.error(new MissingRequiredParameterException("clientNumber")); } + + if (CollectionUtils.isEmpty(groups)) { + return Mono.error(new MissingRequiredParameterException("groups")); + } return forestClientRepository.findByClientNumber(clientNumber) .map(forestClientMapper::toDto) From 9ca2aa12901c9f4f2eb1f671085e6173cb4e2958 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Wed, 27 Nov 2024 15:32:40 -0800 Subject: [PATCH 10/37] Updated query --- .../controller/ClientSearchController.java | 3 +- .../repository/ForestClientRepository.java | 49 +++++++++++++++++++ .../gov/app/service/ClientSearchService.java | 12 +++-- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java index 64061c702c..b46fa62249 100644 --- a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java +++ b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java @@ -2,6 +2,7 @@ import ca.bc.gov.app.dto.AddressSearchDto; import ca.bc.gov.app.dto.ContactSearchDto; +import ca.bc.gov.app.dto.ForestClientDetailsDto; import ca.bc.gov.app.dto.ForestClientDto; import ca.bc.gov.app.dto.PredictiveSearchResultDto; import ca.bc.gov.app.service.ClientSearchService; @@ -76,7 +77,7 @@ public Flux findByIdAndLastName( } @GetMapping("/clientNumber") - public Mono findByClientNumber( + public Mono findByClientNumber( @RequestParam String clientNumber, @RequestParam List groups ) { diff --git a/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java index d23343c824..5c208913bc 100644 --- a/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java +++ b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java @@ -1,5 +1,6 @@ package ca.bc.gov.app.repository; +import ca.bc.gov.app.dto.ForestClientDetailsDto; import ca.bc.gov.app.dto.PredictiveSearchResultDto; import ca.bc.gov.app.entity.ForestClientEntity; import java.time.LocalDateTime; @@ -59,6 +60,54 @@ Flux findClientByIncorporationOrName( Flux matchBy(String companyName); Mono findByClientNumber(String clientNumber); + + @Query(""" + select + c.client_number, + c.client_name, + c.legal_first_name, + c.legal_middle_name, + c.client_status_code, + s.description as client_status_desc, + c.client_type_code, + t.description as client_type_desc, + c.client_id_type_code, + it.description as client_id_type_desc, + c.client_identification, + c.registry_company_type_code, + c.corp_regn_nmbr, + c.client_acronym, + c.wcb_firm_number, + c.ocg_supplier_nmbr, + c.client_comment, + fca.update_userid as latest_update_userid, + fca.update_timestamp as latest_update_timestamp, + '' as good_standing_ind, + c.birthdate + from the.forest_client c + inner join the.client_status_code s on c.client_status_code = s.client_status_code + inner join the.client_type_code t on c.client_type_code = t.client_type_code + left join the.client_id_type_code it on c.client_id_type_code = it.client_id_type_code + left join ( + select + client_number, + update_userid, + update_timestamp + from ( + select + client_number, + update_userid, + update_timestamp, + row_number() over (partition by client_number order by update_timestamp desc) as rn + from + the.for_cli_audit + where + client_comment is not null + ) + where rn = 1 + ) fca on c.client_number = fca.client_number + where c.client_number = :clientNumber""") + Mono findDetailsByClientNumber(String clientNumber); @Query(""" SELECT diff --git a/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java b/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java index e5af48ecd6..f7546bde53 100644 --- a/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java +++ b/legacy/src/main/java/ca/bc/gov/app/service/ClientSearchService.java @@ -6,6 +6,7 @@ import ca.bc.gov.app.configuration.ForestClientConfiguration; import ca.bc.gov.app.dto.AddressSearchDto; import ca.bc.gov.app.dto.ContactSearchDto; +import ca.bc.gov.app.dto.ForestClientDetailsDto; import ca.bc.gov.app.dto.ForestClientDto; import ca.bc.gov.app.dto.PredictiveSearchResultDto; import ca.bc.gov.app.entity.ClientDoingBusinessAsEntity; @@ -13,6 +14,7 @@ import ca.bc.gov.app.entity.ForestClientEntity; import ca.bc.gov.app.entity.ForestClientLocationEntity; import ca.bc.gov.app.exception.MissingRequiredParameterException; +import ca.bc.gov.app.exception.NoValueFoundException; import ca.bc.gov.app.mappers.AbstractForestClientMapper; import ca.bc.gov.app.repository.ClientDoingBusinessAsRepository; import ca.bc.gov.app.repository.ForestClientContactRepository; @@ -539,7 +541,7 @@ public Flux findByClientName(String clientName) { ); } - public Mono findByClientNumber(String clientNumber, List groups) { + public Mono findByClientNumber(String clientNumber, List groups) { log.info("Searching for client with number {}", clientNumber); if (StringUtils.isBlank(clientNumber)) { @@ -550,8 +552,12 @@ public Mono findByClientNumber(String clientNumber, List log.info("Found client with client number {}", clientNumber, From 3c2df9ec549e450b03fb7c2680868c896041d1b1 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Wed, 27 Nov 2024 15:33:35 -0800 Subject: [PATCH 11/37] Added missing dto --- .../gov/app/dto/ForestClientDetailsDto.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java new file mode 100644 index 0000000000..aba1377256 --- /dev/null +++ b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java @@ -0,0 +1,33 @@ +package ca.bc.gov.app.dto; + +import java.time.LocalDate; +import java.util.List; + +public record ForestClientDetailsDto ( + String clientNumber, + String clientName, + String legalFirstName, + String legalMiddleName, + String clientStatusCode, + String clientStatusDesc, + String clientTypeCode, + String clientTypeDesc, + String clientIdTypeCode, + String clientIdTypeDesc, + String clientIdentification, + String registryCompanyTypeCode, + String corpRegnNmbr, + String clientAcronym, + String wcbFirmNumber, + String ocgSupplierNmbr, + String clientComment, + LocalDate clientCommentUpdateDate, + String clientCommentUpdateUser, + String goodStandingInd, + LocalDate birthdate, + + List addresses, + List contacts +) { + +} From ffa7bbfec4019a6b6e54adf4aa49dcebb0555d8c Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Wed, 27 Nov 2024 16:04:16 -0800 Subject: [PATCH 12/37] Removed unneeded field --- .../java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java | 1 - .../main/java/ca/bc/gov/app/service/client/ClientService.java | 1 - .../src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java | 1 - .../java/ca/bc/gov/app/repository/ForestClientRepository.java | 1 - 4 files changed, 4 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java index a7a4a28ca7..c31519c13f 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java @@ -19,7 +19,6 @@ public record ForestClientDetailsDto ( String corpRegnNmbr, String clientAcronym, String wcbFirmNumber, - String ocgSupplierNmbr, String clientComment, LocalDate clientCommentUpdateDate, String clientCommentUpdateUser, 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 8512372f89..473dca2262 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 @@ -201,7 +201,6 @@ private Mono populateGoodStandingInd( forestClientDetailsDto.corpRegnNmbr(), forestClientDetailsDto.clientAcronym(), forestClientDetailsDto.wcbFirmNumber(), - forestClientDetailsDto.ocgSupplierNmbr(), forestClientDetailsDto.clientComment(), forestClientDetailsDto.clientCommentUpdateDate(), forestClientDetailsDto.clientCommentUpdateUser(), diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java index aba1377256..2ced260a9c 100644 --- a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java +++ b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java @@ -19,7 +19,6 @@ public record ForestClientDetailsDto ( String corpRegnNmbr, String clientAcronym, String wcbFirmNumber, - String ocgSupplierNmbr, String clientComment, LocalDate clientCommentUpdateDate, String clientCommentUpdateUser, diff --git a/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java index 5c208913bc..1bcbce10c6 100644 --- a/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java +++ b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientRepository.java @@ -78,7 +78,6 @@ Flux findClientByIncorporationOrName( c.corp_regn_nmbr, c.client_acronym, c.wcb_firm_number, - c.ocg_supplier_nmbr, c.client_comment, fca.update_userid as latest_update_userid, fca.update_timestamp as latest_update_timestamp, From 4f2862e5dd3c611286dd61d5b49c89018358aa6b Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Fri, 29 Nov 2024 10:47:44 -0800 Subject: [PATCH 13/37] Added new field as per requested --- .../gov/app/dto/legacy/ForestClientDetailsDto.java | 3 ++- .../dto/legacy/ForestClientDoingBusinessAsDto.java | 14 ++++++++++++++ .../bc/gov/app/service/client/ClientService.java | 3 ++- .../ca/bc/gov/app/dto/ForestClientDetailsDto.java | 3 ++- 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDoingBusinessAsDto.java diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java index c31519c13f..64b59337c6 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java @@ -26,7 +26,8 @@ public record ForestClientDetailsDto ( LocalDate birthdate, List addresses, - List contacts + List contacts, + List doingBusinessAs ) { } diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDoingBusinessAsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDoingBusinessAsDto.java new file mode 100644 index 0000000000..fe97663ad7 --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDoingBusinessAsDto.java @@ -0,0 +1,14 @@ +package ca.bc.gov.app.dto.legacy; + +import lombok.With; + +@With +public record ForestClientDoingBusinessAsDto( + String clientNumber, + String doingBusinessAsName, + String createdBy, + String updatedBy, + Long orgUnit +) { + +} 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 473dca2262..ec1122ec35 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 @@ -207,7 +207,8 @@ private Mono populateGoodStandingInd( goodStanding, forestClientDetailsDto.birthdate(), forestClientDetailsDto.addresses(), - forestClientDetailsDto.contacts() + forestClientDetailsDto.contacts(), + forestClientDetailsDto.doingBusinessAs() ); }); } diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java index 2ced260a9c..98573c114b 100644 --- a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java +++ b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java @@ -26,7 +26,8 @@ public record ForestClientDetailsDto ( LocalDate birthdate, List addresses, - List contacts + List contacts, + List doingBusinessAs ) { } From 33b32b963cec07dbfb63273e2bb2ca118e127320 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Fri, 29 Nov 2024 13:59:05 -0800 Subject: [PATCH 14/37] feat(be:FSADT1-1575): Changes done after code review --- .../gov/app/service/client/ClientService.java | 92 ++++++++++--------- 1 file changed, 47 insertions(+), 45 deletions(-) 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 ec1122ec35..da00a0e122 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 @@ -161,58 +161,60 @@ public Mono getClientDetailsByClientNumber( log.info("Retrieved corporation registration number: {}", corpRegnNmbr); - Mono documentMono = bcRegistryService - .requestDocumentData(corpRegnNmbr) - .next(); - return populateGoodStandingInd(forestClientDetailsDto, documentMono); + return bcRegistryService + .requestDocumentData(corpRegnNmbr) + .next() + .flatMap(documentMono -> + populateGoodStandingInd(forestClientDetailsDto, + documentMono) + ); }); } private Mono populateGoodStandingInd( ForestClientDetailsDto forestClientDetailsDto, - Mono documentMono + BcRegistryDocumentDto document ) { - return documentMono - .map(document -> { - Boolean goodStandingInd = document.business().goodStanding(); - String goodStanding; - - if (goodStandingInd == null) { - goodStanding = ""; - } else { - goodStanding = goodStandingInd ? "Y" : "N"; - } - log.info("Setting goodStandingInd for client: {} to {}", - forestClientDetailsDto.clientNumber(), goodStanding); - - return new ForestClientDetailsDto( - forestClientDetailsDto.clientNumber(), - forestClientDetailsDto.clientName(), - forestClientDetailsDto.legalFirstName(), - forestClientDetailsDto.legalMiddleName(), - forestClientDetailsDto.clientStatusCode(), - forestClientDetailsDto.clientStatusDesc(), - forestClientDetailsDto.clientTypeCode(), - forestClientDetailsDto.clientTypeDesc(), - forestClientDetailsDto.clientIdTypeCode(), - forestClientDetailsDto.clientIdTypeDesc(), - forestClientDetailsDto.clientIdentification(), - forestClientDetailsDto.registryCompanyTypeCode(), - forestClientDetailsDto.corpRegnNmbr(), - forestClientDetailsDto.clientAcronym(), - forestClientDetailsDto.wcbFirmNumber(), - forestClientDetailsDto.clientComment(), - forestClientDetailsDto.clientCommentUpdateDate(), - forestClientDetailsDto.clientCommentUpdateUser(), - goodStanding, - forestClientDetailsDto.birthdate(), - forestClientDetailsDto.addresses(), - forestClientDetailsDto.contacts(), - forestClientDetailsDto.doingBusinessAs() - ); - }); - } + Boolean goodStandingInd = document.business().goodStanding(); + String goodStanding; + if (goodStandingInd == null) { + goodStanding = ""; + } + else { + goodStanding = goodStandingInd ? "Y" : "N"; + } + + log.info("Setting goodStandingInd for client: {} to {}", + forestClientDetailsDto.clientNumber(), goodStanding); + ForestClientDetailsDto updatedDetails = new ForestClientDetailsDto( + forestClientDetailsDto.clientNumber(), + forestClientDetailsDto.clientName(), + forestClientDetailsDto.legalFirstName(), + forestClientDetailsDto.legalMiddleName(), + forestClientDetailsDto.clientStatusCode(), + forestClientDetailsDto.clientStatusDesc(), + forestClientDetailsDto.clientTypeCode(), + forestClientDetailsDto.clientTypeDesc(), + forestClientDetailsDto.clientIdTypeCode(), + forestClientDetailsDto.clientIdTypeDesc(), + forestClientDetailsDto.clientIdentification(), + forestClientDetailsDto.registryCompanyTypeCode(), + forestClientDetailsDto.corpRegnNmbr(), + forestClientDetailsDto.clientAcronym(), + forestClientDetailsDto.wcbFirmNumber(), + forestClientDetailsDto.clientComment(), + forestClientDetailsDto.clientCommentUpdateDate(), + forestClientDetailsDto.clientCommentUpdateUser(), + goodStanding, + forestClientDetailsDto.birthdate(), + forestClientDetailsDto.addresses(), + forestClientDetailsDto.contacts(), + forestClientDetailsDto.doingBusinessAs() + ); + + return Mono.just(updatedDetails); + } /** * Searches the BC Registry API for {@link BcRegistryFacetSearchResultEntryDto} instances matching From 401537be56d402d2966e945a36b5761aa2552290 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Fri, 29 Nov 2024 14:14:44 -0800 Subject: [PATCH 15/37] Added javadoc --- .../gov/app/controller/ClientSearchController.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java index b46fa62249..4c64a0cf58 100644 --- a/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java +++ b/legacy/src/main/java/ca/bc/gov/app/controller/ClientSearchController.java @@ -56,7 +56,7 @@ public Flux findIndividuals( ) { log.info("Receiving request to search by individual {} {} {} {}", firstName, lastName, dob, identification); - return service.findByIndividual(firstName, lastName, dob, identification,true); + return service.findByIndividual(firstName, lastName, dob, identification, true); } @GetMapping("/match") @@ -76,6 +76,13 @@ public Flux findByIdAndLastName( return service.findByIdAndLastName(clientId, lastName); } + /** + * Handles the HTTP GET request to retrieve client details by client number. + * + * @param clientNumber the client number to search for + * @param groups the list of user groups for authorization or filtering purposes + * @return a Mono containing the client details if found, or an empty Mono if not found + */ @GetMapping("/clientNumber") public Mono findByClientNumber( @RequestParam String clientNumber, @@ -142,9 +149,9 @@ public Flux findByDoingBusinessAs( @RequestParam(required = false,defaultValue = "true") Boolean isFuzzy ) { log.info("Receiving request to search by doing business as name {} being a {} match", - dbaName, BooleanUtils.toString(isFuzzy,"fuzzy","full") + dbaName, BooleanUtils.toString(isFuzzy, "fuzzy", "full") ); - return service.findByDoingBusinessAs(dbaName,isFuzzy); + return service.findByDoingBusinessAs(dbaName, isFuzzy); } @GetMapping("/clientName") From 20b0c09170d6bb014d92a147e8f82b8e0313a79f Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Fri, 29 Nov 2024 14:59:17 -0800 Subject: [PATCH 16/37] Added test --- .../ClientLegacyServiceIntegrationTest.java | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java index 181d984d18..9c32bb1d4f 100644 --- a/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java @@ -10,6 +10,7 @@ import ca.bc.gov.app.dto.legacy.AddressSearchDto; import ca.bc.gov.app.dto.legacy.ContactSearchDto; +import ca.bc.gov.app.dto.legacy.ForestClientDetailsDto; import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest; import ca.bc.gov.app.extensions.WiremockLogNotifier; import com.github.tomakehurst.wiremock.junit5.WireMockExtension; @@ -145,5 +146,100 @@ private static Stream>> invalidValuesForMap(){ Map.of(" ",List.of()) ); } + + @Test + @DisplayName("searching legacy by client number") + void shouldSearchLegacyByClientNumber() { + String clientNumber = "00000001"; + List groups = List.of("CLIENT_VIEWER", "CLIENT_ADMIN"); + + ForestClientDetailsDto expectedDto = new ForestClientDetailsDto( + clientNumber, + "MY COMPANY LTD.", + null, + null, + "ACT", + "Active", + "C", + "Corporation", + null, + null, + null, + "BC", + "9607514", + null, + "678", + "THIS TEST", + null, + null, + "Y", + null, + null, + null, + null + ); + + legacyStub + .stubFor( + get(urlPathEqualTo("/api/search/clientNumber")) + .withQueryParam("clientNumber", equalTo(clientNumber)) + .withQueryParam("groups", equalTo("CLIENT_VIEWER,CLIENT_ADMIN")) + .willReturn(okJson("{" + + "\"clientNumber\":\"00000001\"," + + "\"clientName\":\"MY COMPANY LTD.\"," + + "\"legalFirstName\":null," + + "\"legalMiddleName\":null," + + "\"clientStatusCode\":\"ACT\"," + + "\"clientStatusDesc\":\"Active\"," + + "\"clientTypeCode\":\"C\"," + + "\"clientTypeDesc\":\"Corporation\"," + + "\"clientIdTypeCode\":null," + + "\"clientIdTypeDesc\":null," + + "\"clientIdentification\":null," + + "\"registryCompanyTypeCode\":\"BC\"," + + "\"corpRegnNmbr\":\"9607514\"," + + "\"clientAcronym\":null," + + "\"wcbFirmNumber\":\"678\"," + + "\"ocgSupplierNmbr\":null," + + "\"clientComment\":\"THIS TEST\"," + + "\"clientCommentUpdateDate\":null," + + "\"clientCommentUpdateUser\":null," + + "\"goodStandingInd\":\"Y\"," + + "\"birthdate\":null," + + "\"addresses\":null," + + "\"contacts\":null," + + "\"doingBusinessAs\":null" + + "}")) + ); + + service.searchByClientNumber(clientNumber, groups) + .as(StepVerifier::create) + .assertNext(clientDetailsDto -> { + assertEquals(expectedDto.clientNumber(), clientDetailsDto.clientNumber()); + assertEquals(expectedDto.clientName(), clientDetailsDto.clientName()); + assertNull(clientDetailsDto.legalFirstName()); + assertNull(clientDetailsDto.legalMiddleName()); + assertEquals(expectedDto.clientStatusCode(), clientDetailsDto.clientStatusCode()); + assertEquals(expectedDto.clientStatusDesc(), clientDetailsDto.clientStatusDesc()); + assertEquals(expectedDto.clientTypeCode(), clientDetailsDto.clientTypeCode()); + assertEquals(expectedDto.clientTypeDesc(), clientDetailsDto.clientTypeDesc()); + assertNull(clientDetailsDto.clientIdTypeCode()); + assertNull(clientDetailsDto.clientIdTypeDesc()); + assertNull(clientDetailsDto.clientIdentification()); + assertEquals(expectedDto.registryCompanyTypeCode(), clientDetailsDto.registryCompanyTypeCode()); + assertEquals(expectedDto.corpRegnNmbr(), clientDetailsDto.corpRegnNmbr()); + assertNull(clientDetailsDto.clientAcronym()); + assertEquals(expectedDto.wcbFirmNumber(), clientDetailsDto.wcbFirmNumber()); + assertEquals(expectedDto.clientComment(), clientDetailsDto.clientComment()); + assertNull(clientDetailsDto.clientCommentUpdateDate()); + assertNull(clientDetailsDto.clientCommentUpdateUser()); + assertEquals(expectedDto.goodStandingInd(), clientDetailsDto.goodStandingInd()); + assertNull(clientDetailsDto.birthdate()); + assertNull(clientDetailsDto.addresses()); + assertNull(clientDetailsDto.contacts()); + assertNull(clientDetailsDto.doingBusinessAs()); + }) + .verifyComplete(); + } } \ No newline at end of file From fe325503d83b63865d741fb21d8e6ffe46402c75 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Fri, 29 Nov 2024 15:08:34 -0800 Subject: [PATCH 17/37] Fixed test --- .../app/service/client/ClientLegacyServiceIntegrationTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java index 9c32bb1d4f..c7d6d79d05 100644 --- a/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java @@ -210,6 +210,7 @@ void shouldSearchLegacyByClientNumber() { + "\"contacts\":null," + "\"doingBusinessAs\":null" + "}")) + .withHeader("Content-Type", equalTo("application/json")) ); service.searchByClientNumber(clientNumber, groups) From 383bd6d1e80128839efcfbdf44ae9dfc27d88bc4 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Fri, 29 Nov 2024 15:22:09 -0800 Subject: [PATCH 18/37] Improved test --- .../ClientLegacyServiceIntegrationTest.java | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java index c7d6d79d05..23310e2e47 100644 --- a/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java @@ -6,6 +6,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.*; import ca.bc.gov.app.dto.legacy.AddressSearchDto; @@ -151,7 +152,7 @@ private static Stream>> invalidValuesForMap(){ @DisplayName("searching legacy by client number") void shouldSearchLegacyByClientNumber() { String clientNumber = "00000001"; - List groups = List.of("CLIENT_VIEWER", "CLIENT_ADMIN"); + List groups = List.of("CLIENT_ADMIN"); ForestClientDetailsDto expectedDto = new ForestClientDetailsDto( clientNumber, @@ -183,7 +184,7 @@ void shouldSearchLegacyByClientNumber() { .stubFor( get(urlPathEqualTo("/api/search/clientNumber")) .withQueryParam("clientNumber", equalTo(clientNumber)) - .withQueryParam("groups", equalTo("CLIENT_VIEWER,CLIENT_ADMIN")) + .withQueryParam("groups", equalTo("CLIENT_ADMIN")) .willReturn(okJson("{" + "\"clientNumber\":\"00000001\"," + "\"clientName\":\"MY COMPANY LTD.\"," @@ -216,29 +217,33 @@ void shouldSearchLegacyByClientNumber() { service.searchByClientNumber(clientNumber, groups) .as(StepVerifier::create) .assertNext(clientDetailsDto -> { - assertEquals(expectedDto.clientNumber(), clientDetailsDto.clientNumber()); - assertEquals(expectedDto.clientName(), clientDetailsDto.clientName()); - assertNull(clientDetailsDto.legalFirstName()); - assertNull(clientDetailsDto.legalMiddleName()); - assertEquals(expectedDto.clientStatusCode(), clientDetailsDto.clientStatusCode()); - assertEquals(expectedDto.clientStatusDesc(), clientDetailsDto.clientStatusDesc()); - assertEquals(expectedDto.clientTypeCode(), clientDetailsDto.clientTypeCode()); - assertEquals(expectedDto.clientTypeDesc(), clientDetailsDto.clientTypeDesc()); - assertNull(clientDetailsDto.clientIdTypeCode()); - assertNull(clientDetailsDto.clientIdTypeDesc()); - assertNull(clientDetailsDto.clientIdentification()); - assertEquals(expectedDto.registryCompanyTypeCode(), clientDetailsDto.registryCompanyTypeCode()); - assertEquals(expectedDto.corpRegnNmbr(), clientDetailsDto.corpRegnNmbr()); - assertNull(clientDetailsDto.clientAcronym()); - assertEquals(expectedDto.wcbFirmNumber(), clientDetailsDto.wcbFirmNumber()); - assertEquals(expectedDto.clientComment(), clientDetailsDto.clientComment()); - assertNull(clientDetailsDto.clientCommentUpdateDate()); - assertNull(clientDetailsDto.clientCommentUpdateUser()); - assertEquals(expectedDto.goodStandingInd(), clientDetailsDto.goodStandingInd()); - assertNull(clientDetailsDto.birthdate()); - assertNull(clientDetailsDto.addresses()); - assertNull(clientDetailsDto.contacts()); - assertNull(clientDetailsDto.doingBusinessAs()); + assertThat(clientDetailsDto) + .extracting( + ForestClientDetailsDto::clientNumber, + ForestClientDetailsDto::clientName, + ForestClientDetailsDto::clientStatusCode, + ForestClientDetailsDto::clientStatusDesc, + ForestClientDetailsDto::clientTypeCode, + ForestClientDetailsDto::clientTypeDesc, + ForestClientDetailsDto::registryCompanyTypeCode, + ForestClientDetailsDto::corpRegnNmbr, + ForestClientDetailsDto::wcbFirmNumber, + ForestClientDetailsDto::clientComment, + ForestClientDetailsDto::goodStandingInd + ) + .containsExactly( + expectedDto.clientNumber(), + expectedDto.clientName(), + expectedDto.clientStatusCode(), + expectedDto.clientStatusDesc(), + expectedDto.clientTypeCode(), + expectedDto.clientTypeDesc(), + expectedDto.registryCompanyTypeCode(), + expectedDto.corpRegnNmbr(), + expectedDto.wcbFirmNumber(), + expectedDto.clientComment(), + expectedDto.goodStandingInd() + ); }) .verifyComplete(); } From 385e9b6290d689564cdc9fc28dfc6907f5575c5d Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 2 Dec 2024 08:38:43 -0800 Subject: [PATCH 19/37] feat(be:FSADT1-1575): Added more tests --- .../gov/app/utils/JwtPrincipalUtilTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/backend/src/test/java/ca/bc/gov/app/utils/JwtPrincipalUtilTest.java b/backend/src/test/java/ca/bc/gov/app/utils/JwtPrincipalUtilTest.java index d6ed63d317..28b2c1c57b 100644 --- a/backend/src/test/java/ca/bc/gov/app/utils/JwtPrincipalUtilTest.java +++ b/backend/src/test/java/ca/bc/gov/app/utils/JwtPrincipalUtilTest.java @@ -5,12 +5,16 @@ import ca.bc.gov.app.util.JwtPrincipalUtil; import java.time.LocalDateTime; import java.time.ZoneOffset; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.ValueSource; import org.springframework.security.oauth2.jwt.Jwt; import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; @@ -178,4 +182,51 @@ private JwtAuthenticationToken createJwtAuthenticationTokenWithAttributes( attributes ); } + + @ParameterizedTest + @DisplayName("getGroups should return expected group list") + @MethodSource("provideGroupsTestData") + void shouldGetGroups(Map tokenAttributes, List expectedGroups) { + JwtAuthenticationToken jwtAuthenticationToken = createJwtAuthenticationTokenWithAttributes(tokenAttributes); + + List actualGroups = JwtPrincipalUtil.getGroups(jwtAuthenticationToken); + + assertEquals(expectedGroups, actualGroups); + } + + private static Stream provideGroupsTestData() { + return Stream.of( + // Case 1: Token attributes contain "CLIENT_ADMIN" + Arguments.of( + Map.of("cognito:groups", List.of("CLIENT_ADMIN")), + List.of("CLIENT_ADMIN") + ), + // Case 2: Token attributes contain an empty group list + Arguments.of( + Map.of("cognito:groups", List.of()), + List.of() + ), + // Case 3: Token attributes contain null groups + Arguments.of( + Map.of("cognito:groups", null), + List.of() + ), + // Case 4: Token attributes missing "cognito:groups" + Arguments.of( + Map.of("otherKey", "someValue"), + List.of() + ), + // Case 5: Null JwtAuthenticationToken + Arguments.of( + null, + List.of() + ), + // Case 6: Null token attributes in JwtAuthenticationToken + Arguments.of( + new HashMap<>(), + List.of() + ) + ); + } + } \ No newline at end of file From 8c9bbd0be68176564c94a52609bd3fe57634d3aa Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 2 Dec 2024 09:17:46 -0800 Subject: [PATCH 20/37] Fixed test --- .../ca/bc/gov/app/utils/JwtPrincipalUtilTest.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/backend/src/test/java/ca/bc/gov/app/utils/JwtPrincipalUtilTest.java b/backend/src/test/java/ca/bc/gov/app/utils/JwtPrincipalUtilTest.java index 28b2c1c57b..6da8e96b39 100644 --- a/backend/src/test/java/ca/bc/gov/app/utils/JwtPrincipalUtilTest.java +++ b/backend/src/test/java/ca/bc/gov/app/utils/JwtPrincipalUtilTest.java @@ -187,7 +187,9 @@ private JwtAuthenticationToken createJwtAuthenticationTokenWithAttributes( @DisplayName("getGroups should return expected group list") @MethodSource("provideGroupsTestData") void shouldGetGroups(Map tokenAttributes, List expectedGroups) { - JwtAuthenticationToken jwtAuthenticationToken = createJwtAuthenticationTokenWithAttributes(tokenAttributes); + JwtAuthenticationToken jwtAuthenticationToken = tokenAttributes == null + ? null + : createJwtAuthenticationTokenWithAttributes(tokenAttributes); List actualGroups = JwtPrincipalUtil.getGroups(jwtAuthenticationToken); @@ -208,7 +210,9 @@ private static Stream provideGroupsTestData() { ), // Case 3: Token attributes contain null groups Arguments.of( - Map.of("cognito:groups", null), + new HashMap<>() {{ + put("cognito:groups", null); + }}, List.of() ), // Case 4: Token attributes missing "cognito:groups" @@ -220,11 +224,6 @@ private static Stream provideGroupsTestData() { Arguments.of( null, List.of() - ), - // Case 6: Null token attributes in JwtAuthenticationToken - Arguments.of( - new HashMap<>(), - List.of() ) ); } From 7f454b175d7f813114e5d256c2c8d59d3aa36c9f Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 2 Dec 2024 15:33:34 -0800 Subject: [PATCH 21/37] feat(be:FSADT1-1575): Added more tests --- .../client/ClientServiceIntegrationTest.java | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 backend/src/test/java/ca/bc/gov/app/service/client/ClientServiceIntegrationTest.java diff --git a/backend/src/test/java/ca/bc/gov/app/service/client/ClientServiceIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/service/client/ClientServiceIntegrationTest.java new file mode 100644 index 0000000000..0804376172 --- /dev/null +++ b/backend/src/test/java/ca/bc/gov/app/service/client/ClientServiceIntegrationTest.java @@ -0,0 +1,171 @@ +package ca.bc.gov.app.service.client; + +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.List; +import org.junit.jupiter.api.DisplayName; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.junit.jupiter.api.Test; +import ca.bc.gov.app.dto.bcregistry.BcRegistryAddressDto; +import ca.bc.gov.app.dto.bcregistry.BcRegistryAlternateNameDto; +import ca.bc.gov.app.dto.bcregistry.BcRegistryBusinessAdressesDto; +import ca.bc.gov.app.dto.bcregistry.BcRegistryBusinessDto; +import ca.bc.gov.app.dto.bcregistry.BcRegistryDocumentDto; +import ca.bc.gov.app.dto.bcregistry.BcRegistryOfficerDto; +import ca.bc.gov.app.dto.bcregistry.BcRegistryOfficesDto; +import ca.bc.gov.app.dto.bcregistry.BcRegistryPartyDto; +import ca.bc.gov.app.dto.bcregistry.BcRegistryRoleDto; +import ca.bc.gov.app.dto.legacy.ForestClientDetailsDto; +import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest; +import ca.bc.gov.app.service.bcregistry.BcRegistryService; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; + +@DisplayName("Integrated Test | Client Service") +public class ClientServiceIntegrationTest extends AbstractTestContainerIntegrationTest { + + @Autowired + private ClientService service; + + @MockBean + private ClientLegacyService legacyService; + + @MockBean + private BcRegistryService bcRegistryService; + + @Test + @DisplayName("Return client details with good standing indicator derived from BcRegistryDocumentDto") + void testGetClientDetailsWithGoodStandingIndicator() { + String clientNumber = "123456"; + String corpRegnNmbr = "9607514"; + List groups = List.of("CLIENT_ADMIN"); + + ForestClientDetailsDto initialDto = new ForestClientDetailsDto( + clientNumber, + "MY COMPANY LTD.", + null, + null, + "ACT", + "Active", + "C", + "Corporation", + "ID", + "Client Identification", + "123456789", + "BC", + corpRegnNmbr, + "MYCO", + "678", + "Test Client", + LocalDate.now(), + "Admin", + null, + null, + null, + null, + null); + + BcRegistryOfficerDto mockOfficer = new BcRegistryOfficerDto( + "officer@email.com", + "John", + "Doe", + "D", + "123456", + "My Company Ltd.", + "Person"); + + BcRegistryAddressDto mockAddress = new BcRegistryAddressDto( + "City", + "Canada", + "BC", + "A1B2C3", + "Street", + "", + "", + ""); + + BcRegistryRoleDto mockRole = new BcRegistryRoleDto( + LocalDate.now().minusYears(1), + null, + "Owner"); + + BcRegistryPartyDto mockParty = new BcRegistryPartyDto( + mockAddress, + mockAddress, + mockOfficer, + List.of(mockRole)); + + BcRegistryAddressDto mockMailingAddress = mockAddress; + BcRegistryAddressDto mockDeliveryAddress = mockAddress; + BcRegistryBusinessAdressesDto mockBusinessOffice = new BcRegistryBusinessAdressesDto( + mockMailingAddress, + mockDeliveryAddress); + + BcRegistryAlternateNameDto mockAlternateName = new BcRegistryAlternateNameDto( + "EntityType", + corpRegnNmbr, + "Alternate Name", + ZonedDateTime.now(), + LocalDate.now()); + + BcRegistryBusinessDto mockBusinessDto = new BcRegistryBusinessDto( + List.of(mockAlternateName), + true, + false, + false, + false, + corpRegnNmbr, + "MY COMPANY LTD.", + "Corporation", + "Active"); + + BcRegistryOfficesDto mockOffices = new BcRegistryOfficesDto(mockBusinessOffice); + + BcRegistryDocumentDto mockDocumentDto = + new BcRegistryDocumentDto(mockBusinessDto, mockOffices, List.of(mockParty)); + + ForestClientDetailsDto expectedDto = new ForestClientDetailsDto( + clientNumber, + "MY COMPANY LTD.", + null, + null, + "ACT", + "Active", + "C", + "Corporation", + "ID", + "Client Identification", + "123456789", + "BC", + corpRegnNmbr, + "MYCO", + "678", + "Test Client", + LocalDate.now(), + "Admin", + "Y", + null, + null, + null, + null); + + Mockito + .when(legacyService.searchByClientNumber(clientNumber, groups)) + .thenReturn(Mono.just(initialDto)); + + Mockito + .when(bcRegistryService + .requestDocumentData(corpRegnNmbr)) + .thenReturn(Flux.just(mockDocumentDto)); + + service + .getClientDetailsByClientNumber(clientNumber, groups) + .as(StepVerifier::create) + .expectNext(expectedDto) + .verifyComplete(); + } + +} From 4b6f62c323c41105c261b5156ff0592be9b80e70 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 3 Dec 2024 10:12:31 -0800 Subject: [PATCH 22/37] Added javadoc --- .../app/controller/client/ClientController.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index c1f46f6fe1..64df638f09 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -10,9 +10,9 @@ import ca.bc.gov.app.service.client.ClientService; import ca.bc.gov.app.util.JwtPrincipalUtil; import io.micrometer.observation.annotation.Observed; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import java.util.List; import org.apache.commons.text.WordUtils; import org.springframework.data.util.Pair; import org.springframework.http.MediaType; @@ -54,6 +54,19 @@ public Mono getClientDetailsByIncorporationNumber( ); } + /** + * Handles HTTP GET requests to retrieve client details based on the provided client number. + * + *

This method fetches the details of a client from the {@code ClientService} using the + * specified {@code clientNumber}. The caller's JWT authentication token is used to extract + * user-related information such as groups and user ID.

+ * + * @param clientNumber the unique identifier of the client whose details are to be retrieved. + * @param principal the {@link JwtAuthenticationToken} containing the authenticated user's + * information, including their roles and groups. + * @return a {@link Mono} emitting the {@link ForestClientDetailsDto} containing the requested + * client details, or an error if the client cannot be found or accessed. + */ @GetMapping("/details/{clientNumber}") public Mono getClientDetailsByClientNumber( @PathVariable String clientNumber, From 405a84b575e2b1801446f68d5e69f08d71fafe7f Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 3 Dec 2024 11:02:11 -0800 Subject: [PATCH 23/37] Made code reviews --- .../controller/client/ClientController.java | 48 +++++++---------- .../gov/app/dto/ForestClientDetailsDto.java | 52 +++++++++---------- 2 files changed, 45 insertions(+), 55 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index 64df638f09..84d6bb4065 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -87,35 +87,27 @@ public Flux fullSearch( @RequestParam(required = false, defaultValue = "10") int size, @RequestParam(required = false, defaultValue = "") String keyword, ServerHttpResponse serverResponse) { - - log.info("Listing clients: page={}, size={}, keyword={}", page, size, keyword); - - return clientLegacyService - .search( - page, - size, - keyword - ) - .doOnNext(pair -> { - Long count = pair.getSecond(); - serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of(count.toString()) - ); - } - ) - .map(Pair::getFirst) - .doFinally(signalType -> - serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of("0") - ) - ); + log.info("Listing clients: page={}, size={}, keyword={}", page, size, keyword); + + return clientLegacyService + .search(page, size, keyword) + .doOnNext(pair -> { + Long count = pair.getSecond(); + + serverResponse + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of(count.toString())); + }) + .map(Pair::getFirst) + .doFinally(signalType -> + serverResponse + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of("0"))); } /** diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java index 98573c114b..d729ec6965 100644 --- a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java +++ b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java @@ -3,31 +3,29 @@ import java.time.LocalDate; import java.util.List; -public record ForestClientDetailsDto ( - String clientNumber, - String clientName, - String legalFirstName, - String legalMiddleName, - String clientStatusCode, - String clientStatusDesc, - String clientTypeCode, - String clientTypeDesc, - String clientIdTypeCode, - String clientIdTypeDesc, - String clientIdentification, - String registryCompanyTypeCode, - String corpRegnNmbr, - String clientAcronym, - String wcbFirmNumber, - String clientComment, - LocalDate clientCommentUpdateDate, - String clientCommentUpdateUser, - String goodStandingInd, - LocalDate birthdate, - - List addresses, - List contacts, - List doingBusinessAs -) { - +public record ForestClientDetailsDto( + String clientNumber, + String clientName, + String legalFirstName, + String legalMiddleName, + String clientStatusCode, + String clientStatusDesc, + String clientTypeCode, + String clientTypeDesc, + String clientIdTypeCode, + String clientIdTypeDesc, + String clientIdentification, + String registryCompanyTypeCode, + String corpRegnNmbr, + String clientAcronym, + String wcbFirmNumber, + String clientComment, + LocalDate clientCommentUpdateDate, + String clientCommentUpdateUser, + String goodStandingInd, + LocalDate birthdate, + + List addresses, + List contacts, + List doingBusinessAs) { } From d94a8172541b116a0e808e960d247f596e387f39 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 3 Dec 2024 11:55:53 -0800 Subject: [PATCH 24/37] Added more javadocs --- .../controller/client/ClientController.java | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index 84d6bb4065..bdb6d3f208 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -36,6 +36,17 @@ public class ClientController { private final ClientService clientService; private final ClientLegacyService clientLegacyService; + /** + * Retrieves the details of a client based on the provided incorporation number. + * + *

This endpoint is used to fetch client details by their incorporation number. The request is + * authenticated using a JWT, and additional information (such as user ID, business ID, and + * provider) is extracted from the token to authorize the request. + * + * @param clientNumber the incorporation number of the client whose details are being requested + * @param principal the JWT authentication token containing user and business information + * @return a {@link Mono} emitting the {@link ClientDetailsDto} containing the client's details + */ @GetMapping("/{clientNumber}") public Mono getClientDetailsByIncorporationNumber( @PathVariable String clientNumber, @@ -81,6 +92,18 @@ public Mono getClientDetailsByClientNumber( JwtPrincipalUtil.getGroups(principal)); } + /** + * Performs a full-text search for clients based on the provided keyword, with pagination support. + * + *

This endpoint allows searching for clients by a keyword. The results are paginated, and the + * total count of matching records is included in the response headers. + * + * @param page the page number to retrieve (default is 0) + * @param size the number of records per page (default is 10) + * @param keyword the keyword to search for (default is an empty string, which returns all records) + * @param serverResponse the HTTP response to include the total count of records in the headers + * @return a {@link Flux} emitting {@link ClientListDto} objects containing the search results + */ @GetMapping("/search") public Flux fullSearch( @RequestParam(required = false, defaultValue = "0") int page, @@ -124,24 +147,44 @@ public Flux findByClientName(@PathVariable String name) { .map(client -> client.withName(WordUtils.capitalize(client.name()))); } + /** + * Finds a client based on their registration number. + * + *

This endpoint retrieves client information by searching for a registration number. If no + * client is found, an error is returned. + * + * @param registrationNumber the registration number of the client to look up + * @return a {@link Mono} emitting the {@link ClientLookUpDto} if found, or an error if no data exists + */ @GetMapping(value = "/incorporation/{registrationNumber}") public Mono findByRegistrationNumber( @PathVariable String registrationNumber) { log.info("Requesting a client with registration number {} from the client service.", - registrationNumber); + registrationNumber); return clientService .findByClientNameOrIncorporation(registrationNumber) .next() .switchIfEmpty(Mono.error(new NoClientDataFound(registrationNumber))); } + /** + * Searches for an individual client by user ID and last name. + * + *

This endpoint fetches an individual client using their user ID and last name. The request is + * validated against existing records in the system. + * + * @param userId the unique identifier of the individual to search for + * @param lastName the last name of the individual to search for + * @return a {@link Mono} indicating completion, or an error if the individual is not found + */ @GetMapping(value = "/individual/{userId}") public Mono findByIndividual( @PathVariable String userId, @RequestParam String lastName ) { - log.info("Receiving request to search individual with id {} and last name {}", userId, - lastName); + log.info("Receiving request to search individual with id {} and last name {}", + userId, + lastName); return clientService.findByIndividual(userId, lastName); } From 24506bad40162ab827f1be0ab43559ae9bbd593d Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 3 Dec 2024 12:11:23 -0800 Subject: [PATCH 25/37] Made more code reviews --- .../controller/client/ClientController.java | 42 ++++++++++--------- .../dto/legacy/ForestClientDetailsDto.java | 2 +- .../gov/app/dto/ForestClientDetailsDto.java | 34 ++++++++------- 3 files changed, 42 insertions(+), 36 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index bdb6d3f208..4b000eb8fa 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -100,7 +100,8 @@ public Mono getClientDetailsByClientNumber( * * @param page the page number to retrieve (default is 0) * @param size the number of records per page (default is 10) - * @param keyword the keyword to search for (default is an empty string, which returns all records) + * @param keyword the keyword to search for (default is an empty string, which returns all + * records) * @param serverResponse the HTTP response to include the total count of records in the headers * @return a {@link Flux} emitting {@link ClientListDto} objects containing the search results */ @@ -109,28 +110,31 @@ public Flux fullSearch( @RequestParam(required = false, defaultValue = "0") int page, @RequestParam(required = false, defaultValue = "10") int size, @RequestParam(required = false, defaultValue = "") String keyword, - ServerHttpResponse serverResponse) { - + ServerHttpResponse serverResponse + ) { log.info("Listing clients: page={}, size={}, keyword={}", page, size, keyword); return clientLegacyService - .search(page, size, keyword) - .doOnNext(pair -> { - Long count = pair.getSecond(); + .search(page, size, keyword) + .doOnNext(pair -> { + Long count = pair.getSecond(); - serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of(count.toString())); - }) - .map(Pair::getFirst) - .doFinally(signalType -> - serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of("0"))); + serverResponse + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of(count.toString()) + ); + }) + .map(Pair::getFirst) + .doFinally(signalType -> + serverResponse + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of("0") + ) + ); } /** diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java index 64b59337c6..79f29e48bd 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java @@ -3,7 +3,7 @@ import java.time.LocalDate; import java.util.List; -public record ForestClientDetailsDto ( +public record ForestClientDetailsDto( String clientNumber, String clientName, String legalFirstName, diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java index d729ec6965..19534480f1 100644 --- a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java +++ b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java @@ -5,27 +5,29 @@ public record ForestClientDetailsDto( String clientNumber, - String clientName, + String clientName, String legalFirstName, - String legalMiddleName, - String clientStatusCode, - String clientStatusDesc, + String legalMiddleName, + String clientStatusCode, + String clientStatusDesc, String clientTypeCode, - String clientTypeDesc, - String clientIdTypeCode, + String clientTypeDesc, + String clientIdTypeCode, String clientIdTypeDesc, - String clientIdentification, - String registryCompanyTypeCode, + String clientIdentification, + String registryCompanyTypeCode, String corpRegnNmbr, - String clientAcronym, - String wcbFirmNumber, + String clientAcronym, + String wcbFirmNumber, String clientComment, - LocalDate clientCommentUpdateDate, - String clientCommentUpdateUser, + LocalDate clientCommentUpdateDate, + String clientCommentUpdateUser, String goodStandingInd, LocalDate birthdate, - - List addresses, + + List addresses, List contacts, - List doingBusinessAs) { -} + List doingBusinessAs + ) { + + } From 6a94d5a612de701ee4a1eb5a8a1bb1a6d811184b Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 3 Dec 2024 13:34:27 -0800 Subject: [PATCH 26/37] Made changes after code reviews --- .../controller/client/ClientController.java | 53 ++++++++++--------- .../dto/legacy/ForestClientDetailsDto.java | 50 ++++++++--------- .../gov/app/service/client/ClientService.java | 36 +++---------- .../gov/app/dto/ForestClientDetailsDto.java | 2 + 4 files changed, 62 insertions(+), 79 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index 4b000eb8fa..1112a09bf9 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -112,29 +112,29 @@ public Flux fullSearch( @RequestParam(required = false, defaultValue = "") String keyword, ServerHttpResponse serverResponse ) { - log.info("Listing clients: page={}, size={}, keyword={}", page, size, keyword); + log.info("Listing clients: page={}, size={}, keyword={}", page, size, keyword); - return clientLegacyService - .search(page, size, keyword) - .doOnNext(pair -> { - Long count = pair.getSecond(); + return clientLegacyService + .search(page, size, keyword) + .doOnNext(pair -> { + Long count = pair.getSecond(); - serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of(count.toString()) - ); - }) - .map(Pair::getFirst) - .doFinally(signalType -> - serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of("0") - ) - ); + serverResponse + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of(count.toString()) + ); + }) + .map(Pair::getFirst) + .doFinally(signalType -> + serverResponse + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of("0") + ) + ); } /** @@ -154,11 +154,12 @@ public Flux findByClientName(@PathVariable String name) { /** * Finds a client based on their registration number. * - *

This endpoint retrieves client information by searching for a registration number. If no - * client is found, an error is returned. + * This endpoint retrieves client information by searching for a registration number. + * If no client is found, an error is returned. * * @param registrationNumber the registration number of the client to look up - * @return a {@link Mono} emitting the {@link ClientLookUpDto} if found, or an error if no data exists + * @return a {@link Mono} emitting the {@link ClientLookUpDto} if found, or an error + * if no data exists */ @GetMapping(value = "/incorporation/{registrationNumber}") public Mono findByRegistrationNumber( @@ -174,8 +175,8 @@ public Mono findByRegistrationNumber( /** * Searches for an individual client by user ID and last name. * - *

This endpoint fetches an individual client using their user ID and last name. The request is - * validated against existing records in the system. + * This endpoint fetches an individual client using their user ID and last name. + * The request is validated against existing records in the system. * * @param userId the unique identifier of the individual to search for * @param lastName the last name of the individual to search for diff --git a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java index 79f29e48bd..2a83f8f709 100644 --- a/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java +++ b/backend/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDetailsDto.java @@ -2,32 +2,34 @@ import java.time.LocalDate; import java.util.List; +import lombok.With; +@With public record ForestClientDetailsDto( - String clientNumber, - String clientName, - String legalFirstName, - String legalMiddleName, - String clientStatusCode, - String clientStatusDesc, - String clientTypeCode, - String clientTypeDesc, - String clientIdTypeCode, - String clientIdTypeDesc, - String clientIdentification, - String registryCompanyTypeCode, - String corpRegnNmbr, - String clientAcronym, - String wcbFirmNumber, - String clientComment, - LocalDate clientCommentUpdateDate, - String clientCommentUpdateUser, - String goodStandingInd, - LocalDate birthdate, - - List addresses, - List contacts, - List doingBusinessAs + String clientNumber, + String clientName, + String legalFirstName, + String legalMiddleName, + String clientStatusCode, + String clientStatusDesc, + String clientTypeCode, + String clientTypeDesc, + String clientIdTypeCode, + String clientIdTypeDesc, + String clientIdentification, + String registryCompanyTypeCode, + String corpRegnNmbr, + String clientAcronym, + String wcbFirmNumber, + String clientComment, + LocalDate clientCommentUpdateDate, + String clientCommentUpdateUser, + String goodStandingInd, + LocalDate birthdate, + + List addresses, + List contacts, + List doingBusinessAs ) { } 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 da00a0e122..ac14df55aa 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 @@ -34,6 +34,7 @@ import java.util.function.Predicate; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import reactor.core.publisher.Flux; @@ -177,41 +178,18 @@ private Mono populateGoodStandingInd( ) { Boolean goodStandingInd = document.business().goodStanding(); String goodStanding; + if (goodStandingInd == null) { goodStanding = ""; - } - else { - goodStanding = goodStandingInd ? "Y" : "N"; + } else { + goodStanding = BooleanUtils.toString(goodStandingInd, "Y", "N"); } - log.info("Setting goodStandingInd for client: {} to {}", + log.info("Setting goodStandingInd for client: {} to {}", forestClientDetailsDto.clientNumber(), goodStanding); - ForestClientDetailsDto updatedDetails = new ForestClientDetailsDto( - forestClientDetailsDto.clientNumber(), - forestClientDetailsDto.clientName(), - forestClientDetailsDto.legalFirstName(), - forestClientDetailsDto.legalMiddleName(), - forestClientDetailsDto.clientStatusCode(), - forestClientDetailsDto.clientStatusDesc(), - forestClientDetailsDto.clientTypeCode(), - forestClientDetailsDto.clientTypeDesc(), - forestClientDetailsDto.clientIdTypeCode(), - forestClientDetailsDto.clientIdTypeDesc(), - forestClientDetailsDto.clientIdentification(), - forestClientDetailsDto.registryCompanyTypeCode(), - forestClientDetailsDto.corpRegnNmbr(), - forestClientDetailsDto.clientAcronym(), - forestClientDetailsDto.wcbFirmNumber(), - forestClientDetailsDto.clientComment(), - forestClientDetailsDto.clientCommentUpdateDate(), - forestClientDetailsDto.clientCommentUpdateUser(), - goodStanding, - forestClientDetailsDto.birthdate(), - forestClientDetailsDto.addresses(), - forestClientDetailsDto.contacts(), - forestClientDetailsDto.doingBusinessAs() - ); + ForestClientDetailsDto updatedDetails = + forestClientDetailsDto.withGoodStandingInd(goodStanding); return Mono.just(updatedDetails); } diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java index 19534480f1..738fe6fb0b 100644 --- a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java +++ b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDetailsDto.java @@ -2,7 +2,9 @@ import java.time.LocalDate; import java.util.List; +import lombok.With; +@With public record ForestClientDetailsDto( String clientNumber, String clientName, From baa814412625a04f54b13241ce3dfad25f8481d1 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 3 Dec 2024 14:16:53 -0800 Subject: [PATCH 27/37] SonaCloud fixes --- .../controller/client/ClientController.java | 32 +++++++++---------- .../service/client/ClientLegacyService.java | 18 +++++------ .../ClientDistrictServiceIntegrationTest.java | 2 +- .../client/ClientServiceIntegrationTest.java | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index 1112a09bf9..7d52528488 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -117,23 +117,23 @@ public Flux fullSearch( return clientLegacyService .search(page, size, keyword) .doOnNext(pair -> { - Long count = pair.getSecond(); + Long count = pair.getSecond(); - serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of(count.toString()) - ); + serverResponse + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of(count.toString()) + ); }) .map(Pair::getFirst) .doFinally(signalType -> - serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of("0") - ) + serverResponse + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of("0") + ) ); } @@ -154,12 +154,12 @@ public Flux findByClientName(@PathVariable String name) { /** * Finds a client based on their registration number. * - * This endpoint retrieves client information by searching for a registration number. + *

This endpoint retrieves client information by searching for a registration number. * If no client is found, an error is returned. * * @param registrationNumber the registration number of the client to look up * @return a {@link Mono} emitting the {@link ClientLookUpDto} if found, or an error - * if no data exists + * if no data exists */ @GetMapping(value = "/incorporation/{registrationNumber}") public Mono findByRegistrationNumber( @@ -175,7 +175,7 @@ public Mono findByRegistrationNumber( /** * Searches for an individual client by user ID and last name. * - * This endpoint fetches an individual client using their user ID and last name. + *

This endpoint fetches an individual client using their user ID and last name. * The request is validated against existing records in the system. * * @param userId the unique identifier of the individual to search for diff --git a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java index 19e9398d10..cb9de4a2cb 100644 --- a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java +++ b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java @@ -22,15 +22,15 @@ import reactor.core.publisher.Mono; /** - * This class is responsible for interacting with the legacy API to fetch client data. It uses the - * WebClient to send HTTP requests to the legacy API and converts the responses into Flux of - * ForestClientDto objects. It provides several methods to search for clients in the legacy system - * using different search criteria. - *

- * It is annotated with @Slf4j for logging, @Service to indicate that it's a Spring service bean, - * and @Observed for metrics. - *

- * Each method logs the search parameters and the results for debugging purposes. + * This class is responsible for interacting with the legacy API to fetch client data. + * It uses the WebClient to send HTTP requests to the legacy API and converts the responses + * into Flux of ForestClientDto objects. It provides several methods to search for clients + * in the legacy system using different search criteria. + * + *

It is annotated with @Slf4j for logging, @Service to indicate that it's a + * Spring service bean, and @Observed for metrics. + * + *

Each method logs the search parameters and the results for debugging purposes. */ @Slf4j @Service diff --git a/backend/src/test/java/ca/bc/gov/app/service/client/ClientDistrictServiceIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/service/client/ClientDistrictServiceIntegrationTest.java index a39f17f6e1..99c14a7c7c 100644 --- a/backend/src/test/java/ca/bc/gov/app/service/client/ClientDistrictServiceIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/service/client/ClientDistrictServiceIntegrationTest.java @@ -10,7 +10,7 @@ @Slf4j @DisplayName("Integrated Test | FSA Client District Service") -public class ClientDistrictServiceIntegrationTest extends AbstractTestContainerIntegrationTest { +class ClientDistrictServiceIntegrationTest extends AbstractTestContainerIntegrationTest { @Autowired private ClientDistrictService service; diff --git a/backend/src/test/java/ca/bc/gov/app/service/client/ClientServiceIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/service/client/ClientServiceIntegrationTest.java index 0804376172..779d4f1b75 100644 --- a/backend/src/test/java/ca/bc/gov/app/service/client/ClientServiceIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/service/client/ClientServiceIntegrationTest.java @@ -25,7 +25,7 @@ import reactor.test.StepVerifier; @DisplayName("Integrated Test | Client Service") -public class ClientServiceIntegrationTest extends AbstractTestContainerIntegrationTest { +class ClientServiceIntegrationTest extends AbstractTestContainerIntegrationTest { @Autowired private ClientService service; From c59f69e00fb6a492e7d72f9e2e1e5c531198c147 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 3 Dec 2024 14:44:44 -0800 Subject: [PATCH 28/37] SonarCloud fixes --- .../controller/client/ClientController.java | 20 ++++----- .../service/client/ClientLegacyService.java | 24 ++++++++--- .../gov/app/service/client/ClientService.java | 43 ++++++++++--------- .../ca/bc/gov/app/util/JwtPrincipalUtil.java | 27 ++++++------ 4 files changed, 64 insertions(+), 50 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java index 7d52528488..c1d48d06fd 100644 --- a/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java +++ b/backend/src/main/java/ca/bc/gov/app/controller/client/ClientController.java @@ -120,20 +120,20 @@ public Flux fullSearch( Long count = pair.getSecond(); serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of(count.toString()) - ); + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of(count.toString()) + ); }) .map(Pair::getFirst) .doFinally(signalType -> serverResponse - .getHeaders() - .putIfAbsent( - ApplicationConstant.X_TOTAL_COUNT, - List.of("0") - ) + .getHeaders() + .putIfAbsent( + ApplicationConstant.X_TOTAL_COUNT, + List.of("0") + ) ); } diff --git a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java index cb9de4a2cb..98f28e4acb 100644 --- a/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java +++ b/backend/src/main/java/ca/bc/gov/app/service/client/ClientLegacyService.java @@ -89,6 +89,17 @@ public Flux searchLegacy( registrationNumber, companyName, dto.clientNumber())); } + /** + * Searches for client details by client number using the legacy API. + * + *

This method communicates with the legacy API to retrieve client information based on the + * provided client number. Optionally, a list of groups can be specified to refine the search + * criteria. If a matching record is found, it is returned as a {@link ForestClientDetailsDto}. + * + * @param clientNumber the client number to search for + * @param groups a list of groups to filter the search (optional) + * @return a {@link Mono} emitting the {@link ForestClientDetailsDto} if the client is found + */ public Mono searchByClientNumber( String clientNumber, List groups @@ -194,10 +205,11 @@ public Flux searchIndividual( // Convert the response to a Flux of ForestClientDto objects .exchangeToFlux(response -> response.bodyToFlux(ForestClientDto.class)) // Log the results for debugging purposes - .doOnNext( - dto -> log.info( - "Found Legacy data for first name {} and last name {} in legacy with client number {}", - firstName, lastName, dto.clientNumber()) + .doOnNext(dto -> + log.info( + "Found data for first {} and last name {} in legacy with client number {}", + firstName, lastName, dto.clientNumber() + ) ); } @@ -231,7 +243,7 @@ public Flux searchDocument( // Log the results for debugging purposes .doOnNext( dto -> log.info( - "Found Legacy data for id type {} and identification {} in legacy with client number {}", + "Found data for id type {} and identification {} in legacy with client number {}", idType, identification, dto.clientNumber()) ); @@ -301,7 +313,7 @@ public Flux searchGeneric( // Log the results for debugging purposes .doOnNext( dto -> log.info( - "Found Legacy data for {} with {} in legacy with client number {}", + "Found data for {} with {} in legacy with client number {}", searchType, parameters, dto.clientNumber() 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 ac14df55aa..a1b919ea87 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 @@ -133,10 +133,10 @@ public Mono getClientDetailsByIncorporationNumber( }) // If document type is SP and party contains only one entry that is not a person, fail - .filter(document -> provider.equalsIgnoreCase("idir") || - !("SP".equalsIgnoreCase(document.business().legalType()) && - document.parties().size() == 1 && - !document.parties().get(0).isPerson()) + .filter(document -> provider.equalsIgnoreCase("idir") + || !("SP".equalsIgnoreCase(document.business().legalType()) + && document.parties().size() == 1 + && !document.parties().get(0).isPerson()) ) .flatMap(buildDetails()) .switchIfEmpty(Mono.error(new UnableToProcessRequestException( @@ -153,22 +153,22 @@ public Mono getClientDetailsByClientNumber( return legacyService .searchByClientNumber(clientNumber, groups) .flatMap(forestClientDetailsDto -> { - String corpRegnNmbr = forestClientDetailsDto.corpRegnNmbr(); - - if (corpRegnNmbr == null || corpRegnNmbr.isEmpty()) { - log.info("Corporation registration number not provided. Returning legacy details."); - return Mono.just(forestClientDetailsDto); - } - - log.info("Retrieved corporation registration number: {}", corpRegnNmbr); - - return bcRegistryService - .requestDocumentData(corpRegnNmbr) - .next() - .flatMap(documentMono -> - populateGoodStandingInd(forestClientDetailsDto, - documentMono) - ); + String corpRegnNmbr = forestClientDetailsDto.corpRegnNmbr(); + + if (corpRegnNmbr == null || corpRegnNmbr.isEmpty()) { + log.info("Corporation registration number not provided. Returning legacy details."); + return Mono.just(forestClientDetailsDto); + } + + log.info("Retrieved corporation registration number: {}", corpRegnNmbr); + + return bcRegistryService + .requestDocumentData(corpRegnNmbr) + .next() + .flatMap(documentMono -> + populateGoodStandingInd(forestClientDetailsDto, + documentMono) + ); }); } @@ -222,7 +222,8 @@ public Mono findByIndividual(String userId, String lastName) { return legacyService .searchIdAndLastName(userId, lastName) .doOnNext(legacy -> log.info("Found legacy entry for {} {}", userId, lastName)) - //If we have result, we return a Mono.error with the exception, otherwise return a Mono.empty + //If we have result, we return a Mono.error with the exception, + //otherwise return a Mono.empty .next() .flatMap(legacy -> Mono .error(new ClientAlreadyExistException(legacy.clientNumber())) diff --git a/backend/src/main/java/ca/bc/gov/app/util/JwtPrincipalUtil.java b/backend/src/main/java/ca/bc/gov/app/util/JwtPrincipalUtil.java index b759131056..df2147df20 100644 --- a/backend/src/main/java/ca/bc/gov/app/util/JwtPrincipalUtil.java +++ b/backend/src/main/java/ca/bc/gov/app/util/JwtPrincipalUtil.java @@ -27,7 +27,7 @@ public class JwtPrincipalUtil { * * @param principal JwtAuthenticationToken object from which the provider is to be extracted. * @return The provider of the JWT token in uppercase, or an empty string if the provider is - * blank. + * blank. */ public static String getProvider(JwtAuthenticationToken principal) { return getProviderValue(principal.getTokenAttributes()); @@ -41,7 +41,7 @@ public static String getProvider(JwtAuthenticationToken principal) { * * @param principal Jwt object from which the provider is to be extracted. * @return The provider of the JWT token in uppercase, or an empty string if the provider is - * blank. + * blank. */ public static String getProvider(Jwt principal) { return getProviderValue(principal.getClaims()); @@ -56,7 +56,7 @@ public static String getProvider(Jwt principal) { * * @param principal JwtAuthenticationToken object from which the user ID is to be extracted. * @return The user ID prefixed with the provider in uppercase and a backslash, or an empty string - * if the user ID is blank. + * if the user ID is blank. */ public static String getUserId(JwtAuthenticationToken principal) { return getUserIdValue(principal.getTokenAttributes()); @@ -70,7 +70,7 @@ public static String getUserId(JwtAuthenticationToken principal) { * * @param principal Jwt object from which the user ID is to be extracted. * @return The user ID prefixed with the provider in uppercase and a backslash, or an empty string - * if the user ID is blank. + * if the user ID is blank. */ public static String getUserId(Jwt principal) { return getUserIdValue(principal.getClaims()); @@ -172,7 +172,7 @@ public static String getName(JwtAuthenticationToken principal) { * * @param principal Jwt object from which the display name is to be extracted. * @return The display name, or the concatenated first and last names, or an empty string if both - * the display name and the first and last names are blank. + * the display name and the first and last names are blank. */ public static String getName(Jwt principal) { return getNameValue(principal.getClaims()); @@ -209,7 +209,7 @@ public static String getLastName(Jwt principal) { * @param claims The map containing the JWT claims. * @param claimName The name of the claim to retrieve. * @return The value of the specified claim as a String, or an empty string if the claim is not - * present. + * present. */ private static String getClaimValue(Map claims, String claimName) { return claims @@ -225,7 +225,7 @@ private static String getClaimValue(Map claims, String claimName * * @param claims The map containing the JWT claims. * @return The provider's name in uppercase or "BCSC" if it starts with "ca.bc.gov.flnr.fam.", or - * an empty string if the provider is not specified. + * an empty string if the provider is not specified. */ private static String getProviderValue(Map claims) { String provider = getClaimValue(claims, "custom:idp_name"); @@ -259,7 +259,7 @@ private static String getBusinessNameValue(Map claims) { * * @param claims The map containing the JWT claims. * @return The constructed user ID in the format "Provider\Username" or "Provider\UserID", or an - * empty string if neither the username nor the user ID is present in the claims. + * empty string if neither the username nor the user ID is present in the claims. */ private static String getUserIdValue(Map claims) { return @@ -309,7 +309,7 @@ private static String getEmailValue(Map claims) { * * @param claims The map containing the JWT claims. * @return The display name value as a String, or an empty string if the "custom:idp_display_name" - * claim is not present. + * claim is not present. */ private static String getDisplayNameValue(Map claims) { return getClaimValue(claims, "custom:idp_display_name"); @@ -324,9 +324,10 @@ private static String getDisplayNameValue(Map claims) { * * @param claims The map containing the JWT claims from which the name information is to be * extracted. - * @return A map with keys "businessName", "firstName", "lastName", and "fullName", containing the - * extracted and/or computed name information. If specific name components are not found, their - * values in the map will be empty strings. + * @return A map with keys "businessName", "firstName", "lastName", and "fullName", + * containing the extracted and/or computed name information. + * If specific name components are not found, their values in the map + * will be empty strings. */ private static Map processName(Map claims) { Map additionalInfo = new HashMap<>(); @@ -377,7 +378,7 @@ private static String getLastNameValue(Map claims) { * * @param claims The map containing the JWT claims. * @return The full name (concatenation of first and last names) extracted from the JWT claims, or - * an empty string if not specified. + * an empty string if not specified. */ private static String getNameValue(Map claims) { return processName(claims).get("fullName"); From 55d6769bad426eab0b83cfa82751a2df366025a6 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Tue, 3 Dec 2024 15:25:17 -0800 Subject: [PATCH 29/37] Added more tests --- ...ClientSearchControllerIntegrationTest.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/legacy/src/test/java/ca/bc/gov/app/controller/ClientSearchControllerIntegrationTest.java b/legacy/src/test/java/ca/bc/gov/app/controller/ClientSearchControllerIntegrationTest.java index 8489dfd236..9bc6fdf0ac 100644 --- a/legacy/src/test/java/ca/bc/gov/app/controller/ClientSearchControllerIntegrationTest.java +++ b/legacy/src/test/java/ca/bc/gov/app/controller/ClientSearchControllerIntegrationTest.java @@ -3,8 +3,10 @@ import ca.bc.gov.app.dto.AddressSearchDto; import ca.bc.gov.app.dto.ContactSearchDto; import ca.bc.gov.app.exception.MissingRequiredParameterException; +import ca.bc.gov.app.exception.NoValueFoundException; import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest; import java.util.HashMap; +import java.util.List; import java.util.Optional; import java.util.stream.Stream; import lombok.extern.slf4j.Slf4j; @@ -578,5 +580,57 @@ private static Stream byPredictive() { Arguments.of("matelda", null, null, "00000137", "MATELDA LINDHE (JABBERTYPE)") ); } + + @ParameterizedTest + @MethodSource("byClientNumber") + @DisplayName("Search client by client number and groups") + void shouldFindByClientNumber( + String clientNumber, + List groups, + String expectedClientNumber, + Class exception + ) { + ResponseSpec response = + client + .get() + .uri(uriBuilder -> + uriBuilder + .path("/api/search/clientNumber") + .queryParam("clientNumber", clientNumber) + .queryParam("groups", String.join(",", groups)) + .build(new HashMap<>()) + ) + .header("Content-Type", MediaType.APPLICATION_JSON_VALUE) + .exchange(); + + if (StringUtils.isNotBlank(expectedClientNumber)) { + response + .expectStatus().isOk() + .expectBody() + .jsonPath("$.clientNumber").isNotEmpty() + .jsonPath("$.clientNumber").isEqualTo(expectedClientNumber) + .consumeWith(System.out::println); + } + + if (exception != null) { + response.expectStatus().is4xxClientError(); + } + } + + private static Stream byClientNumber() { + return Stream.of( + // Valid case + Arguments.of("00000123", List.of("CLIENT_ADMIN"), "00000123", null), + + // Invalid case: missing client number + Arguments.of(null, List.of("CLIENT_ADMIN"), null, + MissingRequiredParameterException.class), + + // Invalid case: missing groups + Arguments.of("00000123", List.of(), null, MissingRequiredParameterException.class), + + // Invalid case: client not found + Arguments.of("99999999", List.of("CLIENT_ADMIN"), null, NoValueFoundException.class)); + } } From c0ad9d1cf292c2cf58d34ace64dba1376c60cb08 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Wed, 4 Dec 2024 04:20:20 -0800 Subject: [PATCH 30/37] chore: simplifying boolean check --- .../ca/bc/gov/app/service/client/ClientService.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 a1b919ea87..4ee8e1203f 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 @@ -177,13 +177,12 @@ private Mono populateGoodStandingInd( BcRegistryDocumentDto document ) { Boolean goodStandingInd = document.business().goodStanding(); - String goodStanding; - - if (goodStandingInd == null) { - goodStanding = ""; - } else { - goodStanding = BooleanUtils.toString(goodStandingInd, "Y", "N"); - } + String goodStanding = BooleanUtils.toString( + goodStandingInd, + "Y", + "N", + StringUtils.EMPTY + ); log.info("Setting goodStandingInd for client: {} to {}", forestClientDetailsDto.clientNumber(), goodStanding); From 65fae234d20edf96a3c2557a93aacffb652702e2 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Wed, 4 Dec 2024 10:30:43 -0800 Subject: [PATCH 31/37] Made more code reviews --- .../bc/gov/app/service/ClientSearchServiceIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/legacy/src/test/java/ca/bc/gov/app/service/ClientSearchServiceIntegrationTest.java b/legacy/src/test/java/ca/bc/gov/app/service/ClientSearchServiceIntegrationTest.java index 107f0383f4..5ab6f1207a 100644 --- a/legacy/src/test/java/ca/bc/gov/app/service/ClientSearchServiceIntegrationTest.java +++ b/legacy/src/test/java/ca/bc/gov/app/service/ClientSearchServiceIntegrationTest.java @@ -114,7 +114,7 @@ void shouldSearchWithComplexSearch( .complexSearch(searchValue, PageRequest.of(0, 5)) .as(StepVerifier::create); - if(StringUtils.isNotBlank(expectedClientNumber)) { + if (StringUtils.isNotBlank(expectedClientNumber)) { test .assertNext(dto -> { assertNotNull(dto); From 4ac46f7d0cd9f7b48acc79ffe797c9c91cc22de7 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Wed, 4 Dec 2024 11:18:24 -0800 Subject: [PATCH 32/37] chore: forcing a new build --- legacy/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/legacy/Dockerfile b/legacy/Dockerfile index 62009b82f0..9757727116 100644 --- a/legacy/Dockerfile +++ b/legacy/Dockerfile @@ -43,7 +43,5 @@ USER 1001 EXPOSE ${PORT} HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"' -ENV SPRING_PROFILES_ACTIVE=container - # Startup -ENTRYPOINT ["/app/nr-forest-client-legacy"] \ No newline at end of file +ENTRYPOINT ["/app/nr-forest-client-legacy","--spring.profiles.active=container"] \ No newline at end of file From 00149d368bbc8702039aae9105cad3f2758a3b6c Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Wed, 4 Dec 2024 11:37:20 -0800 Subject: [PATCH 33/37] chore: forcing a new build --- .../ca/bc/gov/app/ApplicationConstants.java | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java b/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java index 8feee9894d..a21d15774b 100644 --- a/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java +++ b/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java @@ -6,50 +6,6 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class ApplicationConstants { public static final String ORACLE_ATTRIBUTE_SCHEMA = "THE"; - public static final String SUBMISSION_POSTPROCESSOR_CHANNEL = "submissionCompletedChannel"; - public static final String NOTIFICATION_PROCESSING_CHANNEL = "notificationProcessingChannel"; - public static final String SUBMISSION_COMPLETION_CHANNEL = "submissionCompletionChannel"; - public static final String SUBMISSION_LEGACY_CHANNEL = "saveToLegacyChannel"; - public static final String SUBMISSION_LIST_CHANNEL = "submissionListChannel"; - public static final String MATCH_CHECKING_CHANNEL = "matchCheckingChannel"; - public static final String FORWARD_CHANNEL = "forwardChannel"; - public static final String AUTO_APPROVE_CHANNEL = "autoApproveChannel"; - public static final String REVIEW_CHANNEL = "reviewChannel"; - public static final String SUBMISSION_MAIL_CHANNEL = "submissionMailChannel"; - public static final String SUBMISSION_LEGACY_CLIENT_CHANNEL = "submissionLegacyClientChannel"; - public static final String SUBMISSION_LEGACY_CLIENT_PERSIST_CHANNEL = "submissionLegacyClientPersistChannel"; - public static final String SUBMISSION_LEGACY_LOCATION_CHANNEL = "submissionLegacyLocationChannel"; - public static final String SUBMISSION_LEGACY_CONTACT_CHANNEL = "submissionLegacyContactChannel"; - public static final String SUBMISSION_LEGACY_AGGREGATE_CHANNEL = "submissionLegacyAggregateChannel"; - public static final String SUBMISSION_LEGACY_NOTIFY_CHANNEL = "submissionLegacyNotifyChannel"; - public static final String SUBMISSION_ID = "submission-id"; - public static final String SUBMISSION_STATUS = "submission-status"; - public static final String SUBMISSION_CLIENTID = "submission-clientid"; - - public static final String SUBMISSION_TYPE = "submission-type-code"; - public static final String SUBMISSION_NAME = "submission-name"; - public static final String SUBMISSION_MESSAGE_SOURCE = "submissionMessages"; - public static final String PROCESSED_MESSAGE_SOURCE = "processedMessage"; - public static final String CREATED_BY = "createdBy"; - public static final String UPDATED_BY = "updatedBy"; - public static final String FOREST_CLIENT_NUMBER = "forestClientNumber"; - public static final String FOREST_CLIENT_NAME = "forestClientName"; - public static final String REGISTRATION_NUMBER = "registrationNumber"; - 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 long ORG_UNIT = 70L; - public static final String LOCATION_CODE = "locationCode"; - public static final String SUBMISSION_MAIL_BUILD_CHANNEL = "submissionMailBuildChannel"; public static final String CLIENT_NUMBER = "CLIENT_NUMBER"; - public static final String CLIENT_TYPE_CODE = "CLIENT_TYPE_CODE"; - public static final String SUBMISSION_LEGACY_INDIVIDUAL_CHANNEL = "submissionLegacyIndividualChannel"; - public static final String SUBMISSION_LEGACY_USP_CHANNEL = "submissionLegacyUSPChannel"; - public static final String SUBMISSION_LEGACY_RSP_CHANNEL = "submissionLegacyRSPChannel"; - public static final String SUBMISSION_LEGACY_OTHER_CHANNEL = "submissionLegacyOtherChannel"; - public static final String CLIENT_EXISTS = "client-exists"; - public static final String CLIENT_SUBMITTER_NAME = "client-submitter-name"; - public static final String CLIENT_NUMBER_LITERAL = "clientNumber"; } From 403b589f2e9300717cc8def527f77780749aeaf4 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Wed, 4 Dec 2024 13:51:26 -0800 Subject: [PATCH 34/37] chore: forcing a new build --- .github/workflows/pr-open.yml | 2 +- backend/Dockerfile | 1 - legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index 0302926e58..6ed25fcb74 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -30,7 +30,7 @@ jobs: matrix: package: [backend, database, frontend, legacy, legacydb, processor] steps: - - uses: bcgov-nr/action-builder-ghcr@v2.3.0 + - uses: bcgov-nr/action-builder-ghcr@v2.2.0 name: Build (${{ matrix.package }}) with: package: ${{ matrix.package }} diff --git a/backend/Dockerfile b/backend/Dockerfile index c2a086b80d..90d295a7de 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -30,7 +30,6 @@ RUN mvn versions:set -DnewVersion=${APP_VERSION} -f pom.xml -DskipTests -Dtests. # Build RUN mvn -Pnative native:compile - ### Deployer FROM gcr.io/distroless/java-base:nonroot AS deploy ARG PORT=8080 diff --git a/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java b/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java index a21d15774b..c312619c52 100644 --- a/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java +++ b/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java @@ -5,7 +5,9 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class ApplicationConstants { + public static final String ORACLE_ATTRIBUTE_SCHEMA = "THE"; public static final String CLIENT_NUMBER = "CLIENT_NUMBER"; public static final String CLIENT_NUMBER_LITERAL = "clientNumber"; + } From 528757e1181b1d31cf13b0bc5bbe3a73bfb7ceed Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Wed, 4 Dec 2024 15:45:18 -0800 Subject: [PATCH 35/37] Made code reviews --- .../service/client/ClientLegacyServiceIntegrationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java index 23310e2e47..09d123c2a8 100644 --- a/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/app/service/client/ClientLegacyServiceIntegrationTest.java @@ -100,7 +100,7 @@ void shouldNotSearchWhenInvalidCasesHitGeneric(Map> paramet @Test @DisplayName("searching legacy for location") - void shouldSearchALocation(){ + void shouldSearchALocation() { legacyStub .stubFor( @@ -116,7 +116,7 @@ void shouldSearchALocation(){ @Test @DisplayName("searching legacy for contact") - void shouldSearchAContact(){ + void shouldSearchAContact() { legacyStub .stubFor( post(urlPathEqualTo("/api/search/contact")) @@ -138,7 +138,7 @@ private static Stream invalidValues() { ); } - private static Stream>> invalidValuesForMap(){ + private static Stream>> invalidValuesForMap() { return Stream.of( Map.of("email",List.of("")), Map.of("email",List.of(" ")), From 9a84c3a1c417b65737d037ba3f8fc79801e4b75e Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Thu, 5 Dec 2024 03:23:41 -0800 Subject: [PATCH 36/37] chore: forcing a new build --- backend/Dockerfile | 2 +- legacy/Dockerfile | 2 +- processor/Dockerfile | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 90d295a7de..bb3a0bdf23 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -44,4 +44,4 @@ EXPOSE ${PORT} HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"' # Startup -ENTRYPOINT ["/app/nr-forest-client-backend","--spring.profiles.active=container"] \ No newline at end of file +ENTRYPOINT ["/app/nr-forest-client-backend","--spring.profiles.active=container"] diff --git a/legacy/Dockerfile b/legacy/Dockerfile index 9757727116..00e9796d75 100644 --- a/legacy/Dockerfile +++ b/legacy/Dockerfile @@ -44,4 +44,4 @@ EXPOSE ${PORT} HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"' # Startup -ENTRYPOINT ["/app/nr-forest-client-legacy","--spring.profiles.active=container"] \ No newline at end of file +ENTRYPOINT ["/app/nr-forest-client-legacy","--spring.profiles.active=container"] diff --git a/processor/Dockerfile b/processor/Dockerfile index 3b368597a7..160917a149 100644 --- a/processor/Dockerfile +++ b/processor/Dockerfile @@ -1,4 +1,3 @@ -### Builder FROM eclipse-temurin:17.0.8.1_1-jdk-jammy AS build # Install Maven From e96c047be8ec66fdb6f78af48570964a2567e90a Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Thu, 5 Dec 2024 04:11:35 -0800 Subject: [PATCH 37/37] chore: forcing a new build --- backend/Dockerfile | 4 +++- legacy/Dockerfile | 4 +++- processor/Dockerfile | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index bb3a0bdf23..3519ab4b1e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -43,5 +43,7 @@ USER 1001 EXPOSE ${PORT} HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"' +ENV SPRING_PROFILES_ACTIVE=container + # Startup -ENTRYPOINT ["/app/nr-forest-client-backend","--spring.profiles.active=container"] +ENTRYPOINT ["/app/nr-forest-client-backend"] diff --git a/legacy/Dockerfile b/legacy/Dockerfile index 00e9796d75..4bc585f391 100644 --- a/legacy/Dockerfile +++ b/legacy/Dockerfile @@ -43,5 +43,7 @@ USER 1001 EXPOSE ${PORT} HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"' +ENV SPRING_PROFILES_ACTIVE=container + # Startup -ENTRYPOINT ["/app/nr-forest-client-legacy","--spring.profiles.active=container"] +ENTRYPOINT ["/app/nr-forest-client-legacy"] diff --git a/processor/Dockerfile b/processor/Dockerfile index 160917a149..c0c67fb645 100644 --- a/processor/Dockerfile +++ b/processor/Dockerfile @@ -42,5 +42,7 @@ USER 1001 EXPOSE ${PORT} HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"' +ENV SPRING_PROFILES_ACTIVE=container + # Startup -ENTRYPOINT ["java", "-jar", "/app/nr-forest-client-processor.jar", "--spring.profiles.active=container"] +ENTRYPOINT ["java", "-jar", "/app/nr-forest-client-processor.jar"]