From 9bc806149f9849d0036a5dae61dd58a4e63216aa Mon Sep 17 00:00:00 2001 From: Nigel Pain Date: Thu, 4 Jul 2024 19:00:55 +0100 Subject: [PATCH 1/3] updated to use schemas from commons library and removed old schemas --- crime-evidence/build.gradle | 2 + .../builder/CapitalEvidenceDTOBuilder.java | 2 +- .../builder/CrimeEvidenceDTOBuilder.java | 2 +- .../builder/EvidenceFeeDTOBuilder.java | 2 +- .../controller/CrimeEvidenceController.java | 4 +- .../evidence/service/EvidenceService.java | 4 +- .../apiCalculateEvidenceFeeRequest.json | 45 ------------------- .../apiCalculateEvidenceFeeResponse.json | 15 ------- .../schemas/common/apiCapitalEvidence.json | 18 -------- .../schemas/common/apiEvidenceFee.json | 17 ------- .../builder/EvidenceFeeDTOBuilderTest.java | 2 +- .../data/builder/TestModelDataBuilder.java | 8 ++-- .../evidence/service/EvidenceServiceTest.java | 2 +- 13 files changed, 15 insertions(+), 108 deletions(-) delete mode 100644 crime-evidence/src/main/resources/schemas/apiCalculateEvidenceFeeRequest.json delete mode 100644 crime-evidence/src/main/resources/schemas/apiCalculateEvidenceFeeResponse.json delete mode 100644 crime-evidence/src/main/resources/schemas/common/apiCapitalEvidence.json delete mode 100644 crime-evidence/src/main/resources/schemas/common/apiEvidenceFee.json diff --git a/crime-evidence/build.gradle b/crime-evidence/build.gradle index 9c82fd5..c63b7db 100644 --- a/crime-evidence/build.gradle +++ b/crime-evidence/build.gradle @@ -17,6 +17,7 @@ jacoco { def versions = [ pitest : "1.16.0", crimeCommonsClasses : "3.4.0", + commonsModSchemas : "1.3.3", commonsRestClient : "3.4.0", wmStubRunnerVersion : "4.1.2", springDocWebMVCVersion: "2.5.0", @@ -40,6 +41,7 @@ repositories { dependencies { implementation "uk.gov.justice.service.laa-crime:crime-commons-spring-boot-starter-rest-client:$versions.commonsRestClient:all" implementation "uk.gov.justice.service.laa-crime:crime-commons-classes:$versions.crimeCommonsClasses" + implementation "uk.gov.justice.service.laa-crime:crime-commons-mod-schemas:$versions.commonsModSchemas" implementation "org.springframework.boot:spring-boot-starter-validation" implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server" diff --git a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/CapitalEvidenceDTOBuilder.java b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/CapitalEvidenceDTOBuilder.java index eabb6c8..cf9a8aa 100644 --- a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/CapitalEvidenceDTOBuilder.java +++ b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/CapitalEvidenceDTOBuilder.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; import org.springframework.stereotype.Component; import uk.gov.justice.laa.crime.evidence.dto.CapitalEvidenceDTO; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeRequest; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeRequest; import java.util.List; diff --git a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/CrimeEvidenceDTOBuilder.java b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/CrimeEvidenceDTOBuilder.java index 8b7e755..718defb 100644 --- a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/CrimeEvidenceDTOBuilder.java +++ b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/CrimeEvidenceDTOBuilder.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; import org.springframework.stereotype.Component; import uk.gov.justice.laa.crime.evidence.dto.CrimeEvidenceDTO; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeRequest; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeRequest; @Component @NoArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/EvidenceFeeDTOBuilder.java b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/EvidenceFeeDTOBuilder.java index d0fadfc..d8bbb9b 100644 --- a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/EvidenceFeeDTOBuilder.java +++ b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/builder/EvidenceFeeDTOBuilder.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; import org.springframework.stereotype.Component; import uk.gov.justice.laa.crime.evidence.dto.EvidenceFeeDTO; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeRequest; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeRequest; @Component @NoArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceController.java b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceController.java index 216d95a..35feeb5 100644 --- a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceController.java +++ b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/controller/CrimeEvidenceController.java @@ -19,8 +19,8 @@ import uk.gov.justice.laa.crime.evidence.builder.CrimeEvidenceDTOBuilder; import uk.gov.justice.laa.crime.evidence.dto.CrimeEvidenceDTO; import uk.gov.justice.laa.crime.evidence.dto.ErrorDTO; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeRequest; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeResponse; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeRequest; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeResponse; import uk.gov.justice.laa.crime.evidence.service.EvidenceService; @Slf4j diff --git a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/service/EvidenceService.java b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/service/EvidenceService.java index cede7a8..5360ee7 100644 --- a/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/service/EvidenceService.java +++ b/crime-evidence/src/main/java/uk/gov/justice/laa/crime/evidence/service/EvidenceService.java @@ -7,8 +7,8 @@ import uk.gov.justice.laa.crime.evidence.common.Constants; import uk.gov.justice.laa.crime.evidence.dto.CrimeEvidenceDTO; import uk.gov.justice.laa.crime.evidence.dto.EvidenceFeeRulesDTO; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeResponse; -import uk.gov.justice.laa.crime.evidence.model.common.ApiEvidenceFee; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeResponse; +import uk.gov.justice.laa.crime.common.model.evidence.ApiEvidenceFee; import uk.gov.justice.laa.crime.enums.EvidenceFeeLevel; import uk.gov.justice.laa.crime.evidence.staticdata.enums.EvidenceFeeRules; diff --git a/crime-evidence/src/main/resources/schemas/apiCalculateEvidenceFeeRequest.json b/crime-evidence/src/main/resources/schemas/apiCalculateEvidenceFeeRequest.json deleted file mode 100644 index 7321a5f..0000000 --- a/crime-evidence/src/main/resources/schemas/apiCalculateEvidenceFeeRequest.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "apiCalculateEvidenceFeeRequest.json", - "type": "object", - "title": "Calculate Evidence Fee Request", - "description": "Data Contract for Calculate Evidence Fee Request", - "properties": { - "repId": { - "type": "integer", - "description": "MAAT / Rep Id" - }, - "magCourtOutcome": { - "type": "string", - "description": "Magistrate Court Outcome" - }, - "evidenceFee": { - "type": "object", - "description": "Evidence Fee", - "$ref": "common/apiEvidenceFee.json" - }, - "capitalEvidence": { - "type": "array", - "description": "List of Capital Evidence", - "items": { - "$ref": "common/apiCapitalEvidence.json" - } - }, - "incomeEvidenceReceivedDate": { - "description": "Income Evidence Received Date", - "type": "string", - "format": "date-time" - }, - "capitalEvidenceReceivedDate": { - "description": "Capital Evidence Received Date", - "type": "string", - "format": "date-time" - }, - "emstCode": { - "description": "Applicant Employment Status Code", - "type": "string" - } - }, - "additionalProperties": false, - "required": ["repId", "magCourtOutcome", "capitalEvidence", "emstCode"] -} diff --git a/crime-evidence/src/main/resources/schemas/apiCalculateEvidenceFeeResponse.json b/crime-evidence/src/main/resources/schemas/apiCalculateEvidenceFeeResponse.json deleted file mode 100644 index f8d9cc1..0000000 --- a/crime-evidence/src/main/resources/schemas/apiCalculateEvidenceFeeResponse.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "apiCalculateEvidenceFeeResponse.json", - "type": "object", - "title": "Calculate Evidence Fee Response", - "description": "Data contract for Calculate Evidence Fee Response", - "properties": { - "evidenceFee": { - "type": "object", - "description": "Evidence Fee", - "$ref": "common/apiEvidenceFee.json" - } - }, - "additionalProperties": false -} diff --git a/crime-evidence/src/main/resources/schemas/common/apiCapitalEvidence.json b/crime-evidence/src/main/resources/schemas/common/apiCapitalEvidence.json deleted file mode 100644 index 4338d19..0000000 --- a/crime-evidence/src/main/resources/schemas/common/apiCapitalEvidence.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "apiCapitalEvidence.json", - "description": "Capital Evidence", - "type": "object", - "properties": { - "evidenceType": { - "description": "Capital Evidence Type", - "type": "string" - }, - "dateReceived": { - "description": "Capital Evidence Date Received", - "type": "string", - "format": "date-time" - } - }, - "additionalProperties": false -} diff --git a/crime-evidence/src/main/resources/schemas/common/apiEvidenceFee.json b/crime-evidence/src/main/resources/schemas/common/apiEvidenceFee.json deleted file mode 100644 index 890beb6..0000000 --- a/crime-evidence/src/main/resources/schemas/common/apiEvidenceFee.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "apiEvidenceFee.json", - "description": "Evidence Fee", - "type": "object", - "properties": { - "feeLevel": { - "description": "Evidence Fee Level", - "type": "string" - }, - "description": { - "description": "Evidence description", - "type": "string" - } - }, - "additionalProperties": false -} diff --git a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/builder/EvidenceFeeDTOBuilderTest.java b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/builder/EvidenceFeeDTOBuilderTest.java index 0c20872..5a56339 100644 --- a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/builder/EvidenceFeeDTOBuilderTest.java +++ b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/builder/EvidenceFeeDTOBuilderTest.java @@ -7,7 +7,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import uk.gov.justice.laa.crime.evidence.data.builder.TestModelDataBuilder; import uk.gov.justice.laa.crime.evidence.dto.EvidenceFeeDTO; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeRequest; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeRequest; import uk.gov.justice.laa.crime.enums.EvidenceFeeLevel; import static org.assertj.core.api.Assertions.assertThat; diff --git a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/data/builder/TestModelDataBuilder.java b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/data/builder/TestModelDataBuilder.java index 121612d..6959dcb 100644 --- a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/data/builder/TestModelDataBuilder.java +++ b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/data/builder/TestModelDataBuilder.java @@ -5,10 +5,10 @@ import uk.gov.justice.laa.crime.evidence.dto.CapitalEvidenceDTO; import uk.gov.justice.laa.crime.evidence.dto.CrimeEvidenceDTO; import uk.gov.justice.laa.crime.evidence.dto.EvidenceFeeDTO; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeRequest; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeResponse; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCapitalEvidence; -import uk.gov.justice.laa.crime.evidence.model.common.ApiEvidenceFee; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeRequest; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeResponse; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCapitalEvidence; +import uk.gov.justice.laa.crime.common.model.evidence.ApiEvidenceFee; import uk.gov.justice.laa.crime.enums.EvidenceFeeLevel; import java.time.LocalDateTime; diff --git a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/service/EvidenceServiceTest.java b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/service/EvidenceServiceTest.java index 70364e8..acd9745 100644 --- a/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/service/EvidenceServiceTest.java +++ b/crime-evidence/src/test/java/uk/gov/justice/laa/crime/evidence/service/EvidenceServiceTest.java @@ -11,7 +11,7 @@ import uk.gov.justice.laa.crime.evidence.common.Constants; import uk.gov.justice.laa.crime.evidence.data.builder.TestModelDataBuilder; import uk.gov.justice.laa.crime.evidence.dto.CrimeEvidenceDTO; -import uk.gov.justice.laa.crime.evidence.model.common.ApiCalculateEvidenceFeeResponse; +import uk.gov.justice.laa.crime.common.model.evidence.ApiCalculateEvidenceFeeResponse; import uk.gov.justice.laa.crime.enums.EvidenceFeeLevel; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; From f6e8afc172dc2942bb7ad04dfd712bcdaf8765bc Mon Sep 17 00:00:00 2001 From: Nigel Pain Date: Thu, 4 Jul 2024 19:06:07 +0100 Subject: [PATCH 2/3] forgot to bump mod schemas to latest version --- crime-evidence/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crime-evidence/build.gradle b/crime-evidence/build.gradle index c63b7db..aadb8f2 100644 --- a/crime-evidence/build.gradle +++ b/crime-evidence/build.gradle @@ -17,7 +17,7 @@ jacoco { def versions = [ pitest : "1.16.0", crimeCommonsClasses : "3.4.0", - commonsModSchemas : "1.3.3", + commonsModSchemas : "1.5.0", commonsRestClient : "3.4.0", wmStubRunnerVersion : "4.1.2", springDocWebMVCVersion: "2.5.0", From 15334c8756fe54f46614a9c3ed0ce425587003a3 Mon Sep 17 00:00:00 2001 From: Nigel Pain Date: Fri, 5 Jul 2024 13:15:36 +0100 Subject: [PATCH 3/3] removed now redundant jsonschema2pojo plugin and config --- crime-evidence/build.gradle | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/crime-evidence/build.gradle b/crime-evidence/build.gradle index aadb8f2..561ec35 100644 --- a/crime-evidence/build.gradle +++ b/crime-evidence/build.gradle @@ -5,7 +5,6 @@ plugins { id 'io.spring.dependency-management' version '1.1.4' id "org.sonarqube" version "4.4.1.3373" id "info.solidsoft.pitest" version "1.15.0" - id "org.jsonschema2dataclass" version "6.0.0" } group = "uk.gov.justice.laa.crime" @@ -114,18 +113,4 @@ sonarqube { property "sonar.pitest.mode", "reuseReport" property "sonar.pitest.reportsDirectory", "build/reports/pitest" } -} - -jsonSchema2Pojo { - executions { - main { - methods.builders = true - methods.buildersDynamic = true - methods.annotateJsr303Jakarta = true - fields.floatUseBigDecimal = true - dateTime.dateTimeType = "java.time.LocalDateTime" - klass.targetPackage = "uk.gov.justice.laa.crime.evidence.model.common" - io.source.setFrom files("${project.rootDir}/src/main/resources/schemas") - } - } } \ No newline at end of file