diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/controller/MaintenanceController.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/controller/MaintenanceController.java new file mode 100644 index 00000000..79e7c1a8 --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/controller/MaintenanceController.java @@ -0,0 +1,73 @@ +package ca.bc.gov.hlth.hnweb.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +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.RestController; + +import ca.bc.gov.hlth.hnweb.converter.rapid.RPBSPRE0Converter; +import ca.bc.gov.hlth.hnweb.model.rapid.RPBSPRE0; +import ca.bc.gov.hlth.hnweb.model.rest.maintenance.ReinstateOverAgeDependentRequest; +import ca.bc.gov.hlth.hnweb.model.rest.maintenance.ReinstateOverAgeDependentResponse; +import ca.bc.gov.hlth.hnweb.persistence.entity.AffectedPartyDirection; +import ca.bc.gov.hlth.hnweb.persistence.entity.IdentifierType; +import ca.bc.gov.hlth.hnweb.persistence.entity.Transaction; +import ca.bc.gov.hlth.hnweb.security.TransactionType; +import ca.bc.gov.hlth.hnweb.service.MaintenanceService; + +/** + * Handles request related to Coverage Maintenance. + */ +@RequestMapping("/maintenance") +@RestController +public class MaintenanceController extends BaseController { + + private static final Logger logger = LoggerFactory.getLogger(MaintenanceController.class); + + @Autowired + private MaintenanceService maintenanceService; + + @PostMapping("/reinstate-over-age-dependent") + public ResponseEntity reinstateOverAgeDependent(@Valid @RequestBody ReinstateOverAgeDependentRequest reinstateRequest, HttpServletRequest request) { + + logger.info("Reinstate over age dependent request: {} ", reinstateRequest.getPhn()); + + Transaction transaction = auditReinstateOverAgeDependentStart(reinstateRequest, request); + + try { + RPBSPRE0Converter converter = new RPBSPRE0Converter(); + RPBSPRE0 pre0Request = converter.convertRequest(reinstateRequest); + + RPBSPRE0 pre0Response = maintenanceService.reinstateOverAgeDependent(pre0Request, transaction); + + ReinstateOverAgeDependentResponse reinstateResponse = converter.convertResponse(pre0Response); + + ResponseEntity response = ResponseEntity.ok(reinstateResponse); + logger.info("reinstateOverAgeDependent response: {} ", reinstateResponse); + + transactionComplete(transaction); + addAffectedParty(transaction, IdentifierType.PHN, reinstateResponse.getPhn(), AffectedPartyDirection.OUTBOUND); + + return response; + } catch (Exception e) { + handleException(transaction, e); + return null; + } + } + + private Transaction auditReinstateOverAgeDependentStart(ReinstateOverAgeDependentRequest reinstateRequest, HttpServletRequest request) { + Transaction transaction = transactionStart(request, TransactionType.REINSTATE_OVER_AGE_DEPENDENT); + addAffectedParty(transaction, IdentifierType.GROUP_NUMBER, reinstateRequest.getGroupNumber(), AffectedPartyDirection.INBOUND); + addAffectedParty(transaction, IdentifierType.PHN, reinstateRequest.getPhn(), AffectedPartyDirection.INBOUND); + addAffectedParty(transaction, IdentifierType.PHN, reinstateRequest.getDependentPhn(), AffectedPartyDirection.INBOUND); + return transaction; + } + +} diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/converter/rapid/BaseRapidConverter.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/converter/rapid/BaseRapidConverter.java index 2f8f922b..dfbe4cd0 100644 --- a/backend/src/main/java/ca/bc/gov/hlth/hnweb/converter/rapid/BaseRapidConverter.java +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/converter/rapid/BaseRapidConverter.java @@ -18,6 +18,8 @@ public abstract class BaseRapidConverter { protected static final String RAPID_DATE_FORMAT = "yyyy-MM-dd"; + protected static final String RAPID_YYYY_MM_FORMAT = "yyyy-MM"; + protected static final String STATUS_CODE_SUCCESS = "RPBS9014"; protected static final String SUCCESS_MESSAGE = "TRANSACTION COMPLETED"; diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/converter/rapid/RPBSPRE0Converter.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/converter/rapid/RPBSPRE0Converter.java new file mode 100644 index 00000000..c9fb5ba0 --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/converter/rapid/RPBSPRE0Converter.java @@ -0,0 +1,62 @@ +package ca.bc.gov.hlth.hnweb.converter.rapid; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +import ca.bc.gov.hlth.hnweb.model.rapid.RE0; +import ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader; +import ca.bc.gov.hlth.hnweb.model.rapid.RPBSPRE0; +import ca.bc.gov.hlth.hnweb.model.rest.maintenance.ReinstateOverAgeDependentRequest; +import ca.bc.gov.hlth.hnweb.model.rest.maintenance.ReinstateOverAgeDependentResponse; + +public class RPBSPRE0Converter extends BaseRapidConverter { + private static final String TRAN_CODE = "RPBSPRE0"; + + public RPBSPRE0Converter() { + super(); + } + + public RPBSPRE0 convertRequest(ReinstateOverAgeDependentRequest request) { + RPBSHeader rpbsHeader = new RPBSHeader(); + rpbsHeader.setOrganization(userInfo.getOrganization()); + rpbsHeader.setTranCode(getTranCode()); + + RE0 re0 = new RE0(); + re0.setSubscriberPHN(request.getPhn()); + re0.setGroupNumber(request.getGroupNumber()); + re0.setDependentPHN(request.getDependentPhn()); + re0.setDependentDOB(formatDate(request.getDependentDateOfBirth())); + re0.setCanadianStudent(request.getIsStudent()); + LocalDate studentEndDate = request.getStudentEndDate() != null ? request.getStudentEndDate() : calculateStudentEndDate(request.getDependentDateOfBirth()); + re0.setStudentEndDate(studentEndDate.format(DateTimeFormatter.ofPattern(RAPID_YYYY_MM_FORMAT))); + + RPBSPRE0 rpbspre0 = new RPBSPRE0(); + rpbspre0.setRpbsHeader(rpbsHeader); + rpbspre0.setRe0(re0); + + return rpbspre0; + } + + public ReinstateOverAgeDependentResponse convertResponse(RPBSPRE0 rpbspre0) { + ReinstateOverAgeDependentResponse response = new ReinstateOverAgeDependentResponse(); + RPBSHeader header = rpbspre0.getRpbsHeader(); + + handleStatus(header, response); + + response.setPhn(rpbspre0.getRe0().getDependentPHN()); + + return response; + } + + @Override + public String getTranCode() { + return TRAN_CODE; + } + + private LocalDate calculateStudentEndDate(LocalDate birthDate) { + // The end date is to be stripped of the dd portion. If the end date is empty then a new end date + // is to be made up from the dependents birth date and the current year plus one + return LocalDate.of(LocalDate.now().getYear(), birthDate.getMonth(), birthDate.getDayOfMonth()).plusYears(1); + } + +} \ No newline at end of file diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rapid/RE0.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rapid/RE0.java new file mode 100644 index 00000000..7b667ece --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rapid/RE0.java @@ -0,0 +1,97 @@ +package ca.bc.gov.hlth.hnweb.model.rapid; + +import org.apache.commons.lang3.StringUtils; + +public class RE0 { + + /** 1 SubscriberPHN String No 0...10 .. */ + private String subscriberPHN; + /** 2 GroupNumber String No 0...7 .. */ + private String groupNumber; + /** 3 DependentPHN String No 0...10 .. */ + private String dependentPHN; + /** 4 DependentDOB RPBSDate No 0...10 .. */ + private String dependentDOB; + /** 5 CanadianStudent String No 0...1 .. (Valid values are 'Y', 'N') **/ + private String canadianStudent; + /** 6 StudentEndDate String No 0...10 .. */ + private String studentEndDate; + + public RE0() { + super(); + } + + public RE0(String message) { + super(); + subscriberPHN = StringUtils.substring(message, 0, 10); + groupNumber = StringUtils.substring(message, 10, 17); + dependentPHN = StringUtils.substring(message, 17, 27); + dependentDOB = StringUtils.substring(message, 27, 34); + canadianStudent = StringUtils.substring(message, 34, 35); + studentEndDate = StringUtils.substring(message, 35, 42); + } + + public String serialize() { + // Serialize is only used in when creating the request + StringBuilder sb = new StringBuilder(); + sb.append(StringUtils.rightPad(subscriberPHN, 10)); + sb.append(StringUtils.rightPad(groupNumber, 7)); + sb.append(StringUtils.rightPad(dependentPHN, 10)); + sb.append(StringUtils.rightPad(dependentDOB, 10)); + sb.append(StringUtils.rightPad(canadianStudent, 1)); + sb.append(StringUtils.rightPad(studentEndDate, 7)); + + return sb.toString(); + } + + public String getSubscriberPHN() { + return subscriberPHN; + } + + public void setSubscriberPHN(String subscriberPHN) { + this.subscriberPHN = subscriberPHN; + } + + public String getGroupNumber() { + return groupNumber; + } + + public void setGroupNumber(String groupNumber) { + this.groupNumber = groupNumber; + } + + public String getDependentPHN() { + return dependentPHN; + } + + public void setDependentPHN(String dependentPHN) { + this.dependentPHN = dependentPHN; + } + + public String getDependentDOB() { + return dependentDOB; + } + + public void setDependentDOB(String dependentDOB) { + this.dependentDOB = dependentDOB; + } + + public String getCanadianStudent() { + return canadianStudent; + } + + public void setCanadianStudent(String canadianStudent) { + this.canadianStudent = canadianStudent; + } + + public String getStudentEndDate() { + return studentEndDate; + } + + public void setStudentEndDate(String studentEndDate) { + this.studentEndDate = studentEndDate; + } + + + +} diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rapid/RPBSPRE0.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rapid/RPBSPRE0.java new file mode 100644 index 00000000..6fba23a5 --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rapid/RPBSPRE0.java @@ -0,0 +1,42 @@ +package ca.bc.gov.hlth.hnweb.model.rapid; + +import org.apache.commons.lang3.StringUtils; + +public class RPBSPRE0 { + private RPBSHeader rpbsHeader = new RPBSHeader(); + private RE0 re0 = new RE0(); + + public RPBSPRE0() { + super(); + } + + public RPBSPRE0(String message) { + String headerText = StringUtils.substring(message, 0, RPBSHeader.SEGMENT_LENGTH); + String bodyText = StringUtils.substring(message, RPBSHeader.SEGMENT_LENGTH); + + rpbsHeader = new RPBSHeader(headerText); + + re0 = new RE0(bodyText); + } + + public RPBSHeader getRpbsHeader() { + return rpbsHeader; + } + + public void setRpbsHeader(RPBSHeader rpbsHeader) { + this.rpbsHeader = rpbsHeader; + } + + public String serialize() { + return rpbsHeader.serialize() + re0.serialize(); + } + + public RE0 getRe0() { + return re0; + } + + public void setRe0(RE0 re0) { + this.re0 = re0; + } + +} diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rest/maintenance/ReinstateOverAgeDependentRequest.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rest/maintenance/ReinstateOverAgeDependentRequest.java new file mode 100644 index 00000000..b338a8db --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rest/maintenance/ReinstateOverAgeDependentRequest.java @@ -0,0 +1,70 @@ +package ca.bc.gov.hlth.hnweb.model.rest.maintenance; + +import java.time.LocalDate; + +import com.fasterxml.jackson.annotation.JsonFormat; + +public class ReinstateOverAgeDependentRequest { + + private String phn; + + private String groupNumber; + + private String dependentPhn; + + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate dependentDateOfBirth; + + private String isStudent; + + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate studentEndDate; + + public String getPhn() { + return phn; + } + + public void setPhn(String phn) { + this.phn = phn; + } + + public String getGroupNumber() { + return groupNumber; + } + + public void setGroupNumber(String groupNumber) { + this.groupNumber = groupNumber; + } + + public String getDependentPhn() { + return dependentPhn; + } + + public void setDependentPhn(String dependentPhn) { + this.dependentPhn = dependentPhn; + } + + public LocalDate getDependentDateOfBirth() { + return dependentDateOfBirth; + } + + public void setDependentDateOfBirth(LocalDate dependentDateOfBirth) { + this.dependentDateOfBirth = dependentDateOfBirth; + } + + public String getIsStudent() { + return isStudent; + } + + public void setIsStudent(String isStudent) { + this.isStudent = isStudent; + } + + public LocalDate getStudentEndDate() { + return studentEndDate; + } + + public void setStudentEndDate(LocalDate studentEndDate) { + this.studentEndDate = studentEndDate; + } +} diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rest/maintenance/ReinstateOverAgeDependentResponse.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rest/maintenance/ReinstateOverAgeDependentResponse.java new file mode 100644 index 00000000..6e2f11fc --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rest/maintenance/ReinstateOverAgeDependentResponse.java @@ -0,0 +1,17 @@ +package ca.bc.gov.hlth.hnweb.model.rest.maintenance; + +import ca.bc.gov.hlth.hnweb.model.rest.BaseResponse; + +public class ReinstateOverAgeDependentResponse extends BaseResponse { + + private String phn; + + public String getPhn() { + return phn; + } + + public void setPhn(String pid) { + this.phn = pid; + } + +} \ No newline at end of file diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/security/SecurityConfig.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/security/SecurityConfig.java index cfee2b10..3469fe49 100644 --- a/backend/src/main/java/ca/bc/gov/hlth/hnweb/security/SecurityConfig.java +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/security/SecurityConfig.java @@ -69,7 +69,8 @@ protected void configure(HttpSecurity http) throws Exception { .mvcMatchers(HttpMethod.POST, "/group-member/add-group-member").hasRole("AddGroupMember") .mvcMatchers(HttpMethod.POST, "/group-member/cancel-dependent").hasRole("CancelDependent") .mvcMatchers(HttpMethod.POST, "/group-member/cancel-group-member").hasRole("CancelGroupMember") - .mvcMatchers(HttpMethod.POST, "/group-member/update-number-and-dept").hasRole("UpdateNumberAndDept") + .mvcMatchers(HttpMethod.POST, "/group-member/update-number-and-dept").hasRole("UpdateNumberAndDept") + .mvcMatchers(HttpMethod.POST, "/group-member/reinstate-over-age-dependent").hasRole("ReinstateOverAgeDependent") .mvcMatchers(HttpMethod.POST, "/msp-contracts/get-contract-periods").hasRole("GetContractPeriods") .mvcMatchers(HttpMethod.POST, "/msp-contracts/update-contract-address").hasRole("UpdateContractAddress") .mvcMatchers(HttpMethod.POST, "/msp-contracts/inquire-contract").hasAnyRole("ContractInquiry", "GetGroupMembersContractAddress") //inquire-contract endpoint will require this multi role as it is used by both R40 and R37 transactions diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/security/TransactionType.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/security/TransactionType.java index 571bbb82..0ed01511 100644 --- a/backend/src/main/java/ca/bc/gov/hlth/hnweb/security/TransactionType.java +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/security/TransactionType.java @@ -17,9 +17,10 @@ public enum TransactionType { CANCEL_GROUP_MEMBER("CancelGroupMember"), CANCEL_DEPENDENT("CancelDependent"), GET_CONTRACT_PERIODS("GetContractPeriods"), - CONTRACT_INQUIRY("ContractInquiry"), //R40 - GET_CONTRACT_ADDRESS("GetContractAddress"), //R37 - UPDATE_CONTRACT_ADDRESS("UpdateContractAddress"), //R38 + CONTRACT_INQUIRY("ContractInquiry"), // R40 + GET_CONTRACT_ADDRESS("GetContractAddress"), // R37 + UPDATE_CONTRACT_ADDRESS("UpdateContractAddress"), // R38 + REINSTATE_OVER_AGE_DEPENDENT("ReinstateOverAgeDependent"), // R43 UNKNOWN("Unknown"); diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/service/MaintenanceService.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/service/MaintenanceService.java new file mode 100644 index 00000000..c122768e --- /dev/null +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/service/MaintenanceService.java @@ -0,0 +1,74 @@ +package ca.bc.gov.hlth.hnweb.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.reactive.function.client.WebClient; + +import ca.bc.gov.hlth.hnweb.exception.ExceptionType; +import ca.bc.gov.hlth.hnweb.exception.HNWebException; +import ca.bc.gov.hlth.hnweb.model.rapid.RPBSPRE0; +import ca.bc.gov.hlth.hnweb.persistence.entity.Transaction; + + +/** + * Service for processing Coverage Maintenance requests. + * + */ +@Service +public class MaintenanceService extends BaseService { + + private static final Logger logger = LoggerFactory.getLogger(MaintenanceService.class); + + @Value("${rapid.r43Path}") + private String r43Path; + + @Autowired + private WebClient rapidWebClient; + + /** + * Reinstate an Over Age Dependent based on the R43/RPBSPRE0 request. + * + * @param rpbspre0 + * @return The RPBSPRE0 response. + * @throws HNWebException + */ + public RPBSPRE0 reinstateOverAgeDependent(RPBSPRE0 rpbspre0, Transaction transaction) throws HNWebException { + String rpbspre0Str = rpbspre0.serialize(); + + logger.info("Request {}", rpbspre0Str); + + messageSent(transaction); + ResponseEntity response = postRapidRequest(r43Path, rpbspre0Str, transaction.getTransactionId().toString()); + + logger.debug("Response Status: {} ; Message:\n{}", response.getStatusCode(), response.getBody()); + + logger.info("Response {}", response.getBody()); + + if (response.getStatusCode() != HttpStatus.OK) { + logger.error("Could not connect to downstream service. Service returned {}", response.getStatusCode()); + throw new HNWebException(ExceptionType.DOWNSTREAM_FAILURE); + } + + messageReceived(transaction); + return new RPBSPRE0(response.getBody()); + } + + private ResponseEntity postRapidRequest(String path, String body, String transactionId) { + return rapidWebClient + .post() + .uri(path) + .contentType(MediaType.TEXT_PLAIN) + .header(TRANSACTION_ID, transactionId) + .bodyValue(body) + .retrieve() + .toEntity(String.class) + .block(); + } + +} diff --git a/backend/src/test/java/ca/bc/gov/hlth/hnweb/BaseControllerTest.java b/backend/src/test/java/ca/bc/gov/hlth/hnweb/BaseControllerTest.java index 9986b178..150c324c 100644 --- a/backend/src/test/java/ca/bc/gov/hlth/hnweb/BaseControllerTest.java +++ b/backend/src/test/java/ca/bc/gov/hlth/hnweb/BaseControllerTest.java @@ -91,7 +91,7 @@ protected Transaction assertTransactionCreated(TransactionType type) { * * @return The number of AffectedPartys found for the specified direction. */ - protected int assertAffectedParyCount(AffectedPartyDirection direction, int count) { + protected int assertAffectedPartyCount(AffectedPartyDirection direction, int count) { AffectedParty example = new AffectedParty(); example.setAffectedPartyId(0); example.setDirection(direction.getValue()); diff --git a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/EligibilityControllerTest.java b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/EligibilityControllerTest.java index b9c7ca31..dfacc54b 100644 --- a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/EligibilityControllerTest.java +++ b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/EligibilityControllerTest.java @@ -160,8 +160,8 @@ public void testCheckEligibility_success_eligible() throws Exception { assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.CHECK_ELIGIBILITY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -193,8 +193,8 @@ public void testCheckEligibility_success_ineligible() throws Exception { assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.CHECK_ELIGIBILITY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -226,8 +226,8 @@ public void testCheckEligibility_error_phnInvalid() throws Exception { assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.CHECK_ELIGIBILITY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -267,8 +267,8 @@ public void testCheckMspCoverageStatus_success_ineligible() throws InterruptedEx assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.MSP_COVERAGE_STATUS_CHECK); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -309,8 +309,8 @@ public void testCheckMspCoverageStatus_success_eligible() throws InterruptedExce assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.MSP_COVERAGE_STATUS_CHECK); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -349,8 +349,8 @@ public void testCheckMspCoverageStatus_error_phnInvalid() throws InterruptedExce assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.MSP_COVERAGE_STATUS_CHECK); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -389,8 +389,8 @@ public void testCheckMspCoverageStatus_error_dateOfBirthMismatch() throws Interr assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.MSP_COVERAGE_STATUS_CHECK); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -429,8 +429,8 @@ public void testInquirePhn_success() throws InterruptedException { assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.PHN_INQUIRY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -459,8 +459,8 @@ public void testInquirePhn_error_noEligibilityDate() throws InterruptedException assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.PHN_INQUIRY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } @Test @@ -489,8 +489,8 @@ public void testInquirePhn_warning_invalidPHN() throws InterruptedException { assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.PHN_INQUIRY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } @Test @@ -531,8 +531,8 @@ public void testInquirePhn_warning_phnNotFound() throws InterruptedException { assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.PHN_INQUIRY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @@ -577,8 +577,8 @@ public void testLookupPhn_success() { // - 1 x Response AffectedParty Transaction transaction = assertTransactionCreated(TransactionType.PHN_LOOKUP); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); assertEquals("00000010", transaction.getOrganization()); assertNotNull(transaction.getServer()); @@ -677,8 +677,8 @@ public void testLookupPhn_warning() { assertEquals("M", beneficiary.getGender()); assertTransactionCreated(TransactionType.PHN_LOOKUP); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 50); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 50); } @Test @@ -704,8 +704,8 @@ public void testLookupPhn_error_invalidContractNumber() { assertEquals(0, beneficiaries.size()); assertTransactionCreated(TransactionType.PHN_LOOKUP); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } @Test @@ -731,8 +731,8 @@ public void testLookupPhn_error_invalidGroupNumber() { assertEquals(0, beneficiaries.size()); assertTransactionCreated(TransactionType.PHN_LOOKUP); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } /** diff --git a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/EnrollmentControllerTest.java b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/EnrollmentControllerTest.java index ff4eb910..0d647d7f 100644 --- a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/EnrollmentControllerTest.java +++ b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/EnrollmentControllerTest.java @@ -87,8 +87,8 @@ void testEnrollSubscriber_Z06_Error() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.ENROLL_SUBSCRIBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } @Test @@ -112,8 +112,8 @@ void testEnrollSubscriber_Z05_Error() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.ENROLL_SUBSCRIBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } @Test @@ -140,8 +140,8 @@ void testEnrollSubscriber_Z06_Success() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.ENROLL_SUBSCRIBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } @Test @@ -167,8 +167,8 @@ void testEnrollSubscriber_Z05_Success() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.ENROLL_SUBSCRIBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @@ -195,8 +195,8 @@ void testGetDemographicsDetails_Success() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.GET_PERSON_DETAILS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -220,8 +220,8 @@ void testGetDemographicsDetails_Warning() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.GET_PERSON_DETAILS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -249,8 +249,8 @@ void testGetDemographicsDetails_Error() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.GET_PERSON_DETAILS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } @Test @@ -280,8 +280,8 @@ void testGetNameSearch_MultiRecords() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.NAME_SEARCH); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 0); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 3); } @@ -309,8 +309,8 @@ void testGetNameSearch_NoRecords() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.NAME_SEARCH); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 0); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } @Test @@ -339,8 +339,8 @@ void testGetNameSearch_Warnings() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.NAME_SEARCH); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 0); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 10); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 10); } @Test @@ -367,8 +367,8 @@ void testGetNameSearch_Error() throws Exception { assertEquals("/", recordedRequest.getPath()); assertTransactionCreated(TransactionType.NAME_SEARCH); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 0); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } /** diff --git a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/GroupMemberControllerTest.java b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/GroupMemberControllerTest.java index 363629f0..e03555ad 100644 --- a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/GroupMemberControllerTest.java +++ b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/GroupMemberControllerTest.java @@ -79,8 +79,8 @@ public void testUpdateGroupMember_invalidRequest() { assertEquals("Department Number or Group Number is required", exception.getReason()); assertTransactionCreated(TransactionType.UPDATE_NUMBER_AND_OR_DEPT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 0); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 0); } @Test @@ -110,8 +110,8 @@ public void testUpdateGroupMember_phnHasNoCoverageInGroup() throws InterruptedEx assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.UPDATE_NUMBER_AND_OR_DEPT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 4); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 4); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -141,8 +141,8 @@ public void testUpdateGroupMember_success() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.UPDATE_NUMBER_AND_OR_DEPT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 4); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 4); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -169,8 +169,8 @@ public void testCancelGroupMember_cancelDateMissing() throws InterruptedExceptio assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_GROUP_MEMBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -198,8 +198,8 @@ public void testCancelGroupMember_cancelDayInvalid() throws InterruptedException assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_GROUP_MEMBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -227,8 +227,8 @@ public void testCancelGroupMember_cancelReasonInvalid() throws InterruptedExcept assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_GROUP_MEMBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -255,8 +255,8 @@ public void testCancelGroupMember_phnDoesNotHaveCoverage() throws InterruptedExc assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_GROUP_MEMBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -283,8 +283,8 @@ public void testCancelGroupMember_futureCancelDate() throws InterruptedException assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_GROUP_MEMBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -311,8 +311,8 @@ public void testCancelGroupMember_success() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_GROUP_MEMBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -346,8 +346,8 @@ public void testAddGroupMember_coverageAlreadyExists() throws InterruptedExcepti assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.ADD_GROUP_MEMBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 4); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 4); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -381,8 +381,8 @@ public void testAddGroupMember_success() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.ADD_GROUP_MEMBER); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 4); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 4); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -410,8 +410,8 @@ public void testAddDependent_success() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.ADD_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -439,8 +439,8 @@ public void testAddDependent_InvalidRelationship() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.ADD_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -469,8 +469,8 @@ public void testAddDependent_InvalidIsStudentFlag() throws InterruptedException assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.ADD_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -498,8 +498,8 @@ public void testAddDependent_PhnNotFound() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.ADD_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -527,8 +527,8 @@ public void testCancelDependent_dependentNotUnderSubcriberCoverage() throws Inte assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -556,8 +556,8 @@ public void testCancelDependent_subscriberPhnNotInGroup() throws InterruptedExce assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -585,8 +585,8 @@ public void testCancelDependent_subscriberAndDependentPhnAreSame() throws Interr assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -614,8 +614,8 @@ public void testCancelDependent_noActiveCoverage() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -643,8 +643,8 @@ public void testCancelDependent_futureCancelDate() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -673,8 +673,8 @@ public void testCancelDependent_success() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertTransactionCreated(TransactionType.CANCEL_DEPENDENT); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 3); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } /** diff --git a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/MaintenanceControllerTest.java b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/MaintenanceControllerTest.java new file mode 100644 index 00000000..7fe655db --- /dev/null +++ b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/MaintenanceControllerTest.java @@ -0,0 +1,197 @@ +package ca.bc.gov.hlth.hnweb.controller; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.springframework.http.HttpHeaders.CONTENT_TYPE; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; + +import ca.bc.gov.hlth.hnweb.BaseControllerTest; +import ca.bc.gov.hlth.hnweb.model.rest.StatusEnum; +import ca.bc.gov.hlth.hnweb.model.rest.maintenance.ReinstateOverAgeDependentRequest; +import ca.bc.gov.hlth.hnweb.model.rest.maintenance.ReinstateOverAgeDependentResponse; +import ca.bc.gov.hlth.hnweb.persistence.entity.AffectedPartyDirection; +import ca.bc.gov.hlth.hnweb.security.TransactionType; +import ca.bc.gov.hlth.hnweb.util.V2MessageUtil; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.RecordedRequest; + +public class MaintenanceControllerTest extends BaseControllerTest { + + private static final String R43_SUCCESS = " RPBSPRE000000010 RESPONSERPBS9014TRANSACTION SUCCESSFUL 9873252394484190498732523872000-05-10Y2022-12"; + + private static final String R43_INVALID_STUDENT_DATE_DATE = " RPBSPRE000000010 ERRORMSGRPBS0111STUDENT END DATE YEAR MUST BE GREATER THAN OR EQUAL TO CURRENT YEAR. 9332912486633710993292797331970-01-01Y2020-01"; + + private static final String R43_NOT_ATTENDING_CANADIAN_SCHOOL = " RPBSPRE000000010 ERRORMSGRPBS0108STUDENT NOT ATTENDING SCHOOL IN CANADA, MUST FORWARD DOCUMENTS TO MSP. 9332912486633710993292797331970-01-01N2023-01"; + + private static final String R43_NO_COVERAGE_FOUND = " RPBSPRE000000010 ERRORMSGRPBS0067NO COVERAGE FOUND FOR THE PHN ENTERED. PLEASE CONTACT MSP 9332912486633710993292797331970-01-01Y2023-01"; + + private static final String R43_CANNOT_BE_REINSTANTED = " RPBSPRE000000010 ERRORMSGRPBS1054DEPENDENT CANNOT BE REINSTATED AS A STUDENT THIS TIME. PLS CONTACT MSP. 9387807484502802293190799262013-03-29Y2022-12"; + + protected static DateTimeFormatter dateOnlyFormatter = DateTimeFormatter.ofPattern(V2MessageUtil.DATE_FORMAT_DATE_ONLY); + + @Autowired + private MaintenanceController maintenanceController; + + @Test + public void testReinstateOverAgeDependent_error_invalidStudentEndDate() throws Exception { + mockBackEnd.enqueue(new MockResponse() + .setBody(R43_INVALID_STUDENT_DATE_DATE) + .addHeader(CONTENT_TYPE, MediaType.TEXT_PLAIN.toString())); + + ReinstateOverAgeDependentRequest reinstateRequest = createReinstateOverAgeDependentRequest("9332912486", LocalDate.of(2020, 1, 1)); + + ResponseEntity response = maintenanceController.reinstateOverAgeDependent(reinstateRequest, createHttpServletRequest()); + + ReinstateOverAgeDependentResponse reinstateResponse = response.getBody(); + assertEquals(StatusEnum.ERROR, reinstateResponse.getStatus()); + assertEquals("RPBS0111 STUDENT END DATE YEAR MUST BE GREATER THAN OR EQUAL TO CURRENT YEAR.", reinstateResponse.getMessage()); + + assertEquals("9329279733", reinstateResponse.getPhn()); + + // Check the client request is sent as expected + RecordedRequest recordedRequest = mockBackEnd.takeRequest(); + assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); + assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); + + assertTransactionCreated(TransactionType.REINSTATE_OVER_AGE_DEPENDENT); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); + } + + @Test + public void testReinstateOverAgeDependent_error_noCoverageFound() throws Exception { + mockBackEnd.enqueue(new MockResponse() + .setBody(R43_NO_COVERAGE_FOUND) + .addHeader(CONTENT_TYPE, MediaType.TEXT_PLAIN.toString())); + + ReinstateOverAgeDependentRequest reinstateRequest = createReinstateOverAgeDependentRequest("9332912486", null); + + ResponseEntity response = maintenanceController.reinstateOverAgeDependent(reinstateRequest, createHttpServletRequest()); + + ReinstateOverAgeDependentResponse reinstateResponse = response.getBody(); + assertEquals(StatusEnum.ERROR, reinstateResponse.getStatus()); + assertEquals("RPBS0067 NO COVERAGE FOUND FOR THE PHN ENTERED. PLEASE CONTACT MSP", reinstateResponse.getMessage()); + + assertEquals("9329279733", reinstateResponse.getPhn()); + + // Check the client request is sent as expected + RecordedRequest recordedRequest = mockBackEnd.takeRequest(); + assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); + assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); + + assertTransactionCreated(TransactionType.REINSTATE_OVER_AGE_DEPENDENT); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); + } + + @Test + public void testReinstateOverAgeDependent_error_notAttendingCanadianSchool() throws Exception { + mockBackEnd.enqueue(new MockResponse() + .setBody(R43_NOT_ATTENDING_CANADIAN_SCHOOL) + .addHeader(CONTENT_TYPE, MediaType.TEXT_PLAIN.toString())); + + ReinstateOverAgeDependentRequest reinstateRequest = createReinstateOverAgeDependentRequest("9332912486", null); + + ResponseEntity response = maintenanceController.reinstateOverAgeDependent(reinstateRequest, createHttpServletRequest()); + + ReinstateOverAgeDependentResponse reinstateResponse = response.getBody(); + assertEquals(StatusEnum.ERROR, reinstateResponse.getStatus()); + assertEquals("RPBS0108 STUDENT NOT ATTENDING SCHOOL IN CANADA, MUST FORWARD DOCUMENTS TO MSP.", reinstateResponse.getMessage()); + + assertEquals("9329279733", reinstateResponse.getPhn()); + + // Check the client request is sent as expected + RecordedRequest recordedRequest = mockBackEnd.takeRequest(); + assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); + assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); + + assertTransactionCreated(TransactionType.REINSTATE_OVER_AGE_DEPENDENT); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); + } + + @Test + public void testReinstateOverAgeDependent_error_cannotBeReinstated() throws Exception { + mockBackEnd.enqueue(new MockResponse() + .setBody(R43_CANNOT_BE_REINSTANTED) + .addHeader(CONTENT_TYPE, MediaType.TEXT_PLAIN.toString())); + + ReinstateOverAgeDependentRequest reinstateRequest = createReinstateOverAgeDependentRequest("9387807484", null); + + ResponseEntity response = maintenanceController.reinstateOverAgeDependent(reinstateRequest, createHttpServletRequest()); + + ReinstateOverAgeDependentResponse reinstateResponse = response.getBody(); + assertEquals(StatusEnum.ERROR, reinstateResponse.getStatus()); + assertEquals("RPBS1054 DEPENDENT CANNOT BE REINSTATED AS A STUDENT THIS TIME. PLS CONTACT MSP.", reinstateResponse.getMessage()); + + assertEquals("9319079926", reinstateResponse.getPhn()); + + // Check the client request is sent as expected + RecordedRequest recordedRequest = mockBackEnd.takeRequest(); + assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); + assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); + + assertTransactionCreated(TransactionType.REINSTATE_OVER_AGE_DEPENDENT); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); + } + + @Test + public void testReinstateOverAgeDependent_success() throws Exception { + mockBackEnd.enqueue(new MockResponse() + .setBody(R43_SUCCESS) + .addHeader(CONTENT_TYPE, MediaType.TEXT_PLAIN.toString())); + + ReinstateOverAgeDependentRequest reinstateRequest = createReinstateOverAgeDependentRequest("9873252394", null); + + ResponseEntity response = maintenanceController.reinstateOverAgeDependent(reinstateRequest, createHttpServletRequest()); + + ReinstateOverAgeDependentResponse reinstateResponse = response.getBody(); + assertEquals(StatusEnum.SUCCESS, reinstateResponse.getStatus()); + assertEquals("RPBS9014 TRANSACTION COMPLETED", reinstateResponse.getMessage()); + + assertEquals("9873252387", reinstateResponse.getPhn()); + + // Check the client request is sent as expected + RecordedRequest recordedRequest = mockBackEnd.takeRequest(); + assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); + assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); + + assertTransactionCreated(TransactionType.REINSTATE_OVER_AGE_DEPENDENT); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 3); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); + } + + /** + * The URL property used by the mocked endpoint needs to be set after the MockWebServer starts as the port it uses is + * created dynamically on start up to ensure it uses an available port so it is not known before then. + * @param registry + */ + @DynamicPropertySource + static void registerMockUrlProperty(DynamicPropertyRegistry registry) { + registry.add("rapid.url", () -> String.format("http://localhost:%s", mockBackEnd.getPort())); + } + + private ReinstateOverAgeDependentRequest createReinstateOverAgeDependentRequest(String phn, LocalDate studentEndDate) { + ReinstateOverAgeDependentRequest reinstateRequest = new ReinstateOverAgeDependentRequest(); + reinstateRequest.setGroupNumber("6337109"); + reinstateRequest.setPhn(phn); + reinstateRequest.setDependentPhn("9329279733"); + reinstateRequest.setDependentDateOfBirth(LocalDate.of(1970, 1, 1)); + reinstateRequest.setStudentEndDate(studentEndDate); + + return reinstateRequest; + } + +} + + diff --git a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/MspContractsControllerTest.java b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/MspContractsControllerTest.java index 3e8c0602..c08d8e6f 100644 --- a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/MspContractsControllerTest.java +++ b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/MspContractsControllerTest.java @@ -153,8 +153,8 @@ public void testGetContractPeriods_success() throws InterruptedException { assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.GET_CONTRACT_PERIODS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 4); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 4); } @Test @@ -198,8 +198,8 @@ public void testGetContractPeriods_warning_moreThan20PersonsFound() throws Inter assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.GET_CONTRACT_PERIODS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 22); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 22); } @Test @@ -230,8 +230,8 @@ public void testGetContractPeriods_error_phnNotFound() throws InterruptedExcepti assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.GET_CONTRACT_PERIODS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 1); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -289,8 +289,8 @@ public void testContractInquiry_success() throws InterruptedException { assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.CONTRACT_INQUIRY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 2); } @Test @@ -321,8 +321,8 @@ public void testContractInquiry_error_phnNotFound() throws InterruptedException assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.CONTRACT_INQUIRY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -352,8 +352,8 @@ public void testContractInquiry_error_NoCoverageFound() throws InterruptedExcept assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.CONTRACT_INQUIRY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -397,8 +397,8 @@ public void testContractInquiry_warning_moreThan20PersonsFound() throws Interrup assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.CONTRACT_INQUIRY); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 20); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 20); } @Test @@ -432,8 +432,8 @@ public void testUpdateContractAddress_error_phoneAlreadyExist() throws Interrupt assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.UPDATE_CONTRACT_ADDRESS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -474,8 +474,8 @@ public void testUpdateContractAddress_success() throws InterruptedException { assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.UPDATE_CONTRACT_ADDRESS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -519,8 +519,8 @@ public void testUpdateContractAddress_error_addressAlreadyExist() throws Interru assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.UPDATE_CONTRACT_ADDRESS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } @Test @@ -556,8 +556,8 @@ public void testUpdateContractAddress_error_phnNotFound() throws InterruptedExce assertEquals(HttpMethod.POST.name(), recordedRequest.getMethod()); assertEquals(MediaType.TEXT_PLAIN.toString(), recordedRequest.getHeader(CONTENT_TYPE)); assertTransactionCreated(TransactionType.UPDATE_CONTRACT_ADDRESS); - assertAffectedParyCount(AffectedPartyDirection.INBOUND, 2); - assertAffectedParyCount(AffectedPartyDirection.OUTBOUND, 1); + assertAffectedPartyCount(AffectedPartyDirection.INBOUND, 2); + assertAffectedPartyCount(AffectedPartyDirection.OUTBOUND, 1); } /** diff --git a/backend/src/test/resources/application-dev.yaml b/backend/src/test/resources/application-dev.yaml index 72f1f90c..0d3d93c8 100644 --- a/backend/src/test/resources/application-dev.yaml +++ b/backend/src/test/resources/application-dev.yaml @@ -36,7 +36,8 @@ rapid: r38Path: r40Path: r41Path: - r42Path: + r42Path: + r43Path: user: name: password: diff --git a/frontend/src/components/template/TheNavBar.vue b/frontend/src/components/template/TheNavBar.vue index e1f972b2..20157def 100644 --- a/frontend/src/components/template/TheNavBar.vue +++ b/frontend/src/components/template/TheNavBar.vue @@ -30,7 +30,9 @@