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 authored Aug 26, 2024
2 parents eccf6e4 + 511fe58 commit f6e8ef5
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public record BcRegistryOfficerDto(
String firstName,
String lastName,
String middleInitial,
String identifier,
String organizationName,
String partyType
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ private BcRegistryPartyDto buildBcRegistryPartyDto(BcRegistryFacetPartyDto party
naming.get("firstName"),
naming.get("lastName"),
null,
StringUtils.EMPTY,
StringUtils.EMPTY,
party.partyType()
),
roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ public class BcRegistryTestConstants {
null,
null,
null,
"BC0123456",
"EXAMPLE COMPANY LTD.",
"organization"
),
List.of(
Expand Down Expand Up @@ -422,6 +424,8 @@ public class BcRegistryTestConstants {
"JOHNATHAN",
"WICK",
null,
null,
null,
"person"
),
List.of(
Expand Down Expand Up @@ -557,6 +561,8 @@ public class BcRegistryTestConstants {
"JOHNATHAN",
"WICK",
"VALELONG",
null,
null,
"person"
),
List.of(
Expand All @@ -573,6 +579,8 @@ public class BcRegistryTestConstants {
"RUSKA",
"ROMA",
null,
null,
null,
"person"
),
List.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import static ca.bc.gov.app.util.ClientValidationUtils.fieldIsMissingErrorMessage;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Named.named;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import ca.bc.gov.app.dto.ValidationError;
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.BcRegistryPartyDto;
import ca.bc.gov.app.dto.client.ClientBusinessInformationDto;
import ca.bc.gov.app.dto.client.ValidationSourceEnum;
import ca.bc.gov.app.service.bcregistry.BcRegistryService;
Expand Down Expand Up @@ -37,38 +40,21 @@ void shouldSupportAllValidationSources(ValidationSourceEnum source, boolean supp
assertEquals(support, validator.supports(source));
}

@ParameterizedTest
@ParameterizedTest(name = "{0}")
@MethodSource("validation")
@DisplayName("Should run validate")
void shouldValidate(
String registrationNumber,
String legalType,
String businessType,
boolean isFoundOnBcRegistry,
boolean isGoodStanding,
BcRegistryDocumentDto document,
String expectedMessage
) {

if (isFoundOnBcRegistry) {
when(service.requestDocumentData(registrationNumber))
.thenReturn(Flux.just(
new BcRegistryDocumentDto(
new BcRegistryBusinessDto(
List.of(),
isGoodStanding,
false,
false,
false,
registrationNumber,
StringUtils.EMPTY,
StringUtils.EMPTY,
StringUtils.EMPTY
),
null,
List.of()
)
)
);
.thenReturn(Flux.just(document));
} else {
when(service.requestDocumentData(registrationNumber))
.thenReturn(Flux.empty());
Expand Down Expand Up @@ -115,19 +101,146 @@ void shouldValidate(
private static Stream<Arguments> validation() {
return
Stream.of(
Arguments.of(StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, false, false,
Arguments.of(
named("all fine, no issues", StringUtils.EMPTY),
StringUtils.EMPTY,
StringUtils.EMPTY,
false,
null,
StringUtils.EMPTY
),

Arguments.of(
named("Registration number missing", StringUtils.EMPTY),
StringUtils.EMPTY,
"R",
false,
null,
fieldIsMissingErrorMessage("registrationNumber")
),

Arguments.of(
named("Big number, no no", "12345678901234"),
StringUtils.EMPTY,
"R",
false,
null,
"has more than 13 characters"
),

Arguments.of(
named("This is what I call good", "XX1234567"),
StringUtils.EMPTY,
"R",
false,
null,
StringUtils.EMPTY
),

Arguments.of(named("Another good day around here", "XX1234567"),
"C", "R", false, null,
StringUtils.EMPTY),
Arguments.of(StringUtils.EMPTY, StringUtils.EMPTY, "R", false, false,
fieldIsMissingErrorMessage("registrationNumber")),
Arguments.of("12345678901234", StringUtils.EMPTY, "R", false, false,
"has more than 13 characters"),
Arguments.of("XX1234567", StringUtils.EMPTY, "R", false, false, StringUtils.EMPTY),
Arguments.of("XX1234567", "C", "R", false, false, StringUtils.EMPTY),
Arguments.of("XX1234567", "SP", "R", false, false,

Arguments.of(named("Oops, not found on bc reg","XX1234567"),
"SP", "R", false,null,
"Incorporation Number was not found in BC Registry"),
Arguments.of("XX1234567", "SP", "R", true, false,

Arguments.of(named("I think you forgot to pay the bills","XX1234567"),
"SP", "R", true,
new BcRegistryDocumentDto(
new BcRegistryBusinessDto(
List.of(),
false,
false,
false,
false,
"XX1234567",
"SAMPLE CORP",
StringUtils.EMPTY,
StringUtils.EMPTY
),
null,
List.of(
new BcRegistryPartyDto(
null,null,
new BcRegistryOfficerDto(
StringUtils.EMPTY,
"Johnathan",
"Wick",
StringUtils.EMPTY,
StringUtils.EMPTY,
StringUtils.EMPTY,
"person"
),
List.of()
)
)
),
"Company is not in goodStanding in BC Registry"),
Arguments.of("XX1234567", "SP", "R", true, true, StringUtils.EMPTY)

Arguments.of(named("Sole prop good for belly","XX1234567"),
"SP", "R", true,
new BcRegistryDocumentDto(
new BcRegistryBusinessDto(
List.of(),
true,
false,
false,
false,
"XX1234567",
"SAMPLE CORP",
StringUtils.EMPTY,
StringUtils.EMPTY
),
null,
List.of(
new BcRegistryPartyDto(
null,null,
new BcRegistryOfficerDto(
StringUtils.EMPTY,
"Johnathan",
"Wick",
StringUtils.EMPTY,
StringUtils.EMPTY,
StringUtils.EMPTY,
"person"
),
List.of()
)
)
), StringUtils.EMPTY),

Arguments.of(named("Sole prop from org is no bueno","XX1234567"),
"SP", "R", true,
new BcRegistryDocumentDto(
new BcRegistryBusinessDto(
List.of(),
true,
false,
false,
false,
"XX1234567",
"SAMPLE CORP",
StringUtils.EMPTY,
StringUtils.EMPTY
),
null,
List.of(
new BcRegistryPartyDto(
null,null,
new BcRegistryOfficerDto(
StringUtils.EMPTY,
StringUtils.EMPTY,
StringUtils.EMPTY,
StringUtils.EMPTY,
StringUtils.EMPTY,
StringUtils.EMPTY,
"organization"
),
List.of()
)
)
), "SAMPLE CORP sole proprietor is not owned by a person")
);
}

Expand Down

0 comments on commit f6e8ef5

Please sign in to comment.