getClientTypeByCode(String code) {
return clientTypeCodeRepository
.findByCode(code)
.map(entity -> new CodeNameDto(entity.getCode(),
- entity.getDescription()));
+ entity.getDescription()));
}
-
+
/**
* List Provinces
* List provinces by country (which include states) by page with a defined size.
@@ -205,7 +205,17 @@ public Mono getClientDetails(
)
)
.map(BcRegistryDocumentDto.class::cast)
- .flatMap(buildDetails());
+
+ //if document type is SP and party contains only one entry that is not a person, fail
+ .filter(document ->
+ !("SP".equalsIgnoreCase(document.business().legalType())
+ && document.parties().size() == 1
+ && !document.parties().get(0).isPerson())
+ )
+ .flatMap(buildDetails())
+ .switchIfEmpty(Mono.error(new UnableToProcessRequestException(
+ "Unable to process request. This sole proprietor is not owner by a person"
+ )));
}
/**
@@ -227,7 +237,14 @@ public Flux findByClientNameOrIncorporation(String value) {
entry.status(),
entry.legalType()
)
- );
+ )
+ .flatMap(client ->{
+ if(List.of("A", "I", "S", "SP","RSP","USP").contains(client.legalType())){
+ return Mono.just(client);
+ }
+ return Mono.error(new UnsuportedClientTypeException(client.legalType()));
+ })
+ .doOnError(System.out::println);
}
/**
@@ -291,7 +308,8 @@ private Mono buildAddress(
addressDto.addressCity(),
addressDto.postalCode().trim().replaceAll("\\s+", ""),
index.getAndIncrement(),
- (addressDto.addressType() != null ? addressDto.addressType() : "").concat(" address").toUpperCase()
+ (addressDto.addressType() != null ? addressDto.addressType() : "").concat(
+ " address").toUpperCase()
)
)
.flatMap(address -> loadCountry(address.country().text()).map(address::withCountry))
@@ -303,6 +321,8 @@ private Mono buildAddress(
.defaultIfEmpty(new ArrayList<>())
.flatMap(addresses ->
Flux.fromIterable(document.parties())
+ .filter(party ->
+ !"SP".equalsIgnoreCase(document.business().legalType()) || party.isPerson())
.map(party ->
new ClientContactDto(
null,
@@ -381,21 +401,21 @@ private Function> triggerEmailDuplicatedC
String email, String userName) {
return legacy -> chesService.sendEmail(
- "matched",
- email,
- "Client number application can’t go ahead",
- legacy.description(userName),
- null)
+ "matched",
+ email,
+ "Client number application can’t go ahead",
+ legacy.description(userName),
+ null)
.thenReturn(legacy);
}
private Mono triggerEmail(EmailRequestDto emailRequestDto) {
return chesService.sendEmail(
- emailRequestDto.templateName(),
- emailRequestDto.email(),
- emailRequestDto.subject(),
- emailRequestDto.variables(),
- null);
+ emailRequestDto.templateName(),
+ emailRequestDto.email(),
+ emailRequestDto.subject(),
+ emailRequestDto.variables(),
+ null);
}
}
diff --git a/backend/src/main/java/ca/bc/gov/app/util/ClientValidationUtils.java b/backend/src/main/java/ca/bc/gov/app/util/ClientValidationUtils.java
index b5d48570fd..a2c7e807ef 100644
--- a/backend/src/main/java/ca/bc/gov/app/util/ClientValidationUtils.java
+++ b/backend/src/main/java/ca/bc/gov/app/util/ClientValidationUtils.java
@@ -54,7 +54,7 @@ public static > boolean isValidEnum(
}
if (!EnumUtils.isValidEnum(enumClass, value)) {
- errors.rejectValue(field, String.format("%s has an invalid value", field));
+ errors.rejectValue(field, String.format("%s has an invalid value [%s]", field,value));
return false;
}
return true;
diff --git a/backend/src/main/java/ca/bc/gov/app/validator/client/ClientSubmitRequestValidator.java b/backend/src/main/java/ca/bc/gov/app/validator/client/ClientSubmitRequestValidator.java
index 4318215a90..6e61e2e522 100644
--- a/backend/src/main/java/ca/bc/gov/app/validator/client/ClientSubmitRequestValidator.java
+++ b/backend/src/main/java/ca/bc/gov/app/validator/client/ClientSubmitRequestValidator.java
@@ -8,6 +8,7 @@
import ca.bc.gov.app.dto.client.ClientLocationDto;
import ca.bc.gov.app.dto.client.ClientSubmissionDto;
import java.time.LocalDate;
+import java.util.List;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;
@@ -19,10 +20,11 @@
@Component
@RequiredArgsConstructor
public class ClientSubmitRequestValidator implements Validator {
+
private final RegisteredBusinessInformationValidator registeredBusinessInformationValidator;
private final UnregisteredBusinessInformationValidator unregisteredBusinessInformationValidator;
private final ClientLocationDtoValidator locationDtoValidator;
-
+
@Override
public boolean supports(Class> clazz) {
return ClientSubmissionDto.class.equals(clazz);
@@ -49,14 +51,13 @@ private void validateBusinessInformation(
return;
}
errors.pushNestedPath(businessInformationField);
-
+
String businessType = businessInformation.businessType();
if (StringUtils.isAllBlank(businessType)) {
errors.rejectValue("businessType", "You must choose an option");
errors.popNestedPath();
return;
- }
- else if (!EnumUtils.isValidEnum(BusinessTypeEnum.class, businessType)) {
+ } else if (!EnumUtils.isValidEnum(BusinessTypeEnum.class, businessType)) {
errors.rejectValue("businessType", String.format("%s has an invalid value", "Business type"));
errors.popNestedPath();
return;
@@ -64,19 +65,24 @@ else if (!EnumUtils.isValidEnum(BusinessTypeEnum.class, businessType)) {
String clientType = businessInformation.clientType();
- if(StringUtils.isBlank(clientType)) {
+ if (StringUtils.isBlank(clientType)) {
errors.rejectValue("clientType", "Client does not have a type");
errors.popNestedPath();
return;
}
if (ApplicationConstant.REG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE.equals(clientType)
- || ApplicationConstant.UNREG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE.equals(clientType)
- || ApplicationConstant.INDIVIDUAL_CLIENT_TYPE_CODE.equals(clientType)
+ || ApplicationConstant.UNREG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE.equals(clientType)
+ || ApplicationConstant.INDIVIDUAL_CLIENT_TYPE_CODE.equals(clientType)
) {
validateBirthdate(businessInformation.birthdate(), errors);
}
-
+
+ if (!List.of("A", "I", "S", "USP", "RSP","SP").contains(clientType)) {
+ errors.rejectValue("businessType",
+ String.format("%s %s is not supported at the moment", "Business type",clientType));
+ }
+
errors.popNestedPath();
if (BusinessTypeEnum.U.toString().equals(businessType)) {
@@ -93,8 +99,7 @@ private void validateBirthdate(LocalDate birthdate, Errors errors) {
String dobFieldName = "birthdate";
if (birthdate == null) {
errors.rejectValue(dobFieldName, fieldIsMissingErrorMessage("Birthdate"));
- }
- else {
+ } else {
LocalDate minAgeDate = LocalDate.now().minusYears(19);
if (birthdate.isAfter(minAgeDate)) {
errors.rejectValue(dobFieldName, "Sole proprietorship must be at least 19 years old");
diff --git a/backend/src/main/java/ca/bc/gov/app/validator/client/UnregisteredBusinessInformationValidator.java b/backend/src/main/java/ca/bc/gov/app/validator/client/UnregisteredBusinessInformationValidator.java
index a98fa6103f..d0cb7ea675 100644
--- a/backend/src/main/java/ca/bc/gov/app/validator/client/UnregisteredBusinessInformationValidator.java
+++ b/backend/src/main/java/ca/bc/gov/app/validator/client/UnregisteredBusinessInformationValidator.java
@@ -24,6 +24,12 @@ public void validate(Object target, Errors errors) {
String businessNameField = "businessName";
ValidationUtils.rejectIfEmpty(errors, businessNameField,
fieldIsMissingErrorMessage(businessNameField));
+
+ // fails if businessName does not contain whitespace, Ex: forest1 should fail, but forest 1 should pass
+ String businessName = (String) errors.getFieldValue(businessNameField);
+ if (businessName != null && !businessName.matches(".*\\s+.*")) {
+ errors.rejectValue(businessNameField, "Business name must be composed of first and last name");
+ }
errors.popNestedPath();
}
}
diff --git a/backend/src/main/resources/db/migration/V2__data_initialization.sql b/backend/src/main/resources/db/migration/V2__data_initialization.sql
index ca96949e6a..91e75ab7c0 100644
--- a/backend/src/main/resources/db/migration/V2__data_initialization.sql
+++ b/backend/src/main/resources/db/migration/V2__data_initialization.sql
@@ -31,29 +31,29 @@ insert into nrfc.client_type_code (client_type_code, description, effective_date
insert into nrfc.client_type_code (client_type_code, description, effective_date, create_user) values ('USP', 'Unregistered sole proprietorship', current_timestamp, 'mariamar') on conflict (client_type_code) do nothing;
insert into nrfc.client_type_code (client_type_code, description, effective_date, create_user) values ('RSP', 'Registered sole proprietorship', current_timestamp, 'mariamar') on conflict (client_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('AP', 'Accounts Payable', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('AR', 'Accounts Receivable', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BA', 'First Nations Administrator', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BC', 'First Nations Council Member', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('AP', 'Accounts Payable', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('AR', 'Accounts Receivable', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('BA', 'First Nations Administrator', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('BC', 'First Nations Council Member', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BL', 'Billing', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BM', 'First Nations Manager', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('BN', 'First Nations Treaty Negotiator', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('CH', 'Chief', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('CL', 'Collections', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('BM', 'First Nations Manager', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('BN', 'First Nations Treaty Negotiator', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('CH', 'Chief', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('CL', 'Collections', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('DI', 'Director', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('EX', 'Export', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('GP', 'General Partner', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('IL', 'Interior Log Cost Reporting', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('LB', 'Log Broker', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('LP', 'Limited Partner', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('RC', 'Recreation Agreement Holder', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('EX', 'Export', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('GP', 'General Partner', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('IL', 'Interior Log Cost Reporting', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('LB', 'Log Broker', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('LP', 'Limited Partner', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('RC', 'Recreation Agreement Holder', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('SI', 'Scale Site Contact', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('SP', 'SPAR System Contact', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('SR', 'Stumpage Rates', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('SS', 'Scaling Software Vendor Contact', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('SS', 'Scaling Software Vendor Contact', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('TC', 'BCTS Contractor', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('TN', 'Tenure Administration', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
-insert into nrfc.contact_type_code (contact_type_code, description, effective_date, create_user) values ('TP', 'EDI Trading Partner', current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
+insert into nrfc.contact_type_code (contact_type_code, description, effective_date, expiry_date, create_user) values ('TP', 'EDI Trading Partner', to_date('99991231','YYYYMMDD'), current_timestamp, 'mariamar') on conflict (contact_type_code) do nothing;
insert into nrfc.country_code (country_code, description, effective_date, create_user) values ('AD', 'Andorra', current_timestamp, 'mariamar') on conflict (country_code) do nothing;
insert into nrfc.country_code (country_code, description, effective_date, create_user) values ('AE', 'United Arab Emirates', current_timestamp, 'mariamar') on conflict (country_code) do nothing;
diff --git a/backend/src/test/java/ca/bc/gov/app/TestConstants.java b/backend/src/test/java/ca/bc/gov/app/TestConstants.java
index 092ae94477..c042e4c4d6 100644
--- a/backend/src/test/java/ca/bc/gov/app/TestConstants.java
+++ b/backend/src/test/java/ca/bc/gov/app/TestConstants.java
@@ -348,8 +348,8 @@ public class TestConstants {
"email": "",
"firstName": "JAMES",
"lastName": "BAXTER",
- "middleInitial": "JAMES",
- "partyType": "Director"
+ "middleInitial": "middleInitial",
+ "partyType": "person"
},
"roles": [
{
@@ -411,10 +411,10 @@ public class TestConstants {
"1234",
"Goldfinger",
"R",
- "P",
+ "RSP",
"Y",
- "GP",
- LocalDate.now()
+ "SP",
+ LocalDate.now().minusYears(20)
),
new ClientLocationDto(
List.of(
@@ -450,7 +450,48 @@ public class TestConstants {
new ClientSubmissionDto(
new ClientBusinessInformationDto(
"",
- "James",
+ "James Baxter",
+ "U",
+ "I",
+ "",
+ "SP",
+ LocalDate.of(1975, 1, 31)
+ ),
+ new ClientLocationDto(
+ List.of(
+ new ClientAddressDto(
+ "3570 S Las Vegas Blvd",
+ new ClientValueTextDto("US", ""),
+ new ClientValueTextDto("NV", ""),
+ "Las Vegas", "89109",
+ 0,
+ "Billing Address"
+ )
+ ),
+ List.of(
+ new ClientContactDto(
+ new ClientValueTextDto("LP", "LP"),
+ "James",
+ "Bond",
+ "9876543210",
+ "bond_james_bond@007.com",
+ 0,
+ List.of(
+ new ClientValueTextDto(
+ "0",
+ "Billing Address"
+ )
+ )
+ )
+ )
+ )
+ );
+
+ public static final ClientSubmissionDto UNREGISTERED_BUSINESS_SUBMISSION_BROKEN_DTO =
+ new ClientSubmissionDto(
+ new ClientBusinessInformationDto(
+ "",
+ "forest1",
"U",
"I",
"",
diff --git a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientControllerIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientControllerIntegrationTest.java
index 0f7cf73bdf..0371e41649 100644
--- a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientControllerIntegrationTest.java
+++ b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientControllerIntegrationTest.java
@@ -165,7 +165,7 @@ void shouldListCountryData(Integer page, Integer size, String code, String name)
@MethodSource("provinceCode")
@DisplayName("List provinces by")
void shouldListProvinceData(String countryCode, Integer page, Integer size, String code,
- String name) {
+ String name) {
//This is to allow parameter to be ommitted during test
Function uri = uriBuilder -> {
@@ -274,18 +274,18 @@ void shouldGetClientDetails(
legacyStub
.stubFor(
get(urlPathEqualTo("/search/incorporationOrName"))
- .withQueryParam("incorporationNumber", equalTo("AA0000001"))
- .withQueryParam("companyName", equalTo("SAMPLE COMPANY"))
- .willReturn(okJson(legacyResponse))
+ .withQueryParam("incorporationNumber", equalTo("AA0000001"))
+ .withQueryParam("companyName", equalTo("SAMPLE COMPANY"))
+ .willReturn(okJson(legacyResponse))
);
WebTestClient.BodyContentSpec response =
client
.get()
.uri("/api/clients/{clientNumber}", Map.of("clientNumber", clientNumber))
- .header(ApplicationConstant.USERID_HEADER,"testUserId")
- .header(ApplicationConstant.USERMAIL_HEADER,"test@test.ca")
- .header(ApplicationConstant.USERNAME_HEADER,"Test User")
+ .header(ApplicationConstant.USERID_HEADER, "testUserId")
+ .header(ApplicationConstant.USERMAIL_HEADER, "test@test.ca")
+ .header(ApplicationConstant.USERNAME_HEADER, "Test User")
.exchange()
.expectStatus().isEqualTo(HttpStatus.valueOf(responseStatus))
.expectBody()
@@ -364,9 +364,9 @@ void shouldGetDataFromNameLookup() {
client
.get()
.uri("/api/clients/name/Power")
- .header(ApplicationConstant.USERID_HEADER,"testUserId")
- .header(ApplicationConstant.USERMAIL_HEADER,"test@test.ca")
- .header(ApplicationConstant.USERNAME_HEADER,"Test User")
+ .header(ApplicationConstant.USERID_HEADER, "testUserId")
+ .header(ApplicationConstant.USERMAIL_HEADER, "test@test.ca")
+ .header(ApplicationConstant.USERNAME_HEADER, "Test User")
.exchange()
.expectStatus().isOk()
.expectBody()
@@ -390,9 +390,9 @@ void shouldGetNoDataFromNameLookup() {
client
.get()
.uri("/api/clients/name/Jhon")
- .header(ApplicationConstant.USERID_HEADER,"testUserId")
- .header(ApplicationConstant.USERMAIL_HEADER,"test@test.ca")
- .header(ApplicationConstant.USERNAME_HEADER,"Test User")
+ .header(ApplicationConstant.USERID_HEADER, "testUserId")
+ .header(ApplicationConstant.USERMAIL_HEADER, "test@test.ca")
+ .header(ApplicationConstant.USERNAME_HEADER, "Test User")
.exchange()
.expectStatus().isOk()
.expectBody()
@@ -401,7 +401,7 @@ void shouldGetNoDataFromNameLookup() {
@Test
@DisplayName("Send an email for already existing client")
- void shouldSendEmail(){
+ void shouldSendEmail() {
chesStub
.stubFor(
post("/chess/uri")
@@ -424,7 +424,8 @@ void shouldSendEmail(){
legacyStub
.stubFor(
get(urlPathEqualTo("/search/incorporationOrName"))
- .withQueryParam("incorporationNumber", equalTo(TestConstants.EMAIL_REQUEST.incorporation()))
+ .withQueryParam("incorporationNumber",
+ equalTo(TestConstants.EMAIL_REQUEST.incorporation()))
.withQueryParam("companyName", equalTo(TestConstants.EMAIL_REQUEST.name()))
.willReturn(okJson(TestConstants.LEGACY_OK))
);
@@ -441,7 +442,7 @@ void shouldSendEmail(){
@Test
@DisplayName("get country by code")
- void shoulGgetCountryByCode(){
+ void shoulGgetCountryByCode() {
client
.get()
@@ -475,7 +476,7 @@ private static Stream clientDetailing() {
200, TestConstants.BCREG_DOC_REQ_RES,
200, TestConstants.BCREG_DOC_DATA,
200, TestConstants.BCREG_RESPONSE_OK,
- TestConstants.LEGACY_OK.replace("0000001","0000002")
+ TestConstants.LEGACY_OK.replace("0000001", "0000002")
),
Arguments.of(
"AA0000001",
@@ -519,6 +520,18 @@ private static Stream clientDetailing() {
400, TestConstants.BCREG_400,
401, TestConstants.BCREG_RESPONSE_401,
TestConstants.LEGACY_EMPTY
+ ),
+ Arguments.of(
+ "AA0000001",
+ 200, TestConstants.BCREG_DOC_REQ_RES,
+ 200, TestConstants.BCREG_DOC_DATA
+ .replace("\"partyType\": \"person\"", "\"partyType\": \"organization\"")
+ .replace("\"firstName\": \"JAMES\",", "\"organizationName\": \"OWNER ORG\",")
+ .replace("\"lastName\": \"BAXTER\",", "\"identifier\": \"BB0000001\",")
+ .replace("\"middleInitial\": \"middleInitial\",", "\"id\": \"1234467\",")
+ ,
+ 422, "Unable to process request. This sole proprietor is not owner by a person",
+ TestConstants.LEGACY_EMPTY
)
);
}
diff --git a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java
index d6e71dbacf..48edf92daf 100644
--- a/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java
+++ b/backend/src/test/java/ca/bc/gov/app/controller/client/ClientSubmissionControllerIntegrationTest.java
@@ -1,6 +1,7 @@
package ca.bc.gov.app.controller.client;
import static ca.bc.gov.app.TestConstants.REGISTERED_BUSINESS_SUBMISSION_DTO;
+import static ca.bc.gov.app.TestConstants.UNREGISTERED_BUSINESS_SUBMISSION_BROKEN_DTO;
import static ca.bc.gov.app.TestConstants.UNREGISTERED_BUSINESS_SUBMISSION_DTO;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
@@ -10,6 +11,7 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.TestConstants;
+import ca.bc.gov.app.dto.ValidationError;
import ca.bc.gov.app.dto.client.ClientSubmissionDto;
import ca.bc.gov.app.dto.submissions.SubmissionApproveRejectDto;
import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest;
@@ -210,7 +212,7 @@ void shouldListAndSearch(
.jsonPath("$.[0].name").isEqualTo("Goldfinger")
.jsonPath("$.[0].requestType").isEqualTo("Submission pending processing")
.jsonPath("$.[0].status").isEqualTo("New")
- .jsonPath("$.[0].clientType").isEqualTo("General Partnership")
+ .jsonPath("$.[0].clientType").isEqualTo("Registered sole proprietorship")
.jsonPath("$.[0].user").isEqualTo("testUserId");
}
}
@@ -250,6 +252,25 @@ void shouldApproveOrReject() {
.isEmpty();
}
+ @Test
+ @DisplayName("Submit broken Unregistered Business client data")
+ @Order(7)
+ void shouldSubmitBrokenUnregisteredBusinessData() {
+ client
+ .post()
+ .uri("/api/clients/submissions")
+ .header(ApplicationConstant.USERID_HEADER, "testUserId")
+ .header(ApplicationConstant.USERMAIL_HEADER, "test@mail.ca")
+ .header(ApplicationConstant.USERNAME_HEADER, "Test User")
+ .body(Mono.just(UNREGISTERED_BUSINESS_SUBMISSION_BROKEN_DTO), ClientSubmissionDto.class)
+ .exchange()
+ .expectStatus().isBadRequest()
+ .expectBodyList(ValidationError.class)
+ .hasSize(1)
+ .contains(new ValidationError("businessInformation.businessName",
+ "Business name must be composed of first and last name"));
+ }
+
private static Stream listValues() {
return
Stream.of(
@@ -258,7 +279,7 @@ private static Stream listValues() {
Arguments.of(null, null, 0, 10, true),
Arguments.of(null, null, null, 10, true),
Arguments.of("requestStatus", "N", null, null, true),
- Arguments.of("clientType", "P", null, null, true),
+ Arguments.of("clientType", "RSP", null, null, true),
Arguments.of("name", "Goldfinger", null, null, true),
Arguments.of("name", "Auric", null, null, false),
Arguments.of(null, null, 1, null, false),
diff --git a/frontend/.devcontainer/frontend.code-workspace b/frontend/.devcontainer/frontend.code-workspace
index 4762389c62..7a2c6b8e08 100644
--- a/frontend/.devcontainer/frontend.code-workspace
+++ b/frontend/.devcontainer/frontend.code-workspace
@@ -11,7 +11,7 @@
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
- "source.fixAll.eslint": true
+ "source.fixAll.eslint": "explicit"
},
"editor.tabSize": 2,
"vs-code-prettier-eslint.prettierLast": true,
diff --git a/frontend/cypress/e2e/SubmissionReviewPage.cy.ts b/frontend/cypress/e2e/SubmissionReviewPage.cy.ts
new file mode 100644
index 0000000000..0e447103de
--- /dev/null
+++ b/frontend/cypress/e2e/SubmissionReviewPage.cy.ts
@@ -0,0 +1,188 @@
+import testCases from '../fixtures/test-cases-review-submissions.json';
+
+/* eslint-disable no-undef */
+describe('Submission Review Page', () => {
+
+ //Login before all tests
+ beforeEach(() => {
+ cy.visit("/");
+ cy.wait(500);
+
+ cy.get("#landing-title").should("contain", "Client Management System");
+
+ cy.get("#landing-subtitle").should(
+ "contain",
+ "Create and manage client accounts"
+ );
+
+ cy.login("uattest@gov.bc.ca", "Uat Test", "idir",
+ {
+ given_name: "James",
+ family_name: "Baxter"
+ }
+ );
+
+ //Some simple checks to make sure we are on the list page
+ cy.contains('Submission')
+
+ cy
+ .get('h3')
+ .should('exist')
+ .should('contain', 'Submissions')
+
+ cy
+ .get('.body-compact-01')
+ .should('exist')
+ .should('contain', 'Check and manage client submissions')
+
+ })
+
+ testCases.forEach((testCase) => {
+
+ if(testCase.approved){
+ it(`Should check for ${testCase.name}`, () => {
+ //Load the fixture for the details
+ cy.intercept("GET", "api/clients/submissions/*", {
+ fixture: testCase.fixture,
+ }).as("loadSubmission");
+
+
+ //Click any submission
+ cy
+ .get('[sort-id="0"] > :nth-child(2)')
+ .click()
+
+ cy
+ .wait('@loadSubmission')
+ .its('response.body.submissionStatus')
+ .should('eq', 'Approved')
+
+ cy
+ .get('.submission-details--title > span')
+ .should('contain', 'Auto approved client:')
+
+ cy.get('[data-testid="display-row-icon"]')
+ .should('exist')
+ .should('have.prop', 'tagName', 'svg')
+ .should('have.attr', 'alt', 'Auto approved client');
+
+ cy.get('[data-testid="subtitle"]')
+ .should('exist')
+ .should('contain', 'Check this new client data');
+
+ cy.get('cds-actionable-notification')
+ .should('exist')
+ .should('contain', 'No matching client records or BC Registries standing issues were found. Review the details in the read-only version below.');
+
+ cy.get('.grouping-10 > :nth-child(2) > .body-compact-01')
+ .should('exist')
+ .should('contain', testCase.clientNumber);
+
+ //Go to the submission list page
+ cy.visit('/submissions');
+
+ //Some simple checks to make sure we are on the list page
+ cy.contains('Submission')
+
+ cy
+ .get('h3')
+ .should('exist')
+ .should('contain', 'Submissions')
+
+ cy
+ .get('.body-compact-01')
+ .should('exist')
+ .should('contain', 'Check and manage client submissions')
+
+ });
+ }else{
+ it(`Should check for ${testCase.name}`, () => {
+ //Load the fixture for the details
+ cy.intercept("GET", "api/clients/submissions/*", {
+ fixture: testCase.fixture,
+ }).as("loadSubmission");
+
+
+ //Click any submission
+ cy
+ .get('[sort-id="0"] > :nth-child(2)')
+ .click()
+
+ cy
+ .wait('@loadSubmission')
+ .its('response.body.submissionStatus')
+ .should('eq', 'New')
+
+ cy
+ .get('.submission-details--title > span')
+ .should('contain', 'Review new client:')
+
+ cy.get('[data-testid="display-row-icon"]')
+ .should('exist')
+ .should('have.prop', 'tagName', 'svg')
+ .should('have.attr', 'alt', 'Review new client');
+
+ cy.get('[data-testid="subtitle"]')
+ .should('exist')
+ .should('contain', 'Check and manage this submission for a new client number');
+
+ if(testCase.goodStanding){
+ cy.get('cds-actionable-notification')
+ .should('exist')
+ .should('contain', "Check this client's standing with");
+ }
+
+ if(testCase.incorporationName){
+ cy.get('cds-actionable-notification')
+ .should('exist')
+ .should('contain', "Review their information in the Client Management System to determine if this submission should be approved or rejected:")
+ .should('contain', `Legal name: ${testCase.incorporationName}`);
+ }
+
+ if(testCase.incorporationNumber){
+ cy.get('cds-actionable-notification')
+ .should('exist')
+ .should('contain', "Review their information in the Client Management System to determine if this submission should be approved or rejected:")
+ .should('contain', `Incorporation number: ${testCase.incorporationNumber}`);
+ }
+
+ if(testCase.contact){
+ cy.get('cds-actionable-notification')
+ .should('exist')
+ .should('contain', "Review their information in the Client Management System to determine if this submission should be approved or rejected:")
+ .should('contain', `Contact: ${testCase.contact}`);
+ }
+
+ cy.get('.grouping-15 > [kind="primary"]')
+ .should('exist')
+
+ cy.get('.grouping-15 > [kind="danger"]')
+ .should('exist')
+
+
+
+ });
+ }
+
+ });
+
+
+ afterEach(() => {
+ //Go to the submission list page
+ cy.visit('/submissions');
+
+ //Some simple checks to make sure we are on the list page
+ cy.contains('Submission')
+
+ cy
+ .get('h3')
+ .should('exist')
+ .should('contain', 'Submissions')
+
+ cy
+ .get('.body-compact-01')
+ .should('exist')
+ .should('contain', 'Check and manage client submissions')
+ });
+
+})
diff --git a/frontend/cypress/fixtures/test-case-review-all.json b/frontend/cypress/fixtures/test-case-review-all.json
new file mode 100644
index 0000000000..db94cd27d2
--- /dev/null
+++ b/frontend/cypress/fixtures/test-case-review-all.json
@@ -0,0 +1,58 @@
+{
+ "submissionId": "1",
+ "submissionStatus": "New",
+ "submissionType": "Review new client",
+ "submittedTimestamp": "2024-01-01 00:00:00",
+ "updateTimestamp": "2024-01-02 00:00:00",
+ "approvedTimestamp": "2024-01-03 00:00:00",
+ "updateUser": "Isador Driver",
+ "business": {
+ "businessType": "Registered Business",
+ "incorporationNumber": "GP12345678",
+ "clientNumber":"",
+ "organizationName": "KOVACEK, THOMPSON AND BOYER",
+ "clientType": "General partnership",
+ "goodStanding": null
+ },
+ "contact": [
+ {
+ "index": 0,
+ "contactType": "Accounts Receivable",
+ "firstName": "Test",
+ "lastName": "Uat",
+ "phoneNumber": "2502502550",
+ "emailAddress": "uattest@gov.bc.ca",
+ "locations": [
+ "Mailing address",
+ "Accountant's address"
+ ],
+ "userId": "290fae20-5694-4dfa-84a0-baabae352ad5"
+ }
+ ],
+ "address": [
+ {
+ "index": 0,
+ "streetAddress":"444 Richmond Ave",
+ "country":"Canada",
+ "province":"Saskatchewan",
+ "city":"Hampton",
+ "postalCode": "H0H0H0",
+ "name": "Mailing address"
+ },
+ {
+ "index": 1,
+ "streetAddress":"333 Oak St",
+ "country":"Canada",
+ "province":"British Columbia",
+ "city":"Deer Lake",
+ "postalCode":"V4V4V4",
+ "name": "Accountant's address"
+ }
+ ],
+ "matchers": {
+ "goodStanding": "Value not found",
+ "corporationName":"00141847",
+ "incorporationNumber":"00151847",
+ "contact":"00161847"
+ }
+}
\ No newline at end of file
diff --git a/frontend/cypress/fixtures/test-case-review-auto-approved.json b/frontend/cypress/fixtures/test-case-review-auto-approved.json
new file mode 100644
index 0000000000..2ef8542799
--- /dev/null
+++ b/frontend/cypress/fixtures/test-case-review-auto-approved.json
@@ -0,0 +1,53 @@
+{
+ "submissionId": "1",
+ "submissionStatus": "Approved",
+ "submissionType": "Auto approved client",
+ "submittedTimestamp": "2024-01-01 00:00:00",
+ "updateTimestamp": "2024-01-02 00:00:00",
+ "approvedTimestamp": "2024-01-02 01:00:00",
+ "updateUser": "CLIADMIN",
+ "business": {
+ "businessType": "Registered Business",
+ "incorporationNumber": "XX12321254",
+ "clientNumber":"12345678",
+ "organizationName": "THE TIMBER SOCIETY OF NORTH SASKATCHEWAN AND REGION LLC",
+ "clientType": "Corporation",
+ "goodStanding": "Y"
+ },
+ "contact": [
+ {
+ "index": 0,
+ "contactType": "Accounts Receivable",
+ "firstName": "Test",
+ "lastName": "Uat",
+ "phoneNumber": "2502502550",
+ "emailAddress": "uattest@gov.bc.ca",
+ "locations": [
+ "Mailing address",
+ "Accountant's address"
+ ],
+ "userId": "db3cd337-38b2-4aa7-b18c-dc6ca2383f8a"
+ }
+ ],
+ "address": [
+ {
+ "index": 0,
+ "streetAddress":"1414 Richmond Ave",
+ "country":"Canada",
+ "province":"Saskatchewan",
+ "city":"Hampton",
+ "postalCode": "H0H0H0",
+ "name": "Mailing address"
+ },
+ {
+ "index": 1,
+ "streetAddress":"333 Oak St",
+ "country":"Canada",
+ "province":"British Columbia",
+ "city":"Deer Lake",
+ "postalCode":"V4V4V4",
+ "name": "Accountant's address"
+ }
+ ],
+ "matchers": {}
+}
\ No newline at end of file
diff --git a/frontend/cypress/fixtures/test-case-review-contact.json b/frontend/cypress/fixtures/test-case-review-contact.json
new file mode 100644
index 0000000000..253a100998
--- /dev/null
+++ b/frontend/cypress/fixtures/test-case-review-contact.json
@@ -0,0 +1,55 @@
+{
+ "submissionId": "1",
+ "submissionStatus": "New",
+ "submissionType": "Review new client",
+ "submittedTimestamp": "2024-01-01 00:00:00",
+ "updateTimestamp": "2024-01-02 00:00:00",
+ "approvedTimestamp": "2024-01-03 00:00:00",
+ "updateUser": "Isador Driver",
+ "business": {
+ "businessType": "Registered Business",
+ "incorporationNumber": "GP12345678",
+ "clientNumber":"",
+ "organizationName": "KOVACEK, THOMPSON AND BOYER",
+ "clientType": "General partnership",
+ "goodStanding": null
+ },
+ "contact": [
+ {
+ "index": 0,
+ "contactType": "Accounts Receivable",
+ "firstName": "Test",
+ "lastName": "Uat",
+ "phoneNumber": "2502502550",
+ "emailAddress": "uattest@gov.bc.ca",
+ "locations": [
+ "Mailing address",
+ "Accountant's address"
+ ],
+ "userId": "290fae20-5694-4dfa-84a0-baabae352ad5"
+ }
+ ],
+ "address": [
+ {
+ "index": 0,
+ "streetAddress":"444 Richmond Ave",
+ "country":"Canada",
+ "province":"Saskatchewan",
+ "city":"Hampton",
+ "postalCode": "H0H0H0",
+ "name": "Mailing address"
+ },
+ {
+ "index": 1,
+ "streetAddress":"333 Oak St",
+ "country":"Canada",
+ "province":"British Columbia",
+ "city":"Deer Lake",
+ "postalCode":"V4V4V4",
+ "name": "Accountant's address"
+ }
+ ],
+ "matchers": {
+ "contact":"00161847"
+ }
+}
\ No newline at end of file
diff --git a/frontend/cypress/fixtures/test-case-review-goodstanding.json b/frontend/cypress/fixtures/test-case-review-goodstanding.json
new file mode 100644
index 0000000000..405ee25658
--- /dev/null
+++ b/frontend/cypress/fixtures/test-case-review-goodstanding.json
@@ -0,0 +1,55 @@
+{
+ "submissionId": "1",
+ "submissionStatus": "New",
+ "submissionType": "Review new client",
+ "submittedTimestamp": "2024-01-01 00:00:00",
+ "updateTimestamp": "2024-01-02 00:00:00",
+ "approvedTimestamp": "2024-01-03 00:00:00",
+ "updateUser": "Isador Driver",
+ "business": {
+ "businessType": "Registered Business",
+ "incorporationNumber": "GP12345678",
+ "clientNumber":"",
+ "organizationName": "KOVACEK, THOMPSON AND BOYER",
+ "clientType": "General partnership",
+ "goodStanding": null
+ },
+ "contact": [
+ {
+ "index": 0,
+ "contactType": "Accounts Receivable",
+ "firstName": "Test",
+ "lastName": "Uat",
+ "phoneNumber": "2502502550",
+ "emailAddress": "uattest@gov.bc.ca",
+ "locations": [
+ "Mailing address",
+ "Accountant's address"
+ ],
+ "userId": "290fae20-5694-4dfa-84a0-baabae352ad5"
+ }
+ ],
+ "address": [
+ {
+ "index": 0,
+ "streetAddress":"444 Richmond Ave",
+ "country":"Canada",
+ "province":"Saskatchewan",
+ "city":"Hampton",
+ "postalCode": "H0H0H0",
+ "name": "Mailing address"
+ },
+ {
+ "index": 1,
+ "streetAddress":"333 Oak St",
+ "country":"Canada",
+ "province":"British Columbia",
+ "city":"Deer Lake",
+ "postalCode":"V4V4V4",
+ "name": "Accountant's address"
+ }
+ ],
+ "matchers": {
+ "goodStanding": "Value not found"
+ }
+}
\ No newline at end of file
diff --git a/frontend/cypress/fixtures/test-case-review-incorporationName.json b/frontend/cypress/fixtures/test-case-review-incorporationName.json
new file mode 100644
index 0000000000..adce0b8579
--- /dev/null
+++ b/frontend/cypress/fixtures/test-case-review-incorporationName.json
@@ -0,0 +1,55 @@
+{
+ "submissionId": "1",
+ "submissionStatus": "New",
+ "submissionType": "Review new client",
+ "submittedTimestamp": "2024-01-01 00:00:00",
+ "updateTimestamp": "2024-01-02 00:00:00",
+ "approvedTimestamp": "2024-01-03 00:00:00",
+ "updateUser": "Isador Driver",
+ "business": {
+ "businessType": "Registered Business",
+ "incorporationNumber": "GP12345678",
+ "clientNumber":"",
+ "organizationName": "KOVACEK, THOMPSON AND BOYER",
+ "clientType": "General partnership",
+ "goodStanding": null
+ },
+ "contact": [
+ {
+ "index": 0,
+ "contactType": "Accounts Receivable",
+ "firstName": "Test",
+ "lastName": "Uat",
+ "phoneNumber": "2502502550",
+ "emailAddress": "uattest@gov.bc.ca",
+ "locations": [
+ "Mailing address",
+ "Accountant's address"
+ ],
+ "userId": "290fae20-5694-4dfa-84a0-baabae352ad5"
+ }
+ ],
+ "address": [
+ {
+ "index": 0,
+ "streetAddress":"444 Richmond Ave",
+ "country":"Canada",
+ "province":"Saskatchewan",
+ "city":"Hampton",
+ "postalCode": "H0H0H0",
+ "name": "Mailing address"
+ },
+ {
+ "index": 1,
+ "streetAddress":"333 Oak St",
+ "country":"Canada",
+ "province":"British Columbia",
+ "city":"Deer Lake",
+ "postalCode":"V4V4V4",
+ "name": "Accountant's address"
+ }
+ ],
+ "matchers": {
+ "corporationName":"00141847"
+ }
+}
\ No newline at end of file
diff --git a/frontend/cypress/fixtures/test-case-review-incorporationNumber.json b/frontend/cypress/fixtures/test-case-review-incorporationNumber.json
new file mode 100644
index 0000000000..058f13854c
--- /dev/null
+++ b/frontend/cypress/fixtures/test-case-review-incorporationNumber.json
@@ -0,0 +1,55 @@
+{
+ "submissionId": "1",
+ "submissionStatus": "New",
+ "submissionType": "Review new client",
+ "submittedTimestamp": "2024-01-01 00:00:00",
+ "updateTimestamp": "2024-01-02 00:00:00",
+ "approvedTimestamp": "2024-01-03 00:00:00",
+ "updateUser": "Isador Driver",
+ "business": {
+ "businessType": "Registered Business",
+ "incorporationNumber": "GP12345678",
+ "clientNumber":"",
+ "organizationName": "KOVACEK, THOMPSON AND BOYER",
+ "clientType": "General partnership",
+ "goodStanding": null
+ },
+ "contact": [
+ {
+ "index": 0,
+ "contactType": "Accounts Receivable",
+ "firstName": "Test",
+ "lastName": "Uat",
+ "phoneNumber": "2502502550",
+ "emailAddress": "uattest@gov.bc.ca",
+ "locations": [
+ "Mailing address",
+ "Accountant's address"
+ ],
+ "userId": "290fae20-5694-4dfa-84a0-baabae352ad5"
+ }
+ ],
+ "address": [
+ {
+ "index": 0,
+ "streetAddress":"444 Richmond Ave",
+ "country":"Canada",
+ "province":"Saskatchewan",
+ "city":"Hampton",
+ "postalCode": "H0H0H0",
+ "name": "Mailing address"
+ },
+ {
+ "index": 1,
+ "streetAddress":"333 Oak St",
+ "country":"Canada",
+ "province":"British Columbia",
+ "city":"Deer Lake",
+ "postalCode":"V4V4V4",
+ "name": "Accountant's address"
+ }
+ ],
+ "matchers": {
+ "incorporationNumber":"00151847"
+ }
+}
\ No newline at end of file
diff --git a/frontend/cypress/fixtures/test-cases-review-submissions.json b/frontend/cypress/fixtures/test-cases-review-submissions.json
new file mode 100644
index 0000000000..4885e48173
--- /dev/null
+++ b/frontend/cypress/fixtures/test-cases-review-submissions.json
@@ -0,0 +1,41 @@
+[
+ {
+ "name": "Auto Approved Corporation",
+ "fixture": "test-case-review-auto-approved.json",
+ "approved": true,
+ "clientNumber": "12345678"
+ },
+ {
+ "name": "Review one match - good standing",
+ "fixture": "test-case-review-goodstanding.json",
+ "approved": false,
+ "goodStanding": true
+ },
+ {
+ "name": "Review one match - incorporation name",
+ "fixture": "test-case-review-incorporationName.json",
+ "approved": false,
+ "incorporationName": "00141847"
+ },
+ {
+ "name": "Review one match - incorporation number",
+ "fixture": "test-case-review-incorporationNumber.json",
+ "approved": false,
+ "incorporationNumber": "00151847"
+ },
+ {
+ "name": "Review one match - contact",
+ "fixture": "test-case-review-contact.json",
+ "approved": false,
+ "contact": "00161847"
+ },
+ {
+ "name": "Review multiple matches",
+ "fixture": "test-case-review-all.json",
+ "approved": false,
+ "goodStanding": true,
+ "incorporationName": "00141847",
+ "incorporationNumber": "00151847",
+ "contact": "00161847"
+ }
+]
\ No newline at end of file
diff --git a/frontend/package.json b/frontend/package.json
index c10335d713..772d757b63 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -39,7 +39,9 @@
"posttest:e2e": "mv reports/.nyc_report reports/e2e",
"test:report:merge": "mkdir -p .nyc_output && rm -rf coverage && nyc --config nyc.config.json merge reports && mv coverage.json .nyc_output/out.json && nyc --config nyc.config.json report --reporter lcov --reporter text-summary --report-dir coverage",
"test:report:clean": "mkdir -p reports/.nyc_output/processinfo && mkdir -p coverage",
- "test:build": "start-server-and-test preview http://127.0.0.1:3000/ 'cypress open'"
+ "test:build": "start-server-and-test preview http://127.0.0.1:3000/ 'cypress open'",
+ "test:flush": "rm -rf reports && rm -rf .nyc_output && rm -rf coverage",
+ "posttest:flush":"npm run coverage"
},
"dependencies": {
"@bcgov-nr/nr-fsa-theme": "^1.1.3",
diff --git a/frontend/src/dto/CommonTypesDto.ts b/frontend/src/dto/CommonTypesDto.ts
index 7d68daf02c..af07cf8609 100644
--- a/frontend/src/dto/CommonTypesDto.ts
+++ b/frontend/src/dto/CommonTypesDto.ts
@@ -166,5 +166,7 @@ export interface SubmissionDetailsAddress {
export interface SubmissionDetailsMatchers {
goodStanding: string
- legalName: string
+ corporationName: string
+ incorporationNumber: string
+ contact: string
}
diff --git a/frontend/src/pages/FormBCeIDPage.vue b/frontend/src/pages/FormBCeIDPage.vue
index bedb58d381..49db5a0d7b 100644
--- a/frontend/src/pages/FormBCeIDPage.vue
+++ b/frontend/src/pages/FormBCeIDPage.vue
@@ -328,6 +328,7 @@ const submit = () => {
exitBus.on((event: Record) => {
endAndLogOut.value = event.goodStanding ? event.goodStanding : false;
mailAndLogOut.value = event.duplicated ? event.duplicated : false;
+ endAndLogOut.value = event.nonPersonSP ? event.nonPersonSP : endAndLogOut.value;
});
progressIndicatorBus.on((event: ProgressNotification) => {
diff --git a/frontend/src/pages/SubmissionReviewPage.vue b/frontend/src/pages/SubmissionReviewPage.vue
index 07e9a1a602..062743c6e8 100644
--- a/frontend/src/pages/SubmissionReviewPage.vue
+++ b/frontend/src/pages/SubmissionReviewPage.vue
@@ -56,7 +56,10 @@ const data = ref({
address: [],
matchers: {
goodStanding: '',
- legalName: '',
+ corporationName: '',
+ incorporationNumber: '',
+ contact: '',
+
}
})
@@ -190,6 +193,20 @@ const tagColor = (status: string) =>{
return 'purple'
}
}
+
+const matchingData = computed(() => {
+ let results = []
+ if(data.value.matchers.corporationName){
+ results = [...results, ...data.value.matchers.corporationName.split(',')]
+ }
+ if(data.value.matchers.incorporationNumber){
+ results = [...results, ...data.value.matchers.incorporationNumber.split(',')]
+ }
+ if(data.value.matchers.contact){
+ results = [...results, ...data.value.matchers.contact.split(',')]
+ }
+ return results
+})
@@ -213,8 +230,8 @@ const tagColor = (status: string) =>{
{{ data.submissionType }}: {{ normalizeString(data.business.organizationName) }}
- Check this new client data
- Check and manage this submission for a new client number
+ Check this new client data
+ Check and manage this submission for a new client number
{
{
title="Possible matching record found"
>
-
- {{ data.matchers.legalName.split(',').length }} similar client record was found.
+
+ {{ matchingData.length }} similar client record was found.
Review their information in the Client Management System to determine if this submission should be approved or rejected:
- {{ data.matchers.legalName.split(',').length }} similar client records were found.
+ {{ matchingData.length }} similar client records were found.
Review their information in the Client Management System to determine if this submission should be approved or rejected:
diff --git a/frontend/src/pages/bceidform/BusinessInformationWizardStep.vue b/frontend/src/pages/bceidform/BusinessInformationWizardStep.vue
index 5c9a3a6a79..fa66a488ff 100644
--- a/frontend/src/pages/bceidform/BusinessInformationWizardStep.vue
+++ b/frontend/src/pages/bceidform/BusinessInformationWizardStep.vue
@@ -95,22 +95,25 @@ const autoCompleteUrl = computed(
const showAutoCompleteInfo = ref(false);
const showGoodStandingError = ref(false);
const showDuplicatedError = ref(false);
+const showNonPersonSPError = ref(false);
const showDetailsLoading = ref(false);
const detailsData = ref(null);
const toggleErrorMessages = (
- goodStanding: boolean | null,
- duplicated: boolean | null
+ goodStanding: boolean | null = null,
+ duplicated: boolean | null = null,
+ nonPersonSP: boolean | null = null
) => {
showGoodStandingError.value = goodStanding ?? false;
showDuplicatedError.value = duplicated ?? false;
+ showNonPersonSPError.value = nonPersonSP ?? false;
- if (goodStanding || duplicated) {
+ if (goodStanding || duplicated || nonPersonSP) {
progressIndicatorBus.emit({ kind: "disabled", value: true });
- exitBus.emit({ goodStanding, duplicated });
+ exitBus.emit({ goodStanding, duplicated, nonPersonSP });
} else {
progressIndicatorBus.emit({ kind: "disabled", value: false });
- exitBus.emit({ goodStanding: false, duplicated: false });
+ exitBus.emit({ goodStanding: false, duplicated: false, nonPersonSP: false });
}
};
@@ -122,7 +125,7 @@ watch([autoCompleteResult], () => {
validation.business = false;
if (autoCompleteResult.value && autoCompleteResult.value.code) {
- toggleErrorMessages(false, false);
+ toggleErrorMessages(false, false, false);
formData.value.businessInformation.incorporationNumber =
autoCompleteResult.value.code;
@@ -152,11 +155,15 @@ watch([autoCompleteResult], () => {
showDetailsLoading.value = true;
watch(error, () => {
if (error.value.response?.status === 409) {
- toggleErrorMessages(null, true);
+ toggleErrorMessages(null, true, null);
+ return;
+ }
+ if (error.value.response?.status === 422) {
+ toggleErrorMessages(null, null, true);
return;
}
if (error.value.response?.status === 404) {
- toggleErrorMessages(null, null);
+ toggleErrorMessages();
validation.business = true;
emit("update:data", formData.value);
return;
@@ -275,7 +282,7 @@ const bcRegistryEmail = "BCRegistries@gov.bc.ca";
Loading client details...
+ v-if="(showAutoCompleteInfo && selectedOption === BusinessTypeEnum.R) || showGoodStandingError || showDuplicatedError || showNonPersonSPError">
+
+
+
+ Looks like “{{ formData.businessInformation.businessName }}” is not
+ owned by a person. Please select another entry or logout.
+
+
+
+
diff --git a/frontend/stub/__files/response-autocomplete.json b/frontend/stub/__files/response-autocomplete.json
index a0a81e88a3..647104f1bb 100644
--- a/frontend/stub/__files/response-autocomplete.json
+++ b/frontend/stub/__files/response-autocomplete.json
@@ -46,5 +46,11 @@
"name":"The Great Pacific Forest Company",
"status":"ACTIVE",
"legalType": "SP"
+ },
+ {
+ "code":"FM7654321",
+ "name":"British Columbia Forest Products",
+ "status":"ACTIVE",
+ "legalType": "SP"
}
]
diff --git a/frontend/stub/mappings/backend.json b/frontend/stub/mappings/backend.json
index b21fe0dce1..f113141962 100644
--- a/frontend/stub/mappings/backend.json
+++ b/frontend/stub/mappings/backend.json
@@ -37,6 +37,18 @@
"transformers": ["response-template"]
}
},
+ {
+ "name":"BC Registry Details Non Person",
+ "request": {
+ "url": "/api/clients/FM7654321",
+ "method": "GET"
+ },
+ "response": {
+ "status": 422,
+ "body": "Unable to process request. This sole proprietor is not owner by a person",
+ "transformers": ["response-template"]
+ }
+ },
{
"name":"Country Codes",
diff --git a/legacy/openshift.deploy.yml b/legacy/openshift.deploy.yml
index ec4b13f8bf..ff7680f261 100644
--- a/legacy/openshift.deploy.yml
+++ b/legacy/openshift.deploy.yml
@@ -142,12 +142,12 @@ objects:
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}
- key: oracle-user
+ key: oracle-user-write
- name: ORACLEDB_PASSWORD
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}
- key: oracle-password
+ key: oracle-password-write
- name: ORACLEDB_DATABASE
valueFrom:
secretKeyRef:
diff --git a/legacy/pom.xml b/legacy/pom.xml
index 67024de06e..0723f9bfb5 100644
--- a/legacy/pom.xml
+++ b/legacy/pom.xml
@@ -44,7 +44,7 @@
${maven.build.timestamp}
yyyy-MM-dd HH:mm:ss
- 1.19.3
+ 1.19.1
5.9.1
1.9.1
@@ -90,7 +90,16 @@
lombok
true
-
+
+ org.mapstruct
+ mapstruct
+ 1.5.5.Final
+
+
+ org.mapstruct
+ mapstruct-processor
+ 1.5.5.Final
+
org.dhatim
fastexcel
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 f5bdca6d91..ed401f532d 100644
--- a/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java
+++ b/legacy/src/main/java/ca/bc/gov/app/ApplicationConstants.java
@@ -1,9 +1,55 @@
package ca.bc.gov.app;
+import java.util.List;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@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 INCORPORATION_NUMBER = "incorporationNumber";
+ 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";
+
}
diff --git a/legacy/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java b/legacy/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java
index 1fbfd00c77..e15b6f2ef8 100644
--- a/legacy/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java
+++ b/legacy/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java
@@ -1,10 +1,17 @@
package ca.bc.gov.app.configuration;
+import ca.bc.gov.app.dto.ClientNameCodeDto;
+import ca.bc.gov.app.dto.ForestClientDto;
+import org.springframework.aot.hint.annotation.RegisterReflectionForBinding;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;
@Configuration
+@RegisterReflectionForBinding({
+ ClientNameCodeDto.class,
+ ForestClientDto.class
+})
public class GlobalServiceConfiguration {
@Bean
diff --git a/legacy/src/main/java/ca/bc/gov/app/controller/ClientContactController.java b/legacy/src/main/java/ca/bc/gov/app/controller/ClientContactController.java
new file mode 100644
index 0000000000..66461fe6a5
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/controller/ClientContactController.java
@@ -0,0 +1,43 @@
+package ca.bc.gov.app.controller;
+
+import ca.bc.gov.app.dto.ForestClientContactDto;
+import ca.bc.gov.app.service.ClientContactService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+@RestController
+@Slf4j
+@RequestMapping(value = "/api/contacts", produces = MediaType.APPLICATION_JSON_VALUE)
+@RequiredArgsConstructor
+public class ClientContactController {
+
+ private final ClientContactService service;
+
+ @PostMapping
+ @ResponseStatus(HttpStatus.CREATED)
+ public Mono saveLocation(@RequestBody ForestClientContactDto dto) {
+ return service.saveAndGetIndex(dto);
+ }
+
+ @GetMapping("/search")
+ public Flux findIndividuals(
+ @RequestParam String firstName,
+ @RequestParam String lastName,
+ @RequestParam String email,
+ @RequestParam String phone
+ ) {
+ return service.search(firstName, lastName, email, phone);
+ }
+
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/controller/ClientController.java b/legacy/src/main/java/ca/bc/gov/app/controller/ClientController.java
new file mode 100644
index 0000000000..5f5fccd74b
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/controller/ClientController.java
@@ -0,0 +1,31 @@
+package ca.bc.gov.app.controller;
+
+import ca.bc.gov.app.dto.ForestClientDto;
+import ca.bc.gov.app.service.ClientService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
+
+@RestController
+@Slf4j
+@RequestMapping(value = "/api/clients", produces = MediaType.APPLICATION_JSON_VALUE)
+@RequiredArgsConstructor
+public class ClientController {
+
+
+ private final ClientService service;
+
+ @PostMapping
+ @ResponseStatus(HttpStatus.CREATED)
+ public Mono saveLocation(@RequestBody ForestClientDto dto){
+ return service.saveAndGetIndex(dto);
+ }
+
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/controller/ClientDoingBusinessAsController.java b/legacy/src/main/java/ca/bc/gov/app/controller/ClientDoingBusinessAsController.java
new file mode 100644
index 0000000000..048df5eac1
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/controller/ClientDoingBusinessAsController.java
@@ -0,0 +1,40 @@
+package ca.bc.gov.app.controller;
+
+import ca.bc.gov.app.dto.ClientDoingBusinessAsDto;
+import ca.bc.gov.app.exception.NoValueFoundException;
+import ca.bc.gov.app.service.ClientDoingBusinessAsService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+@RestController
+@Slf4j
+@RequestMapping(value = "/api/dba", produces = MediaType.APPLICATION_JSON_VALUE)
+@RequiredArgsConstructor
+public class ClientDoingBusinessAsController {
+
+ private final ClientDoingBusinessAsService service;
+
+ @PostMapping
+ @ResponseStatus(HttpStatus.CREATED)
+ public Mono saveLocation(@RequestBody ClientDoingBusinessAsDto dto) {
+ return service.saveAndGetIndex(dto);
+ }
+
+ @GetMapping("/search")
+ public Flux search(@RequestParam String dbaName){
+ return service.search(dbaName).switchIfEmpty(Flux.error(new NoValueFoundException(dbaName)));
+
+ }
+
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/controller/ClientLocationController.java b/legacy/src/main/java/ca/bc/gov/app/controller/ClientLocationController.java
new file mode 100644
index 0000000000..683f2abfdd
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/controller/ClientLocationController.java
@@ -0,0 +1,30 @@
+package ca.bc.gov.app.controller;
+
+import ca.bc.gov.app.dto.ForestClientLocationDto;
+import ca.bc.gov.app.service.ClientLocationService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
+
+@RestController
+@Slf4j
+@RequestMapping(value = "/api/locations", produces = MediaType.APPLICATION_JSON_VALUE)
+@RequiredArgsConstructor
+public class ClientLocationController {
+
+ private final ClientLocationService service;
+
+ @PostMapping
+ @ResponseStatus(HttpStatus.CREATED)
+ public Mono saveLocation(@RequestBody ForestClientLocationDto dto){
+ return service.saveAndGetIndex(dto);
+ }
+
+}
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 d60698f320..b5a695822e 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.ForestClientDto;
import ca.bc.gov.app.service.ClientSearchService;
+import java.time.LocalDate;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
@@ -28,5 +29,20 @@ public Flux findByIncorporationOrName(
.findByIncorporationOrName(incorporationNumber, companyName);
}
+ @GetMapping("/individual")
+ public Flux findIndividuals(
+ @RequestParam String firstName,
+ @RequestParam String lastName,
+ @RequestParam LocalDate dob
+ ) {
+ return service.findByIndividual(firstName, lastName, dob);
+ }
+
+ @GetMapping("/match")
+ public Flux matchBy(
+ @RequestParam String companyName
+ ) {
+ return service.matchBy(companyName);
+ }
}
diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ClientDoingBusinessAsDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ClientDoingBusinessAsDto.java
new file mode 100644
index 0000000000..68f582c409
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/dto/ClientDoingBusinessAsDto.java
@@ -0,0 +1,14 @@
+package ca.bc.gov.app.dto;
+
+import lombok.With;
+
+@With
+public record ClientDoingBusinessAsDto(
+ String clientNumber,
+ String doingBusinessAsName,
+ String createdBy,
+ String updatedBy,
+ Long orgUnit
+) {
+
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientContactDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientContactDto.java
new file mode 100644
index 0000000000..517100602f
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientContactDto.java
@@ -0,0 +1,15 @@
+package ca.bc.gov.app.dto;
+
+public record ForestClientContactDto(
+ String clientNumber,
+ String clientLocnCode,
+ String contactCode,
+ String contactName,
+ String businessPhone,
+ String emailAddress,
+ String createdBy,
+ String updatedBy,
+ Long orgUnit
+) {
+
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDto.java
index 9bd148ee63..5c4074676e 100644
--- a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDto.java
+++ b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientDto.java
@@ -1,5 +1,7 @@
package ca.bc.gov.app.dto;
+import java.time.LocalDate;
+
public record ForestClientDto(
String clientNumber,
String clientName,
@@ -7,13 +9,15 @@ public record ForestClientDto(
String legalMiddleName,
String clientStatusCode,
String clientTypeCode,
+ LocalDate birthdate,
String clientIdTypeCode,
String clientIdentification,
String registryCompanyTypeCode,
String corpRegnNmbr,
- String clientAcronym,
- String wcbFirmNumber,
- String ocgSupplierNmbr,
- String clientComment
+ String clientComment,
+ String createdBy,
+ String updatedBy,
+ Long orgUnit
) {
+
}
diff --git a/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientLocationDto.java b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientLocationDto.java
new file mode 100644
index 0000000000..61692ae519
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/dto/ForestClientLocationDto.java
@@ -0,0 +1,35 @@
+package ca.bc.gov.app.dto;
+
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+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/legacy/src/main/java/ca/bc/gov/app/entity/ClientDoingBusinessAsEntity.java b/legacy/src/main/java/ca/bc/gov/app/entity/ClientDoingBusinessAsEntity.java
index 4be12c6280..b4bcc1a190 100644
--- a/legacy/src/main/java/ca/bc/gov/app/entity/ClientDoingBusinessAsEntity.java
+++ b/legacy/src/main/java/ca/bc/gov/app/entity/ClientDoingBusinessAsEntity.java
@@ -2,6 +2,7 @@
import static ca.bc.gov.app.ApplicationConstants.ORACLE_ATTRIBUTE_SCHEMA;
+import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -20,10 +21,25 @@
public class ClientDoingBusinessAsEntity {
@Id
+ @Column("CLIENT_DBA_ID")
+ private Integer id;
@Column("CLIENT_NUMBER")
private String clientNumber;
-
@Column("DOING_BUSINESS_AS_NAME")
private String doingBusinessAsName;
+ @Column("ADD_TIMESTAMP")
+ private LocalDateTime createdAt;
+ @Column("ADD_USERID")
+ private String createdBy;
+ @Column("UPDATE_TIMESTAMP")
+ private LocalDateTime updatedAt;
+ @Column("UPDATE_USERID")
+ private String updatedBy;
+ @Column("UPDATE_ORG_UNIT")
+ private Long updatedByUnit;
+ @Column("ADD_ORG_UNIT")
+ private Long createdByUnit;
+ @Column("REVISION_COUNT")
+ private Long revision;
}
diff --git a/legacy/src/main/java/ca/bc/gov/app/entity/ClientLocationEntity.java b/legacy/src/main/java/ca/bc/gov/app/entity/ClientLocationEntity.java
deleted file mode 100644
index 15b4dd24c2..0000000000
--- a/legacy/src/main/java/ca/bc/gov/app/entity/ClientLocationEntity.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package ca.bc.gov.app.entity;
-
-
-import static ca.bc.gov.app.ApplicationConstants.ORACLE_ATTRIBUTE_SCHEMA;
-
-import java.time.LocalDate;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.With;
-import org.springframework.data.annotation.Id;
-import org.springframework.data.relational.core.mapping.Column;
-import org.springframework.data.relational.core.mapping.Table;
-
-@NoArgsConstructor
-@AllArgsConstructor
-@Data
-@Builder
-@With
-@Table(name = "CLIENT_LOCATION", schema = ORACLE_ATTRIBUTE_SCHEMA)
-public class ClientLocationEntity {
-
- @Id
- @Column("CLIENT_NUMBER")
- private String clientNumber;
-
- @Column("CLIENT_LOCN_CODE")
- private String clientLocnCode;
-
- @Column("CLIENT_LOCN_NAME")
- private String clientLocnName;
-
- @Column("HDBS_COMPANY_CODE")
- private String hdbsCompanyCode;
-
- @Column("ADDRESS_1")
- private String addressOne;
-
- @Column("ADDRESS_2")
- private String addressTwo;
-
- @Column("ADDRESS_3")
- private String addressThree;
-
- @Column("CITY")
- private String city;
-
- @Column("PROVINCE")
- private String province;
-
- @Column("POSTAL_CODE")
- private String postalCode;
-
- @Column("COUNTRY")
- private String country;
-
- @Column("BUSINESS_PHONE")
- private String businessPhone;
-
- @Column("HOME_PHONE")
- private String homePhone;
-
- @Column("CELL_PHONE")
- private String cellPhone;
-
- @Column("FAX_NUMBER")
- private String faxNumber;
-
- @Column("EMAIL_ADDRESS")
- private String emailAddress;
-
- @Column("LOCN_EXPIRED_IND ")
- private String locnExpiredInd;
-
- @Column("RETURNED_MAIL_DATE")
- private LocalDate returnedMailDate;
-
- @Column("TRUST_LOCATION_IND")
- private String trustLocationInd;
-
- @Column("CLI_LOCN_COMMENT ")
- private String cliLocnComment;
-
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientContactEntity.java b/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientContactEntity.java
similarity index 93%
rename from processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientContactEntity.java
rename to legacy/src/main/java/ca/bc/gov/app/entity/ForestClientContactEntity.java
index 37dff989e3..4447c259c0 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientContactEntity.java
+++ b/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientContactEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.legacy;
+package ca.bc.gov.app.entity;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
@@ -46,9 +46,9 @@ public class ForestClientContactEntity {
@Column("UPDATE_USERID")
private String updatedBy;
@Column("UPDATE_ORG_UNIT")
- private Long updateOrgUnit;
+ private Long updatedByUnit;
@Column("ADD_ORG_UNIT")
- private Long addOrgUnit;
+ private Long createdByUnit;
@Column("REVISION_COUNT")
private Long revision;
}
diff --git a/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientEntity.java b/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientEntity.java
index a13342e79c..cf59f6967c 100644
--- a/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientEntity.java
+++ b/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientEntity.java
@@ -3,12 +3,18 @@
import static ca.bc.gov.app.ApplicationConstants.ORACLE_ATTRIBUTE_SCHEMA;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.With;
import org.springframework.data.annotation.Id;
+import org.springframework.data.annotation.Transient;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;
@@ -23,44 +29,59 @@ public class ForestClientEntity {
@Id
@Column("CLIENT_NUMBER")
private String clientNumber;
-
@Column("CLIENT_NAME")
private String clientName;
-
@Column("LEGAL_FIRST_NAME")
private String legalFirstName;
-
@Column("LEGAL_MIDDLE_NAME")
private String legalMiddleName;
-
@Column("CLIENT_STATUS_CODE")
private String clientStatusCode;
-
@Column("CLIENT_TYPE_CODE")
private String clientTypeCode;
-
+ @Column("BIRTHDATE")
+ private LocalDate birthdate;
@Column("CLIENT_ID_TYPE_CODE")
private String clientIdTypeCode;
-
@Column("CLIENT_IDENTIFICATION ")
private String clientIdentification;
-
@Column("REGISTRY_COMPANY_TYPE_CODE")
private String registryCompanyTypeCode;
-
@Column("CORP_REGN_NMBR")
private String corpRegnNmbr;
-
@Column("CLIENT_ACRONYM")
private String clientAcronym;
-
@Column("WCB_FIRM_NUMBER")
private String wcbFirmNumber;
-
@Column("OCG_SUPPLIER_NMBR")
private String ocgSupplierNmbr;
-
@Column("CLIENT_COMMENT")
private String clientComment;
+ @Column("ADD_TIMESTAMP")
+ private LocalDateTime createdAt;
+ @Column("ADD_USERID")
+ private String createdBy;
+ @Column("UPDATE_TIMESTAMP")
+ private LocalDateTime updatedAt;
+ @Column("UPDATE_USERID")
+ private String updatedBy;
+ @Column("UPDATE_ORG_UNIT")
+ private Long updatedByUnit;
+ @Column("ADD_ORG_UNIT")
+ private Long createdByUnit;
+ @Column("REVISION_COUNT")
+ private Long revision;
+
+
+ @Transient
+ public String getName(){
+ if(Objects.equals(this.clientTypeCode, "I")){
+ return Stream.of(this.legalFirstName, this.legalMiddleName, this.clientName)
+ .filter(Objects::nonNull)
+ .collect(Collectors.joining(" "));
+ }else{
+ return this.clientName;
+ }
+ }
}
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientLocationEntity.java b/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientLocationEntity.java
similarity index 95%
rename from processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientLocationEntity.java
rename to legacy/src/main/java/ca/bc/gov/app/entity/ForestClientLocationEntity.java
index 285b13e8a1..6401fe6e11 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientLocationEntity.java
+++ b/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientLocationEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.legacy;
+package ca.bc.gov.app.entity;
import java.time.LocalDate;
@@ -70,9 +70,9 @@ public class ForestClientLocationEntity {
@Column("UPDATE_USERID")
private String updatedBy;
@Column("UPDATE_ORG_UNIT")
- private Long updateOrgUnit;
+ private Long updatedByUnit;
@Column("ADD_ORG_UNIT")
- private Long addOrgUnit;
+ private Long createdByUnit;
@Column("REVISION_COUNT")
private Long revision;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientLocationEntityKey.java b/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientLocationEntityKey.java
similarity index 92%
rename from processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientLocationEntityKey.java
rename to legacy/src/main/java/ca/bc/gov/app/entity/ForestClientLocationEntityKey.java
index fa685859de..0c5685d559 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientLocationEntityKey.java
+++ b/legacy/src/main/java/ca/bc/gov/app/entity/ForestClientLocationEntityKey.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.legacy;
+package ca.bc.gov.app.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
diff --git a/legacy/src/main/java/ca/bc/gov/app/exception/NoValueFoundException.java b/legacy/src/main/java/ca/bc/gov/app/exception/NoValueFoundException.java
new file mode 100644
index 0000000000..ea96623b12
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/exception/NoValueFoundException.java
@@ -0,0 +1,12 @@
+package ca.bc.gov.app.exception;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.server.ResponseStatusException;
+
+@ResponseStatus(HttpStatus.NOT_FOUND)
+public class NoValueFoundException extends ResponseStatusException {
+ public NoValueFoundException(String errorMessage) {
+ super(HttpStatus.NOT_FOUND,"No value found for " + errorMessage);
+ }
+}
\ No newline at end of file
diff --git a/legacy/src/main/java/ca/bc/gov/app/mappers/AbstractForestClientMapper.java b/legacy/src/main/java/ca/bc/gov/app/mappers/AbstractForestClientMapper.java
new file mode 100644
index 0000000000..a7228e3ac8
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/mappers/AbstractForestClientMapper.java
@@ -0,0 +1,31 @@
+package ca.bc.gov.app.mappers;
+
+import java.time.LocalDateTime;
+import java.util.Objects;
+import org.mapstruct.InheritInverseConfiguration;
+import org.mapstruct.Named;
+
+public interface AbstractForestClientMapper {
+
+ D toDto(E entity);
+
+ @InheritInverseConfiguration
+ E toEntity(D dto);
+
+
+ @Named("EmptySpaceQualifier")
+ default String defaultEmptySpace(Object origin) {
+ return " ";
+ }
+
+ @Named("CurrentDateTimeQualifier")
+ default LocalDateTime currentDateTime(Object origin){
+ return LocalDateTime.now();
+ }
+
+ @Named("InitialRevisionQualifier")
+ default Long initialRevision(Object value) {
+ return Objects.isNull(value) || !(value instanceof Long) ? 1L : (Long) value;
+ }
+
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientContactMapper.java b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientContactMapper.java
new file mode 100644
index 0000000000..a7c405c76a
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientContactMapper.java
@@ -0,0 +1,50 @@
+package ca.bc.gov.app.mappers;
+
+import ca.bc.gov.app.dto.ForestClientContactDto;
+import ca.bc.gov.app.entity.ForestClientContactEntity;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.MappingConstants;
+import org.springframework.stereotype.Component;
+
+@Component
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
+public interface ForestClientContactMapper extends
+ AbstractForestClientMapper {
+
+ @Override
+ @Mapping(
+ source = "updatedByUnit",
+ target = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ ForestClientContactDto toDto(ForestClientContactEntity entity);
+
+ @Override
+ @Mapping(
+ target = "createdAt",
+ source = "clientNumber",
+ qualifiedByName = "CurrentDateTimeQualifier"
+ )
+ @Mapping(
+ target = "updatedAt",
+ source = "clientNumber",
+ qualifiedByName = "CurrentDateTimeQualifier"
+ )
+ @Mapping(
+ target = "createdByUnit",
+ source = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ @Mapping(
+ target = "updatedByUnit",
+ source = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ @Mapping(
+ target = "revision",
+ source = "clientNumber",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ ForestClientContactEntity toEntity(ForestClientContactDto dto);
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapper.java b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapper.java
new file mode 100644
index 0000000000..8bca91ddb8
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapper.java
@@ -0,0 +1,50 @@
+package ca.bc.gov.app.mappers;
+
+import ca.bc.gov.app.dto.ClientDoingBusinessAsDto;
+import ca.bc.gov.app.entity.ClientDoingBusinessAsEntity;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.MappingConstants;
+import org.springframework.stereotype.Component;
+
+@Component
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
+public interface ForestClientDoingBusinessAsMapper extends
+ AbstractForestClientMapper {
+
+ @Override
+ @Mapping(
+ source = "updatedByUnit",
+ target = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ ClientDoingBusinessAsDto toDto(ClientDoingBusinessAsEntity entity);
+
+ @Override
+ @Mapping(
+ target = "createdAt",
+ source = "clientNumber",
+ qualifiedByName = "CurrentDateTimeQualifier"
+ )
+ @Mapping(
+ target = "updatedAt",
+ source = "clientNumber",
+ qualifiedByName = "CurrentDateTimeQualifier"
+ )
+ @Mapping(
+ target = "createdByUnit",
+ source = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ @Mapping(
+ target = "updatedByUnit",
+ source = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ @Mapping(
+ target = "revision",
+ source = "clientNumber",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ ClientDoingBusinessAsEntity toEntity(ClientDoingBusinessAsDto dto);
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientLocationMapper.java b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientLocationMapper.java
new file mode 100644
index 0000000000..a16cf03d7d
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientLocationMapper.java
@@ -0,0 +1,50 @@
+package ca.bc.gov.app.mappers;
+
+import ca.bc.gov.app.dto.ForestClientLocationDto;
+import ca.bc.gov.app.entity.ForestClientLocationEntity;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.MappingConstants;
+import org.springframework.stereotype.Component;
+
+@Component
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
+public interface ForestClientLocationMapper extends
+ AbstractForestClientMapper {
+
+ @Override
+ @Mapping(
+ source = "updatedByUnit",
+ target = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ ForestClientLocationDto toDto(ForestClientLocationEntity entity);
+
+ @Override
+ @Mapping(
+ target = "createdAt",
+ source = "clientNumber",
+ qualifiedByName = "CurrentDateTimeQualifier"
+ )
+ @Mapping(
+ target = "updatedAt",
+ source = "clientNumber",
+ qualifiedByName = "CurrentDateTimeQualifier"
+ )
+ @Mapping(
+ target = "createdByUnit",
+ source = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ @Mapping(
+ target = "updatedByUnit",
+ source = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ @Mapping(
+ target = "revision",
+ source = "clientNumber",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ ForestClientLocationEntity toEntity(ForestClientLocationDto dto);
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientMapper.java b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientMapper.java
new file mode 100644
index 0000000000..612895511c
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/mappers/ForestClientMapper.java
@@ -0,0 +1,56 @@
+package ca.bc.gov.app.mappers;
+
+import ca.bc.gov.app.dto.ForestClientDto;
+import ca.bc.gov.app.entity.ForestClientEntity;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.MappingConstants;
+import org.springframework.stereotype.Component;
+
+@Component
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
+public interface ForestClientMapper extends
+ AbstractForestClientMapper {
+
+ @Override
+ @Mapping(
+ target = "wcbFirmNumber",
+ source = "clientNumber",
+ qualifiedByName = "EmptySpaceQualifier",
+ defaultValue = " "
+ )
+ @Mapping(
+ target = "updatedAt",
+ source = "clientNumber",
+ qualifiedByName = "CurrentDateTimeQualifier"
+ )
+ @Mapping(
+ target = "createdAt",
+ source = "clientNumber",
+ qualifiedByName = "CurrentDateTimeQualifier"
+ )
+ @Mapping(
+ target = "createdByUnit",
+ source = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ @Mapping(
+ target = "updatedByUnit",
+ source = "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ @Mapping(
+ target = "revision",
+ source = "clientNumber",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ ForestClientEntity toEntity(ForestClientDto dto);
+
+ @Override
+ @Mapping(
+ source = "updatedByUnit",
+ target= "orgUnit",
+ qualifiedByName = "InitialRevisionQualifier"
+ )
+ ForestClientDto toDto(ForestClientEntity entity);
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/repository/ClientDoingBusinessAsRepository.java b/legacy/src/main/java/ca/bc/gov/app/repository/ClientDoingBusinessAsRepository.java
index 54d41136fa..d609a3164d 100644
--- a/legacy/src/main/java/ca/bc/gov/app/repository/ClientDoingBusinessAsRepository.java
+++ b/legacy/src/main/java/ca/bc/gov/app/repository/ClientDoingBusinessAsRepository.java
@@ -2,15 +2,25 @@
import ca.bc.gov.app.entity.ClientDoingBusinessAsEntity;
import org.springframework.data.domain.Pageable;
+import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
@Repository
public interface ClientDoingBusinessAsRepository extends
ReactiveCrudRepository,
ReactiveSortingRepository {
- Flux findBy(Pageable page);
+ Mono existsByClientNumber(String clientNumber);
+
+ @Query("""
+ SELECT *
+ FROM THE.CLIENT_DOING_BUSINESS_AS
+ WHERE
+ UTL_MATCH.JARO_WINKLER_SIMILARITY(UPPER(DOING_BUSINESS_AS_NAME),UPPER(:companyName)) >= 95
+ ORDER BY CLIENT_NUMBER""")
+ Flux matchBy(String companyName);
}
diff --git a/legacy/src/main/java/ca/bc/gov/app/repository/ClientLocationRepository.java b/legacy/src/main/java/ca/bc/gov/app/repository/ClientLocationRepository.java
deleted file mode 100644
index 53962c0d33..0000000000
--- a/legacy/src/main/java/ca/bc/gov/app/repository/ClientLocationRepository.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package ca.bc.gov.app.repository;
-
-import ca.bc.gov.app.entity.ClientLocationEntity;
-import org.springframework.data.repository.reactive.ReactiveCrudRepository;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public interface ClientLocationRepository
- extends ReactiveCrudRepository {
-}
diff --git a/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientContactRepository.java b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientContactRepository.java
new file mode 100644
index 0000000000..93b267f4d9
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientContactRepository.java
@@ -0,0 +1,25 @@
+package ca.bc.gov.app.repository;
+
+import ca.bc.gov.app.entity.ForestClientContactEntity;
+import ca.bc.gov.app.entity.ForestClientEntity;
+import org.springframework.data.r2dbc.repository.Query;
+import org.springframework.data.repository.reactive.ReactiveCrudRepository;
+import reactor.core.publisher.Flux;
+
+public interface ForestClientContactRepository
+ extends ReactiveCrudRepository {
+
+ @Query("""
+ SELECT *
+ FROM THE.CLIENT_CONTACT
+ WHERE
+ UTL_MATCH.JARO_WINKLER_SIMILARITY(UPPER(CONTACT_NAME),UPPER(:contactName)) >= 95
+ OR UPPER(BUSINESS_PHONE) = UPPER(:businessPhone)
+ OR UPPER(EMAIL_ADDRESS) = UPPER(:email)""")
+ Flux matchBy(
+ String contactName,
+ String email,
+ String businessPhone
+ );
+
+}
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientLocationRepository.java b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientLocationRepository.java
similarity index 62%
rename from processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientLocationRepository.java
rename to legacy/src/main/java/ca/bc/gov/app/repository/ForestClientLocationRepository.java
index a8375f7a0a..d9e2c66eb9 100644
--- a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientLocationRepository.java
+++ b/legacy/src/main/java/ca/bc/gov/app/repository/ForestClientLocationRepository.java
@@ -1,7 +1,7 @@
-package ca.bc.gov.app.repository.legacy;
+package ca.bc.gov.app.repository;
-import ca.bc.gov.app.entity.legacy.ForestClientLocationEntity;
-import ca.bc.gov.app.entity.legacy.ForestClientLocationEntityKey;
+import ca.bc.gov.app.entity.ForestClientLocationEntity;
+import ca.bc.gov.app.entity.ForestClientLocationEntityKey;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
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 c524f8344d..c89cfeb405 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,7 +1,7 @@
package ca.bc.gov.app.repository;
import ca.bc.gov.app.entity.ForestClientEntity;
-import org.springframework.data.domain.Pageable;
+import java.time.LocalDateTime;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor;
@@ -15,21 +15,36 @@ public interface ForestClientRepository extends ReactiveCrudRepository,
ReactiveSortingRepository {
- Flux findBy(Pageable page);
-
- @Query("""
- select * from FOREST_CLIENT x
- where x.CLIENT_TYPE_CODE = 'B'
- and x.CLIENT_STATUS_CODE = 'ACT'""")
- Flux findAllFirstNationBandClients();
-
@Query("""
- select * from FOREST_CLIENT x
- where (x.REGISTRY_COMPANY_TYPE_CODE || x.CORP_REGN_NMBR) = :incorporationNumber
- or x.CLIENT_NAME = :companyName""")
+ SELECT * FROM FOREST_CLIENT x
+ WHERE (UPPER(x.REGISTRY_COMPANY_TYPE_CODE) || x.CORP_REGN_NMBR) = UPPER(:incorporationNumber)
+ OR UPPER(x.CLIENT_NAME) = UPPER(:companyName)
+ OR (x.CLIENT_ID_TYPE_CODE = 'BCRE' and x.CLIENT_IDENTIFICATION = UPPER(:incorporationNumber))
+ AND x.CLIENT_STATUS_CODE = 'ACT'""")
Flux findClientByIncorporationOrName(
@Param("incorporationNumber") String incorporationNumber,
@Param("companyName") String companyName
);
+ @Query("""
+ SELECT *
+ FROM THE.FOREST_CLIENT
+ WHERE
+ UPPER(LEGAL_FIRST_NAME) = UPPER(:firstName)
+ AND UPPER(CLIENT_NAME) = UPPER(:lastName)
+ AND BIRTHDATE = :dob
+ AND CLIENT_STATUS_CODE = 'ACT'
+ AND CLIENT_TYPE_CODE = 'I'
+ ORDER BY CLIENT_NUMBER""")
+ Flux findByIndividual(String firstName, String lastName, LocalDateTime dob);
+
+ @Query("""
+ SELECT *
+ FROM THE.FOREST_CLIENT
+ WHERE
+ UTL_MATCH.JARO_WINKLER_SIMILARITY(UPPER(CLIENT_NAME),UPPER(:companyName)) >= 95
+ AND CLIENT_STATUS_CODE = 'ACT'
+ ORDER BY CLIENT_NUMBER""")
+ Flux matchBy(String companyName);
+
}
diff --git a/legacy/src/main/java/ca/bc/gov/app/service/ClientContactService.java b/legacy/src/main/java/ca/bc/gov/app/service/ClientContactService.java
new file mode 100644
index 0000000000..2ede5164e1
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/service/ClientContactService.java
@@ -0,0 +1,110 @@
+package ca.bc.gov.app.service;
+
+import ca.bc.gov.app.ApplicationConstants;
+import ca.bc.gov.app.dto.ForestClientContactDto;
+import ca.bc.gov.app.entity.ForestClientContactEntity;
+import ca.bc.gov.app.mappers.AbstractForestClientMapper;
+import ca.bc.gov.app.repository.ForestClientContactRepository;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
+import org.springframework.data.relational.core.query.Criteria;
+import org.springframework.data.relational.core.query.Query;
+import org.springframework.stereotype.Service;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+@RequiredArgsConstructor
+@Service
+@Slf4j
+public class ClientContactService {
+
+ private final R2dbcEntityOperations entityTemplate;
+ private final ForestClientContactRepository repository;
+ private final AbstractForestClientMapper mapper;
+
+ public Mono saveAndGetIndex(ForestClientContactDto dto) {
+ return
+ Mono
+ .just(dto)
+ .filterWhen(locationDto ->
+ locateClientContact(
+ locationDto.clientNumber(),
+ locationDto.clientLocnCode(),
+ locationDto.contactName()
+ )
+ .map(forestClientLocation -> false) // means you can't create it
+ .defaultIfEmpty(true) // means you can create it
+ )
+ .map(mapper::toEntity)
+ .flatMap(entity -> getNextContactId().map(entity::withClientContactId))
+ .flatMap(entity -> entityTemplate
+ .insert(ForestClientContactEntity.class)
+ .using(entity)
+ )
+ .doOnNext(forestClientContact ->
+ log.info(
+ "Saved forest client contact {} {}",
+ forestClientContact.getClientNumber(),
+ forestClientContact.getContactName()
+ )
+ )
+ .map(ForestClientContactEntity::getClientNumber);
+ }
+
+ public Flux search(
+ String firstName,
+ String lastName,
+ String email,
+ String phone
+ ) {
+ return
+ repository
+ .matchBy(String.join(" ", firstName, lastName), email, phone)
+ .doOnNext(forestClientContact ->
+ log.info(
+ "Found forest client contact {} {}",
+ forestClientContact.getClientNumber(),
+ forestClientContact.getContactName()
+ )
+ )
+ .map(mapper::toDto);
+ }
+
+ private Flux locateClientContact(
+ String clientNumber,
+ String locationCode,
+ String contactName
+ ) {
+ return
+ entityTemplate
+ .select(
+ Query
+ .query(
+ Criteria
+ .where(ApplicationConstants.CLIENT_NUMBER)
+ .is(clientNumber)
+ .and("CLIENT_LOCN_CODE").is(locationCode)
+ .and("CONTACT_NAME").is(contactName.toUpperCase())
+ ),
+ ForestClientContactEntity.class
+ )
+ .doOnNext(forestClientLocation -> log.info(
+ "Forest client location {} {} already exists",
+ forestClientLocation.getClientLocnCode(),
+ forestClientLocation.getContactName()
+ )
+ );
+ }
+
+ private Mono getNextContactId() {
+ return entityTemplate
+ .getDatabaseClient()
+ .sql("SELECT THE.client_contact_seq.NEXTVAL FROM dual")
+ .fetch()
+ .first()
+ .map(row -> row.get("NEXTVAL"))
+ .map(String::valueOf);
+ }
+
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/service/ClientDoingBusinessAsService.java b/legacy/src/main/java/ca/bc/gov/app/service/ClientDoingBusinessAsService.java
new file mode 100644
index 0000000000..7358570798
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/service/ClientDoingBusinessAsService.java
@@ -0,0 +1,94 @@
+package ca.bc.gov.app.service;
+
+import ca.bc.gov.app.ApplicationConstants;
+import ca.bc.gov.app.dto.ClientDoingBusinessAsDto;
+import ca.bc.gov.app.entity.ClientDoingBusinessAsEntity;
+import ca.bc.gov.app.mappers.AbstractForestClientMapper;
+import ca.bc.gov.app.repository.ClientDoingBusinessAsRepository;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
+import org.springframework.data.relational.core.query.Criteria;
+import org.springframework.data.relational.core.query.Query;
+import org.springframework.stereotype.Service;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+@RequiredArgsConstructor
+@Service
+@Slf4j
+public class ClientDoingBusinessAsService {
+
+ private final R2dbcEntityOperations entityTemplate;
+ private final ClientDoingBusinessAsRepository repository;
+ private final AbstractForestClientMapper mapper;
+
+ public Mono saveAndGetIndex(ClientDoingBusinessAsDto dto) {
+ return
+ Mono
+ .just(dto)
+ .filterWhen(dbaDto ->
+ locateDoingBusinessAs(
+ dbaDto.clientNumber(),
+ dbaDto.doingBusinessAsName()
+ )
+ .map(forestClientLocation -> false) // means you can't create it
+ .defaultIfEmpty(true) // means you can create it
+ )
+ .map(mapper::toEntity)
+ .flatMap(entity -> getNextDoingBusinessAs().map(entity::withId))
+ .flatMap(entity -> entityTemplate
+ .insert(ClientDoingBusinessAsEntity.class)
+ .using(entity)
+ )
+ .doOnNext(forestClientContact ->
+ log.info(
+ "Saved forest client doing business as {} {}",
+ forestClientContact.getClientNumber(),
+ forestClientContact.getDoingBusinessAsName()
+ )
+ )
+ .map(ClientDoingBusinessAsEntity::getClientNumber);
+ }
+
+ private Flux locateDoingBusinessAs(
+ String clientNumber,
+ String businessName
+ ) {
+ return
+ entityTemplate
+ .select(
+ Query
+ .query(
+ Criteria
+ .where(ApplicationConstants.CLIENT_NUMBER)
+ .is(clientNumber)
+ .and("DOING_BUSINESS_AS_NAME").is(businessName)
+ ),
+ ClientDoingBusinessAsEntity.class
+ )
+ .doOnNext(dba -> log.info(
+ "Forest client doing business as {} {} already exists",
+ dba.getDoingBusinessAsName(),
+ dba.getClientNumber()
+ )
+ );
+ }
+
+ private Mono getNextDoingBusinessAs() {
+ return
+ entityTemplate
+ .getDatabaseClient()
+ .sql("select THE.client_dba_seq.NEXTVAL from dual")
+ .fetch()
+ .first()
+ .map(row -> row.get("NEXTVAL"))
+ .map(String::valueOf)
+ .map(Integer::parseInt);
+ }
+
+ public Flux search(String dbaName) {
+ return repository.matchBy(dbaName)
+ .map(mapper::toDto);
+ }
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/service/ClientLocationService.java b/legacy/src/main/java/ca/bc/gov/app/service/ClientLocationService.java
new file mode 100644
index 0000000000..3265d389f5
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/service/ClientLocationService.java
@@ -0,0 +1,63 @@
+package ca.bc.gov.app.service;
+
+import ca.bc.gov.app.ApplicationConstants;
+import ca.bc.gov.app.dto.ForestClientLocationDto;
+import ca.bc.gov.app.entity.ForestClientLocationEntity;
+import ca.bc.gov.app.mappers.AbstractForestClientMapper;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
+import org.springframework.data.relational.core.query.Criteria;
+import org.springframework.data.relational.core.query.Query;
+import org.springframework.stereotype.Service;
+import reactor.core.publisher.Mono;
+
+@RequiredArgsConstructor
+@Service
+@Slf4j
+public class ClientLocationService {
+
+ private final R2dbcEntityOperations entityTemplate;
+ private final AbstractForestClientMapper mapper;
+
+ public Mono saveAndGetIndex(ForestClientLocationDto dto) {
+ return
+ Mono
+ .just(dto)
+ .filterWhen(locationDto ->
+ locateClientLocation(locationDto.clientNumber(), locationDto.clientLocnCode())
+ .map(forestClientLocation -> false) // means you can't create it
+ .defaultIfEmpty(true) // means you can create it
+ )
+ .map(mapper::toEntity)
+ .flatMap(entity -> entityTemplate
+ .insert(ForestClientLocationEntity.class)
+ .using(entity)
+ )
+ .map(ForestClientLocationEntity::getClientNumber);
+ }
+
+ private Mono locateClientLocation(
+ String clientNumber,
+ String locationCode
+ ) {
+ return
+ entityTemplate
+ .selectOne(
+ Query
+ .query(
+ Criteria
+ .where("CLIENT_LOCN_CODE").is(locationCode)
+ .and(ApplicationConstants.CLIENT_NUMBER).is(clientNumber)
+ ),
+ ForestClientLocationEntity.class
+ )
+ .doOnNext(forestClientLocation -> log.info(
+ "Forest client location {} {} already exists",
+ forestClientLocation.getClientLocnCode(),
+ forestClientLocation.getClientLocnName()
+ )
+ );
+ }
+
+}
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 b8ca141cfa..8b02612aa1 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
@@ -1,9 +1,11 @@
package ca.bc.gov.app.service;
import ca.bc.gov.app.dto.ForestClientDto;
+import ca.bc.gov.app.entity.ForestClientEntity;
import ca.bc.gov.app.exception.MissingRequiredParameterException;
+import ca.bc.gov.app.mappers.AbstractForestClientMapper;
import ca.bc.gov.app.repository.ForestClientRepository;
-import ca.bc.gov.app.util.MonoUtil;
+import java.time.LocalDate;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -16,6 +18,7 @@
public class ClientSearchService {
private final ForestClientRepository forestClientRepository;
+ private final AbstractForestClientMapper mapper;
public Flux findByIncorporationOrName(
String incorporationNumber,
@@ -29,26 +32,34 @@ public Flux findByIncorporationOrName(
return
forestClientRepository
.findClientByIncorporationOrName(incorporationNumber, companyName)
- .doOnNext(MonoUtil.logContent(log))
- .map(entity ->
- new ForestClientDto(
- entity.getClientNumber(),
- entity.getClientName(),
- entity.getLegalFirstName(),
- entity.getLegalMiddleName(),
- entity.getClientStatusCode(),
- entity.getClientTypeCode(),
- entity.getClientIdTypeCode(),
- entity.getClientIdentification(),
- entity.getRegistryCompanyTypeCode(),
- entity.getCorpRegnNmbr(),
- entity.getClientAcronym(),
- entity.getWcbFirmNumber(),
- entity.getOcgSupplierNmbr(),
- entity.getClientComment()
- )
- )
- .doOnNext(MonoUtil.logContent(log));
+ .map(mapper::toDto)
+ .doOnNext(dto -> log.info("Found client: {} {}", dto.clientNumber(), dto.clientName()));
}
+ public Flux findByIndividual(
+ String firstName,
+ String lastName,
+ LocalDate dob
+ ) {
+
+ if (StringUtils.isAnyBlank(firstName, lastName) || dob == null) {
+ throw new MissingRequiredParameterException("firstName, lastName, or dob");
+ }
+
+ return
+ forestClientRepository
+ .findByIndividual(firstName, lastName, dob.atStartOfDay())
+ .map(mapper::toDto)
+ .doOnNext(
+ dto -> log.info("Found individual: {} {}", dto.clientNumber(), dto.clientName()));
+ }
+
+
+ public Flux matchBy(String companyName) {
+ return
+ forestClientRepository
+ .matchBy(companyName)
+ .map(mapper::toDto)
+ .doOnNext(dto -> log.info("Found match: {} {}", dto.clientNumber(), dto.clientName()));
+ }
}
diff --git a/legacy/src/main/java/ca/bc/gov/app/service/ClientService.java b/legacy/src/main/java/ca/bc/gov/app/service/ClientService.java
new file mode 100644
index 0000000000..93dd2a0f81
--- /dev/null
+++ b/legacy/src/main/java/ca/bc/gov/app/service/ClientService.java
@@ -0,0 +1,104 @@
+package ca.bc.gov.app.service;
+
+import ca.bc.gov.app.dto.ForestClientDto;
+import ca.bc.gov.app.entity.ForestClientEntity;
+import ca.bc.gov.app.mappers.AbstractForestClientMapper;
+import ca.bc.gov.app.repository.ForestClientRepository;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
+import org.springframework.stereotype.Service;
+import reactor.core.publisher.Mono;
+
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class ClientService {
+
+ private final R2dbcEntityOperations entityTemplate;
+ private final ForestClientRepository repository;
+ private final AbstractForestClientMapper mapper;
+
+ public Mono saveAndGetIndex(ForestClientDto dto) {
+ return
+ Mono
+ .just(dto)
+ .map(mapper::toEntity)
+ .filterWhen(this::locateClient)
+ .flatMap(entity -> getNextClientNumber().map(entity::withClientNumber))
+ .flatMap(entity -> entityTemplate
+ .insert(ForestClientEntity.class)
+ .using(entity)
+ )
+ .doOnNext(forestClientContact ->
+ log.info(
+ "Saved forest client {} {}",
+ forestClientContact.getClientNumber(),
+ forestClientContact.getName()
+ )
+ )
+ .map(ForestClientEntity::getClientNumber);
+ }
+
+ private Mono locateClient(
+ ForestClientEntity entity
+ ) {
+
+ if (
+ entity
+ .getClientTypeCode()
+ .equalsIgnoreCase("I")
+ ) {
+ return
+ repository
+ .findByIndividual(
+ entity.getLegalFirstName(),
+ entity.getClientName(),
+ entity.getBirthdate().atStartOfDay()
+ )
+ .map(client -> false) // means you can't create it
+ .defaultIfEmpty(true)
+ .doOnNext(tag -> log.info("No individual client found {}", tag))
+ .last();
+ }
+
+ return
+ repository
+ .findClientByIncorporationOrName(
+ entity.getClientName().toUpperCase(),
+ String.join(
+ StringUtils.EMPTY,
+ entity.getRegistryCompanyTypeCode().toUpperCase(),
+ entity.getCorpRegnNmbr()
+ )
+ )
+ .map(client -> false) // means you can't create it
+ .defaultIfEmpty(true)
+ .doOnNext(tag -> log.info("No client with type {} found {}", entity
+ .getClientTypeCode(), tag))
+ .last();
+ }
+
+ private Mono getNextClientNumber() {
+ return
+ entityTemplate
+ .getDatabaseClient()
+ .sql("""
+ UPDATE
+ max_client_nmbr
+ SET
+ client_number = (SELECT LPAD(TO_NUMBER(NVL(max(CLIENT_NUMBER),'0'))+1,8,'0') FROM FOREST_CLIENT)"""
+ )
+ .fetch()
+ .rowsUpdated()
+ .then(
+ entityTemplate
+ .getDatabaseClient()
+ .sql("SELECT client_number FROM max_client_nmbr")
+ .map((row, rowMetadata) -> row.get("client_number", String.class))
+ .first()
+ );
+ }
+
+}
diff --git a/legacy/src/main/java/ca/bc/gov/app/util/MonoUtil.java b/legacy/src/main/java/ca/bc/gov/app/util/MonoUtil.java
deleted file mode 100644
index f89792d377..0000000000
--- a/legacy/src/main/java/ca/bc/gov/app/util/MonoUtil.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package ca.bc.gov.app.util;
-
-import java.util.function.Consumer;
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.slf4j.Logger;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class MonoUtil {
- /**
- * Log Content
- * Log the content of the future.
- *
- * @param The type that will be passed through the future.
- * @return the same content of the future
- */
- public static Consumer logContent(Logger log) {
- return received -> log.info("{}", received);
- }
-
-}
diff --git a/legacy/src/test/java/ca/bc/gov/app/controller/ClientContactControllerIntegrationTest.java b/legacy/src/test/java/ca/bc/gov/app/controller/ClientContactControllerIntegrationTest.java
new file mode 100644
index 0000000000..7780c4e3e5
--- /dev/null
+++ b/legacy/src/test/java/ca/bc/gov/app/controller/ClientContactControllerIntegrationTest.java
@@ -0,0 +1,101 @@
+package ca.bc.gov.app.controller;
+
+
+import ca.bc.gov.app.dto.ForestClientContactDto;
+import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest;
+import java.util.Map;
+import java.util.stream.Stream;
+import lombok.extern.slf4j.Slf4j;
+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.MethodSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.reactive.server.WebTestClient;
+import org.springframework.web.reactive.function.BodyInserters;
+
+@Slf4j
+@DisplayName("Integrated Test | Client Contact Controller")
+class ClientContactControllerIntegrationTest extends
+ AbstractTestContainerIntegrationTest {
+
+ @Autowired
+ protected WebTestClient client;
+
+ @ParameterizedTest
+ @MethodSource("saveContact")
+ @DisplayName("Save a contact")
+ void shouldSaveLocation(String clientNumber) {
+ client
+ .post()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/contacts")
+ .build(Map.of())
+ )
+ .header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
+ .body(BodyInserters.fromValue(
+ new ForestClientContactDto(
+ clientNumber,
+ "00",
+ "BL",
+ "James Baxter",
+ "2502502550",
+ "mail@mail.ca",
+ "Test",
+ "Test",
+ 1L
+ )
+ )
+ )
+ .exchange()
+ .expectStatus().isCreated()
+ .expectBody(String.class)
+ .equals(clientNumber);
+ }
+
+ @ParameterizedTest
+ @MethodSource("search")
+ @DisplayName("Search a contact")
+ void shouldSearchContact(
+ String firstName,
+ String lastName,
+ String email,
+ String phone,
+ Integer expected
+ ) {
+ client
+ .get()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/contacts/search")
+ .queryParam("firstName", firstName)
+ .queryParam("lastName", lastName)
+ .queryParam("email", email)
+ .queryParam("phone", phone)
+ .build(Map.of())
+ )
+ .header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
+ .exchange()
+ .expectStatus().isOk()
+ .expectBodyList(ForestClientContactDto.class)
+ .hasSize(expected);
+ }
+
+ private static Stream saveContact() {
+ return Stream.of("00000001", "00000002", "00000003");
+ }
+
+ private static Stream search() {
+ return Stream.of(
+ Arguments.of("Jason", "Momoa", "myman@momoa.ca", "6046666735", 2),
+ Arguments.of("James", "Baxter", "jbaxter@mail.ca", "6046666755", 3),
+ Arguments.of("Nedad", "Kontic", "konticboss@kelpic.ca", "6046646755", 1),
+ Arguments.of("Jack", "Ryan", "ryan.jack@tomclancy.ca", "6046666735", 2),
+ Arguments.of("Jack", "Ryan", "ryan.jack@tomclancy.ca", "2502502550", 2),
+ Arguments.of("Domingos", "Chaves", "dingo@tomclancy.ca", "2554457789", 0)
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/legacy/src/test/java/ca/bc/gov/app/controller/ClientControllerIntegrationTest.java b/legacy/src/test/java/ca/bc/gov/app/controller/ClientControllerIntegrationTest.java
new file mode 100644
index 0000000000..74f674fa1a
--- /dev/null
+++ b/legacy/src/test/java/ca/bc/gov/app/controller/ClientControllerIntegrationTest.java
@@ -0,0 +1,69 @@
+package ca.bc.gov.app.controller;
+
+import ca.bc.gov.app.dto.ForestClientDto;
+import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest;
+import java.util.Map;
+import java.util.stream.Stream;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.reactive.server.WebTestClient;
+import org.springframework.web.reactive.function.BodyInserters;
+
+@Slf4j
+@DisplayName("Integrated Test | Client Controller")
+class ClientControllerIntegrationTest extends
+ AbstractTestContainerIntegrationTest {
+
+ @Autowired
+ protected WebTestClient client;
+
+ @ParameterizedTest
+ @MethodSource("saveClient")
+ @DisplayName("Save a client")
+ void shouldSaveLocation(String clientName) {
+ client
+ .post()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/clients")
+ .build(Map.of())
+ )
+ .header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
+ .body(BodyInserters.fromValue(
+ new ForestClientDto(
+ null,
+ clientName,
+ null,
+ null,
+ "ACT",
+ "C",
+ null,
+ null,
+ null,
+ "BC",
+ "123456789",
+ "Comment here",
+ "Test",
+ "Test",
+ 1L
+ )
+ )
+ )
+ .exchange()
+ .expectStatus().isCreated()
+ .expectBody(String.class)
+ .value(StringUtils::isNotBlank);
+
+ }
+
+ private static Stream saveClient() {
+ return Stream.of("TESTADOC", "SAMPLER FOREST PRODUCTS INC.", "BORIS AND BORIS INC.",
+ "CORP. OF THE CITY OF VICTORIA");
+ }
+}
diff --git a/legacy/src/test/java/ca/bc/gov/app/controller/ClientDoingBusinessAsControllerIntegrationTest.java b/legacy/src/test/java/ca/bc/gov/app/controller/ClientDoingBusinessAsControllerIntegrationTest.java
new file mode 100644
index 0000000000..e41a0be5d6
--- /dev/null
+++ b/legacy/src/test/java/ca/bc/gov/app/controller/ClientDoingBusinessAsControllerIntegrationTest.java
@@ -0,0 +1,103 @@
+package ca.bc.gov.app.controller;
+
+import ca.bc.gov.app.dto.ClientDoingBusinessAsDto;
+import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest;
+import java.util.Map;
+import java.util.stream.Stream;
+import lombok.extern.slf4j.Slf4j;
+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.MethodSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.reactive.server.WebTestClient;
+import org.springframework.test.web.reactive.server.WebTestClient.ResponseSpec;
+import org.springframework.web.reactive.function.BodyInserters;
+
+@Slf4j
+@DisplayName("Integrated Test | Client Doing Business As Controller")
+class ClientDoingBusinessAsControllerIntegrationTest extends
+ AbstractTestContainerIntegrationTest {
+
+ @Autowired
+ protected WebTestClient client;
+
+ @ParameterizedTest
+ @MethodSource("saveDba")
+ @DisplayName("Save a location")
+ void shouldSaveLocation(String clientNumber) {
+ client
+ .post()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/dba")
+ .build(Map.of())
+ )
+ .header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
+ .body(BodyInserters.fromValue(
+ new ClientDoingBusinessAsDto(
+ clientNumber,
+ "Elaricho",
+ "TEST",
+ "TEST",
+ 1L
+ )
+ )
+ )
+ .exchange()
+ .expectStatus().isCreated()
+ .expectBody(String.class)
+ .equals(clientNumber);
+ }
+
+ @ParameterizedTest
+ @MethodSource("searchDBA")
+ @DisplayName("Search for a dba")
+ void shouldSearchForDba(
+ String dbaName,
+ boolean expected,
+ int size
+ ) {
+ ResponseSpec response =
+ client
+ .get()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/dba/search")
+ .queryParam("dbaName", dbaName)
+ .build(Map.of())
+ )
+ .exchange()
+ .expectStatus()
+ .isEqualTo(expected ? 200 : 404);
+
+ if (expected) {
+ response
+ .expectHeader()
+ .contentType(MediaType.APPLICATION_JSON_VALUE)
+ .expectBodyList(ClientDoingBusinessAsDto.class)
+ .hasSize(size);
+ }else{
+ response
+ .expectBody(String.class)
+ .isEqualTo("No value found for " + dbaName);
+ }
+ }
+
+ private static Stream saveDba() {
+ return Stream.of("00000005", "00000006", "00000007");
+ }
+
+ private static Stream searchDBA() {
+ return
+ Stream.of(
+ Arguments.of("BAXTER''S FAMILY", true, 1),
+ Arguments.of("DOUG FUNNY", true, 1),
+ Arguments.of("BORIS AND BORIS INC.", true, 1),
+ Arguments.of("Elaricho", true, 4),
+ Arguments.of("baldwin", false, 0)
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/legacy/src/test/java/ca/bc/gov/app/controller/ClientLocationControllerIntegrationTest.java b/legacy/src/test/java/ca/bc/gov/app/controller/ClientLocationControllerIntegrationTest.java
new file mode 100644
index 0000000000..5a414448a1
--- /dev/null
+++ b/legacy/src/test/java/ca/bc/gov/app/controller/ClientLocationControllerIntegrationTest.java
@@ -0,0 +1,74 @@
+package ca.bc.gov.app.controller;
+
+import ca.bc.gov.app.dto.ForestClientLocationDto;
+import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest;
+import java.util.Map;
+import java.util.stream.Stream;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.test.web.reactive.server.WebTestClient;
+import org.springframework.web.reactive.function.BodyInserters;
+
+@Slf4j
+@DisplayName("Integrated Test | Client Location Controller")
+class ClientLocationControllerIntegrationTest extends
+ AbstractTestContainerIntegrationTest {
+
+ @Autowired
+ protected WebTestClient client;
+
+ @ParameterizedTest
+ @MethodSource("saveLocation")
+ @DisplayName("Save a location")
+ void shouldSaveLocation(String clientNumber) {
+ client
+ .post()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/locations")
+ .build(Map.of())
+ )
+ .header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
+ .body(BodyInserters.fromValue(
+ new ForestClientLocationDto(
+ clientNumber,
+ "00",
+ "BILLING ADDRESS",
+ "2975 Jutland Rd.",
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ "VICTORIA",
+ "BC",
+ "V8V8V8",
+ "CANADA",
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ "N",
+ null,
+ "Y",
+ StringUtils.EMPTY,
+ "TEST",
+ "TEST",
+ 1L
+ )
+ )
+ )
+ .exchange()
+ .expectStatus().isCreated()
+ .expectBody(String.class)
+ .equals(clientNumber);
+ }
+
+ private static Stream saveLocation() {
+ return Stream.of("00000001", "00000002", "00000008");
+ }
+
+}
\ No newline at end of file
diff --git a/legacy/src/test/java/ca/bc/gov/app/endpoints/ClientSearchIncorporationHandlerIntegrationTest.java b/legacy/src/test/java/ca/bc/gov/app/controller/ClientSearchControllerIntegrationTest.java
similarity index 50%
rename from legacy/src/test/java/ca/bc/gov/app/endpoints/ClientSearchIncorporationHandlerIntegrationTest.java
rename to legacy/src/test/java/ca/bc/gov/app/controller/ClientSearchControllerIntegrationTest.java
index 14d1824acb..6c99886d1c 100644
--- a/legacy/src/test/java/ca/bc/gov/app/endpoints/ClientSearchIncorporationHandlerIntegrationTest.java
+++ b/legacy/src/test/java/ca/bc/gov/app/controller/ClientSearchControllerIntegrationTest.java
@@ -1,9 +1,13 @@
-package ca.bc.gov.app.endpoints;
+package ca.bc.gov.app.controller;
import ca.bc.gov.app.extensions.AbstractTestContainerIntegrationTest;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
import java.util.HashMap;
+import java.util.Optional;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
@@ -16,8 +20,8 @@
import org.springframework.test.web.reactive.server.WebTestClient;
@Slf4j
-@DisplayName("Integrated Test | Client Search Incorporation Controller")
-class ClientSearchIncorporationHandlerIntegrationTest extends
+@DisplayName("Integrated Test | Client Search Controller")
+class ClientSearchControllerIntegrationTest extends
AbstractTestContainerIntegrationTest {
@Autowired
@@ -103,6 +107,77 @@ void shouldSearchByName(String name) {
.consumeWith(System.out::println);
}
+ @Test
+ @DisplayName("Search someone by individual data")
+ void shouldSearchByIndividual() {
+ client
+ .get()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/search/individual")
+ .queryParam("firstName", "JAMES")
+ .queryParam("lastName", "BAXTER")
+ .queryParam("dob", "1959-05-18")
+ .build(new HashMap<>())
+ )
+ .header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
+ .exchange()
+ .expectStatus().isOk()
+ .expectBody()
+ .jsonPath("$[0].clientNumber").isNotEmpty()
+ .jsonPath("$[0].clientName").isNotEmpty()
+ .jsonPath("$[0].clientName").isEqualTo("BAXTER")
+ .consumeWith(System.out::println);
+ }
+
+ @ParameterizedTest
+ @MethodSource("individuals")
+ @DisplayName("Search someone by individual data and fail")
+ void shouldSearchByIndividualFailures(
+ String firstName,
+ String lastName,
+ LocalDate dob
+ ) {
+ client
+ .get()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/search/individual")
+ .queryParamIfPresent("firstName", Optional.ofNullable(firstName))
+ .queryParamIfPresent("lastName", Optional.ofNullable(lastName))
+ .queryParamIfPresent("dob", Optional.ofNullable(dob).map(value -> value.format(
+ DateTimeFormatter.ISO_DATE)))
+ .build(new HashMap<>())
+ )
+ .header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
+ .exchange()
+ .expectStatus()
+ .is4xxClientError();
+ }
+
+ @ParameterizedTest
+ @MethodSource("legalName")
+ @DisplayName("Search someone by legal name")
+ void shouldMatch(
+ String searchParam,
+ String expected
+ ){
+ client
+ .get()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/search/match")
+ .queryParam("companyName", searchParam)
+ .build(new HashMap<>())
+ )
+ .header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
+ .exchange()
+ .expectStatus().isOk()
+ .expectBody()
+ .json(expected)
+ .consumeWith(System.out::println);
+ }
+
private static Stream byLastNameCompanyName() {
return Stream.of("BAXTER", "BORIS AND BORIS INC.");
}
@@ -115,4 +190,39 @@ private static Stream noResults() {
);
}
+ private static Stream individuals() {
+ return Stream
+ .of(
+ Arguments.of("JAMES", "BAXTER", null),
+ Arguments.of("JAMES", null, LocalDate.of(1959, 5, 18)),
+ Arguments.of(null, "BAXTER", LocalDate.of(1959, 5, 18)),
+ Arguments.of("JAMES", StringUtils.EMPTY, LocalDate.of(1959, 5, 18)),
+ Arguments.of(StringUtils.EMPTY, "BAXTER", LocalDate.of(1959, 5, 18))
+ );
+ }
+
+ private static Stream legalName() {
+ return
+ Stream.of(
+ Arguments.of("James", """
+ [
+ {
+ "clientNumber":"00000009",
+ "clientName":"james",
+ "legalFirstName":null,
+ "legalMiddleName":"hunt",
+ "clientStatusCode":"ACT",
+ "clientTypeCode":"I",
+ "birthdate":null,
+ "clientIdTypeCode":null,
+ "clientIdentification":null,
+ "registryCompanyTypeCode":null,
+ "corpRegnNmbr":null
+ }
+ ]"""),
+ Arguments.of("Marco","[]"),
+ Arguments.of("Lucca", "[]")
+ );
+ }
+
}
diff --git a/legacy/src/test/java/ca/bc/gov/app/dto/Dummy.java b/legacy/src/test/java/ca/bc/gov/app/dto/Dummy.java
new file mode 100644
index 0000000000..e161c46ac5
--- /dev/null
+++ b/legacy/src/test/java/ca/bc/gov/app/dto/Dummy.java
@@ -0,0 +1,5 @@
+package ca.bc.gov.app.dto;
+
+public record Dummy(String name,String email) {
+
+}
diff --git a/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientContactMapperTest.java b/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientContactMapperTest.java
new file mode 100644
index 0000000000..afd48f80e9
--- /dev/null
+++ b/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientContactMapperTest.java
@@ -0,0 +1,70 @@
+package ca.bc.gov.app.mappers;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
+
+import ca.bc.gov.app.dto.ForestClientContactDto;
+import ca.bc.gov.app.dto.ForestClientLocationDto;
+import ca.bc.gov.app.entity.ForestClientContactEntity;
+import ca.bc.gov.app.entity.ForestClientLocationEntity;
+import java.time.LocalDateTime;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.mapstruct.factory.Mappers;
+
+@DisplayName("Unit Test | Forest Client Contact Mapper")
+class ForestClientContactMapperTest {
+
+
+ private final ForestClientContactMapper mapper = Mappers.getMapper(
+ ForestClientContactMapper.class);
+
+ ForestClientContactDto dto = new ForestClientContactDto(
+ "00000001",
+ "00",
+ "BL",
+ "James Baxter",
+ "2502502550",
+ "mail@mail.ca",
+ "Test",
+ "Test",
+ 1L
+ );
+
+ ForestClientContactEntity entity =
+ ForestClientContactEntity
+ .builder()
+ .clientNumber("00000001")
+ .clientLocnCode("00")
+ .contactCode("BL")
+ .contactName("James Baxter")
+ .businessPhone("2502502550")
+ .emailAddress("mail@mail.ca")
+ .createdAt(LocalDateTime.now())
+ .updatedAt(LocalDateTime.now())
+ .createdBy("Test")
+ .updatedBy("Test")
+ .createdByUnit(1L)
+ .updatedByUnit(1L)
+ .revision(1L)
+ .build();
+
+ @Test
+ @DisplayName("Should convert to entity")
+ void shouldConvertToEntity() {
+ assertThat(mapper.toEntity(dto))
+ .usingRecursiveComparison()
+ .ignoringFields("createdAt", "updatedAt")
+ .isEqualTo(entity);
+
+ assertNotNull(mapper.toEntity(dto).getCreatedAt());
+ assertNotNull(mapper.toEntity(dto).getUpdatedAt());
+ }
+
+ @Test
+ @DisplayName("Should convert to dto")
+ void shouldConvertToDto() {
+ assertEquals(dto, mapper.toDto(entity));
+ }
+
+}
\ No newline at end of file
diff --git a/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapperTest.java b/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapperTest.java
new file mode 100644
index 0000000000..fa4733a286
--- /dev/null
+++ b/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientDoingBusinessAsMapperTest.java
@@ -0,0 +1,61 @@
+package ca.bc.gov.app.mappers;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import ca.bc.gov.app.dto.ClientDoingBusinessAsDto;
+import ca.bc.gov.app.entity.ClientDoingBusinessAsEntity;
+import java.time.LocalDateTime;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.mapstruct.factory.Mappers;
+
+@DisplayName("Unit Test | Forest Client Doing Business As Mapper")
+class ForestClientDoingBusinessAsMapperTest {
+
+
+ private final ForestClientDoingBusinessAsMapper mapper = Mappers.getMapper(
+ ForestClientDoingBusinessAsMapper.class);
+
+ ClientDoingBusinessAsDto dto = new ClientDoingBusinessAsDto(
+ "00000001",
+ "Spaldingnad",
+ "Test",
+ "Test",
+ 1L
+ );
+
+ ClientDoingBusinessAsEntity entity =
+ ClientDoingBusinessAsEntity
+ .builder()
+ .clientNumber("00000001")
+ .doingBusinessAsName("Spaldingnad")
+ .createdAt(LocalDateTime.now())
+ .updatedAt(LocalDateTime.now())
+ .createdBy("Test")
+ .updatedBy("Test")
+ .createdByUnit(1L)
+ .updatedByUnit(1L)
+ .revision(1L)
+ .build();
+
+ @Test
+ @DisplayName("Should convert to entity")
+ void shouldConvertToEntity() {
+ assertThat(mapper.toEntity(dto))
+ .usingRecursiveComparison()
+ .ignoringFields("createdAt", "updatedAt")
+ .isEqualTo(entity);
+
+ assertNotNull(mapper.toEntity(dto).getCreatedAt());
+ assertNotNull(mapper.toEntity(dto).getUpdatedAt());
+ }
+
+ @Test
+ @DisplayName("Should convert to dto")
+ void shouldConvertToDto() {
+ assertEquals(dto, mapper.toDto(entity));
+ }
+
+}
\ No newline at end of file
diff --git a/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientLocationMapperTest.java b/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientLocationMapperTest.java
new file mode 100644
index 0000000000..e0661cf9d4
--- /dev/null
+++ b/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientLocationMapperTest.java
@@ -0,0 +1,84 @@
+package ca.bc.gov.app.mappers;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import ca.bc.gov.app.dto.ForestClientLocationDto;
+import ca.bc.gov.app.entity.ForestClientLocationEntity;
+import java.time.LocalDateTime;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.mapstruct.factory.Mappers;
+
+@DisplayName("Unit Test | Forest Client Location Mapper")
+class ForestClientLocationMapperTest {
+
+ private final ForestClientLocationMapper mapper = Mappers.getMapper(
+ ForestClientLocationMapper.class);
+
+ ForestClientLocationDto dto = new ForestClientLocationDto(
+ "00000001",
+ "00",
+ "BILLING ADDRESS",
+ "2975 Jutland Road",
+ null,
+ null,
+ "VICTORIA",
+ "BC",
+ "V8V8V8",
+ "CANADA",
+ null,
+ null,
+ null,
+ null,
+ null,
+ "N",
+ null,
+ "Y",
+ null,
+ "Test",
+ "Test",
+ 1L
+ );
+
+ ForestClientLocationEntity entity =
+ ForestClientLocationEntity
+ .builder()
+ .clientNumber("00000001")
+ .clientLocnCode("00")
+ .clientLocnName("BILLING ADDRESS")
+ .addressOne("2975 Jutland Road")
+ .city("VICTORIA")
+ .province("BC")
+ .postalCode("V8V8V8")
+ .country("CANADA")
+ .locnExpiredInd("N")
+ .trustLocationInd("Y")
+ .createdAt(LocalDateTime.now())
+ .updatedAt(LocalDateTime.now())
+ .createdBy("Test")
+ .updatedBy("Test")
+ .createdByUnit(1L)
+ .updatedByUnit(1L)
+ .revision(1L)
+ .build();
+
+ @Test
+ @DisplayName("Should convert to entity")
+ void shouldConvertToEntity() {
+ assertThat(mapper.toEntity(dto))
+ .usingRecursiveComparison()
+ .ignoringFields("createdAt", "updatedAt")
+ .isEqualTo(entity);
+
+ assertNotNull(mapper.toEntity(dto).getCreatedAt());
+ assertNotNull(mapper.toEntity(dto).getUpdatedAt());
+ }
+
+ @Test
+ @DisplayName("Should convert to dto")
+ void shouldConvertToDto() {
+ assertEquals(dto, mapper.toDto(entity));
+ }
+}
\ No newline at end of file
diff --git a/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientMapperTest.java b/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientMapperTest.java
new file mode 100644
index 0000000000..57d235b31a
--- /dev/null
+++ b/legacy/src/test/java/ca/bc/gov/app/mappers/ForestClientMapperTest.java
@@ -0,0 +1,75 @@
+package ca.bc.gov.app.mappers;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import ca.bc.gov.app.dto.ForestClientDto;
+import ca.bc.gov.app.entity.ForestClientEntity;
+import java.time.LocalDateTime;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.mapstruct.factory.Mappers;
+
+@DisplayName("Unit Test | Forest Client Mapper")
+class ForestClientMapperTest {
+
+ private final ForestClientMapper mapper = Mappers.getMapper(ForestClientMapper.class);
+
+ ForestClientDto dto = new ForestClientDto(
+ "00000001",
+ "Test Client",
+ null,
+ null,
+ "ACT",
+ "C",
+ null,
+ null,
+ null,
+ "BC",
+ "0101141401",
+ "Client is Corporation",
+ "Test",
+ "Test",
+ 1L
+ );
+
+ ForestClientEntity entity =
+ ForestClientEntity
+ .builder()
+ .clientNumber("00000001")
+ .clientName("Test Client")
+ .clientStatusCode("ACT")
+ .clientTypeCode("C")
+ .registryCompanyTypeCode("BC")
+ .corpRegnNmbr("0101141401")
+ .wcbFirmNumber(" ")
+ .clientComment("Client is Corporation")
+ .createdAt(LocalDateTime.now())
+ .updatedAt(LocalDateTime.now())
+ .createdBy("Test")
+ .updatedBy("Test")
+ .createdByUnit(1L)
+ .updatedByUnit(1L)
+ .revision(1L)
+ .build();
+
+ @Test
+ @DisplayName("Should convert to entity")
+ void shouldConvertToEntity() {
+ assertThat(mapper.toEntity(dto))
+ .usingRecursiveComparison()
+ .ignoringFields("createdAt", "updatedAt")
+ .isEqualTo(entity);
+
+ assertNotNull(mapper.toEntity(dto).getCreatedAt());
+ assertNotNull(mapper.toEntity(dto).getUpdatedAt());
+ }
+
+ @Test
+ @DisplayName("Should convert to dto")
+ void shouldConvertToDto() {
+ assertEquals(dto, mapper.toDto(entity));
+ }
+
+}
\ No newline at end of file
diff --git a/legacy/src/test/resources/application-default.yml b/legacy/src/test/resources/application-default.yml
index 6d365917e5..9dcb7b9408 100644
--- a/legacy/src/test/resources/application-default.yml
+++ b/legacy/src/test/resources/application-default.yml
@@ -30,6 +30,6 @@ logging:
testcontainers: OFF
com.github.dockerjava: OFF
org.springframework.r2dbc: DEBUG
- io.r2dbc.postgresql.QUERY: DEBUG
- io.r2dbc.postgresql.PARAM: DEBUG
+ io.r2dbc.oracle.QUERY: DEBUG
+ io.r2dbc.oracle.PARAM: DEBUG
ca.bc.gov.app: DEBUG
diff --git a/legacy/src/test/resources/db/migration/V4__manual_data.sql b/legacy/src/test/resources/db/migration/V4__manual_data.sql
index 0cd93b4c9c..be17023099 100644
--- a/legacy/src/test/resources/db/migration/V4__manual_data.sql
+++ b/legacy/src/test/resources/db/migration/V4__manual_data.sql
@@ -18,6 +18,10 @@ INSERT INTO THE.CLIENT_DOING_BUSINESS_AS (CLIENT_DBA_ID,CLIENT_NUMBER,DOING_BUSI
INSERT INTO THE.CLIENT_LOCATION (CLIENT_NUMBER,CLIENT_LOCN_CODE,CLIENT_LOCN_NAME,HDBS_COMPANY_CODE,ADDRESS_1,ADDRESS_2,ADDRESS_3,CITY,PROVINCE,POSTAL_CODE,COUNTRY,BUSINESS_PHONE,HOME_PHONE,CELL_PHONE,FAX_NUMBER,EMAIL_ADDRESS,LOCN_EXPIRED_IND,RETURNED_MAIL_DATE,TRUST_LOCATION_IND,CLI_LOCN_COMMENT,UPDATE_TIMESTAMP,UPDATE_USERID,UPDATE_ORG_UNIT,ADD_TIMESTAMP,ADD_USERID,ADD_ORG_UNIT,REVISION_COUNT) VALUES
('00000002','00',NULL,'01384','Government St','Floor 2',NULL,'VICTORIA','BC','V8V2L8','CANADA',NULL,NULL,NULL,NULL,NULL,'N',NULL,'N',NULL,TIMESTAMP'1991-11-20 13:15:01.0','JBAXTER',70,TIMESTAMP'1989-11-26 08:52:09.0','CONV',70,1);
+INSERT INTO "THE"."CLIENT_CONTACT"
+(CLIENT_CONTACT_ID, CLIENT_NUMBER, CLIENT_LOCN_CODE, BUS_CONTACT_CODE, CONTACT_NAME, BUSINESS_PHONE, CELL_PHONE, FAX_NUMBER, EMAIL_ADDRESS, UPDATE_TIMESTAMP, UPDATE_USERID, UPDATE_ORG_UNIT, ADD_TIMESTAMP, ADD_USERID, ADD_ORG_UNIT, REVISION_COUNT)
+VALUES(client_dba_seq.NEXTVAL, '00000002', '00', 'BL', 'JAMES BAXTER', '6046666755', NULL, NULL, 'jbaxter@mail.ca', TIMESTAMP '1993-03-26 17:40:15.000000', 'IDIR\ITISWATTLES', 1, TIMESTAMP '1993-03-26 17:40:15.000000', 'IDIR\ITISWATTLES', 1, 1);
+
-- 00000003 Boris and Boris, Doing Business and Location
INSERT INTO THE.FOREST_CLIENT (CLIENT_NUMBER,CLIENT_NAME,LEGAL_FIRST_NAME,LEGAL_MIDDLE_NAME,CLIENT_STATUS_CODE,CLIENT_TYPE_CODE,BIRTHDATE,CLIENT_ID_TYPE_CODE,CLIENT_IDENTIFICATION,REGISTRY_COMPANY_TYPE_CODE,CORP_REGN_NMBR,CLIENT_ACRONYM,WCB_FIRM_NUMBER,OCG_SUPPLIER_NMBR,CLIENT_COMMENT,ADD_TIMESTAMP,ADD_USERID,ADD_ORG_UNIT,UPDATE_TIMESTAMP,UPDATE_USERID,UPDATE_ORG_UNIT,REVISION_COUNT) VALUES
@@ -47,6 +51,9 @@ INSERT INTO THE.FOREST_CLIENT
(CLIENT_NUMBER, CLIENT_NAME, LEGAL_FIRST_NAME, LEGAL_MIDDLE_NAME, CLIENT_STATUS_CODE, CLIENT_TYPE_CODE, BIRTHDATE, CLIENT_ID_TYPE_CODE, CLIENT_IDENTIFICATION, REGISTRY_COMPANY_TYPE_CODE, CORP_REGN_NMBR, CLIENT_ACRONYM, WCB_FIRM_NUMBER, OCG_SUPPLIER_NMBR, CLIENT_COMMENT, ADD_TIMESTAMP, ADD_USERID, ADD_ORG_UNIT, UPDATE_TIMESTAMP, UPDATE_USERID, UPDATE_ORG_UNIT, REVISION_COUNT)
VALUES('00000005', 'KRAKOWSKY', 'ERNA', NULL, 'ACT', 'I', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TIMESTAMP '1989-11-26 08:52:38.000000', 'CONV', 70, TIMESTAMP '1989-11-26 08:52:38.000000', 'IDIR\ITISWATTLES', 70, 1);
+INSERT INTO THE.CLIENT_DOING_BUSINESS_AS (CLIENT_DBA_ID,CLIENT_NUMBER,DOING_BUSINESS_AS_NAME,UPDATE_TIMESTAMP,UPDATE_USERID,UPDATE_ORG_UNIT,ADD_TIMESTAMP,ADD_USERID,ADD_ORG_UNIT,REVISION_COUNT) VALUES
+(client_dba_seq.NEXTVAL,'00000005','ELARICHO',TIMESTAMP'2007-04-24 12:21:47.0','IDIR\ITISWATTLES',70,TIMESTAMP'2007-04-24 12:21:47.0','IDIR\ITISWATTLES',70,1);
+
-- 00000006 Indian Canada, Doing Business, Multiple Locations, Org Unit, Contact
INSERT INTO "THE"."FOREST_CLIENT"
@@ -68,10 +75,10 @@ VALUES('00000006', '03', 'SHUSWAP BAND OFFICE', '06901', 'SHUSWAP BAND OFFICE',
INSERT INTO "THE"."CLIENT_CONTACT"
(CLIENT_CONTACT_ID, CLIENT_NUMBER, CLIENT_LOCN_CODE, BUS_CONTACT_CODE, CONTACT_NAME, BUSINESS_PHONE, CELL_PHONE, FAX_NUMBER, EMAIL_ADDRESS, UPDATE_TIMESTAMP, UPDATE_USERID, UPDATE_ORG_UNIT, ADD_TIMESTAMP, ADD_USERID, ADD_ORG_UNIT, REVISION_COUNT)
-VALUES(client_dba_seq.NEXTVAL, '00000006', '00', 'BL', 'JASON MOMOA', '6046666755', NULL, NULL, NULL, TIMESTAMP '1993-03-26 17:40:15.000000', 'IDIR\ITISWATTLES', 1, TIMESTAMP '1993-03-26 17:40:15.000000', 'IDIR\ITISWATTLES', 1, 1);
+VALUES(client_dba_seq.NEXTVAL, '00000006', '00', 'BL', 'JASON MOMOA', '6046666735', NULL, NULL, 'myman@momoa.ca', TIMESTAMP '1993-03-26 17:40:15.000000', 'IDIR\ITISWATTLES', 1, TIMESTAMP '1993-03-26 17:40:15.000000', 'IDIR\ITISWATTLES', 1, 1);
INSERT INTO "THE"."CLIENT_CONTACT"
(CLIENT_CONTACT_ID, CLIENT_NUMBER, CLIENT_LOCN_CODE, BUS_CONTACT_CODE, CONTACT_NAME, BUSINESS_PHONE, CELL_PHONE, FAX_NUMBER, EMAIL_ADDRESS, UPDATE_TIMESTAMP, UPDATE_USERID, UPDATE_ORG_UNIT, ADD_TIMESTAMP, ADD_USERID, ADD_ORG_UNIT, REVISION_COUNT)
-VALUES(client_dba_seq.NEXTVAL, '00000006', '00', 'TN', 'NEDAD KONTIC', '6046666755', NULL, NULL, NULL, TIMESTAMP '1993-03-26 17:37:29.000000', 'IDIR\ITISWATTLES', 1, TIMESTAMP '1993-03-26 17:37:29.000000', 'IDIR\ITISWATTLES', 1, 1);
+VALUES(client_dba_seq.NEXTVAL, '00000006', '00', 'TN', 'NEDAD KONTIC', '6046666735', NULL, NULL, 'konticboss@kelpic.ca', TIMESTAMP '1993-03-26 17:37:29.000000', 'IDIR\ITISWATTLES', 1, TIMESTAMP '1993-03-26 17:37:29.000000', 'IDIR\ITISWATTLES', 1, 1);
-- 00000007 James Bond
@@ -101,7 +108,7 @@ VALUES('00000010', 'bbondd', 'jjamess', 'bbondd', 'ACT', 'A', NULL, NULL, NULL,
INSERT INTO THE.FOREST_CLIENT
(CLIENT_NUMBER, CLIENT_NAME, LEGAL_FIRST_NAME, LEGAL_MIDDLE_NAME, CLIENT_STATUS_CODE, CLIENT_TYPE_CODE, BIRTHDATE, CLIENT_ID_TYPE_CODE, CLIENT_IDENTIFICATION, REGISTRY_COMPANY_TYPE_CODE, CORP_REGN_NMBR, CLIENT_ACRONYM, WCB_FIRM_NUMBER, OCG_SUPPLIER_NMBR, CLIENT_COMMENT, ADD_TIMESTAMP, ADD_USERID, ADD_ORG_UNIT, UPDATE_TIMESTAMP, UPDATE_USERID, UPDATE_ORG_UNIT, REVISION_COUNT)
-VALUES('00000011', 'CORP. OF THE CITY OF VICTORIA', NULL, NULL, 'ACT', 'G', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TIMESTAMP '1989-11-26 08:52:38.000000', 'CONV', 70, TIMESTAMP '1989-11-26 08:52:38.000000', 'IDIR\ITISWATTLES', 70, 1);
+VALUES('00000011', 'CORP. OF THE CITY OF VICTORIA', NULL, NULL, 'ACT', 'C', NULL, NULL, NULL, 'BC', '123456789', NULL, NULL, NULL, NULL, TIMESTAMP '1989-11-26 08:52:38.000000', 'CONV', 70, TIMESTAMP '1989-11-26 08:52:38.000000', 'IDIR\ITISWATTLES', 70, 1);
-- 00000012 Sampler FOREST PRODUCTS INC
diff --git a/processor/config/application-local.yml b/processor/config/application-local.yml
index 78aa482225..e69de29bb2 100644
--- a/processor/config/application-local.yml
+++ b/processor/config/application-local.yml
@@ -1,3 +0,0 @@
-spring:
- r2dbc:
- url: r2dbc:oracle://${ca.bc.gov.nrs.oracle.host}:${ca.bc.gov.nrs.oracle.port}/${ca.bc.gov.nrs.oracle.database}
\ No newline at end of file
diff --git a/processor/openshift.deploy.yml b/processor/openshift.deploy.yml
index f3670728cb..d18cdcbbfe 100644
--- a/processor/openshift.deploy.yml
+++ b/processor/openshift.deploy.yml
@@ -24,8 +24,6 @@ parameters:
- name: PROMOTE
description: Image (namespace/name:tag) to promote/import
value: bcgov/nr-old-growth:prod-backend
- - name: ORACLEDB_KEYSTORE
- description: Oracle database keystore file
- name: CPU_REQUEST
value: 75m
- name: CPU_LIMIT
@@ -34,9 +32,6 @@ parameters:
value: 300Mi
- name: MEMORY_LIMIT
value: 400Mi
- - name: CERT_PVC_SIZE
- description: The amount of storage the cert PVC should have
- value: 25Mi
- name: URL_ZONE
description: Zone to use for URL
required: true
@@ -60,19 +55,6 @@ objects:
name: ${REGISTRY}/${PROMOTE}
referencePolicy:
type: Local
- - apiVersion: v1
- kind: PersistentVolumeClaim
- metadata:
- labels:
- app: ${NAME}-${ZONE}
- name: ${NAME}-${ZONE}-${COMPONENT}
- spec:
- accessModes:
- - ReadWriteMany
- resources:
- requests:
- storage: ${CERT_PVC_SIZE}
- storageClassName: netapp-file-standard
- apiVersion: v1
kind: DeploymentConfig
metadata:
@@ -101,41 +83,6 @@ objects:
app: ${NAME}-${ZONE}
deploymentconfig: ${NAME}-${ZONE}-${COMPONENT}
spec:
- volumes:
- - name: ${NAME}-${ZONE}-${COMPONENT}-certs
- persistentVolumeClaim:
- claimName: ${NAME}-${ZONE}-${COMPONENT}
- initContainers:
- - name: ${NAME}-init
- image: ${REGISTRY}/bcgov/${NAME}/common:${ZONE}
- imagePullPolicy: Always
- env:
- - name: ORACLEDB_HOST
- valueFrom:
- secretKeyRef:
- name: ${NAME}-${ZONE}
- key: oracle-host
- - name: ORACLEDB_SECRET
- valueFrom:
- secretKeyRef:
- name: ${NAME}-${ZONE}
- key: oracle-secret
- - name: ORACLEDB_PORT
- value: "1543"
- - name: CLIENT_URI
- value: https://${NAME}-${ZONE}-backend.${DOMAIN}/api
- - name: TIMING
- value: 30S
- volumeMounts:
- - name: ${NAME}-${ZONE}-${COMPONENT}-certs
- mountPath: /cert
- resources:
- limits:
- cpu: ${CPU_LIMIT}
- memory: ${MEMORY_LIMIT}
- requests:
- cpu: ${CPU_REQUEST}
- memory: ${MEMORY_REQUEST}
containers:
- image: ${NAME}-${ZONE}-${COMPONENT}:${IMAGE_TAG}
imagePullPolicy: Always
@@ -158,42 +105,10 @@ objects:
secretKeyRef:
name: ${NAME}-${ZONE}
key: database-user
- - name: ORACLEDB_USER
- valueFrom:
- secretKeyRef:
- name: ${NAME}-${ZONE}
- key: oracle-user-write
- - name: ORACLEDB_PASSWORD
- valueFrom:
- secretKeyRef:
- name: ${NAME}-${ZONE}
- key: oracle-password-write
- - name: ORACLEDB_DATABASE
- valueFrom:
- secretKeyRef:
- name: ${NAME}-${ZONE}
- key: oracle-database
- - name: ORACLEDB_HOST
- valueFrom:
- secretKeyRef:
- name: ${NAME}-${ZONE}
- key: oracle-host
- - name: ORACLEDB_SERVICENAME
- valueFrom:
- secretKeyRef:
- name: ${NAME}-${ZONE}
- key: oracle-service
- - name: ORACLEDB_PORT
- value: "1543"
- - name: ORACLEDB_SECRET
- valueFrom:
- secretKeyRef:
- name: ${NAME}-${ZONE}
- key: oracle-secret
- - name: ORACLEDB_KEYSTORE
- value: /cert/jssecacerts
- name: CLIENT_URI
value: https://${NAME}-${ZONE}-backend.${DOMAIN}/api
+ - name: LEGACY_URI
+ value: https://${NAME}-${URL_ZONE}-legacy.${DOMAIN}
- name: TIMING
value: 30S
- name: TZ
@@ -213,9 +128,6 @@ objects:
ports:
- containerPort: 3000
protocol: TCP
- volumeMounts:
- - name: ${NAME}-${ZONE}-${COMPONENT}-certs
- mountPath: /cert
resources:
limits:
cpu: ${CPU_LIMIT}
diff --git a/processor/pom.xml b/processor/pom.xml
index 4396f74507..4dc52307c7 100644
--- a/processor/pom.xml
+++ b/processor/pom.xml
@@ -38,7 +38,7 @@
${project.build.directory}/coverage-reports
${maven.build.timestamp}
yyyy-MM-dd HH:mm:ss
- 1.19.3
+ 1.19.1
5.9.1
1.9.1
3.24.2
@@ -69,11 +69,6 @@
org.springframework.boot
spring-boot-starter-validation
-
- com.oracle.database.r2dbc
- oracle-r2dbc
- runtime
-
org.postgresql
postgresql
@@ -127,12 +122,6 @@
postgresql
test
-
- org.testcontainers
- oracle-xe
- 1.19.3
- test
-
org.testcontainers
r2dbc
diff --git a/processor/src/main/java/ca/bc/gov/app/ApplicationConstant.java b/processor/src/main/java/ca/bc/gov/app/ApplicationConstant.java
index 6d0dc3baed..84c074912c 100644
--- a/processor/src/main/java/ca/bc/gov/app/ApplicationConstant.java
+++ b/processor/src/main/java/ca/bc/gov/app/ApplicationConstant.java
@@ -24,7 +24,6 @@ public final class ApplicationConstant {
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";
@@ -46,15 +45,15 @@ public final class ApplicationConstant {
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 MATCH_PARAM_NAME = "corporationName";
+
public static final BcRegistryDocumentRequestBodyDto
BUSINESS_SUMMARY_FILING_HISTORY =
new BcRegistryDocumentRequestBodyDto(
diff --git a/processor/src/main/java/ca/bc/gov/app/configuration/ClientDataConfiguration.java b/processor/src/main/java/ca/bc/gov/app/configuration/ClientDataConfiguration.java
deleted file mode 100644
index d7e442dc5a..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/configuration/ClientDataConfiguration.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package ca.bc.gov.app.configuration;
-
-import io.r2dbc.spi.ConnectionFactories;
-import io.r2dbc.spi.ConnectionFactory;
-import io.r2dbc.spi.ConnectionFactoryOptions;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
-import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
-import org.springframework.data.r2dbc.dialect.PostgresDialect;
-import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
-import org.springframework.r2dbc.core.DatabaseClient;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-@Configuration
-@EnableR2dbcRepositories(
- basePackages = { "ca.bc.gov.app.repository.client" },
- entityOperationsRef = "clientR2dbcEntityOperations"
-)
-@EnableTransactionManagement
-public class ClientDataConfiguration {
-
- @Bean
- @Qualifier(value = "clientConnectionFactory")
- public ConnectionFactory clientConnectionFactory(
- @Value("${ca.bc.gov.nrs.postgres.url}") String url,
- @Value("${ca.bc.gov.nrs.postgres.username}") String username,
- @Value("${ca.bc.gov.nrs.postgres.password}") String password
- ) {
- return ConnectionFactories.get(
- ConnectionFactoryOptions
- .parse(url)
- .mutate()
- .option(ConnectionFactoryOptions.USER, username)
- .option(ConnectionFactoryOptions.PASSWORD, password)
- .build()
- );
- }
-
- @Bean
- public R2dbcEntityOperations clientR2dbcEntityOperations(
- @Qualifier("clientConnectionFactory") ConnectionFactory connectionFactory
- ) {
- return new R2dbcEntityTemplate(
- DatabaseClient.create(connectionFactory),
- PostgresDialect.INSTANCE
- );
- }
-
-}
-
diff --git a/processor/src/main/java/ca/bc/gov/app/configuration/ForestClientConfiguration.java b/processor/src/main/java/ca/bc/gov/app/configuration/ForestClientConfiguration.java
index 130553a648..a2991bbee2 100644
--- a/processor/src/main/java/ca/bc/gov/app/configuration/ForestClientConfiguration.java
+++ b/processor/src/main/java/ca/bc/gov/app/configuration/ForestClientConfiguration.java
@@ -27,6 +27,9 @@ public class ForestClientConfiguration {
@NestedConfigurationProperty
private BackendConfiguration backend;
+ @NestedConfigurationProperty
+ private BackendConfiguration legacy;
+
@NestedConfigurationProperty
private BcRegistryConfiguration bcregistry;
diff --git a/processor/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java b/processor/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java
index 471171bf6a..1ee8560363 100644
--- a/processor/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java
+++ b/processor/src/main/java/ca/bc/gov/app/configuration/GlobalServiceConfiguration.java
@@ -25,6 +25,14 @@ public WebClient forestClientApi(ForestClientConfiguration configuration) {
.build();
}
+ @Bean
+ public WebClient legacyClientApi(ForestClientConfiguration configuration) {
+ return WebClient
+ .builder()
+ .baseUrl(configuration.getLegacy().getUri())
+ .build();
+ }
+
/**
* Returns a configured instance of WebClient for accessing the BC Registry API.
*
diff --git a/processor/src/main/java/ca/bc/gov/app/configuration/LegacyDataConfiguration.java b/processor/src/main/java/ca/bc/gov/app/configuration/LegacyDataConfiguration.java
deleted file mode 100644
index d290592129..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/configuration/LegacyDataConfiguration.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package ca.bc.gov.app.configuration;
-
-import io.r2dbc.spi.ConnectionFactories;
-import io.r2dbc.spi.ConnectionFactory;
-import io.r2dbc.spi.ConnectionFactoryOptions;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
-import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
-import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
-import org.springframework.data.r2dbc.dialect.OracleDialect;
-import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
-import org.springframework.r2dbc.core.DatabaseClient;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-@Configuration
-@EnableR2dbcRepositories(
- basePackages = { "ca.bc.gov.app.repository.legacy" },
- entityOperationsRef = "legacyR2dbcEntityOperations"
-)
-@EnableTransactionManagement
-public class LegacyDataConfiguration {
- @Bean
- @Primary
- @Qualifier(value = "legacyConnectionFactory")
- public ConnectionFactory legacyConnectionFactory(
- @Value("${spring.r2dbc.url}") String url,
- @Value("${spring.r2dbc.username}") String username,
- @Value("${spring.r2dbc.password}") String password
- ) {
- return ConnectionFactories.get(
- ConnectionFactoryOptions
- .parse(url)
- .mutate()
- .option(ConnectionFactoryOptions.USER, username)
- .option(ConnectionFactoryOptions.PASSWORD, password)
- .build()
- );
- }
-
- @Bean
- @Primary
- public R2dbcEntityOperations legacyR2dbcEntityOperations(
- @Qualifier("legacyConnectionFactory") ConnectionFactory connectionFactory
- ) {
- return new R2dbcEntityTemplate(
- DatabaseClient.create(connectionFactory),
- OracleDialect.INSTANCE
- );
- }
-
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/configuration/ProcessorIntegrationConfiguration.java b/processor/src/main/java/ca/bc/gov/app/configuration/ProcessorIntegrationConfiguration.java
index 2777ae349d..3c5ec8d8c8 100644
--- a/processor/src/main/java/ca/bc/gov/app/configuration/ProcessorIntegrationConfiguration.java
+++ b/processor/src/main/java/ca/bc/gov/app/configuration/ProcessorIntegrationConfiguration.java
@@ -1,7 +1,6 @@
package ca.bc.gov.app.configuration;
import ca.bc.gov.app.ApplicationConstant;
-import ca.bc.gov.app.util.LastItemReleaseStrategy;
import java.time.Duration;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
@@ -11,7 +10,6 @@
import org.springframework.integration.channel.FluxMessageChannel;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.Pollers;
-import org.springframework.integration.handler.LoggingHandler.Level;
import org.springframework.integration.r2dbc.inbound.R2dbcMessageSource;
@Configuration
@@ -125,9 +123,7 @@ public FluxMessageChannel submissionMailChannel() {
@Bean
- public R2dbcMessageSource submissionMessages(
- @Qualifier("clientR2dbcEntityOperations") R2dbcEntityTemplate r2dbcEntityTemplate
- ) {
+ public R2dbcMessageSource submissionMessages(R2dbcEntityTemplate r2dbcEntityTemplate) {
final String submissionIdQuery = """
SELECT nrfc.submission.submission_id
FROM nrfc.submission
@@ -143,9 +139,7 @@ public R2dbcMessageSource submissionMessages(
}
@Bean
- public R2dbcMessageSource processedMessage(
- @Qualifier("clientR2dbcEntityOperations") R2dbcEntityTemplate r2dbcEntityTemplate
- ) {
+ public R2dbcMessageSource processedMessage(R2dbcEntityTemplate r2dbcEntityTemplate) {
final String submissionIdQuery = """
SELECT nrfc.submission.submission_id
FROM nrfc.submission
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/converters/SubmissionMatchDetailEntityBeforeConvert.java b/processor/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java
similarity index 95%
rename from processor/src/main/java/ca/bc/gov/app/entity/converters/SubmissionMatchDetailEntityBeforeConvert.java
rename to processor/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java
index 77f63bbdd1..bb90e8acde 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/converters/SubmissionMatchDetailEntityBeforeConvert.java
+++ b/processor/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java
@@ -1,6 +1,6 @@
-package ca.bc.gov.app.entity.converters;
+package ca.bc.gov.app.converters;
-import ca.bc.gov.app.entity.client.SubmissionMatchDetailEntity;
+import ca.bc.gov.app.entity.SubmissionMatchDetailEntity;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.r2dbc.postgresql.codec.Json;
import java.util.Map;
diff --git a/processor/src/main/java/ca/bc/gov/app/dto/SubmissionInformationDto.java b/processor/src/main/java/ca/bc/gov/app/dto/SubmissionInformationDto.java
index 8dbbdb7c85..773cb75e49 100644
--- a/processor/src/main/java/ca/bc/gov/app/dto/SubmissionInformationDto.java
+++ b/processor/src/main/java/ca/bc/gov/app/dto/SubmissionInformationDto.java
@@ -5,6 +5,7 @@
@With
public record SubmissionInformationDto(
+ Integer submissionId,
String corporationName,
LocalDate dateOfBirth,
String incorporationNumber,
diff --git a/processor/src/main/java/ca/bc/gov/app/dto/legacy/ClientDoingBusinessAsDto.java b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ClientDoingBusinessAsDto.java
new file mode 100644
index 0000000000..26102c48d0
--- /dev/null
+++ b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ClientDoingBusinessAsDto.java
@@ -0,0 +1,14 @@
+package ca.bc.gov.app.dto.legacy;
+
+import lombok.With;
+
+@With
+public record ClientDoingBusinessAsDto(
+ String clientNumber,
+ String doingBusinessAsName,
+ String createdBy,
+ String updatedBy,
+ Long orgUnit
+) {
+
+}
diff --git a/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java
new file mode 100644
index 0000000000..2326aa046f
--- /dev/null
+++ b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientContactDto.java
@@ -0,0 +1,15 @@
+package ca.bc.gov.app.dto.legacy;
+
+public record ForestClientContactDto(
+ String clientNumber,
+ String clientLocnCode,
+ String contactCode,
+ String contactName,
+ String businessPhone,
+ String emailAddress,
+ String createdBy,
+ String updatedBy,
+ Long orgUnit
+) {
+
+}
diff --git a/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDto.java b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDto.java
new file mode 100644
index 0000000000..4cf392523f
--- /dev/null
+++ b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientDto.java
@@ -0,0 +1,25 @@
+package ca.bc.gov.app.dto.legacy;
+
+import java.time.LocalDate;
+import lombok.With;
+
+@With
+public record ForestClientDto(
+ String clientNumber,
+ String clientName,
+ String legalFirstName,
+ String legalMiddleName,
+ String clientStatusCode,
+ String clientTypeCode,
+ LocalDate birthdate,
+ String clientIdTypeCode,
+ String clientIdentification,
+ String registryCompanyTypeCode,
+ String corpRegnNmbr,
+ String clientComment,
+ String createdBy,
+ String updatedBy,
+ Long orgUnit
+) {
+
+}
diff --git a/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java
new file mode 100644
index 0000000000..860066f669
--- /dev/null
+++ b/processor/src/main/java/ca/bc/gov/app/dto/legacy/ForestClientLocationDto.java
@@ -0,0 +1,34 @@
+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 updateOrgUnit,
+ Long addOrgUnit
+) {
+
+}
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/BaseEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/BaseEntity.java
similarity index 93%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/BaseEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/BaseEntity.java
index 8f7ce24478..f9f303948d 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/BaseEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/BaseEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/CountryCodeEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/CountryCodeEntity.java
similarity index 97%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/CountryCodeEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/CountryCodeEntity.java
index 86e706f458..d72cabb4ab 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/CountryCodeEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/CountryCodeEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import ca.bc.gov.app.ApplicationConstant;
import jakarta.validation.constraints.NotNull;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/ExpirableBaseEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/ExpirableBaseEntity.java
similarity index 96%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/ExpirableBaseEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/ExpirableBaseEntity.java
index d2d254a32e..d089a25a08 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/ExpirableBaseEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/ExpirableBaseEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionContactEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionContactEntity.java
similarity index 92%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionContactEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/SubmissionContactEntity.java
index 61fcaccf97..be93a73e0f 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionContactEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionContactEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import ca.bc.gov.app.ApplicationConstant;
import lombok.AllArgsConstructor;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionDetailEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionDetailEntity.java
similarity index 93%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionDetailEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/SubmissionDetailEntity.java
index 014b830d13..070150dbf7 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionDetailEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionDetailEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import ca.bc.gov.app.ApplicationConstant;
import java.time.LocalDate;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionEntity.java
similarity index 93%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/SubmissionEntity.java
index 0de98525a5..5508e53909 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import ca.bc.gov.app.ApplicationConstant;
import java.time.LocalDateTime;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionLocationContactEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionLocationContactEntity.java
similarity index 94%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionLocationContactEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/SubmissionLocationContactEntity.java
index 4b98e409b7..5f48ad1ffd 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionLocationContactEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionLocationContactEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import ca.bc.gov.app.ApplicationConstant;
import lombok.AllArgsConstructor;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionLocationContactIdEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionLocationContactIdEntity.java
similarity index 92%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionLocationContactIdEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/SubmissionLocationContactIdEntity.java
index 1270816f4d..ec519d38a4 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionLocationContactIdEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionLocationContactIdEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionLocationEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionLocationEntity.java
similarity index 92%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionLocationEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/SubmissionLocationEntity.java
index f79a02c98d..d09c9efb84 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionLocationEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionLocationEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import ca.bc.gov.app.ApplicationConstant;
import lombok.AllArgsConstructor;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionMatchDetailEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionMatchDetailEntity.java
similarity index 97%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionMatchDetailEntity.java
rename to processor/src/main/java/ca/bc/gov/app/entity/SubmissionMatchDetailEntity.java
index 3a65edb21a..6a6ba17246 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionMatchDetailEntity.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionMatchDetailEntity.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import ca.bc.gov.app.ApplicationConstant;
import io.r2dbc.postgresql.codec.Json;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionStatusEnum.java b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionStatusEnum.java
similarity index 97%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionStatusEnum.java
rename to processor/src/main/java/ca/bc/gov/app/entity/SubmissionStatusEnum.java
index ec22710273..e8c5ca369f 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionStatusEnum.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionStatusEnum.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionTypeCodeEnum.java b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionTypeCodeEnum.java
similarity index 97%
rename from processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionTypeCodeEnum.java
rename to processor/src/main/java/ca/bc/gov/app/entity/SubmissionTypeCodeEnum.java
index dc74d93446..11d848f4a2 100644
--- a/processor/src/main/java/ca/bc/gov/app/entity/client/SubmissionTypeCodeEnum.java
+++ b/processor/src/main/java/ca/bc/gov/app/entity/SubmissionTypeCodeEnum.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.entity.client;
+package ca.bc.gov.app.entity;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ClientDoingBusinessAsEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/legacy/ClientDoingBusinessAsEntity.java
deleted file mode 100644
index a93c71283e..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ClientDoingBusinessAsEntity.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package ca.bc.gov.app.entity.legacy;
-
-import java.time.LocalDateTime;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.With;
-import org.springframework.data.annotation.Id;
-import org.springframework.data.relational.core.mapping.Column;
-import org.springframework.data.relational.core.mapping.Table;
-
-@NoArgsConstructor
-@AllArgsConstructor
-@Data
-@Builder
-@With
-@Table(name = "CLIENT_DOING_BUSINESS_AS", schema = "THE")
-public class ClientDoingBusinessAsEntity {
-
- @Id
- @Column("CLIENT_DBA_ID")
- private Integer id;
-
- @Column("CLIENT_NUMBER")
- private String clientNumber;
-
- @Column("DOING_BUSINESS_AS_NAME")
- private String doingBusinessAsName;
-
- @Column("ADD_TIMESTAMP")
- private LocalDateTime createdAt;
- @Column("ADD_USERID")
- private String createdBy;
- @Column("UPDATE_TIMESTAMP")
- private LocalDateTime updatedAt;
- @Column("UPDATE_USERID")
- private String updatedBy;
- @Column("UPDATE_ORG_UNIT")
- private Long updateOrgUnit;
- @Column("ADD_ORG_UNIT")
- private Long addOrgUnit;
- @Column("REVISION_COUNT")
- private Long revision;
-
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ClientTypeCompanyXrefEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/legacy/ClientTypeCompanyXrefEntity.java
deleted file mode 100644
index 52f39292ca..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ClientTypeCompanyXrefEntity.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package ca.bc.gov.app.entity.legacy;
-
-import java.time.LocalDateTime;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.With;
-import org.springframework.data.relational.core.mapping.Column;
-import org.springframework.data.relational.core.mapping.Table;
-
-@NoArgsConstructor
-@AllArgsConstructor
-@Data
-@Builder
-@With
-@Table(name = "CLIENT_TYPE_COMPANY_XREF", schema = "THE")
-public class ClientTypeCompanyXrefEntity {
-
- @Column("CLIENT_TYPE_CODE")
- private String clientTypeCode;
- @Column("REGISTRY_COMPANY_TYPE_CODE")
- private String registryCompanyTypeCode;
- @Column("ADD_TIMESTAMP")
- private LocalDateTime createdAt;
- @Column("ADD_USERID")
- private String createdBy;
- @Column("UPDATE_TIMESTAMP")
- private LocalDateTime updatedAt;
- @Column("UPDATE_USERID")
- private String updatedBy;
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ClientTypeCompanyXrefEntityKey.java b/processor/src/main/java/ca/bc/gov/app/entity/legacy/ClientTypeCompanyXrefEntityKey.java
deleted file mode 100644
index aa26188e60..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ClientTypeCompanyXrefEntityKey.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package ca.bc.gov.app.entity.legacy;
-
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.With;
-import org.springframework.data.relational.core.mapping.Column;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@With
-@Builder
-public class ClientTypeCompanyXrefEntityKey {
-
- @Column("CLIENT_TYPE_CODE")
- private String clientTypeCode;
- @Column("REGISTRY_COMPANY_TYPE_CODE")
- private String registryCompanyTypeCode;
-
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientEntity.java b/processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientEntity.java
deleted file mode 100644
index 71178fc001..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/entity/legacy/ForestClientEntity.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package ca.bc.gov.app.entity.legacy;
-
-
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.With;
-import org.springframework.data.annotation.Id;
-import org.springframework.data.relational.core.mapping.Column;
-import org.springframework.data.relational.core.mapping.Table;
-
-@NoArgsConstructor
-@AllArgsConstructor
-@Data
-@Builder
-@With
-@Table(name = "FOREST_CLIENT", schema = "THE")
-public class ForestClientEntity {
-
- @Id
- @Column("CLIENT_NUMBER")
- private String clientNumber;
- @Column("CLIENT_NAME")
- private String clientName;
- @Column("LEGAL_FIRST_NAME")
- private String legalFirstName;
- @Column("LEGAL_MIDDLE_NAME")
- private String legalMiddleName;
- @Column("CLIENT_STATUS_CODE")
- private String clientStatusCode;
- @Column("CLIENT_TYPE_CODE")
- private String clientTypeCode;
- @Column("BIRTHDATE")
- private LocalDate birthdate;
- @Column("CLIENT_ID_TYPE_CODE")
- private String clientIdTypeCode;
- @Column("CLIENT_IDENTIFICATION ")
- private String clientIdentification;
- @Column("REGISTRY_COMPANY_TYPE_CODE")
- private String registryCompanyTypeCode;
- @Column("CORP_REGN_NMBR")
- private String corpRegnNmbr;
- @Column("CLIENT_ACRONYM")
- private String clientAcronym;
- @Column("WCB_FIRM_NUMBER")
- private String wcbFirmNumber;
- @Column("OCG_SUPPLIER_NMBR")
- private String ocgSupplierNmbr;
- @Column("CLIENT_COMMENT")
- private String clientComment;
- @Column("ADD_TIMESTAMP")
- private LocalDateTime createdAt;
- @Column("ADD_USERID")
- private String createdBy;
- @Column("UPDATE_TIMESTAMP")
- private LocalDateTime updatedAt;
- @Column("UPDATE_USERID")
- private String updatedBy;
- @Column("UPDATE_ORG_UNIT")
- private Long updateOrgUnit;
- @Column("ADD_ORG_UNIT")
- private Long addOrgUnit;
- @Column("REVISION_COUNT")
- private Long revision;
-
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/matchers/ContactMatcher.java b/processor/src/main/java/ca/bc/gov/app/matchers/ContactMatcher.java
new file mode 100644
index 0000000000..9b363ceea3
--- /dev/null
+++ b/processor/src/main/java/ca/bc/gov/app/matchers/ContactMatcher.java
@@ -0,0 +1,71 @@
+package ca.bc.gov.app.matchers;
+
+import static java.util.function.Predicate.not;
+
+import ca.bc.gov.app.dto.MatcherResult;
+import ca.bc.gov.app.dto.SubmissionInformationDto;
+import ca.bc.gov.app.dto.legacy.ForestClientContactDto;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
+
+@Component
+@Slf4j
+public class ContactMatcher implements ProcessorMatcher {
+
+ private final WebClient legacyClientApi;
+ private final SubmissionContactRepository contactRepository;
+
+ public ContactMatcher(
+ @Qualifier("legacyClientApi") WebClient legacyClientApi,
+ SubmissionContactRepository contactRepository
+ ) {
+ this.legacyClientApi = legacyClientApi;
+ this.contactRepository = contactRepository;
+ }
+
+ @Override
+ public boolean enabled(SubmissionInformationDto submission) {
+ return true;
+ }
+
+ @Override
+ public String name() {
+ return "Contact Matcher";
+ }
+
+ @Override
+ public Mono matches(SubmissionInformationDto submission) {
+
+ log.info("{} :: Validating {}", name(), submission.corporationName());
+
+ return
+ contactRepository
+ .findBySubmissionId(submission.submissionId())
+ .flatMap(contact ->
+ legacyClientApi
+ .get()
+ .uri(
+ uriBuilder ->
+ uriBuilder
+ .path("/api/contacts/search")
+ .queryParam("firstName", contact.getFirstName())
+ .queryParam("lastName", contact.getLastName())
+ .queryParam("email", contact.getEmailAddress())
+ .queryParam("phone", contact.getBusinessPhoneNumber())
+ .build()
+ )
+ .exchangeToFlux(response -> response.bodyToFlux(ForestClientContactDto.class))
+ )
+ .map(ForestClientContactDto::clientNumber)
+ .collectList()
+ .filter(not(List::isEmpty))
+ .map(values ->
+ new MatcherResult("contact", String.join(",", values))
+ );
+ }
+}
diff --git a/processor/src/main/java/ca/bc/gov/app/service/processor/DoingBusinessAsProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/matchers/DoingBusinessAsProcessorMatcher.java
similarity index 67%
rename from processor/src/main/java/ca/bc/gov/app/service/processor/DoingBusinessAsProcessorMatcher.java
rename to processor/src/main/java/ca/bc/gov/app/matchers/DoingBusinessAsProcessorMatcher.java
index f5a763c4c0..33e2ae584b 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/processor/DoingBusinessAsProcessorMatcher.java
+++ b/processor/src/main/java/ca/bc/gov/app/matchers/DoingBusinessAsProcessorMatcher.java
@@ -1,11 +1,12 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
import static java.util.function.Predicate.not;
+import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.entity.legacy.ClientDoingBusinessAsEntity;
-import ca.bc.gov.app.repository.legacy.ClientDoingBusinessAsRepository;
+import ca.bc.gov.app.dto.legacy.ClientDoingBusinessAsDto;
+import ca.bc.gov.app.service.legacy.LegacyService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -18,7 +19,7 @@
@Slf4j
public class DoingBusinessAsProcessorMatcher implements ProcessorMatcher {
- private final ClientDoingBusinessAsRepository doingBusinessAsRepository;
+ private final LegacyService legacyService;
@Override
public boolean enabled(SubmissionInformationDto submission) {
@@ -37,18 +38,18 @@ public Mono matches(SubmissionInformationDto submission) {
return
matchBy(submission.corporationName())
- .map(ClientDoingBusinessAsEntity::getClientNumber)
+ .map(ClientDoingBusinessAsDto::clientNumber)
.collectList()
.filter(not(List::isEmpty))
.map(values ->
- new MatcherResult("corporationName", String.join(",", values))
+ new MatcherResult(ApplicationConstant.MATCH_PARAM_NAME, String.join(",", values))
);
}
- private Flux matchBy(String companyName) {
+ private Flux matchBy(String companyName) {
return
- doingBusinessAsRepository
- .matchBy(companyName)
+ legacyService
+ .matchDba(companyName)
.doOnNext(entity -> log.info("Found a match {}", entity));
}
diff --git a/processor/src/main/java/ca/bc/gov/app/service/processor/GoodStandingProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/matchers/GoodStandingProcessorMatcher.java
similarity index 96%
rename from processor/src/main/java/ca/bc/gov/app/service/processor/GoodStandingProcessorMatcher.java
rename to processor/src/main/java/ca/bc/gov/app/matchers/GoodStandingProcessorMatcher.java
index 815e0d1e2c..1029bc6a92 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/processor/GoodStandingProcessorMatcher.java
+++ b/processor/src/main/java/ca/bc/gov/app/matchers/GoodStandingProcessorMatcher.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
diff --git a/processor/src/main/java/ca/bc/gov/app/service/processor/IncorporationNumberProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/matchers/IncorporationNumberProcessorMatcher.java
similarity index 55%
rename from processor/src/main/java/ca/bc/gov/app/service/processor/IncorporationNumberProcessorMatcher.java
rename to processor/src/main/java/ca/bc/gov/app/matchers/IncorporationNumberProcessorMatcher.java
index d9a7c9f5c6..3dc17bf3cb 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/processor/IncorporationNumberProcessorMatcher.java
+++ b/processor/src/main/java/ca/bc/gov/app/matchers/IncorporationNumberProcessorMatcher.java
@@ -1,23 +1,30 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
import static java.util.function.Predicate.not;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.legacy.ForestClientRepository;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
import java.util.List;
-import lombok.RequiredArgsConstructor;
+import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
+import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
@Component
-@RequiredArgsConstructor
@Slf4j
public class IncorporationNumberProcessorMatcher implements ProcessorMatcher {
- private final ForestClientRepository forestClientRepository;
+
+ private final WebClient legacyClientApi;
+
+ public IncorporationNumberProcessorMatcher(
+ @Qualifier("legacyClientApi") WebClient legacyClientApi
+ ) {
+ this.legacyClientApi = legacyClientApi;
+ }
@Override
public boolean enabled(SubmissionInformationDto submission) {
@@ -35,10 +42,18 @@ public Mono matches(SubmissionInformationDto submission) {
log.info("{} :: Validating {}", name(), submission.incorporationNumber());
return
- forestClientRepository
- .findByIncorporationNumber(submission.incorporationNumber())
+ legacyClientApi
+ .get()
+ .uri(
+ uriBuilder ->
+ uriBuilder
+ .path("/api/search/incorporationOrName")
+ .queryParam("incorporationNumber", submission.incorporationNumber())
+ .build(Map.of())
+ )
+ .exchangeToFlux(response -> response.bodyToFlux(ForestClientDto.class))
.doOnNext(entity -> log.info("Found a match {}", entity))
- .map(ForestClientEntity::getClientNumber)
+ .map(ForestClientDto::clientNumber)
.collectList()
.filter(not(List::isEmpty))
.map(values ->
diff --git a/processor/src/main/java/ca/bc/gov/app/matchers/IndividualProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/matchers/IndividualProcessorMatcher.java
new file mode 100644
index 0000000000..19b5cac0d8
--- /dev/null
+++ b/processor/src/main/java/ca/bc/gov/app/matchers/IndividualProcessorMatcher.java
@@ -0,0 +1,67 @@
+package ca.bc.gov.app.matchers;
+
+import static java.util.function.Predicate.not;
+
+import ca.bc.gov.app.dto.MatcherResult;
+import ca.bc.gov.app.dto.SubmissionInformationDto;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
+import ca.bc.gov.app.util.ProcessorUtil;
+import java.util.List;
+import java.util.Map;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
+
+@Component
+@Slf4j
+public class IndividualProcessorMatcher implements ProcessorMatcher {
+
+ private final WebClient legacyClientApi;
+
+ public IndividualProcessorMatcher(
+ @Qualifier("legacyClientApi") WebClient legacyClientApi
+ ) {
+ this.legacyClientApi = legacyClientApi;
+ }
+
+ @Override
+ public boolean enabled(SubmissionInformationDto submission) {
+ return "I".equalsIgnoreCase(submission.clientType());
+ }
+
+ @Override
+ public String name() {
+ return "Individual Matcher";
+ }
+
+ @Override
+ public Mono matches(SubmissionInformationDto submission) {
+
+ log.info("{} :: Validating {}", name(), submission.corporationName());
+
+ return
+ legacyClientApi
+ .get()
+ .uri(
+ uriBuilder ->
+ uriBuilder
+ .path("/api/search/individual")
+ .queryParam("firstName",
+ ProcessorUtil.splitName(submission.corporationName())[1])
+ .queryParam("lastName",
+ ProcessorUtil.splitName(submission.corporationName())[0])
+ .queryParam("dob", submission.dateOfBirth())
+ .build(Map.of())
+ )
+ .exchangeToFlux(response -> response.bodyToFlux(ForestClientDto.class))
+ .map(ForestClientDto::clientNumber)
+ .collectList()
+ .filter(not(List::isEmpty))
+ .map(values ->
+ new MatcherResult("corporationName", String.join(",", values))
+ );
+ }
+
+}
diff --git a/processor/src/main/java/ca/bc/gov/app/service/processor/LegalNameProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/matchers/LegalNameProcessorMatcher.java
similarity index 54%
rename from processor/src/main/java/ca/bc/gov/app/service/processor/LegalNameProcessorMatcher.java
rename to processor/src/main/java/ca/bc/gov/app/matchers/LegalNameProcessorMatcher.java
index 871d75b55d..53dd3a45aa 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/processor/LegalNameProcessorMatcher.java
+++ b/processor/src/main/java/ca/bc/gov/app/matchers/LegalNameProcessorMatcher.java
@@ -1,24 +1,29 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
import static java.util.function.Predicate.not;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.legacy.ForestClientRepository;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
import java.util.List;
-import lombok.RequiredArgsConstructor;
+import java.util.Map;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
-import reactor.core.publisher.Flux;
+import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
@Component
-@RequiredArgsConstructor
@Slf4j
public class LegalNameProcessorMatcher implements ProcessorMatcher {
- private final ForestClientRepository forestClientRepository;
+ private final WebClient legacyClientApi;
+
+ public LegalNameProcessorMatcher(
+ @Qualifier("legacyClientApi") WebClient legacyClientApi
+ ) {
+ this.legacyClientApi = legacyClientApi;
+ }
@Override
public boolean enabled(SubmissionInformationDto submission) {
@@ -36,8 +41,18 @@ public Mono matches(SubmissionInformationDto submission) {
log.info("{} :: Validating {}", name(), submission.corporationName());
return
- matchBy(submission.corporationName())
- .map(ForestClientEntity::getClientNumber)
+ legacyClientApi
+ .get()
+ .uri(
+ uriBuilder ->
+ uriBuilder
+ .path("/api/search/match")
+ .queryParam("companyName", submission.corporationName())
+ .build(Map.of())
+ )
+ .exchangeToFlux(response -> response.bodyToFlux(ForestClientDto.class))
+ .map(ForestClientDto::clientNumber)
+ .doOnNext(entity -> log.info("Found a match {}", entity))
.collectList()
.filter(not(List::isEmpty))
.map(values ->
@@ -45,12 +60,4 @@ public Mono matches(SubmissionInformationDto submission) {
);
}
- private Flux matchBy(String companyName) {
- return
- forestClientRepository
- .matchBy(companyName)
- .doOnNext(entity -> log.info("Found a match {}", entity));
-
- }
-
}
diff --git a/processor/src/main/java/ca/bc/gov/app/service/processor/ProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/matchers/ProcessorMatcher.java
similarity index 88%
rename from processor/src/main/java/ca/bc/gov/app/service/processor/ProcessorMatcher.java
rename to processor/src/main/java/ca/bc/gov/app/matchers/ProcessorMatcher.java
index 1c892dcc63..fa996918f2 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/processor/ProcessorMatcher.java
+++ b/processor/src/main/java/ca/bc/gov/app/matchers/ProcessorMatcher.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
diff --git a/processor/src/main/java/ca/bc/gov/app/matchers/SoleProprietorProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/matchers/SoleProprietorProcessorMatcher.java
new file mode 100644
index 0000000000..cd9d7a3184
--- /dev/null
+++ b/processor/src/main/java/ca/bc/gov/app/matchers/SoleProprietorProcessorMatcher.java
@@ -0,0 +1,67 @@
+package ca.bc.gov.app.matchers;
+
+import static java.util.function.Predicate.not;
+
+import ca.bc.gov.app.dto.MatcherResult;
+import ca.bc.gov.app.dto.SubmissionInformationDto;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
+import ca.bc.gov.app.util.ProcessorUtil;
+import java.util.List;
+import java.util.Map;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Mono;
+
+@Component
+@Slf4j
+public class SoleProprietorProcessorMatcher implements ProcessorMatcher {
+
+ private final WebClient legacyClientApi;
+
+ public SoleProprietorProcessorMatcher(
+ @Qualifier("legacyClientApi") WebClient legacyClientApi
+ ) {
+ this.legacyClientApi = legacyClientApi;
+ }
+
+ @Override
+ public boolean enabled(SubmissionInformationDto submission) {
+ return List.of("USP", "RSP").contains(submission.clientType());
+ }
+
+ @Override
+ public String name() {
+ return "Sole Proprietor Matcher";
+ }
+
+ @Override
+ public Mono matches(SubmissionInformationDto submission) {
+
+ log.info("{} :: Validating {}", name(), submission.corporationName());
+
+ return
+ legacyClientApi
+ .get()
+ .uri(
+ uriBuilder ->
+ uriBuilder
+ .path("/api/search/individual")
+ .queryParam("firstName",
+ ProcessorUtil.splitName(submission.corporationName())[1])
+ .queryParam("lastName",
+ ProcessorUtil.splitName(submission.corporationName())[0])
+ .queryParam("dob", submission.dateOfBirth())
+ .build(Map.of())
+ )
+ .exchangeToFlux(response -> response.bodyToFlux(ForestClientDto.class))
+ .doOnNext(entity -> log.info("Found a match {}", entity))
+ .map(ForestClientDto::clientNumber)
+ .collectList()
+ .filter(not(List::isEmpty))
+ .map(values ->
+ new MatcherResult("corporationName", String.join(",", values))
+ );
+ }
+}
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/client/CountryCodeRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/CountryCodeRepository.java
similarity index 89%
rename from processor/src/main/java/ca/bc/gov/app/repository/client/CountryCodeRepository.java
rename to processor/src/main/java/ca/bc/gov/app/repository/CountryCodeRepository.java
index 72830d5fd4..b6829f587b 100644
--- a/processor/src/main/java/ca/bc/gov/app/repository/client/CountryCodeRepository.java
+++ b/processor/src/main/java/ca/bc/gov/app/repository/CountryCodeRepository.java
@@ -1,6 +1,6 @@
-package ca.bc.gov.app.repository.client;
+package ca.bc.gov.app.repository;
-import ca.bc.gov.app.entity.client.CountryCodeEntity;
+import ca.bc.gov.app.entity.CountryCodeEntity;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionContactRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionContactRepository.java
similarity index 80%
rename from processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionContactRepository.java
rename to processor/src/main/java/ca/bc/gov/app/repository/SubmissionContactRepository.java
index 44a98ecf2a..f7ec39ab91 100644
--- a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionContactRepository.java
+++ b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionContactRepository.java
@@ -1,6 +1,6 @@
-package ca.bc.gov.app.repository.client;
+package ca.bc.gov.app.repository;
-import ca.bc.gov.app.entity.client.SubmissionContactEntity;
+import ca.bc.gov.app.entity.SubmissionContactEntity;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionDetailRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionDetailRepository.java
similarity index 78%
rename from processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionDetailRepository.java
rename to processor/src/main/java/ca/bc/gov/app/repository/SubmissionDetailRepository.java
index 850f7e0a46..c0de3680f9 100644
--- a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionDetailRepository.java
+++ b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionDetailRepository.java
@@ -1,6 +1,6 @@
-package ca.bc.gov.app.repository.client;
+package ca.bc.gov.app.repository;
-import ca.bc.gov.app.entity.client.SubmissionDetailEntity;
+import ca.bc.gov.app.entity.SubmissionDetailEntity;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Mono;
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionLocationContactRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionLocationContactRepository.java
similarity index 71%
rename from processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionLocationContactRepository.java
rename to processor/src/main/java/ca/bc/gov/app/repository/SubmissionLocationContactRepository.java
index 5bacd19ff1..ef963a02ad 100644
--- a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionLocationContactRepository.java
+++ b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionLocationContactRepository.java
@@ -1,7 +1,7 @@
-package ca.bc.gov.app.repository.client;
+package ca.bc.gov.app.repository;
-import ca.bc.gov.app.entity.client.SubmissionLocationContactEntity;
-import ca.bc.gov.app.entity.client.SubmissionLocationContactIdEntity;
+import ca.bc.gov.app.entity.SubmissionLocationContactEntity;
+import ca.bc.gov.app.entity.SubmissionLocationContactIdEntity;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionLocationRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionLocationRepository.java
similarity index 76%
rename from processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionLocationRepository.java
rename to processor/src/main/java/ca/bc/gov/app/repository/SubmissionLocationRepository.java
index a6c66de747..e5d411ca21 100644
--- a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionLocationRepository.java
+++ b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionLocationRepository.java
@@ -1,6 +1,6 @@
-package ca.bc.gov.app.repository.client;
+package ca.bc.gov.app.repository;
-import ca.bc.gov.app.entity.client.SubmissionLocationEntity;
+import ca.bc.gov.app.entity.SubmissionLocationEntity;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionMatchDetailRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionMatchDetailRepository.java
similarity index 82%
rename from processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionMatchDetailRepository.java
rename to processor/src/main/java/ca/bc/gov/app/repository/SubmissionMatchDetailRepository.java
index 64440bae24..c9175bc346 100644
--- a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionMatchDetailRepository.java
+++ b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionMatchDetailRepository.java
@@ -1,6 +1,6 @@
-package ca.bc.gov.app.repository.client;
+package ca.bc.gov.app.repository;
-import ca.bc.gov.app.entity.client.SubmissionMatchDetailEntity;
+import ca.bc.gov.app.entity.SubmissionMatchDetailEntity;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionRepository.java
similarity index 70%
rename from processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionRepository.java
rename to processor/src/main/java/ca/bc/gov/app/repository/SubmissionRepository.java
index 190bf5b632..4eade01c49 100644
--- a/processor/src/main/java/ca/bc/gov/app/repository/client/SubmissionRepository.java
+++ b/processor/src/main/java/ca/bc/gov/app/repository/SubmissionRepository.java
@@ -1,7 +1,7 @@
-package ca.bc.gov.app.repository.client;
+package ca.bc.gov.app.repository;
-import ca.bc.gov.app.entity.client.SubmissionEntity;
-import ca.bc.gov.app.entity.client.SubmissionTypeCodeEnum;
+import ca.bc.gov.app.entity.SubmissionEntity;
+import ca.bc.gov.app.entity.SubmissionTypeCodeEnum;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ClientDoingBusinessAsRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/legacy/ClientDoingBusinessAsRepository.java
deleted file mode 100644
index a88b803025..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ClientDoingBusinessAsRepository.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package ca.bc.gov.app.repository.legacy;
-
-import ca.bc.gov.app.entity.legacy.ClientDoingBusinessAsEntity;
-import org.springframework.data.r2dbc.repository.Query;
-import org.springframework.data.repository.reactive.ReactiveCrudRepository;
-import org.springframework.data.repository.reactive.ReactiveSortingRepository;
-import org.springframework.stereotype.Repository;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-@Repository
-public interface ClientDoingBusinessAsRepository extends
- ReactiveCrudRepository,
- ReactiveSortingRepository {
-
- Mono existsByClientNumber(String clientNumber);
-
- @Query("""
- SELECT *
- FROM THE.CLIENT_DOING_BUSINESS_AS
- WHERE
- UTL_MATCH.JARO_WINKLER_SIMILARITY(UPPER(DOING_BUSINESS_AS_NAME),UPPER(:companyName)) >= 95
- ORDER BY CLIENT_NUMBER""")
- Flux matchBy(String companyName);
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ClientTypeCompanyXrefRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/legacy/ClientTypeCompanyXrefRepository.java
deleted file mode 100644
index 4b4353dfb4..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ClientTypeCompanyXrefRepository.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package ca.bc.gov.app.repository.legacy;
-
-import ca.bc.gov.app.entity.legacy.ClientTypeCompanyXrefEntity;
-import ca.bc.gov.app.entity.legacy.ClientTypeCompanyXrefEntityKey;
-import org.springframework.data.repository.reactive.ReactiveCrudRepository;
-import reactor.core.publisher.Flux;
-
-public interface ClientTypeCompanyXrefRepository
- extends ReactiveCrudRepository {
-
- Flux findByClientTypeCode(String clientTypeCode);
-
- Flux findByClientTypeCodeAndRegistryCompanyTypeCode(
- String clientTypeCode, String registryCompanyTypeCode);
-
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientContactRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientContactRepository.java
deleted file mode 100644
index 59a90039b5..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientContactRepository.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package ca.bc.gov.app.repository.legacy;
-
-import ca.bc.gov.app.entity.legacy.ForestClientContactEntity;
-import org.springframework.data.repository.reactive.ReactiveCrudRepository;
-
-public interface ForestClientContactRepository
- extends ReactiveCrudRepository {
-
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientRepository.java b/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientRepository.java
deleted file mode 100644
index a58b118b61..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/repository/legacy/ForestClientRepository.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package ca.bc.gov.app.repository.legacy;
-
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import java.time.LocalDateTime;
-import org.springframework.data.r2dbc.repository.Query;
-import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor;
-import org.springframework.data.repository.reactive.ReactiveCrudRepository;
-import org.springframework.data.repository.reactive.ReactiveSortingRepository;
-import org.springframework.stereotype.Repository;
-import reactor.core.publisher.Flux;
-
-@Repository
-public interface ForestClientRepository extends ReactiveCrudRepository,
- ReactiveQueryByExampleExecutor,
- ReactiveSortingRepository {
-
- @Query("""
- SELECT *
- FROM THE.FOREST_CLIENT
- WHERE
- UTL_MATCH.JARO_WINKLER_SIMILARITY(UPPER(CLIENT_NAME),UPPER(:companyName)) >= 95
- AND CLIENT_STATUS_CODE = 'ACT'
- ORDER BY CLIENT_NUMBER""")
- Flux matchBy(String companyName);
-
- @Query("""
- SELECT *
- FROM THE.FOREST_CLIENT
- WHERE
- (REGISTRY_COMPANY_TYPE_CODE || CORP_REGN_NMBR) = :incorporationNumber
- AND CLIENT_STATUS_CODE = 'ACT'
- ORDER BY CLIENT_NUMBER""")
- Flux findByIncorporationNumber(String incorporationNumber);
-
- @Query("""
- SELECT *
- FROM THE.FOREST_CLIENT
- WHERE
- UPPER(LEGAL_FIRST_NAME) = UPPER(:firstName)
- AND UPPER(CLIENT_NAME) = UPPER(:lastName)
- AND BIRTHDATE = :dob
- AND CLIENT_STATUS_CODE = 'ACT'
- AND CLIENT_TYPE_CODE = 'I'
- ORDER BY CLIENT_NUMBER""")
- Flux findByIndividual(String firstName, String lastName, LocalDateTime dob);
-
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionAutoProcessingService.java b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionAutoProcessingService.java
index e268fe8659..4b669dc66a 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionAutoProcessingService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionAutoProcessingService.java
@@ -3,11 +3,11 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.EmailRequestDto;
import ca.bc.gov.app.dto.MatcherResult;
-import ca.bc.gov.app.entity.client.SubmissionMatchDetailEntity;
-import ca.bc.gov.app.entity.client.SubmissionStatusEnum;
-import ca.bc.gov.app.entity.client.SubmissionTypeCodeEnum;
-import ca.bc.gov.app.repository.client.SubmissionMatchDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
+import ca.bc.gov.app.entity.SubmissionMatchDetailEntity;
+import ca.bc.gov.app.entity.SubmissionStatusEnum;
+import ca.bc.gov.app.entity.SubmissionTypeCodeEnum;
+import ca.bc.gov.app.repository.SubmissionMatchDetailRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
diff --git a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingService.java b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingService.java
index 7eb7f998d6..398e9b9843 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingService.java
@@ -3,8 +3,8 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.EmailRequestDto;
import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -43,6 +43,7 @@ public Mono> loadSubmissionDetails(Integer sub
.doOnNext(submission -> log.info("Loaded submission details {}", submission))
//Grab what we need for the match part
.map(details -> new SubmissionInformationDto(
+ submissionId,
details.getOrganizationName(),
details.getBirthdate(),
details.getIncorporationNumber(),
diff --git a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java
index 519ee2b7c4..7388ba75db 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionMailService.java
@@ -2,7 +2,7 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.EmailRequestDto;
-import ca.bc.gov.app.entity.client.SubmissionTypeCodeEnum;
+import ca.bc.gov.app.entity.SubmissionTypeCodeEnum;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
diff --git a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionProcessingService.java b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionProcessingService.java
index 2a73e3f2ea..8b0491a5c0 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionProcessingService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/client/ClientSubmissionProcessingService.java
@@ -2,12 +2,12 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.EmailRequestDto;
-import ca.bc.gov.app.entity.client.SubmissionMatchDetailEntity;
-import ca.bc.gov.app.entity.client.SubmissionStatusEnum;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionMatchDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
+import ca.bc.gov.app.entity.SubmissionMatchDetailEntity;
+import ca.bc.gov.app.entity.SubmissionStatusEnum;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionMatchDetailRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import ca.bc.gov.app.util.ProcessorUtil;
import java.util.Map;
import java.util.Optional;
diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java
index 57397db2a3..c2fd9a0478 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceService.java
@@ -1,45 +1,23 @@
package ca.bc.gov.app.service.legacy;
-import static java.util.function.Predicate.not;
-
import ca.bc.gov.app.ApplicationConstant;
-import ca.bc.gov.app.entity.client.SubmissionContactEntity;
-import ca.bc.gov.app.entity.client.SubmissionDetailEntity;
-import ca.bc.gov.app.entity.client.SubmissionLocationContactEntity;
-import ca.bc.gov.app.entity.client.SubmissionLocationEntity;
-import ca.bc.gov.app.entity.client.SubmissionTypeCodeEnum;
-import ca.bc.gov.app.entity.legacy.ClientDoingBusinessAsEntity;
-import ca.bc.gov.app.entity.legacy.ForestClientContactEntity;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.entity.legacy.ForestClientLocationEntity;
-import ca.bc.gov.app.repository.client.CountryCodeRepository;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
-import ca.bc.gov.app.repository.legacy.ClientDoingBusinessAsRepository;
+import ca.bc.gov.app.dto.legacy.ForestClientContactDto;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
+import ca.bc.gov.app.entity.SubmissionDetailEntity;
+import ca.bc.gov.app.entity.SubmissionLocationEntity;
+import ca.bc.gov.app.entity.SubmissionTypeCodeEnum;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionLocationContactRepository;
+import ca.bc.gov.app.repository.SubmissionLocationRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import ca.bc.gov.app.util.ProcessorUtil;
-import jakarta.annotation.PostConstruct;
-import java.time.LocalDateTime;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.BiFunction;
-import java.util.function.Consumer;
import java.util.function.Function;
-import java.util.function.IntFunction;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.StringUtils;
-import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
-import org.springframework.data.relational.core.query.Criteria;
-import org.springframework.data.relational.core.query.Query;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
@@ -63,35 +41,14 @@ public abstract class LegacyAbstractPersistenceService {
@Getter
private final SubmissionContactRepository contactRepository;
private final SubmissionLocationContactRepository locationContactRepository;
- private final R2dbcEntityOperations legacyR2dbcEntityTemplate;
- private final CountryCodeRepository countryCodeRepository;
- private final ClientDoingBusinessAsRepository doingBusinessAsRepository;
-
- private final Map countryList = new HashMap<>();
-
+ private final LegacyService legacyService;
- abstract Mono> generateForestClient(Message message);
+ abstract Mono> generateForestClient(Message message);
abstract boolean filterByType(String clientTypeCode);
abstract String getNextChannel();
- /**
- * Loads the country list from the database.
- */
- @PostConstruct
- public void setUp() {
- countryCodeRepository
- .findAll()
- .doOnNext(countryCode ->
- countryList.put(
- countryCode.getCountryCode(),
- countryCode.getDescription()
- )
- )
- .collectList()
- .subscribe();
- }
/**
* Loads the submission from the database and prepares the message for next step.
@@ -127,10 +84,6 @@ public Mono> loadSubmission(Message message) {
async = "true"
)
public Mono> checkClientData(Message message) {
-
- AtomicBoolean existingClient = new AtomicBoolean(false);
- AtomicReference clientTypeCode = new AtomicReference<>(StringUtils.EMPTY);
-
return submissionDetailRepository
.findBySubmissionId(message.getPayload())
.doOnNext(
@@ -142,57 +95,22 @@ public Mono> checkClientData(Message message) {
submissionDetail.getIncorporationNumber()
)
)
- .doOnNext(submissionDetail ->
- clientTypeCode.set(submissionDetail.getClientTypeCode()))
+ .filter(submissionDetail -> filterByType(submissionDetail.getClientTypeCode()))
.flatMap(submissionDetail ->
- Mono.justOrEmpty(
- Optional
- .ofNullable(submissionDetail.getClientNumber())
- .filter(StringUtils::isNotBlank)
- )
- .doOnNext(clientNumber -> log.info(
- "Client number {} exists for submission {}",
- clientNumber,
- message.getPayload()
- ))
- .doOnNext(clientNumber -> existingClient.set(true))
- .switchIfEmpty(getNextClientNumber())
- )
- .filter(data -> filterByType(clientTypeCode.get()))
- .doOnNext(clientNumber ->
- log.info(
- "Client number {}{} for submission {}",
- clientNumber,
- existingClient.get() ? " exists" : " is new",
- message.getPayload()
- )
- )
- .flatMap(clientNumber ->
-
contactRepository
.findFirstBySubmissionId(message.getPayload())
.map(contact ->
MessageBuilder
- .withPayload(existingClient.get() ? message.getPayload() : clientNumber)
+ .withPayload(message.getPayload())
.copyHeaders(message.getHeaders())
.setHeader(ApplicationConstant.SUBMISSION_ID, message.getPayload())
- .setHeader(ApplicationConstant.CLIENT_EXISTS, existingClient.get())
- .setHeader(ApplicationConstant.CLIENT_TYPE_CODE, clientTypeCode.get())
- .setHeader(ApplicationConstant.FOREST_CLIENT_NUMBER, clientNumber)
+ .setHeader(ApplicationConstant.CLIENT_TYPE_CODE,
+ submissionDetail.getClientTypeCode())
.setHeader(ApplicationConstant.CLIENT_SUBMITTER_NAME,
contact.getFirstName() + " " + contact.getLastName())
- .setReplyChannelName(
- existingClient.get()
- ? ApplicationConstant.SUBMISSION_LEGACY_LOCATION_CHANNEL
- : getNextChannel())
- .setHeader("output-channel",
- existingClient.get()
- ? ApplicationConstant.SUBMISSION_LEGACY_LOCATION_CHANNEL
- : getNextChannel())
- .setHeader(MessageHeaders.REPLY_CHANNEL,
- existingClient.get()
- ? ApplicationConstant.SUBMISSION_LEGACY_LOCATION_CHANNEL
- : getNextChannel())
+ .setReplyChannelName(getNextChannel())
+ .setHeader("output-channel", getNextChannel())
+ .setHeader(MessageHeaders.REPLY_CHANNEL, getNextChannel())
.build()
)
);
@@ -206,7 +124,7 @@ public Mono> checkClientData(Message message) {
outputChannel = ApplicationConstant.SUBMISSION_LEGACY_LOCATION_CHANNEL,
async = "true"
)
- public Mono> createForestClient(Message message) {
+ public Mono> createForestClient(Message message) {
if (!filterByType(
message.getHeaders().get(ApplicationConstant.CLIENT_TYPE_CODE, String.class))) {
@@ -215,19 +133,16 @@ public Mono> createForestClient(Message mes
log.info("Creating Forest Client {} {}",
message.getHeaders().get(ApplicationConstant.FOREST_CLIENT_NAME),
- message.getPayload().getClientNumber()
+ message.getPayload().clientNumber()
);
+
return
- legacyR2dbcEntityTemplate
- .insert(ForestClientEntity.class)
- .using(message.getPayload())
- .flatMap(forestClient ->
- Mono.just(isRegisteredSoleProprietorship(forestClient))
- .filter(Boolean::booleanValue)
- .flatMap(isRSP -> createClientDoingBusinessAs(message, forestClient))
- .thenReturn(forestClient.getClientNumber())
- .defaultIfEmpty(forestClient.getClientNumber())
- )
+ // Create the client
+ legacyService
+ .createClient(message.getPayload())
+ // Create the doing business as IF exists
+ .flatMap(clientNumber -> createClientDoingBusinessAs(message, clientNumber))
+ // Updates the submission detail with the client number
.flatMap(clientNumber ->
submissionDetailRepository
.findBySubmissionId(
@@ -254,9 +169,12 @@ public Mono> createForestClient(Message mes
);
}
-
/**
- * Creates a location if does not exist on oracle.
+ * Creates a location if it does not exist on oracle. The creation happens by sending a request to
+ * the legacy service.
+ *
+ * @param message A message containing the submission id
+ * @return A flux of messages containing the submission id and the location id
*/
@ServiceActivator(
inputChannel = ApplicationConstant.SUBMISSION_LEGACY_LOCATION_CHANNEL,
@@ -282,59 +200,15 @@ public Flux> createLocations(Message message) {
)
);
- BiFunction> locateClientLocation = (clientNumber, locationCode) ->
- legacyR2dbcEntityTemplate
- .selectOne(
- Query.query(
- Criteria
- .where("CLIENT_LOCN_CODE").is(locationCode)
- .and(ApplicationConstant.CLIENT_NUMBER).is(clientNumber)
- ),
- ForestClientLocationEntity.class
- )
- .doOnNext(forestClientLocation ->
- log.info(
- "Forest client location {} {} already exists for submission {}",
- forestClientLocation.getClientLocnCode(),
- forestClientLocation.getClientLocnName(),
- message.getPayload()
- )
- );
-
- BiFunction> createClientLocation = (index, detail) ->
- toForestClientLocationEntity(index, detail)
- .doOnNext(submissionLocation ->
- log.info(
- "Loaded submission location for persistence on oracle {} {} {}",
- message.getPayload(),
- submissionLocation.getClientLocnCode(),
- submissionLocation.getClientLocnName()
- )
- )
- .doOnNext(forestClient -> forestClient.setCreatedBy(getUser(message,
- ApplicationConstant.CREATED_BY)))
- .doOnNext(forestClient -> forestClient.setUpdatedBy(getUser(message,
- ApplicationConstant.UPDATED_BY)))
- .doOnNext(forestClient -> forestClient.setClientNumber(getClientNumber(message)))
- .doOnNext(forestClient ->
- log.info(
- "Saving forest client location {} {} {}",
- message.getPayload(),
- forestClient.getClientLocnName(),
- forestClient
- )
- )
- .flatMap(forestClientLocation ->
- legacyR2dbcEntityTemplate
- .insert(ForestClientLocationEntity.class)
- .using(forestClientLocation)
- );
-
return data
.index((index, detail) ->
- locateClientLocation
- .apply(getClientNumber(message), String.format("%02d", index))
- .switchIfEmpty(createClientLocation.apply(index, detail))
+ legacyService
+ .createLocation(
+ detail,
+ getClientNumber(message),
+ index,
+ getUser(message, ApplicationConstant.CREATED_BY)
+ )
.flatMap(forestClient ->
data
.count()
@@ -351,7 +225,7 @@ public Flux> createLocations(Message message) {
.fromMessage(message)
.copyHeaders(message.getHeaders())
.setHeader(ApplicationConstant.LOCATION_CODE,
- forestClient.getClientLocnCode())
+ String.format("%02d", index))
.setHeader(ApplicationConstant.LOCATION_ID,
detail.getSubmissionLocationId())
.setHeader(ApplicationConstant.TOTAL, count)
@@ -379,102 +253,47 @@ public Mono> createContact(Message message) {
message.getHeaders().get(ApplicationConstant.CLIENT_TYPE_CODE, String.class))) {
return Mono.empty();
}
-
- // Load the contact in case it exists
- IntFunction> forestContact =
- contactId ->
- contactRepository
- .findById(contactId)
- .flatMapMany(submissionContact ->
- legacyR2dbcEntityTemplate
- .select(
- Query
- .query(
- Criteria
- .where(ApplicationConstant.CLIENT_NUMBER)
- .is(getClientNumber(message))
- .and("CLIENT_LOCN_CODE").is(
- Objects.requireNonNull(message.getHeaders()
- .get(ApplicationConstant.LOCATION_CODE, String.class)
- )
- )
- .and("CONTACT_NAME").is(
- String.format("%s %s",
- submissionContact.getFirstName().toUpperCase(),
- submissionContact.getLastName().toUpperCase())
- )
- ),
- ForestClientContactEntity.class
- )
- )
- .next()
- .doOnNext(forestClientContact ->
- log.info(
- "Forest client contact {} {} already exists for submission {}",
- forestClientContact.getClientContactId(),
- forestClientContact.getContactName(),
- message.getPayload()
- )
- );
-
- // Load the contact and converts it into a forest client contact entity
- IntFunction> toContact = contactId ->
- contactRepository
- .findById(contactId)
- .doOnNext(submissionContact ->
- log.info(
- "Loaded submission contact for persistence on oracle {} {} {} {}",
- message.getPayload(),
- submissionContact.getFirstName(),
- submissionContact.getLastName(),
- message.getHeaders().get(ApplicationConstant.LOCATION_CODE, String.class)
- )
- )
- .map(this::toForestClientContactEntity)
- .doOnNext(forestClient -> forestClient.setCreatedBy(getUser(message,
- ApplicationConstant.CREATED_BY)))
- .doOnNext(forestClient -> forestClient.setUpdatedBy(getUser(message,
- ApplicationConstant.UPDATED_BY)))
- .doOnNext(forestClient -> forestClient.setClientNumber(getClientNumber(message)))
- .doOnNext(forestClientContact -> forestClientContact.setClientLocnCode(
- message.getHeaders().get(ApplicationConstant.LOCATION_CODE, String.class)
- )
- );
-
- // Convert the contact into a forest client contact entity and save it
- Function> createContact =
- locationContact ->
- toContact
- .apply(locationContact.getSubmissionContactId())
- .flatMap(forestClientContact ->
- getNextContactId()
- .doOnNext(forestClientContact::setClientContactId)
- .thenReturn(forestClientContact)
- )
- .flatMap(contact ->
- legacyR2dbcEntityTemplate
- .insert(ForestClientContactEntity.class)
- .using(contact)
- )
- .doOnNext(forestClientContact ->
- log.info(
- "Saved forest client contact {} {} {}",
- message.getPayload(),
- getClientNumber(message),
- forestClientContact.getContactName()
- )
- );
-
+ // Load all contacts for this location
return locationContactRepository
.findBySubmissionLocationId(
message.getHeaders().get(ApplicationConstant.LOCATION_ID, Integer.class)
)
- .flatMap(locationContactEntity ->
- forestContact
- .apply(locationContactEntity.getSubmissionContactId())
- .switchIfEmpty(createContact.apply(locationContactEntity))
+ // Load the contact detail
+ .flatMap(locationContact ->
+ contactRepository
+ .findById(locationContact.getSubmissionContactId())
+ )
+ // Log the contact detail
+ .doOnNext(submissionContact ->
+ log.info(
+ "Loaded submission contact for persistence on oracle {} {} {} {}",
+ message.getPayload(),
+ submissionContact.getFirstName(),
+ submissionContact.getLastName(),
+ message.getHeaders().get(ApplicationConstant.LOCATION_CODE, String.class)
+ )
)
+ // Convert it to a DTO
+ .map(submissionContact ->
+ new ForestClientContactDto(
+ getClientNumber(message),
+ message.getHeaders().get(ApplicationConstant.LOCATION_CODE, String.class),
+ submissionContact.getContactTypeCode(),
+ String.format("%s %s", submissionContact.getFirstName(),
+ submissionContact.getLastName()).toUpperCase(),
+ RegExUtils.replaceAll(submissionContact.getBusinessPhoneNumber(), "\\D",
+ StringUtils.EMPTY),
+ submissionContact.getEmailAddress(),
+ getUser(message, ApplicationConstant.CREATED_BY),
+ getUser(message, ApplicationConstant.UPDATED_BY),
+ ApplicationConstant.ORG_UNIT
+ )
+ )
+ // Send it to the legacy service for processing
+ .flatMap(legacyService::createContact)
+ // Gets all back in sequence
.collectList()
+ // Move on to the next step
.thenReturn(message);
}
@@ -515,27 +334,27 @@ public Mono> sendNotification(Message message) {
);
}
- protected ForestClientEntity getBaseForestClient(
- String createdBy,
- String updatedBy
- ) {
- return ForestClientEntity
- .builder()
- .clientNumber("000")
- .clientStatusCode("ACT")
- .createdAt(LocalDateTime.now())
- .updatedAt(LocalDateTime.now())
- .revision(1L)
- .createdBy(ApplicationConstant.PROCESSOR_USER_NAME)
- .updatedBy(ApplicationConstant.PROCESSOR_USER_NAME)
- .addOrgUnit(ApplicationConstant.ORG_UNIT)
- .updateOrgUnit(ApplicationConstant.ORG_UNIT)
- .createdBy(createdBy)
- .updatedBy(updatedBy)
- .build();
+ protected ForestClientDto getBaseForestClient(String createdBy, String updatedBy) {
+ return
+ new ForestClientDto(
+ "00",
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ "ACT",
+ StringUtils.EMPTY,
+ null,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ createdBy,
+ updatedBy,
+ ApplicationConstant.ORG_UNIT
+ );
}
-
protected String getUser(Message> message, String headerName) {
return ProcessorUtil
.readHeader(
@@ -546,170 +365,34 @@ protected String getUser(Message> message, String headerName) {
.orElse(ApplicationConstant.PROCESSOR_USER_NAME);
}
- private Mono getNextClientNumber() {
- return
- legacyR2dbcEntityTemplate
- .getDatabaseClient()
- .sql("""
- UPDATE
- max_client_nmbr
- SET
- client_number = (SELECT LPAD(TO_NUMBER(NVL(max(CLIENT_NUMBER),'0'))+1,8,'0') FROM FOREST_CLIENT)"""
- )
- .fetch()
- .rowsUpdated()
- .then(
- legacyR2dbcEntityTemplate
- .getDatabaseClient()
- .sql("SELECT client_number FROM max_client_nmbr")
- .map((row, rowMetadata) -> row.get("client_number", String.class))
- .first()
- );
- }
-
- private Mono getNextDoingBusinessAs() {
- return
- legacyR2dbcEntityTemplate
- .getDatabaseClient()
- .sql("select THE.client_dba_seq.NEXTVAL from dual")
- .fetch()
- .first()
- .map(row -> row.get("NEXTVAL"))
- .map(String::valueOf)
- .map(Integer::parseInt);
+ private String getClientNumber(Message> message) {
+ return ProcessorUtil.readHeader(message, ApplicationConstant.FOREST_CLIENT_NUMBER, String.class)
+ .orElse(StringUtils.EMPTY);
}
- private Mono getNextContactId() {
- return legacyR2dbcEntityTemplate
- .getDatabaseClient()
- .sql("SELECT THE.client_contact_seq.NEXTVAL FROM dual")
- .fetch()
- .first()
- .map(row -> row.get("NEXTVAL"))
- .map(String::valueOf);
+ private boolean isRegisteredSoleProprietorship(ForestClientDto forestClient) {
+ return forestClient.clientTypeCode().equalsIgnoreCase("I") && StringUtils.equalsIgnoreCase(
+ forestClient.clientIdTypeCode(), "BCRE");
}
- private Mono createClientDoingBusinessAs(
- Message message, ForestClientEntity forestClient) {
- return doingBusinessAsRepository
- .existsByClientNumber(forestClient.getClientNumber())
- .filter(not(Boolean::booleanValue))
- .flatMap(doesNotExist -> getNextDoingBusinessAs())
- .map(nextId ->
- ClientDoingBusinessAsEntity
- .builder()
- .id(nextId)
- .clientNumber(forestClient.getClientNumber())
- .doingBusinessAsName(message
- .getHeaders()
- .get(ApplicationConstant.FOREST_CLIENT_NAME,
- String.class)
- )
- .revision(1L)
- .createdBy(ApplicationConstant.PROCESSOR_USER_NAME)
- .createdAt(LocalDateTime.now())
- .updatedBy(ApplicationConstant.PROCESSOR_USER_NAME)
- .updatedAt(LocalDateTime.now())
- .addOrgUnit(ApplicationConstant.ORG_UNIT)
- .updateOrgUnit(ApplicationConstant.ORG_UNIT)
- .build()
+ private Mono createClientDoingBusinessAs(Message message,
+ String clientNumber) {
+ return Mono
+ .just(clientNumber)
+ .filter(
+ forestClientNumber -> isRegisteredSoleProprietorship(message.getPayload())
)
- .flatMap(doingBusinessAs ->
- legacyR2dbcEntityTemplate
- .insert(ClientDoingBusinessAsEntity.class)
- .using(doingBusinessAs)
- );
- }
-
- private boolean isRegisteredSoleProprietorship(ForestClientEntity forestClient) {
- return forestClient
- .getClientTypeCode()
- .equalsIgnoreCase("I")
- &&
- StringUtils.equalsIgnoreCase(
- forestClient
- .getClientIdTypeCode(),
- "BCRE"
- );
- }
-
- private Mono toForestClientLocationEntity(
- long index,
- SubmissionLocationEntity submissionLocation
- ) {
- return Mono.just(ForestClientLocationEntity
- .builder()
- .clientLocnCode(String.format("%02d", index))
- .clientLocnName(submissionLocation.getName().toUpperCase())
- .addressOne(submissionLocation.getStreetAddress())
- .city(submissionLocation.getCityName())
- .province(submissionLocation.getProvinceCode())
- //So as not to impact HBS, set HDBS Company Code to a space if not provided
- //as it would have been in CLI
- .hdbsCompanyCode(" ")
- .country(
- countryList
- .getOrDefault(
- submissionLocation.getCountryCode(),
- submissionLocation.getCountryCode()
+ .flatMap(forestClientNumber ->
+ legacyService
+ .createDoingBusinessAs(
+ forestClientNumber,
+ message.getHeaders().get(ApplicationConstant.FOREST_CLIENT_NAME,
+ String.class),
+ getUser(message, ApplicationConstant.CREATED_BY),
+ getUser(message, ApplicationConstant.UPDATED_BY)
)
)
- .postalCode(submissionLocation.getPostalCode())
- .businessPhone(null)
- .homePhone(null)
- .cellPhone(null)
- .faxNumber(null)
- .emailAddress(null)
- .locnExpiredInd("N")
- .returnedMailDate(null)
- .trustLocationInd("Y")
- .cliLocnComment(null)
- .createdAt(LocalDateTime.now())
- .updatedAt(LocalDateTime.now())
- .revision(1L)
- .createdBy(ApplicationConstant.PROCESSOR_USER_NAME)
- .updatedBy(ApplicationConstant.PROCESSOR_USER_NAME)
- .addOrgUnit(ApplicationConstant.ORG_UNIT)
- .updateOrgUnit(ApplicationConstant.ORG_UNIT)
- .build()
- );
- }
-
- private String getClientNumber(Message> message) {
- return ProcessorUtil
- .readHeader(
- message,
- ApplicationConstant.FOREST_CLIENT_NUMBER,
- String.class
- )
- .orElse(StringUtils.EMPTY);
- }
-
- private ForestClientContactEntity toForestClientContactEntity(
- SubmissionContactEntity submissionContact
- ) {
- return ForestClientContactEntity
- .builder()
- .contactCode(submissionContact.getContactTypeCode())
- .contactName(String.format("%s %s", submissionContact.getFirstName(),
- submissionContact.getLastName()).toUpperCase())
- .businessPhone(
- RegExUtils.replaceAll(submissionContact.getBusinessPhoneNumber(), "\\D",
- StringUtils.EMPTY)
- )
- .emailAddress(submissionContact.getEmailAddress())
- .createdAt(LocalDateTime.now())
- .updatedAt(LocalDateTime.now())
- .revision(1L)
- .createdBy(ApplicationConstant.PROCESSOR_USER_NAME)
- .updatedBy(ApplicationConstant.PROCESSOR_USER_NAME)
- .addOrgUnit(ApplicationConstant.ORG_UNIT)
- .updateOrgUnit(ApplicationConstant.ORG_UNIT)
- .build();
- }
-
- private Consumer debug(String message) {
- return data -> log.info("[{}] :: {}", message, data);
+ .defaultIfEmpty(clientNumber);
}
}
diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyClientPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyClientPersistenceService.java
index 6b56aef1a5..3a17348e28 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyClientPersistenceService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyClientPersistenceService.java
@@ -2,19 +2,16 @@
package ca.bc.gov.app.service.legacy;
import ca.bc.gov.app.ApplicationConstant;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.client.CountryCodeRepository;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
-import ca.bc.gov.app.repository.legacy.ClientDoingBusinessAsRepository;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionLocationContactRepository;
+import ca.bc.gov.app.repository.SubmissionLocationRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import ca.bc.gov.app.util.ProcessorUtil;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
@@ -29,26 +26,17 @@
@Slf4j
public class LegacyClientPersistenceService extends LegacyAbstractPersistenceService {
+
public LegacyClientPersistenceService(
SubmissionDetailRepository submissionDetailRepository,
SubmissionRepository submissionRepository,
SubmissionLocationRepository locationRepository,
SubmissionContactRepository contactRepository,
SubmissionLocationContactRepository locationContactRepository,
- R2dbcEntityOperations legacyR2dbcEntityTemplate,
- CountryCodeRepository countryCodeRepository,
- ClientDoingBusinessAsRepository doingBusinessAsRepository
+ LegacyService legacyService
) {
- super(
- submissionDetailRepository,
- submissionRepository,
- locationRepository,
- contactRepository,
- locationContactRepository,
- legacyR2dbcEntityTemplate,
- countryCodeRepository,
- doingBusinessAsRepository
- );
+ super(submissionDetailRepository, submissionRepository, locationRepository, contactRepository,
+ locationContactRepository, legacyService);
}
/**
@@ -73,7 +61,7 @@ String getNextChannel() {
async = "true"
)
@Override
- public Mono> generateForestClient(Message message) {
+ public Mono> generateForestClient(Message message) {
return
getSubmissionDetailRepository()
.findBySubmissionId(
@@ -107,12 +95,12 @@ public Mono> generateForestClient(Message me
.withPayload(forestClient)
.copyHeaders(message.getHeaders())
.setHeader(ApplicationConstant.FOREST_CLIENT_NAME,
- forestClient.getClientName()
+ forestClient.clientName()
)
.setHeader(ApplicationConstant.INCORPORATION_NUMBER,
String.join(StringUtils.EMPTY,
- forestClient.getRegistryCompanyTypeCode(),
- forestClient.getCorpRegnNmbr()
+ forestClient.registryCompanyTypeCode(),
+ forestClient.corpRegnNmbr()
)
)
.build()
diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java
index 61220add32..84361bd6db 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyIndividualPersistenceService.java
@@ -2,18 +2,15 @@
package ca.bc.gov.app.service.legacy;
import ca.bc.gov.app.ApplicationConstant;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.client.CountryCodeRepository;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
-import ca.bc.gov.app.repository.legacy.ClientDoingBusinessAsRepository;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionLocationContactRepository;
+import ca.bc.gov.app.repository.SubmissionLocationRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import ca.bc.gov.app.util.ProcessorUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
@@ -28,26 +25,17 @@
@Slf4j
public class LegacyIndividualPersistenceService extends LegacyAbstractPersistenceService {
+
public LegacyIndividualPersistenceService(
SubmissionDetailRepository submissionDetailRepository,
SubmissionRepository submissionRepository,
SubmissionLocationRepository locationRepository,
SubmissionContactRepository contactRepository,
SubmissionLocationContactRepository locationContactRepository,
- R2dbcEntityOperations legacyR2dbcEntityTemplate,
- CountryCodeRepository countryCodeRepository,
- ClientDoingBusinessAsRepository doingBusinessAsRepository
+ LegacyService legacyService
) {
- super(
- submissionDetailRepository,
- submissionRepository,
- locationRepository,
- contactRepository,
- locationContactRepository,
- legacyR2dbcEntityTemplate,
- countryCodeRepository,
- doingBusinessAsRepository
- );
+ super(submissionDetailRepository, submissionRepository, locationRepository, contactRepository,
+ locationContactRepository, legacyService);
}
/**
@@ -75,7 +63,7 @@ String getNextChannel() {
async = "true"
)
@Override
- public Mono> generateForestClient(Message message) {
+ public Mono> generateForestClient(Message message) {
return
getSubmissionDetailRepository()
.findBySubmissionId(
@@ -112,8 +100,8 @@ public Mono> generateForestClient(Message me
.copyHeaders(message.getHeaders())
.setHeader(ApplicationConstant.FOREST_CLIENT_NAME,
String.join(" ",
- forestClient.getLegalFirstName(),
- forestClient.getClientName()
+ forestClient.legalFirstName(),
+ forestClient.clientName()
)
)
.setHeader(ApplicationConstant.INCORPORATION_NUMBER,
diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyLoadingService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyLoadingService.java
index 3271d46a75..08a3c88cb1 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyLoadingService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyLoadingService.java
@@ -3,7 +3,7 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.service.processor.ProcessorMatcher;
+import ca.bc.gov.app.matchers.ProcessorMatcher;
import java.util.List;
import java.util.function.Function;
import lombok.RequiredArgsConstructor;
diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceService.java
index 6321fa2386..b5e3a636a6 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyRegisteredSPPersistenceService.java
@@ -3,20 +3,17 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.bcregistry.BcRegistryPartyDto;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.client.CountryCodeRepository;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
-import ca.bc.gov.app.repository.legacy.ClientDoingBusinessAsRepository;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionLocationContactRepository;
+import ca.bc.gov.app.repository.SubmissionLocationRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import ca.bc.gov.app.service.bcregistry.BcRegistryService;
import ca.bc.gov.app.util.ProcessorUtil;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
@@ -41,24 +38,15 @@ public LegacyRegisteredSPPersistenceService(
SubmissionLocationRepository locationRepository,
SubmissionContactRepository contactRepository,
SubmissionLocationContactRepository locationContactRepository,
- R2dbcEntityOperations legacyR2dbcEntityTemplate,
- CountryCodeRepository countryCodeRepository,
- ClientDoingBusinessAsRepository doingBusinessAsRepository,
+ LegacyService legacyService,
BcRegistryService bcRegistryService
) {
- super(
- submissionDetailRepository,
- submissionRepository,
- locationRepository,
- contactRepository,
- locationContactRepository,
- legacyR2dbcEntityTemplate,
- countryCodeRepository,
- doingBusinessAsRepository
- );
+ super(submissionDetailRepository, submissionRepository, locationRepository, contactRepository,
+ locationContactRepository, legacyService);
this.bcRegistryService = bcRegistryService;
}
+
/**
* This method is responsible for filtering the submission based on the type.
*
@@ -81,7 +69,7 @@ String getNextChannel() {
async = "true"
)
@Override
- public Mono> generateForestClient(Message message) {
+ public Mono> generateForestClient(Message message) {
return
getSubmissionDetailRepository()
@@ -115,7 +103,7 @@ public Mono> generateForestClient(Message me
//Load the details to set the remaining fields
.flatMap(forestClient ->
bcRegistryService
- .requestDocumentData(forestClient.getClientIdentification())
+ .requestDocumentData(forestClient.clientIdentification())
// Should only be one
.next()
// Get the proprietor or empty if none
@@ -170,13 +158,13 @@ public Mono> generateForestClient(Message me
.copyHeaders(message.getHeaders())
.setHeader(ApplicationConstant.FOREST_CLIENT_NAME,
forestClient
- .getClientComment()
+ .clientComment()
.split("and company name ")[1]
)
.setHeader(ApplicationConstant.INCORPORATION_NUMBER,
String.join(StringUtils.EMPTY,
- forestClient.getRegistryCompanyTypeCode(),
- forestClient.getCorpRegnNmbr()
+ forestClient.registryCompanyTypeCode(),
+ forestClient.corpRegnNmbr()
)
)
.build()
diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java
new file mode 100644
index 0000000000..3628936fbd
--- /dev/null
+++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyService.java
@@ -0,0 +1,153 @@
+package ca.bc.gov.app.service.legacy;
+
+import ca.bc.gov.app.ApplicationConstant;
+import ca.bc.gov.app.dto.legacy.ClientDoingBusinessAsDto;
+import ca.bc.gov.app.dto.legacy.ForestClientContactDto;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
+import ca.bc.gov.app.dto.legacy.ForestClientLocationDto;
+import ca.bc.gov.app.entity.SubmissionLocationEntity;
+import ca.bc.gov.app.repository.CountryCodeRepository;
+import jakarta.annotation.PostConstruct;
+import java.util.HashMap;
+import java.util.Map;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Service;
+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;
+
+@Service
+@Slf4j
+public class LegacyService {
+
+ private final WebClient legacyApi;
+ private final CountryCodeRepository countryCodeRepository;
+ private final Map countryList = new HashMap<>();
+
+
+ public LegacyService(
+ @Qualifier("legacyClientApi") WebClient legacyApi,
+ CountryCodeRepository countryCodeRepository
+ ) {
+ this.legacyApi = legacyApi;
+ this.countryCodeRepository = countryCodeRepository;
+ }
+
+ /**
+ * Loads the country list from the database.
+ */
+ @PostConstruct
+ public void setUp() {
+ countryCodeRepository.findAll().doOnNext(
+ countryCode -> countryList.put(countryCode.getCountryCode(), countryCode.getDescription()))
+ .collectList().subscribe();
+ }
+
+
+ public Mono createLocation(
+ SubmissionLocationEntity detail,
+ String clientNumber,
+ Long index,
+ String user
+ ) {
+
+ ForestClientLocationDto dto =
+ new ForestClientLocationDto(
+ clientNumber,
+ String.format("%02d", index),
+ detail.getName(),
+ detail.getStreetAddress(),
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ detail.getCityName(),
+ detail.getProvinceCode(),
+ detail.getPostalCode(),
+ countryList.getOrDefault(detail.getCountryCode(), detail.getCountryCode()),
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ StringUtils.EMPTY,
+ "N",
+ null,
+ "Y",
+ StringUtils.EMPTY,
+ user,
+ user,
+ ApplicationConstant.ORG_UNIT,
+ ApplicationConstant.ORG_UNIT
+ );
+
+ return postRequestToLegacy("/api/locations", dto)
+ .thenReturn(clientNumber);
+ }
+
+ public Mono createContact(ForestClientContactDto dto) {
+ return postRequestToLegacy("/api/contacts", dto)
+ .thenReturn(dto.clientNumber());
+ }
+
+ public Mono createClient(ForestClientDto dto) {
+ return postRequestToLegacy("/api/clients", dto);
+ }
+
+ public Mono createDoingBusinessAs(
+ String clientNumber,
+ String doingBusinessAsName,
+ String createdBy,
+ String updatedBy
+ ) {
+ return postRequestToLegacy(
+ "/api/dba",
+ new ClientDoingBusinessAsDto(
+ clientNumber,
+ doingBusinessAsName,
+ createdBy,
+ updatedBy,
+ ApplicationConstant.ORG_UNIT
+ )
+ )
+ .thenReturn(clientNumber);
+ }
+
+ public Flux matchDba(String dbaName) {
+ return legacyApi
+ .get()
+ .uri(uriBuilder ->
+ uriBuilder
+ .path("/api/dba/search")
+ .queryParam("dbaName", dbaName)
+ .build()
+ )
+ .exchangeToFlux(response -> {
+ if (response.statusCode().is2xxSuccessful()) {
+ return response.bodyToFlux(ClientDoingBusinessAsDto.class);
+ } else {
+ return Flux.empty();
+ }
+ });
+ }
+
+ private Mono postRequestToLegacy(
+ String url,
+ Object dto
+ ) {
+ return
+ legacyApi
+ .post()
+ .uri(url)
+ .body(BodyInserters.fromValue(dto))
+ .exchangeToMono(response -> {
+ //if 201 is good, else already exist, so move forward
+ if (response.statusCode().is2xxSuccessful()) {
+ return response.bodyToMono(String.class);
+ } else {
+ return Mono.error(new RuntimeException("Failed to submit " + url));
+ }
+ });
+ }
+
+}
diff --git a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java
index 9a99b27a97..8193587e8a 100644
--- a/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java
+++ b/processor/src/main/java/ca/bc/gov/app/service/legacy/LegacyUnregisteredSPPersistenceService.java
@@ -2,20 +2,17 @@
package ca.bc.gov.app.service.legacy;
import ca.bc.gov.app.ApplicationConstant;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.client.CountryCodeRepository;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
-import ca.bc.gov.app.repository.legacy.ClientDoingBusinessAsRepository;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionLocationContactRepository;
+import ca.bc.gov.app.repository.SubmissionLocationRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import ca.bc.gov.app.util.ProcessorUtil;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.springframework.data.r2dbc.core.R2dbcEntityOperations;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
@@ -24,43 +21,35 @@
/**
- * This class is responsible for persisting the submission of unregistered sole proprietorship
- * into the legacy database.
+ * This class is responsible for persisting the submission of unregistered sole proprietorship into
+ * the legacy database.
*/
@Service
@Slf4j
public class LegacyUnregisteredSPPersistenceService extends LegacyAbstractPersistenceService {
+
public LegacyUnregisteredSPPersistenceService(
SubmissionDetailRepository submissionDetailRepository,
SubmissionRepository submissionRepository,
SubmissionLocationRepository locationRepository,
SubmissionContactRepository contactRepository,
SubmissionLocationContactRepository locationContactRepository,
- R2dbcEntityOperations legacyR2dbcEntityTemplate,
- CountryCodeRepository countryCodeRepository,
- ClientDoingBusinessAsRepository doingBusinessAsRepository
+ LegacyService legacyService
) {
- super(
- submissionDetailRepository,
- submissionRepository,
- locationRepository,
- contactRepository,
- locationContactRepository,
- legacyR2dbcEntityTemplate,
- countryCodeRepository,
- doingBusinessAsRepository
- );
+ super(submissionDetailRepository, submissionRepository, locationRepository, contactRepository,
+ locationContactRepository, legacyService);
}
/**
* This method is responsible for filtering the submission based on the type.
+ *
* @param clientTypeCode - the client type code.
* @return - true if the type is USP, otherwise false.
*/
@Override
boolean filterByType(String clientTypeCode) {
- return StringUtils.equalsIgnoreCase(clientTypeCode,"USP");
+ return StringUtils.equalsIgnoreCase(clientTypeCode, "USP");
}
@Override
@@ -69,7 +58,9 @@ String getNextChannel() {
}
/**
- * This method is responsible for generating the forest client for unregistered sole proprietorship.
+ * This method is responsible for generating the forest client for unregistered sole
+ * proprietorship.
+ *
* @param message - the message containing the submission id.
* @return - the forest client.
*/
@@ -79,7 +70,7 @@ String getNextChannel() {
async = "true"
)
@Override
- public Mono> generateForestClient(Message message) {
+ public Mono> generateForestClient(Message message) {
return
getSubmissionDetailRepository()
.findBySubmissionId(
@@ -93,19 +84,22 @@ public Mono> generateForestClient(Message me
getUser(message, ApplicationConstant.UPDATED_BY)
)
.withBirthdate(detail.getBirthdate())
- .withLegalFirstName(ProcessorUtil.splitName(detail.getOrganizationName())[1].toUpperCase())
- .withClientName(ProcessorUtil.splitName(detail.getOrganizationName())[0].toUpperCase())
- .withLegalMiddleName(ProcessorUtil.splitName(detail.getOrganizationName())[2].toUpperCase())
+ .withLegalFirstName(
+ ProcessorUtil.splitName(detail.getOrganizationName())[1].toUpperCase())
+ .withClientName(
+ ProcessorUtil.splitName(detail.getOrganizationName())[0].toUpperCase())
+ .withLegalMiddleName(
+ ProcessorUtil.splitName(detail.getOrganizationName())[2].toUpperCase())
.withClientComment(
getUser(message, ApplicationConstant.CLIENT_SUBMITTER_NAME) +
" submitted the sole proprietor with data acquired from Business BCeID")
.withClientTypeCode("I")
- .withClientNumber(message.getHeaders().get(ApplicationConstant.FOREST_CLIENT_NUMBER, String.class))
+ .withClientNumber(message.getHeaders()
+ .get(ApplicationConstant.FOREST_CLIENT_NUMBER, String.class))
)
.doOnNext(forestClient ->
- log.info("generated forest client for USP {} {}",
- forestClient.getClientNumber(),
- message.getHeaders().get(ApplicationConstant.FOREST_CLIENT_NUMBER, String.class)
+ log.info("Generated forest client for USP {}",
+ forestClient.clientName()
)
)
.map(forestClient ->
@@ -114,12 +108,12 @@ public Mono> generateForestClient(Message me
.copyHeaders(message.getHeaders())
.setHeader(ApplicationConstant.FOREST_CLIENT_NAME,
Stream.of(
- forestClient.getLegalFirstName(),
- forestClient.getLegalMiddleName(),
- forestClient.getClientName()
- )
- .filter(StringUtils::isNotBlank)
- .collect(Collectors.joining(" "))
+ forestClient.legalFirstName(),
+ forestClient.legalMiddleName(),
+ forestClient.clientName()
+ )
+ .filter(StringUtils::isNotBlank)
+ .collect(Collectors.joining(" "))
)
.setHeader(ApplicationConstant.INCORPORATION_NUMBER,
"not applicable")
diff --git a/processor/src/main/java/ca/bc/gov/app/service/processor/IndividualProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/service/processor/IndividualProcessorMatcher.java
deleted file mode 100644
index fabb1c11e4..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/service/processor/IndividualProcessorMatcher.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package ca.bc.gov.app.service.processor;
-
-import static java.util.function.Predicate.not;
-
-import ca.bc.gov.app.dto.MatcherResult;
-import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.legacy.ForestClientRepository;
-import ca.bc.gov.app.util.ProcessorUtil;
-import java.util.List;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-import reactor.core.publisher.Mono;
-
-@Component
-@RequiredArgsConstructor
-@Slf4j
-public class IndividualProcessorMatcher implements ProcessorMatcher {
-
- private final ForestClientRepository forestClientRepository;
-
- @Override
- public boolean enabled(SubmissionInformationDto submission) {
- return "I".equalsIgnoreCase(submission.clientType());
- }
-
- @Override
- public String name() {
- return "Individual Matcher";
- }
-
- @Override
- public Mono matches(SubmissionInformationDto submission) {
-
- log.info("{} :: Validating {}", name(), submission.corporationName());
-
- return
- forestClientRepository
- .findByIndividual(
- ProcessorUtil.splitName(submission.corporationName())[1],
- ProcessorUtil.splitName(submission.corporationName())[0],
- submission.dateOfBirth()!= null ? submission.dateOfBirth().atStartOfDay() : null
- )
- .map(ForestClientEntity::getClientNumber)
- .collectList()
- .filter(not(List::isEmpty))
- .map(values ->
- new MatcherResult("corporationName", String.join(",", values))
- );
- }
-
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcher.java b/processor/src/main/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcher.java
deleted file mode 100644
index 2aa05d4d8c..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcher.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package ca.bc.gov.app.service.processor;
-
-import static java.util.function.Predicate.not;
-
-import ca.bc.gov.app.dto.MatcherResult;
-import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.legacy.ForestClientRepository;
-import ca.bc.gov.app.util.ProcessorUtil;
-import java.util.List;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-import reactor.core.publisher.Mono;
-
-@Component
-@RequiredArgsConstructor
-@Slf4j
-public class SoleProprietorProcessorMatcher implements ProcessorMatcher {
-
- private final ForestClientRepository forestClientRepository;
-
- @Override
- public boolean enabled(SubmissionInformationDto submission) {
- return List.of("USP", "RSP").contains(submission.clientType());
- }
-
- @Override
- public String name() {
- return "Sole Proprietor Matcher";
- }
-
- @Override
- public Mono matches(SubmissionInformationDto submission) {
-
- log.info("{} :: Validating {}", name(), submission.corporationName());
-
- return
- forestClientRepository
- .findByIndividual(
- ProcessorUtil.splitName(submission.corporationName())[1],
- ProcessorUtil.splitName(submission.corporationName())[0],
- submission.dateOfBirth()!= null ? submission.dateOfBirth().atStartOfDay() : null
- )
- .doOnNext(entity -> log.info("Found a match {}", entity))
- .map(ForestClientEntity::getClientNumber)
- .collectList()
- .filter(not(List::isEmpty))
- .map(values ->
- new MatcherResult("corporationName", String.join(",", values))
- );
- }
-}
diff --git a/processor/src/main/java/ca/bc/gov/app/util/LastItemReleaseStrategy.java b/processor/src/main/java/ca/bc/gov/app/util/LastItemReleaseStrategy.java
deleted file mode 100644
index 446ff9e5fb..0000000000
--- a/processor/src/main/java/ca/bc/gov/app/util/LastItemReleaseStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package ca.bc.gov.app.util;
-
-import java.util.Optional;
-import org.apache.commons.lang3.math.NumberUtils;
-import org.springframework.integration.aggregator.ReleaseStrategy;
-import org.springframework.integration.store.MessageGroup;
-import org.springframework.messaging.Message;
-
-public class LastItemReleaseStrategy implements ReleaseStrategy {
-
- @Override
- public boolean canRelease(MessageGroup messageGroup) {
- int messageCount = messageGroup.size();
- int totalMessages = messageGroup
- .getMessages()
- .stream()
- .map(Message::getHeaders)
- .filter(headers -> headers.containsKey("total"))
- .map(headers ->
- Optional
- .ofNullable(headers.get("total"))
- .map(Object::toString)
- .filter(NumberUtils::isDigits)
- .map(Integer::parseInt)
- .orElse(0)
- )
- .findFirst()
- .orElse(0);
-
- return messageCount == totalMessages; // Release the group if all messages have been received
- }
-}
-
diff --git a/processor/src/main/resources/application.yml b/processor/src/main/resources/application.yml
index d414535509..098e9be4d3 100644
--- a/processor/src/main/resources/application.yml
+++ b/processor/src/main/resources/application.yml
@@ -9,18 +9,18 @@ spring:
banner-mode: "off"
allow-bean-definition-overriding: true
r2dbc:
- url: r2dbcs:oracle:thin:@tcps://${ca.bc.gov.nrs.oracle.host}:${ca.bc.gov.nrs.oracle.port}/${ca.bc.gov.nrs.oracle.service}?javax.net.ssl.trustStore=${ca.bc.gov.nrs.oracle.keystore}&javax.net.ssl.trustStorePassword=${ca.bc.gov.nrs.oracle.secret}&javax.net.ssl.keyStore=${ca.bc.gov.nrs.oracle.keystore}&javax.net.ssl.keyStorePassword=${ca.bc.gov.nrs.oracle.secret}&oracle.net.ssl_certificate_alias=${ca.bc.gov.nrs.oracle.host}&oracle.net.ssl_server_dn_match=false
- username: ${ca.bc.gov.nrs.oracle.username}
- password: ${ca.bc.gov.nrs.oracle.password}
+ url: r2dbc:postgresql://${ca.bc.gov.nrs.postgres.host}/${ca.bc.gov.nrs.postgres.database}
+ username: ${ca.bc.gov.nrs.postgres.username}
+ password: ${ca.bc.gov.nrs.postgres.password}
pool:
enabled: true
initialSize: 1
minIdle: 1
- maxSize: 3
+ maxSize: 1
maxLifeTime: 60000
maxIdleTime: 45000
maxCreateConnectionTime: 90000
- poolName: FsaLegacyClientConPool
+ poolName: FsaProcessorClientConPool
management:
enable-native-support: true
@@ -41,15 +41,8 @@ ca:
poolTime: ${TIMING:5M}
backend:
uri: ${CLIENT_URI:http://localhost:8080/api}
- oracle:
- service: ${ORACLEDB_SERVICENAME:fsa-forest}
- database: ${ORACLEDB_DATABASE:fsa-forest}
- host: ${ORACLEDB_HOST:localhost}
- port: ${ORACLEDB_PORT:1521}
- username: ${ORACLEDB_USER:user}
- password: ${ORACLEDB_PASSWORD:passwd}
- keystore: ${ORACLEDB_KEYSTORE:jssecacerts.jks}
- secret: ${ORACLEDB_SECRET:changeit}
+ legacy:
+ uri: ${LEGACY_URI:http://localhost:9999/api}
postgres:
database: ${POSTGRESQL_DATABASE:fsa-forest}
host: ${POSTGRESQL_HOST:localhost}:5432
diff --git a/processor/src/test/java/ca/bc/gov/app/TestConstants.java b/processor/src/test/java/ca/bc/gov/app/TestConstants.java
index 910b9d8957..e2e018aa60 100644
--- a/processor/src/test/java/ca/bc/gov/app/TestConstants.java
+++ b/processor/src/test/java/ca/bc/gov/app/TestConstants.java
@@ -6,9 +6,9 @@
import ca.bc.gov.app.dto.bcregistry.BcRegistryOfficerDto;
import ca.bc.gov.app.dto.bcregistry.BcRegistryPartyDto;
import ca.bc.gov.app.dto.bcregistry.BcRegistryRoleDto;
-import ca.bc.gov.app.entity.client.SubmissionContactEntity;
-import ca.bc.gov.app.entity.client.SubmissionDetailEntity;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
+import ca.bc.gov.app.dto.legacy.ForestClientDto;
+import ca.bc.gov.app.entity.SubmissionContactEntity;
+import ca.bc.gov.app.entity.SubmissionDetailEntity;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@@ -30,7 +30,7 @@ public class TestConstants {
.build();
public static final SubmissionInformationDto SUBMISSION_INFORMATION =
- new SubmissionInformationDto("TEST", null, "00000000", "Y", "C");
+ new SubmissionInformationDto(1,"TEST", null, "00000000", "Y", "C");
public static final EmailRequestDto EMAIL_REQUEST = new EmailRequestDto(
"ABC1234",
@@ -147,14 +147,28 @@ public class TestConstants {
}""";
public static final String BCREG_RES2 = """
- {
- "errorMessage": "API backend third party service error.",
- "rootCause": "message:ResourceErrorCodes.NOT_FOUND_ERR: no Document found for 7QbI0M6uBxx. "
- }""";
+ {
+ "errorMessage": "API backend third party service error.",
+ "rootCause": "message:ResourceErrorCodes.NOT_FOUND_ERR: no Document found for 7QbI0M6uBxx. "
+ }""";
- public static final ForestClientEntity CLIENT_ENTITY = ForestClientEntity.builder()
- .clientNumber("00001000")
- .clientTypeCode("C")
- .build();
+ public static final ForestClientDto CLIENT_ENTITY = new ForestClientDto(
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+ ).withClientNumber("00001000")
+ .withClientTypeCode("C");
}
diff --git a/processor/src/test/java/ca/bc/gov/app/extensions/AbstractTestContainer.java b/processor/src/test/java/ca/bc/gov/app/extensions/AbstractTestContainer.java
index 22534548a5..245a8f1fa9 100644
--- a/processor/src/test/java/ca/bc/gov/app/extensions/AbstractTestContainer.java
+++ b/processor/src/test/java/ca/bc/gov/app/extensions/AbstractTestContainer.java
@@ -1,13 +1,9 @@
package ca.bc.gov.app.extensions;
-import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardOpenOption;
import java.util.List;
import java.util.UUID;
-import java.util.stream.Stream;
import lombok.SneakyThrows;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -16,7 +12,6 @@
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
-import org.testcontainers.containers.OracleContainer;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.junit.jupiter.Testcontainers;
@@ -26,103 +21,10 @@
@ContextConfiguration
public abstract class AbstractTestContainer {
- static {
- Path finalFile = Paths.get("./src", "test", "resources", "init_pg.sql").normalize();
-
- //File used to initialize things on postgres container
- Path init = Paths.get("./src", "test", "resources", "postgres", "init.sql").normalize();
- //Test specific content
- Path tests = Paths.get("./src", "test", "resources", "postgres", "test.sql").normalize();
- //Backend related scripts folder
- Path backendFolder =
- Paths.get("../backend", "src", "main", "resources", "db", "migration").normalize();
-
- if (!finalFile.toFile().exists()) {
- try {
- finalFile.toFile().createNewFile();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- try {
-
- Stream initStream = Stream.of(init);
- Stream testStream = Stream.of(tests);
- Stream backEndStream = Files.list(backendFolder).map(Path::normalize);
-
- Stream finalStream = Stream
- .concat(Stream.concat(initStream, backEndStream), testStream);
-
- Files
- .write(
- finalFile,
- finalStream
- .filter(path -> path.toFile().exists())
- .map(AbstractTestContainer::readAll)
- .flatMap(List::stream)
- .toList(),
- StandardOpenOption.TRUNCATE_EXISTING
- );
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- static {
-
- Path finalFile = Paths.get("./src", "test", "resources", "db", "migration",
- "V1__init_oracle.sql").normalize();
-
- if (!finalFile.toFile().getParentFile().exists()) {
- finalFile.toFile().getParentFile().mkdirs();
- } else {
- try {
- Files.list(finalFile.toFile().getParentFile().toPath())
- .forEach(path -> {
- try {
- Files.delete(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- Path legacyFolder =
- Paths.get("../legacy", "src", "test", "resources", "db", "migration").normalize();
-
- try {
- Stream legacyStream = Files
- .list(legacyFolder)
- .map(Path::normalize);
-
- // copy the files from legacyStream into the same folder as the finalFile
- legacyStream
- .forEach(path -> {
- try {
- Files.copy(path, finalFile.resolveSibling(path.getFileName()));
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
-
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- static final OracleContainer oracle;
static final PostgreSQLContainer postgres;
static {
- postgres = (PostgreSQLContainer) new PostgreSQLContainer("postgres:13")
- .withInitScript("init_pg.sql")
+ postgres = new PostgreSQLContainer("postgres:13")
.withDatabaseName("nfrc")
.withUsername("nrfc")
.withPassword(genPassword());
@@ -130,67 +32,9 @@ public abstract class AbstractTestContainer {
postgres.start();
}
-
- static {
-
- oracle = new OracleContainer("gvenzl/oracle-xe:18.4.0-slim-faststart")
- .withDatabaseName("legacyfsa")
- .withUsername("THE")
- .withPassword(genPassword());
- oracle.start();
-
- }
-
@DynamicPropertySource
static void registerDynamicProperties(DynamicPropertyRegistry registry) {
- postgresSetup(registry);
- oracleSetup(registry);
- }
- @SneakyThrows
- private static void oracleSetup(DynamicPropertyRegistry registry) {
- registry
- .add(
- "ca.bc.gov.nrs.oracle.database",
- oracle::getDatabaseName
- );
- registry
- .add(
- "ca.bc.gov.nrs.oracle.service",
- oracle::getDatabaseName
- );
-
- registry
- .add(
- "ca.bc.gov.nrs.oracle.host",
- oracle::getHost);
-
- registry
- .add(
- "ca.bc.gov.nrs.oracle.port",
- () -> oracle.getMappedPort(1521));
-
- registry
- .add(
- "ca.bc.gov.nrs.oracle.username",
- oracle::getUsername
- );
- registry
- .add(
- "ca.bc.gov.nrs.oracle.schema",
- oracle::getUsername
- );
-
- registry
- .add(
- "ca.bc.gov.nrs.oracle.password",
- oracle::getPassword
- );
-
- }
-
- @SneakyThrows
- private static void postgresSetup(DynamicPropertyRegistry registry) {
registry
.add(
"ca.bc.gov.nrs.postgres.database",
@@ -225,10 +69,5 @@ private static String genPassword() {
.substring(24);
}
- @SneakyThrows
- private static List readAll(Path path) {
- return Files.readAllLines(path);
- }
-
}
diff --git a/processor/src/test/java/ca/bc/gov/app/matchers/ContactMatcherTest.java b/processor/src/test/java/ca/bc/gov/app/matchers/ContactMatcherTest.java
new file mode 100644
index 0000000000..56da30bae4
--- /dev/null
+++ b/processor/src/test/java/ca/bc/gov/app/matchers/ContactMatcherTest.java
@@ -0,0 +1,124 @@
+package ca.bc.gov.app.matchers;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import ca.bc.gov.app.dto.MatcherResult;
+import ca.bc.gov.app.dto.SubmissionInformationDto;
+import ca.bc.gov.app.entity.SubmissionContactEntity;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
+import java.time.LocalDate;
+import java.util.stream.Stream;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.junit.runners.Parameterized.Parameter;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.core.publisher.Flux;
+import reactor.test.StepVerifier;
+
+@DisplayName("Unit Test | Contact Matcher")
+class ContactMatcherTest {
+
+ @RegisterExtension
+ static WireMockExtension wireMockExtension = WireMockExtension
+ .newInstance()
+ .options(wireMockConfig().port(10012))
+ .configureStaticDsl(true)
+ .build();
+
+ private final SubmissionContactRepository contactRepository = mock(
+ SubmissionContactRepository.class);
+ private final ProcessorMatcher matcher = new ContactMatcher(
+ WebClient.builder().baseUrl("http://localhost:10012").build(),
+ contactRepository
+ );
+
+ @Test
+ @DisplayName("Name matching")
+ void shouldMatchName() {
+ assertEquals("Contact Matcher", matcher.name());
+ }
+
+ @ParameterizedTest
+ @MethodSource("contact")
+ @DisplayName("Match or not")
+ void shouldMatchOrNot(
+ SubmissionInformationDto dto,
+ boolean success,
+ MatcherResult result,
+ String mockData
+ ) {
+ wireMockExtension.resetAll();
+ wireMockExtension
+ .stubFor(
+ get(urlPathEqualTo("/api/contacts/search"))
+ .willReturn(okJson(mockData))
+ );
+
+ when(contactRepository.findBySubmissionId(any()))
+ .thenReturn(
+ Flux.just(
+ SubmissionContactEntity
+ .builder()
+ .submissionId(1)
+ .firstName("John")
+ .lastName("Smith")
+ .emailAddress("mail@mail.ca")
+ .businessPhoneNumber("1234567890")
+ .build()
+ )
+ );
+
+ StepVerifier.FirstStep verifier =
+ matcher
+ .matches(dto)
+ .as(StepVerifier::create);
+
+ if (success) {
+ verifier.verifyComplete();
+ } else {
+ verifier
+ .expectNext(result)
+ .verifyComplete();
+ }
+ }
+
+ private static Stream contact(){
+ return Stream.of(
+ Arguments.of(
+ new SubmissionInformationDto(1,"James Frank", LocalDate.of(1985, 10, 4), null, "Y",
+ "I"),
+ true,
+ null,
+ "[]"
+ ),
+ Arguments.of(
+ new SubmissionInformationDto(1,"Marco Polo", LocalDate.of(1977, 3, 22), null, "Y",
+ "I"),
+ false,
+ new MatcherResult("contact", String.join(",", "00000000")),
+ "[{\"clientNumber\":\"00000000\"}]"
+ ),
+ Arguments.of(
+ new SubmissionInformationDto(1,"Lucca DeBiaggio", LocalDate.of(1951, 12, 25), null,
+ "Y", "I"),
+ false,
+ new MatcherResult("contact", String.join(",", "00000000", "00000001")),
+ "[{\"clientNumber\":\"00000000\"},{\"clientNumber\":\"00000001\"}]"
+ )
+ );
+ }
+
+
+}
\ No newline at end of file
diff --git a/processor/src/test/java/ca/bc/gov/app/service/processor/DoingBusinessAsProcessorMatcherTest.java b/processor/src/test/java/ca/bc/gov/app/matchers/DoingBusinessAsProcessorMatcherTest.java
similarity index 61%
rename from processor/src/test/java/ca/bc/gov/app/service/processor/DoingBusinessAsProcessorMatcherTest.java
rename to processor/src/test/java/ca/bc/gov/app/matchers/DoingBusinessAsProcessorMatcherTest.java
index 0024623834..46f2536b27 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/processor/DoingBusinessAsProcessorMatcherTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/matchers/DoingBusinessAsProcessorMatcherTest.java
@@ -1,4 +1,4 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
@@ -6,10 +6,13 @@
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.entity.legacy.ClientDoingBusinessAsEntity;
-import ca.bc.gov.app.repository.legacy.ClientDoingBusinessAsRepository;
+import ca.bc.gov.app.dto.legacy.ClientDoingBusinessAsDto;
+import ca.bc.gov.app.matchers.DoingBusinessAsProcessorMatcher;
+import ca.bc.gov.app.matchers.ProcessorMatcher;
+import ca.bc.gov.app.service.legacy.LegacyService;
import java.time.LocalDate;
import java.util.stream.Stream;
+import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
@@ -21,9 +24,8 @@
@DisplayName("Unit Test | Doing Business As Matcher")
class DoingBusinessAsProcessorMatcherTest {
- private final ClientDoingBusinessAsRepository repository = mock(
- ClientDoingBusinessAsRepository.class);
- ProcessorMatcher matcher = new DoingBusinessAsProcessorMatcher(repository);
+ private final LegacyService legacyService = mock(LegacyService.class);
+ ProcessorMatcher matcher = new DoingBusinessAsProcessorMatcher(legacyService);
@Test
@DisplayName("Name matching")
@@ -38,10 +40,10 @@ void shouldMatchOrNot(
SubmissionInformationDto dto,
boolean success,
MatcherResult result,
- Flux mockData
+ Flux mockData
) {
- when(repository.matchBy(dto.corporationName()))
+ when(legacyService.matchDba(dto.corporationName()))
.thenReturn(mockData);
StepVerifier.FirstStep verifier =
@@ -62,25 +64,30 @@ private static Stream legalName() {
return
Stream.of(
Arguments.of(
- new SubmissionInformationDto("James", LocalDate.of(1970, 3, 4), "FM001122334", "Y",
+ new SubmissionInformationDto(1,"James", LocalDate.of(1970, 3, 4), "FM001122334", "Y",
"RSP"),
true,
null,
Flux.empty()
),
Arguments.of(
- new SubmissionInformationDto("Marco Polo Navigation Inc", LocalDate.of(1970, 3, 4),
+ new SubmissionInformationDto(1,"Marco Polo Navigation Inc", LocalDate.of(1970, 3, 4),
"FM001122334", "Y", "RSP"),
false,
new MatcherResult("corporationName", String.join(",", "00000000")),
- Flux.just(new ClientDoingBusinessAsEntity().withClientNumber("00000000"))
+ Flux.just(
+ new ClientDoingBusinessAsDto("00000000", StringUtils.EMPTY, StringUtils.EMPTY,
+ StringUtils.EMPTY, 1L))
),
Arguments.of(
- new SubmissionInformationDto("Lucca", null, null, null, "RSP"),
+ new SubmissionInformationDto(1,"Lucca", null, null, null, "RSP"),
false,
new MatcherResult("corporationName", String.join(",", "00000000", "00000001")),
- Flux.just(new ClientDoingBusinessAsEntity().withClientNumber("00000000"),
- new ClientDoingBusinessAsEntity().withClientNumber("00000001"))
+ Flux.just(
+ new ClientDoingBusinessAsDto("00000000", StringUtils.EMPTY, StringUtils.EMPTY,
+ StringUtils.EMPTY, 1L),
+ new ClientDoingBusinessAsDto("00000001", StringUtils.EMPTY, StringUtils.EMPTY,
+ StringUtils.EMPTY, 1L))
)
);
}
diff --git a/processor/src/test/java/ca/bc/gov/app/service/processor/GoodStandingProcessorMatcherTest.java b/processor/src/test/java/ca/bc/gov/app/matchers/GoodStandingProcessorMatcherTest.java
similarity index 82%
rename from processor/src/test/java/ca/bc/gov/app/service/processor/GoodStandingProcessorMatcherTest.java
rename to processor/src/test/java/ca/bc/gov/app/matchers/GoodStandingProcessorMatcherTest.java
index d921072eb5..6cc8cea9cd 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/processor/GoodStandingProcessorMatcherTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/matchers/GoodStandingProcessorMatcherTest.java
@@ -1,10 +1,12 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
+import ca.bc.gov.app.matchers.GoodStandingProcessorMatcher;
+import ca.bc.gov.app.matchers.ProcessorMatcher;
import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.DisplayName;
@@ -63,22 +65,22 @@ private static Stream goodStanding() {
return
Stream.of(
Arguments.of(
- new SubmissionInformationDto(null, null,null, StringUtils.EMPTY,null),
+ new SubmissionInformationDto(1,null, null,null, StringUtils.EMPTY,null),
false,
new MatcherResult("goodStanding", "Value not found")
),
Arguments.of(
- new SubmissionInformationDto(null, null,null, null,null),
+ new SubmissionInformationDto(1,null, null,null, null,null),
false,
new MatcherResult("goodStanding", "Value not found")
),
Arguments.of(
- new SubmissionInformationDto(null, null,null, "N",null),
+ new SubmissionInformationDto(1,null, null,null, "N",null),
false,
new MatcherResult("goodStanding", "Client not in good standing")
),
Arguments.of(
- new SubmissionInformationDto(null, null,null, "Y",null),
+ new SubmissionInformationDto(1,null, null,null, "Y",null),
true,
null
)
diff --git a/processor/src/test/java/ca/bc/gov/app/service/processor/IncorporationNumberProcessorMatcherTest.java b/processor/src/test/java/ca/bc/gov/app/matchers/IncorporationNumberProcessorMatcherTest.java
similarity index 53%
rename from processor/src/test/java/ca/bc/gov/app/service/processor/IncorporationNumberProcessorMatcherTest.java
rename to processor/src/test/java/ca/bc/gov/app/matchers/IncorporationNumberProcessorMatcherTest.java
index 3d8de2ba1a..ef86613a44 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/processor/IncorporationNumberProcessorMatcherTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/matchers/IncorporationNumberProcessorMatcherTest.java
@@ -1,28 +1,41 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
-import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.legacy.ForestClientRepository;
+import ca.bc.gov.app.matchers.IncorporationNumberProcessorMatcher;
+import ca.bc.gov.app.matchers.ProcessorMatcher;
+import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
-import reactor.core.publisher.Flux;
+import org.springframework.web.reactive.function.client.WebClient;
import reactor.test.StepVerifier;
@DisplayName("Unit Test | Incorporation Number Matcher")
class IncorporationNumberProcessorMatcherTest {
- private final ForestClientRepository repository = mock(ForestClientRepository.class);
- ProcessorMatcher matcher = new IncorporationNumberProcessorMatcher(repository);
+ @RegisterExtension
+ static WireMockExtension wireMockExtension = WireMockExtension
+ .newInstance()
+ .options(wireMockConfig().port(10011))
+ .configureStaticDsl(true)
+ .build();
+
+ ProcessorMatcher matcher = new IncorporationNumberProcessorMatcher(
+ WebClient.builder().baseUrl("http://localhost:10011").build()
+ );
@Test
@DisplayName("Name matching")
@@ -37,7 +50,7 @@ void shouldBeEnabled(
SubmissionInformationDto dto,
boolean success,
MatcherResult result,
- Flux mockData
+ String mockData
) {
assertTrue(matcher.enabled(dto));
}
@@ -49,11 +62,15 @@ void shouldMatchOrNot(
SubmissionInformationDto dto,
boolean success,
MatcherResult result,
- Flux mockData
+ String mockData
) {
- when(repository.findByIncorporationNumber(dto.incorporationNumber()))
- .thenReturn(mockData);
+ wireMockExtension.resetAll();
+ wireMockExtension
+ .stubFor(
+ get(urlPathEqualTo("/api/search/incorporationOrName"))
+ .willReturn(okJson(mockData))
+ );
StepVerifier.FirstStep verifier =
matcher
@@ -73,16 +90,16 @@ private static Stream incorporation() {
return
Stream.of(
Arguments.of(
- new SubmissionInformationDto(null,null, "00000007", null,"C"),
+ new SubmissionInformationDto(1,null, null, "00000007", null, "C"),
true,
null,
- Flux.empty()
+ "[]"
),
Arguments.of(
- new SubmissionInformationDto(null,null, "00000006", null,"C"),
+ new SubmissionInformationDto(1,null, null, "00000006", null, "C"),
false,
new MatcherResult("incorporationNumber", "00000006"),
- Flux.just(new ForestClientEntity().withClientNumber("00000006"))
+ "[{\"clientNumber\":\"00000006\"}]"
)
);
}
diff --git a/processor/src/test/java/ca/bc/gov/app/matchers/IndividualProcessorMatcherTest.java b/processor/src/test/java/ca/bc/gov/app/matchers/IndividualProcessorMatcherTest.java
new file mode 100644
index 0000000000..334c5bbb32
--- /dev/null
+++ b/processor/src/test/java/ca/bc/gov/app/matchers/IndividualProcessorMatcherTest.java
@@ -0,0 +1,102 @@
+package ca.bc.gov.app.matchers;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import ca.bc.gov.app.dto.MatcherResult;
+import ca.bc.gov.app.dto.SubmissionInformationDto;
+import ca.bc.gov.app.matchers.IndividualProcessorMatcher;
+import ca.bc.gov.app.matchers.ProcessorMatcher;
+import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
+import java.time.LocalDate;
+import java.util.stream.Stream;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.springframework.web.reactive.function.client.WebClient;
+import reactor.test.StepVerifier;
+
+@DisplayName("Unit Test | Individual Matcher")
+class IndividualProcessorMatcherTest {
+
+ @RegisterExtension
+ static WireMockExtension wireMockExtension = WireMockExtension
+ .newInstance()
+ .options(wireMockConfig().port(10012))
+ .configureStaticDsl(true)
+ .build();
+ private final ProcessorMatcher matcher = new IndividualProcessorMatcher(
+ WebClient.builder().baseUrl("http://localhost:10012").build()
+ );
+
+
+ @Test
+ @DisplayName("Name matching")
+ void shouldMatchName() {
+ assertEquals("Individual Matcher", matcher.name());
+ }
+
+ @ParameterizedTest
+ @MethodSource("legalName")
+ @DisplayName("Match or not")
+ void shouldMatchOrNot(
+ SubmissionInformationDto dto,
+ boolean success,
+ MatcherResult result,
+ String mockData
+ ) {
+ wireMockExtension.resetAll();
+ wireMockExtension
+ .stubFor(
+ get(urlPathEqualTo("/api/search/individual"))
+ .willReturn(okJson(mockData))
+ );
+
+ StepVerifier.FirstStep verifier =
+ matcher
+ .matches(dto)
+ .as(StepVerifier::create);
+
+ if (success) {
+ verifier.verifyComplete();
+ } else {
+ verifier
+ .expectNext(result)
+ .verifyComplete();
+ }
+ }
+
+ private static Stream legalName() {
+ return
+ Stream.of(
+ Arguments.of(
+ new SubmissionInformationDto(1,"James Frank", LocalDate.of(1985, 10, 4), null, "Y",
+ "I"),
+ true,
+ null,
+ "[]"
+ ),
+ Arguments.of(
+ new SubmissionInformationDto(1,"Marco Polo", LocalDate.of(1977, 3, 22), null, "Y",
+ "I"),
+ false,
+ new MatcherResult("corporationName", String.join(",", "00000000")),
+ "[{\"clientNumber\":\"00000000\"}]"
+ ),
+ Arguments.of(
+ new SubmissionInformationDto(1,"Lucca DeBiaggio", LocalDate.of(1951, 12, 25), null,
+ "Y", "I"),
+ false,
+ new MatcherResult("corporationName", String.join(",", "00000000", "00000001")),
+ "[{\"clientNumber\":\"00000000\"},{\"clientNumber\":\"00000001\"}]"
+ )
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/processor/src/test/java/ca/bc/gov/app/service/processor/LegalNameProcessorMatcherTest.java b/processor/src/test/java/ca/bc/gov/app/matchers/LegalNameProcessorMatcherTest.java
similarity index 51%
rename from processor/src/test/java/ca/bc/gov/app/service/processor/LegalNameProcessorMatcherTest.java
rename to processor/src/test/java/ca/bc/gov/app/matchers/LegalNameProcessorMatcherTest.java
index b4d13deafd..29f03b82c0 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/processor/LegalNameProcessorMatcherTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/matchers/LegalNameProcessorMatcherTest.java
@@ -1,27 +1,38 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.legacy.ForestClientRepository;
+import ca.bc.gov.app.matchers.LegalNameProcessorMatcher;
+import ca.bc.gov.app.matchers.ProcessorMatcher;
+import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
-import reactor.core.publisher.Flux;
+import org.springframework.web.reactive.function.client.WebClient;
import reactor.test.StepVerifier;
@DisplayName("Unit Test | Legal Name Matcher")
class LegalNameProcessorMatcherTest {
- private final ForestClientRepository repository = mock(ForestClientRepository.class);
- ProcessorMatcher matcher = new LegalNameProcessorMatcher(repository);
+ @RegisterExtension
+ static WireMockExtension wireMockExtension = WireMockExtension
+ .newInstance()
+ .options(wireMockConfig().port(10013))
+ .configureStaticDsl(true)
+ .build();
+ ProcessorMatcher matcher = new LegalNameProcessorMatcher(
+ WebClient.builder().baseUrl("http://localhost:10013").build()
+ );
@Test
@DisplayName("Name matching")
@@ -36,11 +47,15 @@ void shouldMatchOrNot(
SubmissionInformationDto dto,
boolean success,
MatcherResult result,
- Flux mockData
+ String mockData
) {
- when(repository.matchBy(dto.corporationName()))
- .thenReturn(mockData);
+ wireMockExtension.resetAll();
+ wireMockExtension
+ .stubFor(
+ get(urlPathEqualTo("/api/search/match"))
+ .willReturn(okJson(mockData))
+ );
StepVerifier.FirstStep verifier =
matcher
@@ -60,23 +75,22 @@ private static Stream legalName() {
return
Stream.of(
Arguments.of(
- new SubmissionInformationDto("James", null,null, null,"C"),
+ new SubmissionInformationDto(1,"James", null, null, null, "C"),
true,
null,
- Flux.empty()
+ "[]"
),
Arguments.of(
- new SubmissionInformationDto("Marco", null, null, null,"C"),
+ new SubmissionInformationDto(1,"Marco", null, null, null, "C"),
false,
new MatcherResult("corporationName", String.join(",", "00000000")),
- Flux.just(new ForestClientEntity().withClientNumber("00000000"))
+ "[{\"clientNumber\":\"00000000\"}]"
),
Arguments.of(
- new SubmissionInformationDto("Lucca", null, null, null,"C"),
+ new SubmissionInformationDto(1,"Lucca", null, null, null, "C"),
false,
new MatcherResult("corporationName", String.join(",", "00000000", "00000001")),
- Flux.just(new ForestClientEntity().withClientNumber("00000000"),
- new ForestClientEntity().withClientNumber("00000001"))
+ "[{\"clientNumber\":\"00000000\"},{\"clientNumber\":\"00000001\"}]"
)
);
}
diff --git a/processor/src/test/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcherTest.java b/processor/src/test/java/ca/bc/gov/app/matchers/SoleProprietorProcessorMatcherTest.java
similarity index 51%
rename from processor/src/test/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcherTest.java
rename to processor/src/test/java/ca/bc/gov/app/matchers/SoleProprietorProcessorMatcherTest.java
index 3aed05a741..2b89ab3ed5 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/processor/SoleProprietorProcessorMatcherTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/matchers/SoleProprietorProcessorMatcherTest.java
@@ -1,31 +1,40 @@
-package ca.bc.gov.app.service.processor;
+package ca.bc.gov.app.matchers;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.okForContentType;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import ca.bc.gov.app.dto.MatcherResult;
import ca.bc.gov.app.dto.SubmissionInformationDto;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.repository.legacy.ForestClientRepository;
+import ca.bc.gov.app.matchers.ProcessorMatcher;
+import ca.bc.gov.app.matchers.SoleProprietorProcessorMatcher;
+import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
import java.time.LocalDate;
import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
-import reactor.core.publisher.Flux;
+import org.springframework.web.reactive.function.client.WebClient;
import reactor.test.StepVerifier;
@DisplayName("Unit Test | Sole Proprietor Matcher")
class SoleProprietorProcessorMatcherTest {
- private final ForestClientRepository repository = mock(ForestClientRepository.class);
- private final ProcessorMatcher matcher = new SoleProprietorProcessorMatcher(repository);
+ @RegisterExtension
+ static WireMockExtension wireMockExtension = WireMockExtension
+ .newInstance()
+ .options(wireMockConfig().port(10010))
+ .configureStaticDsl(true)
+ .build();
+ private final ProcessorMatcher matcher = new SoleProprietorProcessorMatcher(
+ WebClient.builder().baseUrl("http://localhost:10010").build()
+ );
@Test
@DisplayName("Name matching")
@@ -40,11 +49,19 @@ void shouldMatchOrNot(
SubmissionInformationDto dto,
boolean success,
MatcherResult result,
- Flux mockData
+ String mockData
) {
- when(repository.findByIndividual(anyString(), anyString(), any()))
- .thenReturn(mockData);
+ wireMockExtension.resetAll();
+ wireMockExtension
+ .stubFor(
+ get(urlPathEqualTo("/api/search/individual"))
+ .willReturn(
+ okForContentType("application/json", mockData)
+ .withHeader("Content-Type", "application/json")
+ )
+
+ );
StepVerifier.FirstStep verifier =
matcher
@@ -64,26 +81,25 @@ private static Stream legalName() {
return
Stream.of(
Arguments.of(
- new SubmissionInformationDto("James Frank", LocalDate.of(2023, 4, 5), null, null,
+ new SubmissionInformationDto(1,"James Frank", LocalDate.of(2023, 4, 5), null, null,
"USP"),
true,
null,
- Flux.empty()
+ "[]"
),
Arguments.of(
- new SubmissionInformationDto("Marco Polo", LocalDate.of(2023, 9, 12), null, null,
+ new SubmissionInformationDto(1,"Marco Polo", LocalDate.of(2023, 9, 12), null, null,
"RSP"),
false,
new MatcherResult("corporationName", String.join(",", "00000000")),
- Flux.just(new ForestClientEntity().withClientNumber("00000000"))
+ "[{\"clientNumber\":\"00000000\"}]"
),
Arguments.of(
- new SubmissionInformationDto("Lucca DeBiaggio", LocalDate.of(2023, 10, 11), null,
+ new SubmissionInformationDto(1,"Lucca DeBiaggio", LocalDate.of(2023, 10, 11), null,
null, "USP"),
false,
new MatcherResult("corporationName", String.join(",", "00000000", "00000001")),
- Flux.just(new ForestClientEntity().withClientNumber("00000000"),
- new ForestClientEntity().withClientNumber("00000001"))
+ "[{\"clientNumber\":\"00000000\"},{\"clientNumber\":\"00000001\"}]"
)
);
}
diff --git a/processor/src/test/java/ca/bc/gov/app/service/ProcessorIntegrationTest.java b/processor/src/test/java/ca/bc/gov/app/service/ProcessorIntegrationTest.java
index fd5d1b7b05..9889b0bce6 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/ProcessorIntegrationTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/service/ProcessorIntegrationTest.java
@@ -1,22 +1,30 @@
package ca.bc.gov.app.service;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.okJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.awaitility.Awaitility.await;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.verify;
+import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.extensions.AbstractTestContainer;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
-import ca.bc.gov.app.repository.legacy.ForestClientRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
+import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
import java.time.Duration;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.integration.channel.FluxMessageChannel;
import org.springframework.integration.support.MessageBuilder;
+import org.springframework.messaging.MessageHeaders;
@DisplayName("Integration Test | Processor End-to-End Flow")
class ProcessorIntegrationTest extends AbstractTestContainer {
@@ -27,16 +35,41 @@ class ProcessorIntegrationTest extends AbstractTestContainer {
@SpyBean
private SubmissionDetailRepository detailRepository;
- @SpyBean
- private ForestClientRepository forestClientRepository;
+ @RegisterExtension
+ static WireMockExtension wireMockExtension = WireMockExtension
+ .newInstance()
+ .options(wireMockConfig().port(10014))
+ .configureStaticDsl(true)
+ .build();
@Autowired
+ @Qualifier(ApplicationConstant.SUBMISSION_LIST_CHANNEL)
private FluxMessageChannel submissionListChannel;
@Test
@DisplayName("Process one entity")
void test() {
- submissionListChannel.send(MessageBuilder.withPayload(1).build());
+ submissionListChannel.send(
+ MessageBuilder
+ .withPayload(1)
+ .setReplyChannelName(ApplicationConstant.SUBMISSION_LIST_CHANNEL)
+ .setHeader("output-channel", ApplicationConstant.SUBMISSION_LIST_CHANNEL)
+ .setHeader(MessageHeaders.REPLY_CHANNEL, ApplicationConstant.SUBMISSION_LIST_CHANNEL)
+ .build()
+ );
+
+ wireMockExtension.resetAll();
+ wireMockExtension
+ .stubFor(
+ get(urlPathEqualTo("/api/search/match"))
+ .willReturn(okJson("[]"))
+ );
+
+ wireMockExtension
+ .stubFor(
+ get(urlPathEqualTo("/api/search/incorporationOrName"))
+ .willReturn(okJson("[]"))
+ );
await()
.alias("Load details")
@@ -44,14 +77,14 @@ void test() {
.untilAsserted(() -> verify(detailRepository, atLeastOnce()).findBySubmissionId(eq(1)));
await()
- .alias("Fuzzy Search")
- .atMost(Duration.ofSeconds(5))
- .untilAsserted(() -> verify(forestClientRepository, atLeastOnce()).matchBy(any(String.class)));
+ .alias("Match by incorporation number")
+ .atMost(Duration.ofSeconds(5))
+ .untilAsserted(() -> wireMockExtension.verify(getRequestedFor(urlPathEqualTo("/api/search/match"))));
await()
- .alias("Incorporation Search")
+ .alias("Match by incorporation number")
.atMost(Duration.ofSeconds(5))
- .untilAsserted(() -> verify(forestClientRepository, atLeastOnce()).findByIncorporationNumber(any(String.class)));
+ .untilAsserted(() -> wireMockExtension.verify(getRequestedFor(urlPathEqualTo("/api/search/incorporationOrName"))));
}
}
diff --git a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionAutoProcessingServiceIntegrationTest.java b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionAutoProcessingServiceIntegrationTest.java
index e0c9c26e85..d9e9ff6e19 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionAutoProcessingServiceIntegrationTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionAutoProcessingServiceIntegrationTest.java
@@ -7,16 +7,15 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.MatcherResult;
-import ca.bc.gov.app.entity.client.SubmissionEntity;
-import ca.bc.gov.app.entity.client.SubmissionMatchDetailEntity;
+import ca.bc.gov.app.entity.SubmissionEntity;
+import ca.bc.gov.app.entity.SubmissionMatchDetailEntity;
import ca.bc.gov.app.extensions.AbstractTestContainer;
-import ca.bc.gov.app.repository.client.SubmissionMatchDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
+import ca.bc.gov.app.repository.SubmissionMatchDetailRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
@@ -24,7 +23,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.integration.support.MessageBuilder;
diff --git a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingServiceTest.java b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingServiceTest.java
index 46a73d814e..5fa719e432 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingServiceTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionLoadingServiceTest.java
@@ -8,9 +8,9 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.TestConstants;
-import ca.bc.gov.app.entity.client.SubmissionTypeCodeEnum;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
+import ca.bc.gov.app.entity.SubmissionTypeCodeEnum;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
diff --git a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java
index ca7b9a2da7..cb164232e5 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionMailServiceTest.java
@@ -11,7 +11,7 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.TestConstants;
-import ca.bc.gov.app.entity.client.SubmissionTypeCodeEnum;
+import ca.bc.gov.app.entity.SubmissionTypeCodeEnum;
import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
import java.time.Duration;
import org.junit.jupiter.api.BeforeAll;
diff --git a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionProcessingServiceIntegrationTest.java b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionProcessingServiceIntegrationTest.java
index af819d3be2..ab16b27cf1 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionProcessingServiceIntegrationTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/service/client/ClientSubmissionProcessingServiceIntegrationTest.java
@@ -11,15 +11,15 @@
import ca.bc.gov.app.ApplicationConstant;
import ca.bc.gov.app.dto.EmailRequestDto;
-import ca.bc.gov.app.entity.client.SubmissionContactEntity;
-import ca.bc.gov.app.entity.client.SubmissionDetailEntity;
-import ca.bc.gov.app.entity.client.SubmissionEntity;
-import ca.bc.gov.app.entity.client.SubmissionMatchDetailEntity;
-import ca.bc.gov.app.entity.client.SubmissionStatusEnum;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionMatchDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
+import ca.bc.gov.app.entity.SubmissionContactEntity;
+import ca.bc.gov.app.entity.SubmissionDetailEntity;
+import ca.bc.gov.app.entity.SubmissionEntity;
+import ca.bc.gov.app.entity.SubmissionMatchDetailEntity;
+import ca.bc.gov.app.entity.SubmissionStatusEnum;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionMatchDetailRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import java.time.Duration;
import java.util.Map;
import java.util.stream.Stream;
diff --git a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceServiceTest.java b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceServiceTest.java
index 59c0723128..92240ae5a8 100644
--- a/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceServiceTest.java
+++ b/processor/src/test/java/ca/bc/gov/app/service/legacy/LegacyAbstractPersistenceServiceTest.java
@@ -1,47 +1,31 @@
package ca.bc.gov.app.service.legacy;
+import static ca.bc.gov.app.TestConstants.CLIENT_ENTITY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import ca.bc.gov.app.ApplicationConstant;
-import ca.bc.gov.app.TestConstants;
-import ca.bc.gov.app.entity.client.CountryCodeEntity;
-import ca.bc.gov.app.entity.client.SubmissionContactEntity;
-import ca.bc.gov.app.entity.client.SubmissionDetailEntity;
-import ca.bc.gov.app.entity.client.SubmissionLocationContactEntity;
-import ca.bc.gov.app.entity.client.SubmissionLocationEntity;
-import ca.bc.gov.app.entity.legacy.ForestClientContactEntity;
-import ca.bc.gov.app.entity.legacy.ForestClientEntity;
-import ca.bc.gov.app.entity.legacy.ForestClientLocationEntity;
-import ca.bc.gov.app.repository.client.CountryCodeRepository;
-import ca.bc.gov.app.repository.client.SubmissionContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionDetailRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationContactRepository;
-import ca.bc.gov.app.repository.client.SubmissionLocationRepository;
-import ca.bc.gov.app.repository.client.SubmissionRepository;
-import ca.bc.gov.app.repository.legacy.ClientDoingBusinessAsRepository;
-import java.util.Map;
-import java.util.function.BiFunction;
+import ca.bc.gov.app.entity.SubmissionContactEntity;
+import ca.bc.gov.app.entity.SubmissionDetailEntity;
+import ca.bc.gov.app.entity.SubmissionLocationContactEntity;
+import ca.bc.gov.app.entity.SubmissionLocationEntity;
+import ca.bc.gov.app.repository.SubmissionContactRepository;
+import ca.bc.gov.app.repository.SubmissionDetailRepository;
+import ca.bc.gov.app.repository.SubmissionLocationContactRepository;
+import ca.bc.gov.app.repository.SubmissionLocationRepository;
+import ca.bc.gov.app.repository.SubmissionRepository;
import java.util.stream.Stream;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
-import org.springframework.data.r2dbc.core.R2dbcEntityTemplate;
-import org.springframework.data.r2dbc.core.ReactiveInsertOperation.ReactiveInsert;
import org.springframework.integration.support.MessageBuilder;
-import org.springframework.r2dbc.core.DatabaseClient;
-import org.springframework.r2dbc.core.DatabaseClient.GenericExecuteSpec;
-import org.springframework.r2dbc.core.FetchSpec;
-import org.springframework.r2dbc.core.RowsFetchSpec;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -58,33 +42,21 @@ class LegacyAbstractPersistenceServiceTest {
SubmissionContactRepository.class);
private final SubmissionLocationContactRepository locationContactRepository = mock(
SubmissionLocationContactRepository.class);
- private final R2dbcEntityTemplate legacyR2dbcEntityTemplate = mock(R2dbcEntityTemplate.class);
- private final CountryCodeRepository countryCodeRepository = mock(CountryCodeRepository.class);
- private final ClientDoingBusinessAsRepository doingBusinessAsRepository = mock(
- ClientDoingBusinessAsRepository.class);
-
+ private final LegacyService legacyService = mock(LegacyService.class);
private final LegacyClientPersistenceService service = new LegacyClientPersistenceService(
submissionDetailRepository,
submissionRepository,
locationRepository,
contactRepository,
locationContactRepository,
- legacyR2dbcEntityTemplate,
- countryCodeRepository,
- doingBusinessAsRepository
+ legacyService
);
- @BeforeEach
- void beforeEach() {
- when(countryCodeRepository.findAll())
- .thenReturn(Flux.just(new CountryCodeEntity("CA", "Canada")));
- }
@ParameterizedTest
- @MethodSource("contactExisted")
+ @MethodSource("contactExist")
@DisplayName("create locations")
void shouldCreateLocations(boolean locationExisted) {
- ReactiveInsert reactiveInsert = mock(ReactiveInsert.class);
when(locationRepository.findBySubmissionId(eq(2)))
.thenReturn(Flux.just(
@@ -101,17 +73,8 @@ void shouldCreateLocations(boolean locationExisted) {
.build()
)
);
- when(legacyR2dbcEntityTemplate.insert(eq(ForestClientLocationEntity.class)))
- .thenReturn(reactiveInsert);
- ForestClientLocationEntity location = ForestClientLocationEntity.builder()
- .clientLocnCode("00")
- .build();
-
- when(reactiveInsert.using(any()))
- .thenReturn(Mono.just(location));
-
- when(legacyR2dbcEntityTemplate.selectOne(any(), any()))
- .thenReturn(locationExisted ? Mono.just(location) : Mono.empty());
+ when(legacyService.createLocation(any(), anyString(), any(), anyString()))
+ .thenReturn(Mono.just("00123456"));
service
.createLocations(
@@ -186,13 +149,9 @@ void shouldCreateLocations(boolean locationExisted) {
}
@ParameterizedTest
- @MethodSource("contactExisted")
+ @MethodSource("contactExist")
@DisplayName("create contacts")
void shouldCreateContacts(boolean contactExisted) {
- ReactiveInsert insert = mock(ReactiveInsert.class);
- DatabaseClient dbCLient = mock(DatabaseClient.class);
- GenericExecuteSpec execSpec = mock(GenericExecuteSpec.class);
- FetchSpec