From 5035b87f1c29a8c9fdee292d672e1ed12677b78e Mon Sep 17 00:00:00 2001 From: DeclanClarkeCGI <142809814+DeclanClarkeCGI@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:41:42 +0000 Subject: [PATCH] Null json schema update (#695) * update json schemas, allow optional fields to be null * update json schemas, allow ALL fields to be null * update json schemas, allow ALL fields to be null * update json schemas, allow ALL fields to be null * update json schemas, allow ALL fields to be null * update json schemas, allow optional fields to be null * update json schemas, allow additional nullable fields * update json schemas, type changes for result_id and originator_id * update json schemas, type changes for result_id and originator_id --- .../draftAccounts/accountJson/account.json | 4 +- .../accountJson/adultAccount.json | 4 +- ...DraftAccountControllerIntegrationTest.java | 8 +- src/main/resources/jsonSchemas/account.json | 225 +++++++++--------- .../jsonSchemas/addDraftAccountRequest.json | 6 +- .../createDefendantAccountRequest.json | 4 +- .../jsonSchemas/getDraftAccountResponse.json | 10 +- .../jsonSchemas/getDraftAccountsResponse.json | 16 +- .../replaceDraftAccountRequest.json | 6 +- .../resources/jsonSchemas/timelineData.json | 6 +- .../updateDraftAccountRequest.json | 6 +- .../DraftAccountControllerTest.java | 156 ++++++------ .../service/opal/DraftAccountServiceTest.java | 4 +- 13 files changed, 238 insertions(+), 217 deletions(-) diff --git a/src/functionalTest/resources/features/opalMode/manualAccountCreation/draftAccounts/accountJson/account.json b/src/functionalTest/resources/features/opalMode/manualAccountCreation/draftAccounts/accountJson/account.json index c5a84f40a..dcade155f 100644 --- a/src/functionalTest/resources/features/opalMode/manualAccountCreation/draftAccounts/accountJson/account.json +++ b/src/functionalTest/resources/features/opalMode/manualAccountCreation/draftAccounts/accountJson/account.json @@ -2,7 +2,7 @@ "account_type": "Fine", "defendant_type": "DEFENDANT", "originator_name": "ORIGINATOR_NAME", - "originator_id": "ORIGINATOR_ID", + "originator_id": 1234, "enforcement_court_id": 101, "collection_order_made": true, "collection_order_made_today": false, @@ -18,7 +18,7 @@ "offence_id": 1234, "impositions": [ { - "result_id": 1, + "result_id": "1234", "amount_imposed": 500.0, "amount_paid": 200.0 } diff --git a/src/functionalTest/resources/features/opalMode/manualAccountCreation/draftAccounts/accountJson/adultAccount.json b/src/functionalTest/resources/features/opalMode/manualAccountCreation/draftAccounts/accountJson/adultAccount.json index a7f06cf3d..e75be5398 100644 --- a/src/functionalTest/resources/features/opalMode/manualAccountCreation/draftAccounts/accountJson/adultAccount.json +++ b/src/functionalTest/resources/features/opalMode/manualAccountCreation/draftAccounts/accountJson/adultAccount.json @@ -2,7 +2,7 @@ "account_type": "Fine", "defendant_type": "Adult", "originator_name": "Police Force", - "originator_id": "PF12345", + "originator_id": 12345, "enforcement_court_id": 101, "collection_order_made": true, "collection_order_made_today": false, @@ -21,7 +21,7 @@ "offence_id": 1234, "impositions": [ { - "result_id": 1, + "result_id": "1234", "amount_imposed": 500.0, "amount_paid": 200.0 } diff --git a/src/integrationTest/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerIntegrationTest.java b/src/integrationTest/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerIntegrationTest.java index 2c204719d..c3c44d64f 100644 --- a/src/integrationTest/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerIntegrationTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerIntegrationTest.java @@ -846,7 +846,7 @@ private static String validCreateRequestBody() { "account_type": "Fine", "defendant_type": "Adult", "originator_name": "Police Force", - "originator_id": "PF12345", + "originator_id": 12345, "enforcement_court_id": 101, "collection_order_made": true, "collection_order_made_today": false, @@ -887,7 +887,7 @@ private static String validCreateRequestBody() { "offence_id": 1234, "impositions": [ { - "result_id": 1, + "result_id": "1", "amount_imposed": 500.00, "amount_paid": 200.00, "major_creditor_id": 999 @@ -997,7 +997,7 @@ private final String validAccountJson() { "account_type": "Fine", "defendant_type": "Adult", "originator_name": "Police Force", - "originator_id": "PF12345", + "originator_id": 12345, "enforcement_court_id": 101, "collection_order_made": true, "collection_order_made_today": false, @@ -1036,7 +1036,7 @@ private final String validAccountJson() { "offence_id": 1234, "impositions": [ { - "result_id": 1, + "result_id": "1", "amount_imposed": 500.00, "amount_paid": 200.00, "major_creditor_id": 999 diff --git a/src/main/resources/jsonSchemas/account.json b/src/main/resources/jsonSchemas/account.json index 0755fe9cf..657cffe71 100644 --- a/src/main/resources/jsonSchemas/account.json +++ b/src/main/resources/jsonSchemas/account.json @@ -32,11 +32,11 @@ "description": "Name of the originator - LJS, Police Force or CTO" }, "originator_id": { - "type": "string", + "type": "integer", "description": "ID for the originator" }, "prosecutor_case_reference": { - "type": "string", + "type": ["string", "null"], "description": "Reference for the prosecutor case" }, "enforcement_court_id": { @@ -44,25 +44,25 @@ "description": "Enforcing court" }, "collection_order_made": { - "type": "boolean", + "type": ["boolean", "null"], "description": "Indicator if collection order is made" }, "collection_order_made_today": { - "type": "boolean", + "type": ["boolean", "null"], "description": "Indicator if collection order is made today" }, "collection_order_date": { - "type": "string", + "type": ["string", "null"], "format": "date", "description": "Date of the collection order" }, "suspended_committal_date": { - "type": "string", + "type": ["string", "null"], "format": "date", "description": "Date for suspended committal" }, "payment_card_request": { - "type": "boolean", + "type": ["boolean", "null"], "description": "Indicator if payment card is requested" }, "account_sentence_date": { @@ -90,7 +90,7 @@ "description": "Payment terms for the account" }, "account_notes": { - "type": "array", + "type": ["array", "null"], "items": { "$ref": "#/$defs/account_note" }, @@ -108,31 +108,30 @@ "description": "Type code for payment terms" }, "effective_date": { - "type": "string", + "type": ["string", "null"], "format": "date", "description": "Effective date for the payment terms" }, "instalment_period": { - "type": "string", - "enum": ["W", "M", "F"], + "enum": ["W", "M", "F", null], "description": "Period for installment payments" }, "lump_sum_amount": { - "type": "number", + "type": ["number", "null"], "multipleOf": 0.01, "description": "Lump sum amount for payment" }, "instalment_amount": { - "type": "number", + "type": ["number", "null"], "multipleOf": 0.01, "description": "Amount for each installment" }, "default_days_in_jail": { - "type": "integer", + "type": ["integer", "null"], "description": "Default days in jail if payment is not made" }, "enforcements": { - "type": "array", + "type": ["array", "null"], "items": { "$ref": "#/$defs/enforcement" }, @@ -141,7 +140,7 @@ } }, "enforcement": { - "type": "object", + "type": ["object", "null"], "required": ["result_id"], "properties": { "result_id": { @@ -150,7 +149,7 @@ "description": "Identifier for the result" }, "enforcement_result_responses": { - "type": "array", + "type": ["array", "null"], "items": { "$ref": "#/$defs/enforcement_result_response" }, @@ -159,7 +158,7 @@ } }, "enforcement_result_response": { - "type": "object", + "type": ["object", "null"], "required": ["parameter_name", "response"], "properties": { "parameter_name": { @@ -173,7 +172,7 @@ } }, "account_note": { - "type": "object", + "type": ["object", "null"], "required": ["account_note_serial", "account_note_text", "note_type"], "properties": { "account_note_serial": { @@ -192,84 +191,84 @@ } }, "alias": { - "type": "object", + "type": ["object", "null"], "properties": { "alias_forenames": { - "type": "string", + "type": ["string", "null"], "description": "Forenames of the alias" }, "alias_surname": { - "type": "string", + "type": ["string", "null"], "description": "Surname of the alias" }, "alias_company_name": { - "type": "string", + "type": ["string", "null"], "description": "Organisation name of the alias" } } }, "debtor_detail": { - "type": "object", + "type": ["object", "null"], "required": ["document_language", "hearing_language"], "properties": { "vehicle_make": { - "type": "string", + "type": ["string", "null"], "description": "Make of the vehicle" }, "vehicle_registration_mark": { - "type": "string", + "type": ["string", "null"], "description": "Registration mark of the vehicle" }, "document_language": { - "type": "string", + "type": ["string", "null"], "description": "Language of the document" }, "hearing_language": { - "type": "string", + "type": ["string", "null"], "description": "Language for the hearing" }, "employee_reference": { - "type": "string", + "type": ["string", "null"], "description": "Reference for the employer" }, "employer_company_name": { - "type": "string", + "type": ["string", "null"], "description": "Name of the employer company" }, "employer_address_line_1": { - "type": "string", + "type": ["string", "null"], "description": "Address line 1 of the employer" }, "employer_address_line_2": { - "type": "string", + "type": ["string", "null"], "description": "Address line 2 of the employer" }, "employer_address_line_3": { - "type": "string", + "type": ["string", "null"], "description": "Address line 3 of the employer" }, "employer_address_line_4": { - "type": "string", + "type": ["string", "null"], "description": "Address line 4 of the employer" }, "employer_address_line_5": { - "type": "string", + "type": ["string", "null"], "description": "Address line 5 of the employer" }, "employer_post_code": { - "type": "string", + "type": ["string", "null"], "description": "Postcode of the employer" }, "employer_telephone_number": { - "type": "string", + "type": ["string", "null"], "description": "Telephone number of the employer" }, "employer_email_address": { - "type": "string", + "type": ["string", "null"], "description": "Email address of the employer" }, "aliases": { - "type": "array", + "type": ["array", "null"], "items": { "$ref": "#/$defs/alias" }, @@ -279,7 +278,7 @@ } }, "parent_guardian": { - "type": "object", + "type": ["object", "null"], "required": ["company_flag", "address_line_1"], "properties": { "company_flag": { @@ -287,24 +286,24 @@ "description": "Flag indicating if it's an organisation" }, "company_name": { - "type": "string", + "type": ["string", "null"], "description": "Name of the organisation" }, "surname": { - "type": "string", + "type": ["string", "null"], "description": "Surname of the parent/guardian" }, "forenames": { - "type": "string", + "type": ["string", "null"], "description": "Forename of the parent/guardian" }, "dob": { - "type": "string", + "type": ["string", "null"], "format": "date", "description": "Date of birth of the parent/guardian" }, "national_insurance_number": { - "type": "string", + "type": ["string", "null"], "description": "National insurance number" }, "address_line_1": { @@ -312,43 +311,43 @@ "description": "Address line 1" }, "address_line_2": { - "type": "string", + "type": ["string", "null"], "description": "Address line 2" }, "address_line_3": { - "type": "string", + "type": ["string", "null"], "description": "Address line 3" }, "address_line_4": { - "type": "string", + "type": ["string", "null"], "description": "Address line 4" }, "address_line_5": { - "type": "string", + "type": ["string", "null"], "description": "Address line 5" }, "post_code": { - "type": "string", + "type": ["string", "null"], "description": "Postcode" }, "telephone_number_home": { - "type": "string", + "type": ["string", "null"], "description": "Home telephone number" }, "telephone_number_business": { - "type": "string", + "type": ["string", "null"], "description": "Business telephone number" }, "telephone_number_mobile": { - "type": "string", + "type": ["string", "null"], "description": "Mobile telephone number" }, "email_address_1": { - "type": "string", + "type": ["string", "null"], "description": "Primary email address" }, "email_address_2": { - "type": "string", + "type": ["string", "null"], "description": "Secondary email address" }, "debtor_detail": { @@ -358,36 +357,36 @@ } }, "fp_ticket_detail": { - "type": "object", + "type": ["object", "null"], "properties": { "notice_number": { - "type": "string", + "type": ["string", "null"], "description": "Notice number" }, "date_of_issue": { - "type": "string", + "type": ["string", "null"], "format": "date", "description": "Date of issue" }, "time_of_issue": { - "type": "string", + "type": ["string", "null"], "format": "time", "description": "Date of issue" }, "fp_registration_number": { - "type": "string", + "type": ["string", "null"], "description": "FP registration number" }, "notice_to_owner_hirer": { - "type": "string", + "type": ["string", "null"], "description": "Notice to owner/hirer" }, "place_of_offence": { - "type": "string", + "type": ["string", "null"], "description": "Place of offence" }, "fp_driving_licence_number": { - "type": "string", + "type": ["string", "null"], "description": "Driving licence number" } } @@ -402,7 +401,7 @@ "description": "Date of sentence" }, "imposing_court_id": { - "type": "integer", + "type": ["integer", "null"], "description": "Court imposing the sentence" }, "offence_id": { @@ -423,7 +422,7 @@ "required": ["result_id", "amount_imposed", "amount_paid"], "properties": { "result_id": { - "type": "integer", + "type": "string", "description": "Result identifier" }, "amount_imposed": { @@ -437,7 +436,7 @@ "description": "Amount paid" }, "major_creditor_id": { - "type": "integer", + "type": ["integer", "null"], "description": "Major creditor id" }, "minor_creditor": { @@ -447,7 +446,7 @@ } }, "minor_creditor": { - "type": "object", + "type": ["object", "null"], "required": ["company_flag", "payout_hold", "pay_by_bacs"], "properties": { "company_flag": { @@ -455,56 +454,56 @@ "description": "Flag indicating if it's an organisation" }, "title": { - "type": "string", + "type": ["string", "null"], "description": "Title of the minor creditor" }, "company_name": { - "type": "string", + "type": ["string", "null"], "description": "Company name" }, "surname": { - "type": "string", + "type": ["string", "null"], "description": "Surname of the minor creditor" }, "forenames": { - "type": "string", + "type": ["string", "null"], "description": "Forenames of the minor creditor" }, "dob": { - "type": "string", + "type": ["string", "null"], "format": "date", "description": "Date of birth" }, "address_line_1": { - "type": "string", + "type": ["string", "null"], "description": "Address" }, "address_line_2": { - "type": "string", + "type": ["string", "null"], "description": "Address line 2" }, "address_line_3": { - "type": "string", + "type": ["string", "null"], "description": "Address line 3" }, "address_line_4": { - "type": "string", + "type": ["string", "null"], "description": "Address line 4" }, "address_line_5": { - "type": "string", + "type": ["string", "null"], "description": "Address line 5" }, "post_code": { - "type": "string", + "type": ["string", "null"], "description": "Postcode" }, "telephone": { - "type": "string", + "type": ["string", "null"], "description": "Telephone number" }, "email_address": { - "type": "string", + "type": ["string", "null"], "description": "Email address" }, "payout_hold": { @@ -516,23 +515,23 @@ "description": "Indicator if payment is by BACS" }, "bank_account_type": { - "type": "string", + "type": ["string", "null"], "description": "Type of bank account" }, "bank_sort_code": { - "type": "string", + "type": ["string", "null"], "description": "Bank sort code" }, "bank_account_number": { - "type": "string", + "type": ["string", "null"], "description": "Bank account number" }, "bank_account_name": { - "type": "string", + "type": ["string", "null"], "description": "Name of the account" }, "bank_account_ref": { - "type": "string", + "type": ["string", "null"], "description": "Bank account reference" } } @@ -546,23 +545,23 @@ "description": "Flag indicating if it's an organisation" }, "title": { - "type": "string", + "type": ["string", "null"], "description": "Title of the defendant" }, "surname": { - "type": "string", + "type": ["string", "null"], "description": "Surname of the defendant" }, "company_name": { - "type": "string", + "type": ["string", "null"], "description": "Company name of the defendant" }, "forenames": { - "type": "string", + "type": ["string", "null"], "description": "First forename of the defendant" }, "dob": { - "type": "string", + "type": ["string", "null"], "format": "date", "description": "Date of birth of the defendant" }, @@ -571,95 +570,95 @@ "description": "Address line 1" }, "address_line_2": { - "type": "string", + "type": ["string", "null"], "description": "Address line 2" }, "address_line_3": { - "type": "string", + "type": ["string", "null"], "description": "Address line 3" }, "address_line_4": { - "type": "string", + "type": ["string", "null"], "description": "Address line 4" }, "address_line_5": { - "type": "string", + "type": ["string", "null"], "description": "Address line 5" }, "post_code": { - "type": "string", + "type": ["string", "null"], "description": "Postcode" }, "telephone_number_home": { - "type": "string", + "type": ["string", "null"], "description": "Home telephone number" }, "telephone_number_business": { - "type": "string", + "type": ["string", "null"], "description": "Business telephone number" }, "telephone_number_mobile": { - "type": "string", + "type": ["string", "null"], "description": "Mobile telephone number" }, "email_address_1": { - "type": "string", + "type": ["string", "null"], "description": "Primary email address" }, "email_address_2": { - "type": "string", + "type": ["string", "null"], "description": "Secondary email address" }, "national_insurance_number": { - "type": "string", + "type": ["string", "null"], "description": "National insurance number" }, "driving_licence_number": { - "type": "string", + "type": ["string", "null"], "description": "Driving licence number" }, "pnc_id": { - "type": "string", + "type": ["string", "null"], "description": "PNC ID" }, "nationality_1": { - "type": "string", + "type": ["string", "null"], "description": "Primary nationality" }, "nationality_2": { - "type": "string", + "type": ["string", "null"], "description": "Secondary nationality" }, "ethnicity_self_defined": { - "type": "string", + "type": ["string", "null"], "description": "Self-defined ethnicity" }, "ethnicity_observed": { - "type": "string", + "type": ["string", "null"], "description": "Observed ethnicity" }, "cro_number": { - "type": "string", + "type": ["string", "null"], "description": "CRO number" }, "occupation": { - "type": "string", + "type": ["string", "null"], "description": "Occupation" }, "gender": { - "type": "string", + "type": ["string", "null"], "description": "Gender" }, "custody_status": { - "type": "string", + "type": ["string", "null"], "description": "Custody status" }, "prison_number": { - "type": "string", + "type": ["string", "null"], "description": "Prison number" }, "interpreter_lang": { - "type": "string", + "type": ["string", "null"], "description": "Interpreter language" }, "debtor_detail": { diff --git a/src/main/resources/jsonSchemas/addDraftAccountRequest.json b/src/main/resources/jsonSchemas/addDraftAccountRequest.json index afc4e89d3..8a2457001 100644 --- a/src/main/resources/jsonSchemas/addDraftAccountRequest.json +++ b/src/main/resources/jsonSchemas/addDraftAccountRequest.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", + "type": ["object", "null"], "properties": { "business_unit_id": { "type": "integer", @@ -24,11 +24,11 @@ "description": "Type of Account, such as Fixed Penalty Registration" }, "account_status": { - "type": "string", + "type": ["string", "null"], "description": "Status of the Draft Account - one of Submitted, Resubmitted, Rejected, Approved, Deleted" }, "status_message": { - "type": "string", + "type": ["string", "null"], "description": "System message related to the account_status" }, "timeline_data": { diff --git a/src/main/resources/jsonSchemas/createDefendantAccountRequest.json b/src/main/resources/jsonSchemas/createDefendantAccountRequest.json index 47be5ec88..379117cab 100644 --- a/src/main/resources/jsonSchemas/createDefendantAccountRequest.json +++ b/src/main/resources/jsonSchemas/createDefendantAccountRequest.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://opal-fines-service/createDefendantAccountRequest.json", - "type": "object", + "type": ["object", "null"], "properties": { "business_unit_id": { "type": "integer", @@ -21,4 +21,4 @@ "business_unit_user_id", "defendant_account" ] -} \ No newline at end of file +} diff --git a/src/main/resources/jsonSchemas/getDraftAccountResponse.json b/src/main/resources/jsonSchemas/getDraftAccountResponse.json index fbfa7c086..3abfb449f 100644 --- a/src/main/resources/jsonSchemas/getDraftAccountResponse.json +++ b/src/main/resources/jsonSchemas/getDraftAccountResponse.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", + "type": ["object", "null"], "properties": { "draft_account_id": { "type": "integer", @@ -22,12 +22,12 @@ "description": "ID of the User that last submitted the Draft Account for checking" }, "validated_at": { - "type": "string", + "type": ["string", "null"], "format": "date-time", "description": "[Optional] Date the Draft Account was validated - System generated (BE)" }, "validated_by": { - "type": "string", + "type": ["string", "null"], "description": "[Optional] ID of the User that validated the Draft Account" }, "account": { @@ -51,11 +51,11 @@ "description": "Status changes to the Draft Account in chronological order (JSON Array) - System generated (UI)" }, "account_number": { - "type": "string", + "type": ["string", "null"], "description": "[Optional] The Opal Account Number (2char letter code+account number) created on validation - System generated (BE)" }, "account_id": { - "type": "integer", + "type": ["integer", "null"], "format": "int64", "description": "[Optional] Opal Account ID created on validation - System generated (BE)" } diff --git a/src/main/resources/jsonSchemas/getDraftAccountsResponse.json b/src/main/resources/jsonSchemas/getDraftAccountsResponse.json index 3865bd68b..042e21d9d 100644 --- a/src/main/resources/jsonSchemas/getDraftAccountsResponse.json +++ b/src/main/resources/jsonSchemas/getDraftAccountsResponse.json @@ -1,14 +1,14 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://opal-fines-service/getDraftAccountRequest.json", - "type": "object", + "type": ["object", "null"], "properties": { "count": { - "type": "integer", + "type": ["integer", "null"], "description": "The count of Draft Accounts returned" }, "draft_accounts": { - "type": "array", + "type": ["array", "null"], "items": { "$ref": "#/$defs/draft_account" } @@ -39,12 +39,12 @@ "description": "Identifier for the user that submitted the account" }, "validated_at": { - "type": "string", + "type": ["string", "null"], "format": "date-time", "description": "[Optional] Date the Draft Account was validated - System generated (BE)" }, "validated_by": { - "type": "string", + "type": ["string", "null"], "description": "[Optional] ID of the User that validated the Draft Account" }, "account_snapshot": { @@ -65,15 +65,15 @@ "description": "Date of account_status" }, "status_message": { - "type": "string", + "type": ["string", "null"], "description": "System message related to the account_status" }, "account_number": { - "type": "string", + "type": ["string", "null"], "description": "[Optional] The Opal Account Number (2char letter code+account number) created on validation - System generated (BE)" }, "account_id": { - "type": "integer", + "type": ["integer", "null"], "description": "[Optional] Opal Account ID created on validation - System generated (BE)" } }, diff --git a/src/main/resources/jsonSchemas/replaceDraftAccountRequest.json b/src/main/resources/jsonSchemas/replaceDraftAccountRequest.json index 796c6adb2..6c7359e1c 100644 --- a/src/main/resources/jsonSchemas/replaceDraftAccountRequest.json +++ b/src/main/resources/jsonSchemas/replaceDraftAccountRequest.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://opal-fines-service/replaceDraftAccountRequest.json", - "type": "object", + "type": ["object", "null"], "properties": { "business_unit_id": { "type": "integer", @@ -17,7 +17,7 @@ "description": "Value of the name claim in the AAD Acces Token" }, "validated_by": { - "type": "string", + "type": ["string", "null"], "description": "ID of the User that validated the Draft Account for checking" }, "account": { @@ -29,7 +29,7 @@ "description": "Type of Account, such as Fixed Penalty Registration" }, "account_status": { - "type": "string", + "type": ["string", "null"], "description": "Status of the Draft Account - one of Submitted, Resubmitted, Rejected, Approved, Deleted" }, "timeline_data": { diff --git a/src/main/resources/jsonSchemas/timelineData.json b/src/main/resources/jsonSchemas/timelineData.json index 786c90a6c..171bbad9b 100644 --- a/src/main/resources/jsonSchemas/timelineData.json +++ b/src/main/resources/jsonSchemas/timelineData.json @@ -3,14 +3,14 @@ "$id": "https://opal-fines-service/timelineData.json", "title": "Timeline Data", "description": "Timeline Data for a Draft Account", - "type": "array", + "type": ["array", "null"], "minItems": 0, "items": { "$ref": "#/$defs/timeline_data_entry" }, "$defs": { "timeline_data_entry": { - "type": "object", + "type": ["object", "null"], "required": ["username", "status", "status_date"], "properties": { "username": { @@ -27,7 +27,7 @@ "description": "Date when the state was changed" }, "reason_text": { - "type": "string", + "type": ["string", "null"], "description": "Reason text for the timeline event" } } diff --git a/src/main/resources/jsonSchemas/updateDraftAccountRequest.json b/src/main/resources/jsonSchemas/updateDraftAccountRequest.json index f852a76fd..1d394499f 100644 --- a/src/main/resources/jsonSchemas/updateDraftAccountRequest.json +++ b/src/main/resources/jsonSchemas/updateDraftAccountRequest.json @@ -1,14 +1,14 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://opal-fines-service/updateDraftAccountRequest.json", - "type": "object", + "type": ["object", "null"], "properties": { "validated_by": { - "type": "string", + "type": ["string", "null"], "description": "ID of the User that validated the Draft Account for checking" }, "validated_by_name": { - "type": "string", + "type": ["string", "null"], "description": "Value of the name claim in the AAD Acces Token" }, "business_unit_id": { diff --git a/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java b/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java index c4aee1c1d..2712039d8 100644 --- a/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java +++ b/src/test/java/uk/gov/hmcts/opal/controllers/DraftAccountControllerTest.java @@ -203,73 +203,95 @@ DraftAccountSummaryDto toSummaryDto(DraftAccountEntity entity) { private String getAccountJson() { return """ { - "account_type": "Fine", - "defendant_type": "Adult", - "originator_name": "Police Force", - "originator_id": "PF12345", - "enforcement_court_id": 101, - "collection_order_made": true, - "collection_order_made_today": false, - "payment_card_request": true, - "account_sentence_date": "2023-12-01", - "defendant": { - "company_flag": false, - "title": "Mr", - "surname": "LNAME", - "forenames": "John", - "dob": "1985-04-15", - "address_line_1": "123 Elm Street", - "address_line_2": "Suite 45", - "post_code": "AB1 2CD", - "telephone_number_home": "0123456789", - "telephone_number_mobile": "07712345678", - "email_address_1": "john.doe@example.com", - "national_insurance_number": "AB123456C", - "nationality_1": "British", - "occupation": "Engineer", - "debtor_detail": { - "document_language": "English", - "hearing_language": "English", - "vehicle_make": "Toyota", - "vehicle_registration_mark": "ABC123", - "aliases": [ - { - "alias_forenames": "Jon", - "alias_surname": "Smith" - } - ] - } - }, - "offences": [ - { - "date_of_sentence": "2023-11-15", - "imposing_court_id": 202, - "offence_id": 1234, - "impositions": [ - { - "result_id": 1, - "amount_imposed": 500.00, - "amount_paid": 200.00, - "major_creditor_id": 999 - } - ] - } - ], - "payment_terms": { - "payment_terms_type_code": "P", - "effective_date": "2023-11-01", - "instalment_period": "M", - "lump_sum_amount": 1000.00, - "instalment_amount": 200.00, - "default_days_in_jail": 5 - }, - "account_notes": [ - { - "account_note_serial": 1, - "account_note_text": "Defendant requested an installment plan.", - "note_type": "AC" - } - ] + "account_type": "fine", + "defendant_type": "company", + "originator_name": "Asylum & Immigration Tribunal", + "originator_id": 3865, + "prosecutor_case_reference": "AB123456", + "enforcement_court_id": 6255, + "collection_order_made": true, + "collection_order_made_today": true, + "collection_order_date": null, + "suspended_committal_date": null, + "payment_card_request": true, + "account_sentence_date": "2025-01-01", + "defendant": { + "company_flag": true, + "title": null, + "surname": null, + "forenames": null, + "company_name": "Acme Co Ltd", + "dob": null, + "address_line_1": "1 Test Lane", + "address_line_2": null, + "address_line_3": null, + "address_line_4": null, + "address_line_5": null, + "post_code": null, + "telephone_number_home": null, + "telephone_number_business": null, + "telephone_number_mobile": null, + "email_address_1": null, + "email_address_2": null, + "national_insurance_number": null, + "driving_licence_number": null, + "pnc_id": null, + "nationality_1": null, + "nationality_2": null, + "ethnicity_self_defined": null, + "ethnicity_observed": null, + "cro_number": null, + "occupation": null, + "gender": null, + "custody_status": null, + "prison_number": null, + "interpreter_lang": null, + "debtor_detail": { + "vehicle_make": null, + "vehicle_registration_mark": null, + "document_language": "EN", + "hearing_language": "EN", + "employee_reference": null, + "employer_company_name": null, + "employer_address_line_1": null, + "employer_address_line_2": null, + "employer_address_line_3": null, + "employer_address_line_4": null, + "employer_address_line_5": null, + "employer_post_code": null, + "employer_telephone_number": null, + "employer_email_address": null, + "aliases": null + }, + "parent_guardian": null + }, + "offences": [ + { + "date_of_sentence": "01/01/2025", + "imposing_court_id": 6255, + "offence_id": 35014, + "impositions": [ + { + "result_id": "100", + "amount_imposed": 100, + "amount_paid": 0, + "major_creditor_id": null, + "minor_creditor": null + } + ] + } + ], + "fp_ticket_detail": null, + "payment_terms": { + "payment_terms_type_code": "B", + "effective_date": "2025-01-31", + "instalment_period": null, + "lump_sum_amount": null, + "instalment_amount": null, + "default_days_in_jail": null, + "enforcements": null + }, + "account_notes": null }"""; } diff --git a/src/test/java/uk/gov/hmcts/opal/service/opal/DraftAccountServiceTest.java b/src/test/java/uk/gov/hmcts/opal/service/opal/DraftAccountServiceTest.java index f782848e9..e4141e66a 100644 --- a/src/test/java/uk/gov/hmcts/opal/service/opal/DraftAccountServiceTest.java +++ b/src/test/java/uk/gov/hmcts/opal/service/opal/DraftAccountServiceTest.java @@ -428,7 +428,7 @@ private String createAccountString() { "account_type": "Fine", "defendant_type": "Adult", "originator_name": "Police Force", - "originator_id": "PF12345", + "originator_id": 12345, "enforcement_court_id": 101, "collection_order_made": true, "collection_order_made_today": false, @@ -469,7 +469,7 @@ private String createAccountString() { "offence_id": 1234, "impositions": [ { - "result_id": 1, + "result_id": "1", "amount_imposed": 500.0, "amount_paid": 200.0, "major_creditor_id": 999