Skip to content

Commit

Permalink
Merge branch 'main' into feat/ci/legacydb
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Aug 27, 2024
2 parents 5dbf49a + a88339b commit fc8c8b1
Show file tree
Hide file tree
Showing 21 changed files with 438 additions and 216 deletions.
6 changes: 3 additions & 3 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.4.0</version>
<version>3.5.0</version>
<executions>
<execution>
<id>integration-tests</id>
Expand All @@ -317,7 +317,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.4.0</version>
<version>3.5.0</version>
<configuration>
<argLine>@{argLine}</argLine>
<skipTests>${skip.unit.tests}</skipTests>
Expand Down Expand Up @@ -446,7 +446,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.8.0</version>
<version>3.10.0</version>
<configuration>
<source>8</source>
<doctitle>Javadoc Documentation for ${project.name} ${project.version}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,21 @@ public BcRegistryService(
* Searches the BC Registry API for {@link BcRegistryFacetSearchResultEntryDto} instances matching
* the given value.
*
* @param value the value to search for
* @param name the name value to search for
* @param identifier the identifier value to search for
* @return a {@link Flux} of matching {@link BcRegistryFacetSearchResultEntryDto} instances
* @throws NoClientDataFound if no matching data is found
* @throws InvalidAccessTokenException if the access token is invalid or expired
*/
public Flux<BcRegistryFacetSearchResultEntryDto> searchByFacets(String value) {
log.info("Searching BC Registry for {}", value);
public Flux<BcRegistryFacetSearchResultEntryDto> searchByFacets(String name, String identifier) {
log.info("Searching BC Registry for {}", name);
return
bcRegistryApi
.post()
.uri("/registry-search/api/v2/search/businesses")
.body(BodyInserters.fromValue(
new BcRegistryFacetRequestBodyDto(
new BcRegistryFacetRequestQueryDto(value, value, null),
new BcRegistryFacetRequestQueryDto(Objects.toString(name,identifier), name, identifier),
Map.of("status", List.of("ACTIVE")),
100,
0
Expand Down Expand Up @@ -190,7 +191,7 @@ public Flux<BcRegistryDocumentDto> requestDocumentData(String value) {
.flatMap(documentKey -> getDocumentData(value, documentKey))
//This will try to load the standing and business data for entries with no documents
.onErrorResume(NoClientDataFound.class, exception ->
searchByFacets(value).next().map(this::buildDocumentData)
searchByFacets(null, value).next().map(this::buildDocumentData)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ public Flux<CodeNameDto> getActiveDistrictCodes(int page, int size) {
return districtCodeRepository
.findAllBy(PageRequest.of(page, size, Sort.by("description")))
.filter(entity -> (currentDate.isBefore(entity.getExpiredAt())
|| currentDate.isEqual(entity.getExpiredAt()))
&&
(currentDate.isAfter(entity.getEffectiveAt())
|| currentDate.isEqual(entity.getEffectiveAt())))
|| currentDate.isEqual(entity.getExpiredAt()))
&&
(currentDate.isAfter(entity.getEffectiveAt())
|| currentDate.isEqual(entity.getEffectiveAt())))
.map(entity -> new CodeNameDto(entity.getCode(), entity.getDescription()));
}

Expand All @@ -127,10 +127,10 @@ public Flux<CodeNameDto> listCountries(int page, int size) {
return countryCodeRepository
.findAllBy(PageRequest.of(page, size, Sort.by("order", "description")))
.filter(entity -> (currentDate.isBefore(entity.getExpiredAt())
|| currentDate.isEqual(entity.getExpiredAt()))
&&
(currentDate.isAfter(entity.getEffectiveAt())
|| currentDate.isEqual(entity.getEffectiveAt())))
|| currentDate.isEqual(entity.getExpiredAt()))
&&
(currentDate.isAfter(entity.getEffectiveAt())
|| currentDate.isEqual(entity.getEffectiveAt())))
.map(entity -> new CodeNameDto(entity.getCountryCode(), entity.getDescription()));
}

Expand Down Expand Up @@ -267,8 +267,9 @@ public Mono<ClientDetailsDto> getClientDetails(

.flatMap(client -> {
// FSADT1-1388: Allow IDIR users to search for any client type
if(provider.equalsIgnoreCase("idir"))
if (provider.equalsIgnoreCase("idir")) {
return Mono.just(client);
}

if (ApplicationConstant.AVAILABLE_CLIENT_TYPES.contains(
ClientValidationUtils.getClientType(
Expand All @@ -291,10 +292,10 @@ public Mono<ClientDetailsDto> getClientDetails(
.filter(document ->
// FSADT1-1388: Allow IDIR users to search for any client type
provider.equalsIgnoreCase("idir") ||
!("SP".equalsIgnoreCase(document.business().legalType())
&& document.parties().size() == 1
&& !document.parties().get(0).isPerson()
)
!("SP".equalsIgnoreCase(document.business().legalType())
&& document.parties().size() == 1
&& !document.parties().get(0).isPerson()
)
)
.flatMap(buildDetails())
.switchIfEmpty(Mono.error(new UnableToProcessRequestException(
Expand All @@ -315,7 +316,7 @@ public Mono<ClientDetailsDto> getClientDetails(
public Flux<ClientLookUpDto> findByClientNameOrIncorporation(String value) {
log.info("Searching for {}", value);
return bcRegistryService
.searchByFacets(value)
.searchByFacets(value, null)
.map(entry -> new ClientLookUpDto(
entry.identifier(),
entry.name(),
Expand Down Expand Up @@ -373,20 +374,20 @@ public Mono<Void> findByIndividual(String userId, String lastName) {
.error(new ClientAlreadyExistException(legacy.clientNumber()))
);
}

public Mono<String> findByUserIdAndLastName(String userId, String lastName) {
return legacyService
.searchIdAndLastName(userId, lastName)
.doOnNext(legacy -> log.info("Found legacy entry for {} {}", userId, lastName))
.next()
.map(ForestClientDto::clientNumber);
}

private Function<BcRegistryDocumentDto, Mono<ClientDetailsDto>> buildDetails() {
return document ->
buildAddress(
document,
buildSimpleClientDetails(document.business(),document.isOwnedByPerson())
buildSimpleClientDetails(document.business(), document.isOwnedByPerson())
);
}

Expand Down Expand Up @@ -536,13 +537,13 @@ private Predicate<ForestClientDto> isMatchWith(BcRegistryDocumentDto document) {
return legacy ->
StringUtils.equals(
StringUtils.defaultString(legacy.registryCompanyTypeCode()) +
StringUtils.defaultString(legacy.corpRegnNmbr()),
StringUtils.defaultString(legacy.corpRegnNmbr()),
document.business().identifier()
) &&
StringUtils.equals(
document.business().legalName(),
legacy.legalName()
);
StringUtils.equals(
document.business().legalName(),
legacy.legalName()
);
}

private Function<ForestClientDto, Mono<ForestClientDto>> triggerEmailDuplicatedClient(
Expand Down Expand Up @@ -594,30 +595,32 @@ public Mono<DistrictDto> getDistrictByCode(String districtCode) {
* Retrieves all active identification types as of the specified target date.
*
* @param targetDate the date to check for active identification types.
* @return a Flux stream of IdentificationTypeDto containing the code, description, and country code of each active identification type.
* @return a Flux stream of IdentificationTypeDto containing the code, description, and country
* code of each active identification type.
*/
public Flux<IdentificationTypeDto> getAllActiveIdentificationTypes(LocalDate targetDate) {
log.info("Loading active identification type codes by {}", targetDate);
return identificationTypeCodeRepository
.findActiveAt(targetDate)
.map(entity -> new IdentificationTypeDto(
entity.getCode(),
entity.getDescription(),
entity.getCountryCode()));
entity.getCode(),
entity.getDescription(),
entity.getCountryCode()));
}

/**
* Retrieves an identification type by its code.
*
* @param idCode the code of the identification type to retrieve.
* @return a Mono containing a CodeNameDto with the code and description of the identification type, or an empty Mono if not found.
* @return a Mono containing a CodeNameDto with the code and description of the identification
* type, or an empty Mono if not found.
*/
public Mono<CodeNameDto> getIdentificationTypeByCode(String idCode) {
log.info("Loading identification type by {}", idCode);
return identificationTypeCodeRepository
.findByCode(idCode)
.map(entity -> new CodeNameDto(entity.getCode(),
entity.getDescription()));
entity.getDescription()));
}

public Mono<CodeNameDto> getProvinceByCountryAndProvinceCode(
Expand All @@ -627,7 +630,7 @@ public Mono<CodeNameDto> getProvinceByCountryAndProvinceCode(
return provinceCodeRepository
.findByCountryCodeAndProvinceCode(countryCode, provinceCode)
.map(entity -> new CodeNameDto(entity.getProvinceCode(),
entity.getDescription()));
entity.getDescription()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private Flux<MatchResult> processSingleLocation(ClientAddressDto location) {
location.city(),
location.province().value(),
location.postalCode(),
location.country().value()
location.country().text()
)
),
FIELD_NAME_PREFIX + location.index() + "].streetAddress",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,6 @@ void shouldGetClientDetails(
bcRegistryStub
.stubFor(
post(urlPathEqualTo("/registry-search/api/v2/search/businesses"))
.withRequestBody(equalToJson(
String.format("""
{
"query": { "value": "%s","name": "%s" },
"categories":{ "status":["ACTIVE"] },
"rows": 100,
"start":0
}""", clientNumber, clientNumber)
)
)
.willReturn(okJson(
BcRegistryTestConstants.BCREG_FACET_ANY
.replace("C0123456", clientNumber)
Expand Down Expand Up @@ -240,16 +230,6 @@ void shouldGetClientDetailsForStaff(
bcRegistryStub
.stubFor(
post(urlPathEqualTo("/registry-search/api/v2/search/businesses"))
.withRequestBody(equalToJson(
String.format("""
{
"query": { "value": "%s","name": "%s" },
"categories":{ "status":["ACTIVE"] },
"rows": 100,
"start":0
}""", clientNumber, clientNumber)
)
)
.willReturn(okJson(
BcRegistryTestConstants.BCREG_FACET_ANY
.replace("C0123456", clientNumber)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void shouldSearch(

FirstStep<BcRegistryFacetSearchResultEntryDto> step =
service
.searchByFacets(data)
.searchByFacets(data,null)
.as(StepVerifier::create);

if (responseStatus != 200) {
Expand Down
30 changes: 30 additions & 0 deletions frontend/cypress/e2e/pages/FormStaffPageFuzzy.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,19 @@ describe("Staff Form Fuzzy Matches", () => {

});

describe("when we go back to the previous step", () => {
beforeEach(function () {
interceptFuzzyMatch(2, "Step 2: full address email match");
fillLocation(0);
clickNext(2);
cy.get('#reviewStatement').should('be.visible');
clickBack();
});
it("does not display the review statement checkbox", () => {
cy.get('#reviewStatement').should('not.exist');
});
});

});

describe('Contacts fuzzy matching',() =>{
Expand Down Expand Up @@ -1279,6 +1292,19 @@ describe("Staff Form Fuzzy Matches", () => {

});

describe("when we go back to the previous step", () => {
beforeEach(function () {
interceptFuzzyMatch(3, "Step 3: full contact email match");
fillContactWithoutName();
clickNext(3);
cy.get('#reviewStatement').should('be.visible');
clickBack();
});
it("does not display the review statement checkbox", () => {
cy.get('#reviewStatement').should('not.exist');
});
});

});

const clickNext = (step: number) => {
Expand All @@ -1290,6 +1316,10 @@ describe("Staff Form Fuzzy Matches", () => {
cy.wait(`@doMatch${step}`);
};

const clickBack = () => {
cy.get("[data-test='wizard-back-button']").click();
};

const clickAddLocation = (index: number) => {
cy.contains("cds-button", "Add another location").should("be.visible").click();
cy.get(`cds-accordion-item[data-focus="address-${index}-heading"]`).focused();
Expand Down
Loading

0 comments on commit fc8c8b1

Please sign in to comment.