Skip to content

Commit

Permalink
update claim amount validation (#72)
Browse files Browse the repository at this point in the history
* update claim amount validation
pointing at Civil pr

* update/fix test

* update/fix test

* pointing at CCD branch

* test

* remove PR pointing
  • Loading branch information
drummondjm authored Sep 14, 2023
1 parent 50efc3d commit 76ddcb9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ civil-service:
STITCHING_API_ENABLED: false
DOCUMENT_MANAGEMENT_SECURED: true
RD_COMMONDATA_API_URL: http://rd-commondata-api-{{ .Values.global.environment }}.service.core-compute-{{ .Values.global.environment }}.internal
SERVICE_REQUEST_UPDATE: https://${SERVICE_NAME}.preview.platform.hmcts.net/service-request-update
SERVICE_REQUEST_UPDATE_CLAIM_ISSUED: https://${SERVICE_NAME}.preview.platform.hmcts.net/service-request-update-claim-issued
SERVICE_REQUEST_UPDATE: https://civil-service-${SERVICE_NAME}.preview.platform.hmcts.net/service-request-update
SERVICE_REQUEST_UPDATE_CLAIM_ISSUED: https://civil-service-${SERVICE_NAME}.preview.platform.hmcts.net/service-request-update-claim-issued
ccd:
enabled: true
ccd:
Expand Down
1 change: 1 addition & 0 deletions config/owasp/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<cve>CVE-2020-8908</cve>
<cve>CVE-2023-33201</cve>
<cve>CVE-2023-35116</cve>
<cve>CVE-2023-41080</cve>
</suppress>
<!--End of temporary suppression section -->
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class CreateClaimRequest {
private String particulars;
@NotNull(message = "Claim amount should not be null")
@Min(value = 0, message = "claim amount should not be less than 0")
@Max(value = 99999, message = "claim amount should not be more than 99999")
@Max(value = 9999999, message = "claim amount should not be more than £99,999")
@Schema(description = "claim amount should be between 0 and 99999", example = "87989")
private Long claimAmount;
private Boolean reserveRightToClaimInterest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public ResponseEntity<CreateClaimResponse> submitClaim(String authorization, Cre
try {
ResponseEntity<String> response = civilServiceApi.caseworkerSubmitEvent(userId,authorization,requestBody);
if (response.getStatusCode().is2xxSuccessful()) {
log.info("Submission of claim successful");
return getBulkCaseManClaimNumber(response);
}
} catch (HttpClientErrorException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void init() {
void shouldThrowErrorMessageWhenBulkClaimIdIsNotInValidFormat() {
claimRequest = CreateClaimRequest.builder().bulkCustomerId("abc123678")
.sdtRequestId("testId")
.claimAmount(Long.valueOf(7890))
.claimAmount(7890L)
.claimantReference("1568h8992334")
.defendant1(DefendantType.builder().name("defendant1").build())
.defendant2(DefendantType.builder().name("defendant2").build())
Expand All @@ -42,7 +42,7 @@ void shouldThrowErrorMessageWhenBulkClaimIdIsNotInValidFormat() {
void shouldThrowErrorMessageWhenBulkClaimIdIsNull() {
claimRequest = CreateClaimRequest.builder()
.sdtRequestId("testId")
.claimAmount(Long.valueOf(7890))
.claimAmount(7890L)
.claimantReference("1568h8992334")
.particulars("particulars")
.sotSignature("sotSignatureExample")
Expand All @@ -58,7 +58,7 @@ void shouldThrowErrorMessageWhenClaimantReferenceIsNull() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.sdtRequestId("testId")
.claimAmount(Long.valueOf(7890))
.claimAmount(7890L)
.particulars("particulars")
.sotSignature("sotSignatureExample")
.defendant1(DefendantType.builder().name("defendant1").build())
Expand All @@ -73,7 +73,7 @@ void shouldThrowErrorMessageWhenParticularsExceedsMaximumLength() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.sdtRequestId("testId")
.claimAmount(Long.valueOf(8000))
.claimAmount(8000L)
.particulars("particulars length should ne less than or equal to forty five. testing is in progress")
.claimantReference("1568h8992334")
.sotSignature("sotSignatureExample")
Expand All @@ -88,7 +88,7 @@ void shouldThrowErrorMessageWhenParticularsExceedsMaximumLength() {
void shouldThrowErrorMessageWhenDefendantNameIsNull() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.claimAmount(Long.valueOf(8000))
.claimAmount(8000L)
.particulars("particulars length")
.claimantReference("1568h8992334")
.sotSignature("sotSignatureExample")
Expand All @@ -103,7 +103,7 @@ void shouldThrowErrorMessageWhenDefendantNameIsNull() {
void shouldThrowErrorMessageWhenDefendant2NameIsNull() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.claimAmount(Long.valueOf(8000))
.claimAmount(8000L)
.particulars("particulars length")
.claimantReference("1568h8992334")
.sotSignature("sotSignatureExample")
Expand All @@ -119,7 +119,7 @@ void shouldThrowErrorMessageWhenSotSignatureIsNull() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.sdtRequestId("testId")
.claimAmount(Long.valueOf(8000))
.claimAmount(8000L)
.particulars("particulars")
.claimantReference("1568h8992334")
.defendant1(DefendantType.builder().name("defendant1").build())
Expand Down Expand Up @@ -149,7 +149,7 @@ void shouldThrowErrorMessageWhenClaimAmountIsLessThanZero() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.sdtRequestId("testId")
.claimAmount(Long.valueOf(-1))
.claimAmount((long) -1)
.particulars("particulars")
.claimantReference("1568h8992334")
.sotSignature("sotSignatureExample")
Expand All @@ -165,23 +165,23 @@ void shouldThrowErrorMessageWhenClaimAmountIsGreaterThanMaximumValue() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.sdtRequestId("testId")
.claimAmount(Long.valueOf(9999999))
.claimAmount(99999999L)
.particulars("particulars")
.claimantReference("1568h8992334")
.sotSignature("sotSignatureExample")
.defendant1(DefendantType.builder().name("defendant1").build())
.defendant2(DefendantType.builder().name("defendant2").build())
.build();
constraintViolations = validator.validate(claimRequest);
assertEquals(constraintViolations.iterator().next().getMessage(), "claim amount should not be more than 99999");
assertEquals(constraintViolations.iterator().next().getMessage(), "claim amount should not be more than £99,999");
}

@Test
void shouldThrowCustomErrorWhenDefendant1NameIsEqualToDefendant2Name() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.sdtRequestId("testId")
.claimAmount(Long.valueOf(9999))
.claimAmount(9999L)
.particulars("particulars")
.claimantReference("1568h8992334")
.claimant(ClaimantType.builder().name("claimant").build())
Expand All @@ -199,7 +199,7 @@ void shouldNotThrowErrorWhenDefendant1NameIsNotEqualToDefendant2Name() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.sdtRequestId("testId")
.claimAmount(Long.valueOf(9999))
.claimAmount(9999L)
.particulars("particulars")
.claimantReference("1568h8992334")
.claimant(ClaimantType.builder().name("claimant").build())
Expand All @@ -216,7 +216,7 @@ void shouldProceedWithoutErrorsWhenDefendant2DoesNotExist() {

claimRequest = CreateClaimRequest.builder().bulkCustomerId("15678908")
.sdtRequestId("testId")
.claimAmount(Long.valueOf(9999))
.claimAmount(9999L)
.particulars("particulars")
.claimantReference("1568h8992334")
.claimant(ClaimantType.builder().name("claimant").build())
Expand Down

0 comments on commit 76ddcb9

Please sign in to comment.