From c3de40e6415c8a6189e8c110c53065ad358553e4 Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Mon, 21 Oct 2024 13:15:21 +0100 Subject: [PATCH 1/2] PI-2563 Remove Community API comparison code (#4324) --- .../deploy/values-dev.yml | 1 - .../deploy/values-preprod.yml | 1 - .../deploy/values-prod.yml | 1 - .../__files/GET_conviction_C123456.json | 125 --- .../__files/GET_convictions_C123456.json | 814 ------------------ .../__files/GET_offender_C123456.json | 58 -- .../__files/GET_offender_U123456.json | 58 -- .../__files/GET_offender_all_C123456.json | 159 ---- .../__files/GET_offender_all_U123456.json | 159 ---- .../__files/GET_offender_all_Y123456.json | 4 - ...ffender_all_offender_managers_C123456.json | 49 -- .../__files/GET_requirements_C123456.json | 39 - .../__files/documentsForOrderCcd.json | 34 - .../__files/documentsForOrderComApi.json | 34 - .../simulations/__files/forCompare.json | 162 ---- .../__files/get_attendances_C123456.json | 14 - .../get_court_appearances_C123456.json | 15 - .../__files/get_court_reports_C123456.json | 25 - .../get_documents_grouped_C123456.json | 22 - .../get_licence_conditions_C123456.json | 22 - .../simulations/__files/get_nsi_C123456.json | 184 ---- .../simulations/__files/get_pss_C123456.json | 26 - .../__files/get_registrations_C123456.json | 104 --- .../__files/get_sentence_status_C123456.json | 16 - .../__files/get_single_nsi_C123456.json | 180 ---- .../simulations/mappings/GET_offender.json | 126 --- .../simulations/mappings/get-convictions.json | 198 ----- .../simulations/mappings/get-documents.json | 72 -- .../mappings/get-registrations.json | 17 - .../digital/hmpps/ProxyIntegrationTest.kt | 377 -------- .../hmpps/ProxyToNewIntegrationTest.kt | 85 -- .../hmpps/api/proxy/CommunityApiClient.kt | 12 - .../hmpps/api/proxy/CommunityApiController.kt | 480 ----------- .../hmpps/api/proxy/CommunityApiService.kt | 140 --- .../digital/hmpps/api/proxy/Compare.kt | 6 - .../digital/hmpps/api/proxy/CompareAll.kt | 8 - .../hmpps/api/proxy/CompareAllReport.kt | 14 - .../digital/hmpps/api/proxy/CompareReport.kt | 9 - .../api/proxy/DataNotAvailableException.kt | 7 - .../digital/hmpps/api/proxy/PersonEvent.kt | 44 - .../justice/digital/hmpps/api/proxy/README.md | 43 - .../justice/digital/hmpps/api/proxy/Uri.kt | 101 --- .../api/resource/CommunityApiController.kt | 134 +++ .../digital/hmpps/config/RestClientConfig.kt | 4 - 44 files changed, 134 insertions(+), 4049 deletions(-) delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_conviction_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_convictions_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_U123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_U123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_Y123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_offender_managers_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_requirements_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/documentsForOrderCcd.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/documentsForOrderComApi.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/forCompare.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_attendances_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_court_appearances_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_court_reports_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_documents_grouped_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_licence_conditions_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_nsi_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_pss_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_registrations_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_sentence_status_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/__files/get_single_nsi_C123456.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/mappings/GET_offender.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-convictions.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-documents.json delete mode 100644 projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-registrations.json delete mode 100644 projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProxyIntegrationTest.kt delete mode 100644 projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProxyToNewIntegrationTest.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiClient.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiController.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiService.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/Compare.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareAll.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareAllReport.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareReport.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/DataNotAvailableException.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/PersonEvent.kt delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/README.md delete mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/Uri.kt create mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/resource/CommunityApiController.kt diff --git a/projects/court-case-and-delius/deploy/values-dev.yml b/projects/court-case-and-delius/deploy/values-dev.yml index af271f34d7..3c9ca72055 100644 --- a/projects/court-case-and-delius/deploy/values-dev.yml +++ b/projects/court-case-and-delius/deploy/values-dev.yml @@ -11,7 +11,6 @@ generic-service: SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: http://hmpps-auth.hmpps-auth-dev.svc.cluster.local/auth/.well-known/jwks.json SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-dev.hmpps.service.justice.gov.uk/auth/issuer SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: http://hmpps-auth.hmpps-auth-dev.svc.cluster.local/auth/oauth/token - COMMUNITY-API_URL: https://community-api.test.probation.service.justice.gov.uk INTEGRATIONS_ALFRESCO_URL: https://hmpps-delius-alfresco-test.apps.live.cloud-platform.service.justice.gov.uk/alfresco/service/noms-spg/ generic-prometheus-alerts: diff --git a/projects/court-case-and-delius/deploy/values-preprod.yml b/projects/court-case-and-delius/deploy/values-preprod.yml index 8a6cb13579..330a66f8d1 100644 --- a/projects/court-case-and-delius/deploy/values-preprod.yml +++ b/projects/court-case-and-delius/deploy/values-preprod.yml @@ -10,7 +10,6 @@ generic-service: SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: http://hmpps-auth.hmpps-auth-preprod.svc.cluster.local/auth/.well-known/jwks.json SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in-preprod.hmpps.service.justice.gov.uk/auth/issuer SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: http://hmpps-auth.hmpps-auth-preprod.svc.cluster.local/auth/oauth/token - COMMUNITY-API_URL: https://community-api.pre-prod.delius.probation.hmpps.dsd.io INTEGRATIONS_ALFRESCO_URL: https://alfresco.pre-prod.delius.probation.hmpps.dsd.io/alfresco/service/noms-spg/ generic-prometheus-alerts: diff --git a/projects/court-case-and-delius/deploy/values-prod.yml b/projects/court-case-and-delius/deploy/values-prod.yml index c6be8a774b..56b1021cf4 100644 --- a/projects/court-case-and-delius/deploy/values-prod.yml +++ b/projects/court-case-and-delius/deploy/values-prod.yml @@ -7,5 +7,4 @@ generic-service: SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK_SET_URI: http://hmpps-auth.hmpps-auth-prod.svc.cluster.local/auth/.well-known/jwks.json SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI: https://sign-in.hmpps.service.justice.gov.uk/auth/issuer SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_HMPPS-AUTH_TOKEN-URI: http://hmpps-auth.hmpps-auth-prod.svc.cluster.local/auth/oauth/token - COMMUNITY-API_URL: https://community-api.probation.service.justice.gov.uk INTEGRATIONS_ALFRESCO_URL: https://alfresco.probation.service.justice.gov.uk/alfresco/service/noms-spg/ diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_conviction_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_conviction_C123456.json deleted file mode 100644 index b5f27a2948..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_conviction_C123456.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "convictionId": 2501033211, - "index": "7", - "active": false, - "inBreach": false, - "failureToComplyCount": 0, - "awaitingPsr": false, - "convictionDate": "2024-07-04", - "referralDate": "2024-07-04", - "offences": [ - { - "offenceId": "M2501032211", - "mainOffence": true, - "detail": { - "code": "80500", - "description": "Accident offences - 80500", - "mainCategoryCode": "805", - "mainCategoryDescription": "Accident offences", - "mainCategoryAbbreviation": "Accident offences", - "ogrsOffenceCategory": "Other motoring", - "subCategoryCode": "00", - "subCategoryDescription": "Accident offences", - "form20Code": "13" - }, - "offenceDate": "2024-07-04T00:00:00", - "offenceCount": 1, - "offenderId": 2501155433, - "createdDatetime": "2024-07-04T09:46:29", - "lastUpdatedDatetime": "2024-07-04T09:46:29" - } - ], - "sentence": { - "sentenceId": 2500981555, - "description": "Adult Custody < 12m", - "originalLength": 9, - "originalLengthUnits": "Months", - "defaultLength": 9, - "lengthInDays": 273, - "expectedSentenceEndDate": "2024-07-04", - "startDate": "2024-07-04", - "terminationDate": "2024-07-04", - "terminationReason": "Term Other Reason (29)", - "sentenceType": { - "code": "SC", - "description": "Adult Custody < 12m" - }, - "failureToComplyLimit": 3, - "cja2003Order": true, - "legacyOrder": false - }, - "latestCourtAppearanceOutcome": { - "code": "307", - "description": "Adult Custody < 12m" - }, - "custody": { - "institution": { - "institutionId": 157, - "isEstablishment": true, - "code": "UNKNOW", - "description": "Unknown", - "institutionName": "Unknown", - "establishmentType": { - "code": "E", - "description": "Prison" - }, - "nomsPrisonInstitutionCode": "UNK" - }, - "keyDates": {}, - "status": { - "code": "T", - "description": "Terminated" - }, - "sentenceStartDate": "2024-07-04" - }, - "responsibleCourt": { - "courtId": 1, - "code": "ABDRM1", - "selectable": true, - "courtName": "Aberdare Magistrates Court", - "telephoneNumber": "01685 721731", - "fax": "01685 723919", - "buildingName": "The Court House", - "street": "Cwmbach Road", - "locality": "Aberdare", - "town": "Aberdare", - "county": "Glamorgan", - "postcode": "CF44 0NW", - "country": "Wales", - "courtTypeId": 310, - "createdDatetime": "2013-02-05T10:08:41", - "lastUpdatedDatetime": "2021-09-20T16:33:49", - "probationAreaId": 1500001002, - "probationArea": { - "code": "N03", - "description": "Wales" - }, - "courtType": { - "code": "MAG", - "description": "Magistrates Court" - } - }, - "courtAppearance": { - "courtAppearanceId": 2501104581, - "appearanceDate": "2024-07-04T00:00:00", - "courtCode": "ABDRM1", - "courtName": "Aberdare Magistrates Court", - "appearanceType": { - "code": "S", - "description": "Sentence" - }, - "crn": "X756510" - }, - "orderManagers": [ - { - "probationAreaId": 1500001006, - "teamId": 1500119967, - "officerId": 2501115997, - "name": "Unallocated Staff(N07) Staff", - "staffCode": "N07UATU", - "dateStartOfAllocation": "2024-07-04T00:00:00", - "teamCode": "N07UAT", - "probationAreaCode": "N07" - } - ] -} diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_convictions_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_convictions_C123456.json deleted file mode 100644 index 2c648b81a8..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_convictions_C123456.json +++ /dev/null @@ -1,814 +0,0 @@ -[ - { - "convictionId": 2501033211, - "index": "7", - "active": false, - "inBreach": false, - "failureToComplyCount": 0, - "awaitingPsr": false, - "convictionDate": "2024-07-04", - "referralDate": "2024-07-04", - "offences": [ - { - "offenceId": "M2501032211", - "mainOffence": true, - "detail": { - "code": "80500", - "description": "Accident offences - 80500", - "mainCategoryCode": "805", - "mainCategoryDescription": "Accident offences", - "mainCategoryAbbreviation": "Accident offences", - "ogrsOffenceCategory": "Other motoring", - "subCategoryCode": "00", - "subCategoryDescription": "Accident offences", - "form20Code": "13" - }, - "offenceDate": "2024-07-04T00:00:00", - "offenceCount": 1, - "offenderId": 2501155433, - "createdDatetime": "2024-07-04T09:46:29", - "lastUpdatedDatetime": "2024-07-04T09:46:29" - } - ], - "sentence": { - "sentenceId": 2500981555, - "description": "Adult Custody < 12m", - "originalLength": 9, - "originalLengthUnits": "Months", - "defaultLength": 9, - "lengthInDays": 273, - "expectedSentenceEndDate": "2024-07-04", - "startDate": "2024-07-04", - "terminationDate": "2024-07-04", - "terminationReason": "Term Other Reason (29)", - "sentenceType": { - "code": "SC", - "description": "Adult Custody < 12m" - }, - "failureToComplyLimit": 3, - "cja2003Order": true, - "legacyOrder": false - }, - "latestCourtAppearanceOutcome": { - "code": "307", - "description": "Adult Custody < 12m" - }, - "custody": { - "institution": { - "institutionId": 157, - "isEstablishment": true, - "code": "UNKNOW", - "description": "Unknown", - "institutionName": "Unknown", - "establishmentType": { - "code": "E", - "description": "Prison" - }, - "nomsPrisonInstitutionCode": "UNK" - }, - "keyDates": {}, - "status": { - "code": "T", - "description": "Terminated" - }, - "sentenceStartDate": "2024-07-04" - }, - "responsibleCourt": { - "courtId": 1, - "code": "ABDRM1", - "selectable": true, - "courtName": "Aberdare Magistrates Court", - "telephoneNumber": "01685 721731", - "fax": "01685 723919", - "buildingName": "The Court House", - "street": "Cwmbach Road", - "locality": "Aberdare", - "town": "Aberdare", - "county": "Glamorgan", - "postcode": "CF44 0NW", - "country": "Wales", - "courtTypeId": 310, - "createdDatetime": "2013-02-05T10:08:41", - "lastUpdatedDatetime": "2021-09-20T16:33:49", - "probationAreaId": 1500001002, - "probationArea": { - "code": "N03", - "description": "Wales" - }, - "courtType": { - "code": "MAG", - "description": "Magistrates Court" - } - }, - "courtAppearance": { - "courtAppearanceId": 2501104581, - "appearanceDate": "2024-07-04T00:00:00", - "courtCode": "ABDRM1", - "courtName": "Aberdare Magistrates Court", - "appearanceType": { - "code": "S", - "description": "Sentence" - }, - "crn": "X756510" - }, - "orderManagers": [ - { - "probationAreaId": 1500001006, - "teamId": 1500119967, - "officerId": 2501115997, - "name": "Unallocated Staff(N07) Staff", - "staffCode": "N07UATU", - "dateStartOfAllocation": "2024-07-04T00:00:00", - "teamCode": "N07UAT", - "probationAreaCode": "N07" - } - ] - }, - { - "convictionId": 2501027213, - "index": "6", - "active": true, - "inBreach": false, - "failureToComplyCount": 0, - "awaitingPsr": false, - "convictionDate": "2024-06-18", - "referralDate": "2024-06-18", - "offences": [ - { - "offenceId": "M2501026213", - "mainOffence": true, - "detail": { - "code": "02500", - "description": "(Abduction - 02500)", - "mainCategoryCode": "025", - "mainCategoryDescription": "Abduction", - "mainCategoryAbbreviation": "Abduction", - "ogrsOffenceCategory": "Sexual (not against child)", - "subCategoryCode": "00", - "subCategoryDescription": "Abduction", - "form20Code": "3" - }, - "offenceDate": "2024-05-07T00:00:00", - "offenceCount": 1, - "offenderId": 2501155433, - "createdDatetime": "2024-06-18T14:56:06", - "lastUpdatedDatetime": "2024-06-18T14:56:06" - } - ], - "sentence": { - "sentenceId": 2500975554, - "description": "CJA - Community Order", - "originalLength": 12, - "originalLengthUnits": "Months", - "defaultLength": 12, - "lengthInDays": 364, - "expectedSentenceEndDate": "2025-06-17", - "unpaidWork": { - "minutesOrdered": 2160, - "minutesCompleted": 0, - "appointments": { - "total": 0, - "attended": 0, - "acceptableAbsences": 0, - "unacceptableAbsences": 0, - "noOutcomeRecorded": 0 - }, - "status": "Being Worked" - }, - "startDate": "2024-06-18", - "sentenceType": { - "code": "SP", - "description": "CJA - Community Order" - }, - "additionalSentences": [ - { - "additionalSentenceId": 2500274980, - "type": { - "code": "ASBO", - "description": "Anti-Social Behaviour Order" - }, - "length": 12, - "notes": "Comment added by Paul McPhee on 18/06/2024 at 15:04\nAn additional sentence" - } - ], - "failureToComplyLimit": 2, - "cja2003Order": true, - "legacyOrder": false - }, - "latestCourtAppearanceOutcome": { - "code": "424", - "description": "Lie on File" - }, - "responsibleCourt": { - "courtId": 2500015964, - "code": "BSLDCC", - "selectable": true, - "courtName": "Basildon Crown Court", - "telephoneNumber": "01268 458000", - "fax": "01268 458100", - "buildingName": "Basildon Combined Court", - "street": "The Gore", - "town": "Basildon", - "county": "Essex", - "postcode": "SS14 2EU", - "country": "England", - "courtTypeId": 294, - "createdDatetime": "2022-12-29T10:50:41", - "lastUpdatedDatetime": "2023-07-19T11:51:22", - "probationAreaId": 2500010506, - "probationArea": { - "code": "N56", - "description": "East of England" - }, - "courtType": { - "code": "CRN", - "description": "Crown Court" - } - }, - "courtAppearance": { - "courtAppearanceId": 2501098089, - "appearanceDate": "2024-06-18T00:00:00", - "courtCode": "BSLDCC", - "courtName": "Basildon Crown Court", - "appearanceType": { - "code": "A", - "description": "Appeal" - }, - "crn": "X756510" - }, - "orderManagers": [ - { - "probationAreaId": 2500010506, - "teamId": 2500038739, - "officerId": 2501110001, - "name": "Unallocated Staff", - "staffCode": "N56UATU", - "dateStartOfAllocation": "2024-06-18T00:00:00", - "teamCode": "N56UAT", - "probationAreaCode": "N56" - } - ] - }, - { - "convictionId": 2501027202, - "index": "5", - "active": false, - "inBreach": false, - "failureToComplyCount": 0, - "awaitingPsr": false, - "convictionDate": "2024-06-04", - "referralDate": "2024-06-07", - "offences": [ - { - "offenceId": "M2501026202", - "mainOffence": true, - "detail": { - "code": "03702", - "description": "Aggravated TWOC - dangerous driving, causing injury or damage - 03702", - "mainCategoryCode": "037", - "mainCategoryDescription": "Aggravated taking of a vehicle", - "mainCategoryAbbreviation": "Aggravated taking of a vehicle", - "ogrsOffenceCategory": "Taking and driving away and related offences", - "subCategoryCode": "02", - "subCategoryDescription": "Aggravated TWOC - dangerous driving causing injury or damage £5000+", - "form20Code": "47" - }, - "offenceDate": "2024-06-04T00:00:00", - "offenceCount": 1, - "offenderId": 2501155433, - "createdDatetime": "2024-06-18T09:45:32", - "lastUpdatedDatetime": "2024-06-18T09:45:32" - } - ], - "sentence": { - "sentenceId": 2500975553, - "description": "Not Guilty", - "startDate": "2024-06-18", - "terminationDate": "2024-06-18", - "terminationReason": "Auto Terminated", - "sentenceType": { - "code": "NP", - "description": "Not Guilty" - }, - "failureToComplyLimit": 2, - "cja2003Order": true, - "legacyOrder": true - }, - "latestCourtAppearanceOutcome": { - "code": "425", - "description": "Not Guilty" - }, - "responsibleCourt": { - "courtId": 2500015964, - "code": "BSLDCC", - "selectable": true, - "courtName": "Basildon Crown Court", - "telephoneNumber": "01268 458000", - "fax": "01268 458100", - "buildingName": "Basildon Combined Court", - "street": "The Gore", - "town": "Basildon", - "county": "Essex", - "postcode": "SS14 2EU", - "country": "England", - "courtTypeId": 294, - "createdDatetime": "2022-12-29T10:50:41", - "lastUpdatedDatetime": "2023-07-19T11:51:22", - "probationAreaId": 2500010506, - "probationArea": { - "code": "N56", - "description": "East of England" - }, - "courtType": { - "code": "CRN", - "description": "Crown Court" - } - }, - "courtAppearance": { - "courtAppearanceId": 2501098088, - "appearanceDate": "2024-06-18T10:00:00", - "courtCode": "BSLDCC", - "courtName": "Basildon Crown Court", - "appearanceType": { - "code": "C", - "description": "Courts Martial" - }, - "crn": "X756510" - }, - "orderManagers": [ - { - "probationAreaId": 2500010506, - "teamId": 2500038739, - "officerId": 2501109987, - "name": "Unallocated Staff", - "staffCode": "N56UATU", - "dateStartOfAllocation": "2024-06-07T00:00:00", - "dateEndOfAllocation": "2024-06-18T10:00:00", - "teamCode": "N56UAT", - "probationAreaCode": "N56" - }, - { - "probationAreaId": 2500010506, - "teamId": 2500038739, - "officerId": 2501110000, - "name": "Unallocated Staff", - "staffCode": "N56UATU", - "dateStartOfAllocation": "2024-06-18T10:00:00", - "teamCode": "N56UAT", - "probationAreaCode": "N56" - } - ] - }, - { - "convictionId": 2500994213, - "index": "3", - "active": false, - "inBreach": false, - "failureToComplyCount": 0, - "awaitingPsr": false, - "convictionDate": "2024-04-10", - "referralDate": "2024-04-10", - "offences": [ - { - "offenceId": "M2500993213", - "mainOffence": true, - "detail": { - "code": "04300", - "description": "Abstracting electricity - 04300", - "mainCategoryCode": "043", - "mainCategoryDescription": "Abstracting electricity", - "mainCategoryAbbreviation": "Abstracting electricity", - "ogrsOffenceCategory": "Theft (Non-motor)", - "subCategoryCode": "00", - "subCategoryDescription": "Abstracting electricity", - "form20Code": "7" - }, - "offenceDate": "2024-04-10T00:00:00", - "offenceCount": 1, - "offenderId": 2501155433, - "createdDatetime": "2024-04-10T13:25:01", - "lastUpdatedDatetime": "2024-04-10T13:25:02" - } - ], - "sentence": { - "sentenceId": 2500943056, - "description": "ORA Community Order", - "originalLength": 12, - "originalLengthUnits": "Months", - "defaultLength": 12, - "lengthInDays": 364, - "expectedSentenceEndDate": "2025-04-09", - "startDate": "2024-04-10", - "terminationDate": "2024-04-10", - "terminationReason": "Completed - early good progress", - "sentenceType": { - "code": "SP", - "description": "ORA Community Order" - }, - "failureToComplyLimit": 0, - "cja2003Order": true, - "legacyOrder": false - }, - "latestCourtAppearanceOutcome": { - "code": "329", - "description": "ORA Community Order" - }, - "responsibleCourt": { - "courtId": 960, - "code": "ABDSUM", - "selectable": true, - "courtName": "Aberdeen Sheriff's Court (ABDSHF)", - "courtTypeId": 315, - "createdDatetime": "2013-02-05T10:08:43", - "lastUpdatedDatetime": "2023-07-19T11:51:21", - "probationAreaId": 49, - "probationArea": { - "code": "ALL", - "description": "No Trust or Trust Unknown" - }, - "courtType": { - "code": "SHF", - "description": "Sheriff's Court (Scottish)" - } - }, - "courtAppearance": { - "courtAppearanceId": 2501065583, - "appearanceDate": "2024-06-12T10:00:00", - "courtCode": "ABGVMC", - "courtName": "Abergavenny Magistrates Court", - "appearanceType": { - "code": "S", - "description": "Sentence" - }, - "crn": "X756510" - }, - "orderManagers": [ - { - "probationAreaId": 1500001006, - "teamId": 2500031214, - "officerId": 2501077501, - "name": "Annette Anyld", - "staffCode": "N07B542", - "dateStartOfAllocation": "2024-04-10T00:00:00", - "gradeCode": "PSR", - "teamCode": "N07SP1", - "probationAreaCode": "N07" - } - ] - }, - { - "convictionId": 2500986800, - "index": "1", - "active": false, - "inBreach": false, - "failureToComplyCount": 1, - "awaitingPsr": false, - "convictionDate": "2024-03-05", - "referralDate": "2024-03-12", - "offences": [ - { - "offenceId": "M2500985800", - "mainOffence": true, - "detail": { - "code": "03200", - "description": "(Entering with intent to commit felony (entering by night or breaking into houses, shops, etc, with intent to commit felony) - 03200)", - "mainCategoryCode": "032", - "mainCategoryDescription": "Entering with intent to commit felony", - "mainCategoryAbbreviation": "Entering with intent to commit felony", - "ogrsOffenceCategory": "Violence", - "subCategoryCode": "00", - "subCategoryDescription": "Entering with intent to commit felony", - "form20Code": "15" - }, - "offenceDate": "2023-10-10T00:00:00", - "offenceCount": 1, - "offenderId": 2501155433, - "createdDatetime": "2024-03-19T14:58:03", - "lastUpdatedDatetime": "2024-07-19T12:42:57" - } - ], - "sentence": { - "sentenceId": 2500935632, - "description": "Life imprisonment (Adult)", - "originalLength": 20, - "originalLengthUnits": "Years", - "secondLength": 1, - "secondLengthUnits": "Years", - "defaultLength": 240, - "lengthInDays": 7304, - "expectedSentenceEndDate": "2025-08-12", - "startDate": "2024-03-12", - "terminationDate": "2024-07-19", - "terminationReason": "Term Other Reason (29)", - "sentenceType": { - "code": "SC", - "description": "Life imprisonment (Adult)" - }, - "failureToComplyLimit": 3, - "cja2003Order": true, - "legacyOrder": true - }, - "latestCourtAppearanceOutcome": { - "code": "308", - "description": "Life imprisonment (Adult)" - }, - "custody": { - "institution": { - "institutionId": 156, - "isEstablishment": true, - "code": "COMMUN", - "description": "In the Community", - "institutionName": "In the Community", - "establishmentType": { - "code": "E", - "description": "Prison" - } - }, - "keyDates": {}, - "status": { - "code": "T", - "description": "Terminated" - }, - "sentenceStartDate": "2024-03-12" - }, - "responsibleCourt": { - "courtId": 2500015964, - "code": "BSLDCC", - "selectable": true, - "courtName": "Basildon Crown Court", - "telephoneNumber": "01268 458000", - "fax": "01268 458100", - "buildingName": "Basildon Combined Court", - "street": "The Gore", - "town": "Basildon", - "county": "Essex", - "postcode": "SS14 2EU", - "country": "England", - "courtTypeId": 294, - "createdDatetime": "2022-12-29T10:50:41", - "lastUpdatedDatetime": "2023-07-19T11:51:22", - "probationAreaId": 2500010506, - "probationArea": { - "code": "N56", - "description": "East of England" - }, - "courtType": { - "code": "CRN", - "description": "Crown Court" - } - }, - "courtAppearance": { - "courtAppearanceId": 2501058177, - "appearanceDate": "2024-04-10T10:00:00", - "courtCode": "BSLDCC", - "courtName": "Basildon Crown Court", - "appearanceType": { - "code": "S", - "description": "Sentence" - }, - "crn": "X756510" - }, - "orderManagers": [ - { - "probationAreaId": 1500001006, - "teamId": 2500404721, - "officerId": 2501069591, - "name": "Tom Fletcher", - "staffCode": "N07B764", - "dateStartOfAllocation": "2024-03-12T00:00:00", - "gradeCode": "PS1", - "teamCode": "N07LCA", - "probationAreaCode": "N07" - } - ] - }, - { - "convictionId": 2500994214, - "index": "4", - "active": false, - "inBreach": false, - "failureToComplyCount": 0, - "awaitingPsr": false, - "convictionDate": "2024-03-06", - "referralDate": "2024-03-06", - "offences": [ - { - "offenceId": "M2500993214", - "mainOffence": true, - "detail": { - "code": "16100", - "description": "Allowing a chimney to be on fire - 16100", - "mainCategoryCode": "161", - "mainCategoryDescription": "Allowing a chimney to be on fire", - "mainCategoryAbbreviation": "Allowing a chimney to be on fire", - "ogrsOffenceCategory": "Other offence", - "subCategoryCode": "00", - "subCategoryDescription": "Allowing a chimney to be on fire", - "form20Code": "15" - }, - "offenceDate": "2024-02-06T00:00:00", - "offenceCount": 1, - "offenderId": 2501155433, - "createdDatetime": "2024-04-10T13:55:55", - "lastUpdatedDatetime": "2024-07-19T12:42:58" - } - ], - "sentence": { - "sentenceId": 2500943057, - "description": "ORA Community Order", - "originalLength": 12, - "originalLengthUnits": "Months", - "defaultLength": 12, - "lengthInDays": 364, - "expectedSentenceEndDate": "2024-04-09", - "startDate": "2024-03-06", - "terminationDate": "2024-05-20", - "terminationReason": "Completed - early good progress", - "sentenceType": { - "code": "SP", - "description": "ORA Community Order" - }, - "failureToComplyLimit": 0, - "cja2003Order": true, - "legacyOrder": false - }, - "latestCourtAppearanceOutcome": { - "code": "329", - "description": "ORA Community Order" - }, - "responsibleCourt": { - "courtId": 2500015964, - "code": "BSLDCC", - "selectable": true, - "courtName": "Basildon Crown Court", - "telephoneNumber": "01268 458000", - "fax": "01268 458100", - "buildingName": "Basildon Combined Court", - "street": "The Gore", - "town": "Basildon", - "county": "Essex", - "postcode": "SS14 2EU", - "country": "England", - "courtTypeId": 294, - "createdDatetime": "2022-12-29T10:50:41", - "lastUpdatedDatetime": "2023-07-19T11:51:22", - "probationAreaId": 2500010506, - "probationArea": { - "code": "N56", - "description": "East of England" - }, - "courtType": { - "code": "CRN", - "description": "Crown Court" - } - }, - "courtAppearance": { - "courtAppearanceId": 2501065585, - "appearanceDate": "2024-05-01T10:00:00", - "courtCode": "CRT079", - "courtName": "Airdrie Sheriff Court", - "appearanceType": { - "code": "S", - "description": "Sentence" - }, - "crn": "X756510" - }, - "orderManagers": [ - { - "probationAreaId": 1500001006, - "teamId": 2500031214, - "officerId": 2501077502, - "name": "Annette Anyld", - "staffCode": "N07B542", - "dateStartOfAllocation": "2024-03-06T00:00:00", - "gradeCode": "PSR", - "teamCode": "N07SP1", - "probationAreaCode": "N07" - } - ] - }, - { - "convictionId": 2500986882, - "index": "2", - "active": false, - "inBreach": false, - "failureToComplyCount": 0, - "awaitingPsr": false, - "convictionDate": "1985-09-08", - "referralDate": "1985-09-08", - "offences": [ - { - "offenceId": "M2500985882", - "mainOffence": true, - "detail": { - "code": "10300", - "description": "(Aggravated assaults - 10300)", - "mainCategoryCode": "103", - "mainCategoryDescription": "Aggravated Assaults", - "mainCategoryAbbreviation": "Aggravated Assaults", - "ogrsOffenceCategory": "Violence", - "subCategoryCode": "00", - "subCategoryDescription": "Aggravated Assaults", - "form20Code": "15" - }, - "offenceDate": "1984-12-01T00:00:00", - "offenceCount": 1, - "offenderId": 2501155433, - "createdDatetime": "2024-03-19T18:34:06", - "lastUpdatedDatetime": "2024-03-19T18:34:06" - } - ], - "sentence": { - "sentenceId": 2500935703, - "description": "Imprisonment - Fine Default", - "originalLength": 4, - "originalLengthUnits": "Years", - "defaultLength": 48, - "lengthInDays": 1460, - "expectedSentenceEndDate": "1989-09-07", - "startDate": "1985-09-08", - "terminationDate": "1985-09-08", - "terminationReason": "Auto Terminated", - "sentenceType": { - "code": "NC", - "description": "Imprisonment - Fine Default" - }, - "failureToComplyLimit": 3, - "cja2003Order": true, - "legacyOrder": true - }, - "latestCourtAppearanceOutcome": { - "code": "428", - "description": "Imprisonment - Fine Default" - }, - "custody": { - "institution": { - "institutionId": 157, - "isEstablishment": true, - "code": "UNKNOW", - "description": "Unknown", - "institutionName": "Unknown", - "establishmentType": { - "code": "E", - "description": "Prison" - }, - "nomsPrisonInstitutionCode": "UNK" - }, - "keyDates": {}, - "status": { - "code": "AT", - "description": "Auto Terminated" - }, - "sentenceStartDate": "1985-09-08" - }, - "responsibleCourt": { - "courtId": 885, - "code": "CRT027", - "selectable": true, - "courtName": "Barkingside Magistrates Court - BARSMC", - "telephoneNumber": "020 8551 4461", - "fax": "020 8550 2101", - "buildingName": "850", - "street": "Cranbrook Road", - "locality": "Barkingside", - "town": "Ilford", - "county": "Essex", - "postcode": "IG1 1HW", - "courtTypeId": 310, - "createdDatetime": "2013-02-05T10:08:43", - "lastUpdatedDatetime": "2023-07-19T11:51:22", - "probationAreaId": 1500001006, - "probationArea": { - "code": "N07", - "description": "London" - }, - "courtType": { - "code": "MAG", - "description": "Magistrates Court" - } - }, - "courtAppearance": { - "courtAppearanceId": 2501058272, - "appearanceDate": "1985-09-08T00:00:00", - "courtCode": "CRT027", - "courtName": "Barkingside Magistrates Court - BARSMC", - "appearanceType": { - "code": "S", - "description": "Sentence" - }, - "crn": "X756510" - }, - "orderManagers": [ - { - "probationAreaId": 1500001006, - "teamId": 1500119967, - "officerId": 2501069954, - "name": "Unallocated Staff(N07) Staff", - "staffCode": "N07UATU", - "dateStartOfAllocation": "1985-09-08T00:00:00", - "teamCode": "N07UAT", - "probationAreaCode": "N07" - } - ] - } -] \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_C123456.json deleted file mode 100644 index fb12420851..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_C123456.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "offenderId": 2500343964, - "title": "Mr.", - "firstName": "Aadland", - "middleNames": [ - "Felix", - "Hope" - ], - "surname": "Bertrand", - "dateOfBirth": "2000-07-19", - "gender": "Male", - "otherIds": { - "crn": "X320741", - "pncNumber": "2004/0712343H", - "croNumber": "123456/04A", - "nomsNumber": "G9542VP", - "mostRecentPrisonerNumber": "V74111" - }, - "contactDetails": { - "addresses": [ - { - "from": "2017-09-13", - "noFixedAbode": false, - "addressNumber": "22", - "streetName": "Montague Road", - "town": "Leicester", - "postcode": "LE2 1TG", - "status": { - "code": "MA", - "description": "Postal" - } - }, - { - "from": "2019-09-13", - "noFixedAbode": false, - "addressNumber": "19", - "streetName": "Junction Road", - "district": "Blackheath", - "town": "Sheffield", - "county": "South Yorkshire", - "postcode": "S10 2NA", - "status": { - "code": "M", - "description": "Main" - } - } - ] - }, - "offenderProfile": { - "offenderLanguages": {}, - "previousConviction": {} - }, - "softDeleted": false, - "currentDisposal": "1", - "partitionArea": "National Data", - "currentRestriction": false, - "currentExclusion": false -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_U123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_U123456.json deleted file mode 100644 index fb12420851..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_U123456.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "offenderId": 2500343964, - "title": "Mr.", - "firstName": "Aadland", - "middleNames": [ - "Felix", - "Hope" - ], - "surname": "Bertrand", - "dateOfBirth": "2000-07-19", - "gender": "Male", - "otherIds": { - "crn": "X320741", - "pncNumber": "2004/0712343H", - "croNumber": "123456/04A", - "nomsNumber": "G9542VP", - "mostRecentPrisonerNumber": "V74111" - }, - "contactDetails": { - "addresses": [ - { - "from": "2017-09-13", - "noFixedAbode": false, - "addressNumber": "22", - "streetName": "Montague Road", - "town": "Leicester", - "postcode": "LE2 1TG", - "status": { - "code": "MA", - "description": "Postal" - } - }, - { - "from": "2019-09-13", - "noFixedAbode": false, - "addressNumber": "19", - "streetName": "Junction Road", - "district": "Blackheath", - "town": "Sheffield", - "county": "South Yorkshire", - "postcode": "S10 2NA", - "status": { - "code": "M", - "description": "Main" - } - } - ] - }, - "offenderProfile": { - "offenderLanguages": {}, - "previousConviction": {} - }, - "softDeleted": false, - "currentDisposal": "1", - "partitionArea": "National Data", - "currentRestriction": false, - "currentExclusion": false -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_C123456.json deleted file mode 100644 index 7d45f90570..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_C123456.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "offenderId": 2500343964, - "title": "Mr.", - "firstName": "Aadland", - "middleNames": [ - "Felix", - "Hope" - ], - "surname": "Bertrand", - "dateOfBirth": "2000-07-19", - "gender": "Male", - "offenderAliases": [ - { - "dateOfBirth": "2022-05-17", - "firstName": "Aliasone", - "gender": "Male", - "middleNames": [ - "Midone", "Midtwo" - ], - "surname": "Bertrand" - }, - { - "dateOfBirth": "2022-05-17", - "firstName": "Aliastwo", - "gender": "Male", - "middleNames": ["Midthree"], - "surname": "Bertrand" - } - ], - "otherIds": { - "crn": "C123456", - "pncNumber": "2004/0712343H", - "croNumber": "123456/04A", - "nomsNumber": "G9542VP", - "mostRecentPrisonerNumber": "V74111" - }, - "contactDetails": { - "addresses": [ - { - "from": "2017-09-13", - "noFixedAbode": false, - "addressNumber": "22", - "streetName": "Montague Road", - "town": "Leicester", - "postcode": "LE2 1TG", - "status": { - "code": "MA", - "description": "Postal" - } - }, - { - "from": "2019-09-13", - "noFixedAbode": false, - "addressNumber": "19", - "streetName": "Junction Road", - "district": "Blackheath", - "town": "Sheffield", - "county": "South Yorkshire", - "postcode": "S10 2NA", - "status": { - "code": "M", - "description": "Main" - } - } - ] - }, - "offenderProfile": { - "offenderLanguages": {}, - "remandStatus": "Bail - Unconditional", - "previousConviction": { - "convictionDate": "2019-09-01", - "detail": { - "documentName": "PRE-CONS.pdf" - } - } - }, - "offenderManagers": [ - { - "trustOfficer": { - "forenames": "Unallocated", - "surname": "Staff" - }, - "staff": { - "forenames": "Temperance", - "surname": "Brennan" - }, - "partitionArea": "National Data", - "softDeleted": false, - "team": { - "description": "OMIC OMU A", - "telephone": "0151 222 3333", - "localDeliveryUnit": { - "code": "LDU_CODE", - "description": "LDU Description" - }, - "district": { - "code": "N02OMIC", - "description": "OMiC POM Responsibility" - }, - "borough": { - "code": "N02ALL", - "description": "All NPS North East" - } - }, - "probationArea": { - "code": "N02", - "description": "NPS North East", - "nps": true - }, - "fromDate": "2019-09-30", - "active": true, - "allocationReason": { - "code": "TIN", - "description": "Transfer In" - } - }, - { - "trustOfficer": { - "forenames": "Unallocated", - "surname": "Staff" - }, - "staff": { - "forenames": "Temperance", - "surname": "Brennan" - }, - "partitionArea": "National Data", - "softDeleted": false, - "team": { - "description": "OMIC OMU A ", - "district": { - "code": "N02OMIC", - "description": "OMiC POM Responsibility" - }, - "borough": { - "code": "N02ALL", - "description": "All NPS North East" - } - }, - "probationArea": { - "code": "N02", - "description": "NPS North East", - "nps": true - }, - "fromDate": "2019-09-30", - "active": false, - "allocationReason": { - "code": "TIN", - "description": "Transfer In" - } - } - ], - "softDeleted": false, - "currentDisposal": "1", - "partitionArea": "National Data", - "currentRestriction": false, - "restrictionMessage": "This is a restricted offender record. Please contact a system administrator", - "currentExclusion": false, - "exclusionMessage": "You are excluded from viewing this offender record. Please contact a system administrator" -} diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_U123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_U123456.json deleted file mode 100644 index 7d45f90570..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_U123456.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "offenderId": 2500343964, - "title": "Mr.", - "firstName": "Aadland", - "middleNames": [ - "Felix", - "Hope" - ], - "surname": "Bertrand", - "dateOfBirth": "2000-07-19", - "gender": "Male", - "offenderAliases": [ - { - "dateOfBirth": "2022-05-17", - "firstName": "Aliasone", - "gender": "Male", - "middleNames": [ - "Midone", "Midtwo" - ], - "surname": "Bertrand" - }, - { - "dateOfBirth": "2022-05-17", - "firstName": "Aliastwo", - "gender": "Male", - "middleNames": ["Midthree"], - "surname": "Bertrand" - } - ], - "otherIds": { - "crn": "C123456", - "pncNumber": "2004/0712343H", - "croNumber": "123456/04A", - "nomsNumber": "G9542VP", - "mostRecentPrisonerNumber": "V74111" - }, - "contactDetails": { - "addresses": [ - { - "from": "2017-09-13", - "noFixedAbode": false, - "addressNumber": "22", - "streetName": "Montague Road", - "town": "Leicester", - "postcode": "LE2 1TG", - "status": { - "code": "MA", - "description": "Postal" - } - }, - { - "from": "2019-09-13", - "noFixedAbode": false, - "addressNumber": "19", - "streetName": "Junction Road", - "district": "Blackheath", - "town": "Sheffield", - "county": "South Yorkshire", - "postcode": "S10 2NA", - "status": { - "code": "M", - "description": "Main" - } - } - ] - }, - "offenderProfile": { - "offenderLanguages": {}, - "remandStatus": "Bail - Unconditional", - "previousConviction": { - "convictionDate": "2019-09-01", - "detail": { - "documentName": "PRE-CONS.pdf" - } - } - }, - "offenderManagers": [ - { - "trustOfficer": { - "forenames": "Unallocated", - "surname": "Staff" - }, - "staff": { - "forenames": "Temperance", - "surname": "Brennan" - }, - "partitionArea": "National Data", - "softDeleted": false, - "team": { - "description": "OMIC OMU A", - "telephone": "0151 222 3333", - "localDeliveryUnit": { - "code": "LDU_CODE", - "description": "LDU Description" - }, - "district": { - "code": "N02OMIC", - "description": "OMiC POM Responsibility" - }, - "borough": { - "code": "N02ALL", - "description": "All NPS North East" - } - }, - "probationArea": { - "code": "N02", - "description": "NPS North East", - "nps": true - }, - "fromDate": "2019-09-30", - "active": true, - "allocationReason": { - "code": "TIN", - "description": "Transfer In" - } - }, - { - "trustOfficer": { - "forenames": "Unallocated", - "surname": "Staff" - }, - "staff": { - "forenames": "Temperance", - "surname": "Brennan" - }, - "partitionArea": "National Data", - "softDeleted": false, - "team": { - "description": "OMIC OMU A ", - "district": { - "code": "N02OMIC", - "description": "OMiC POM Responsibility" - }, - "borough": { - "code": "N02ALL", - "description": "All NPS North East" - } - }, - "probationArea": { - "code": "N02", - "description": "NPS North East", - "nps": true - }, - "fromDate": "2019-09-30", - "active": false, - "allocationReason": { - "code": "TIN", - "description": "Transfer In" - } - } - ], - "softDeleted": false, - "currentDisposal": "1", - "partitionArea": "National Data", - "currentRestriction": false, - "restrictionMessage": "This is a restricted offender record. Please contact a system administrator", - "currentExclusion": false, - "exclusionMessage": "You are excluded from viewing this offender record. Please contact a system administrator" -} diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_Y123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_Y123456.json deleted file mode 100644 index 451a35e19b..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_Y123456.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "status": 403, - "developerMessage": "This is a restricted record. Please contact a system administrator" -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_offender_managers_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_offender_managers_C123456.json deleted file mode 100644 index 2a930545cd..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_offender_all_offender_managers_C123456.json +++ /dev/null @@ -1,49 +0,0 @@ -[ - { - "staffCode": "N55A032", - "staffId": 2500393723, - "isResponsibleOfficer": true, - "isPrisonOffenderManager": false, - "isUnallocated": false, - "staff": { - "forenames": "Lyndsey", - "surname": "Potter", - "email": "Lyndsey.potter@digital.justice.gov.uk" - }, - "team": { - "code": "N07AAT", - "description": "Automated Allocation Team", - "localDeliveryUnit": { - "code": "N07ALL", - "description": "All London" - }, - "teamType": { - "code": "N07UAT", - "description": "Unallocated LDU(N07)" - }, - "district": { - "code": "N07ALL", - "description": "All London" - }, - "borough": { - "code": "N07ALL", - "description": "All London" - }, - "startDate": "2022-06-16" - }, - "probationArea": { - "probationAreaId": 1500001006, - "code": "N07", - "description": "London", - "organisation": { - "code": "NPS", - "description": "Probation Service" - } - }, - "fromDate": "2024-06-18", - "grade": { - "code": "NPS1", - "description": "NPS - Other" - } - } -] \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_requirements_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_requirements_C123456.json deleted file mode 100644 index 0398dccb70..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/GET_requirements_C123456.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "requirements": [ - { - "requirementId": 93, - "requirementNotes": "notes", - "commencementDate": "2024-01-01", - "startDate": "2024-01-02", - "terminationDate": "2024-01-03", - "expectedStartDate": "2024-01-04", - "expectedEndDate": "2024-01-05", - "createdDatetime": "2023-12-31T12:00:00Z", - "active": true, - "requirementTypeSubCategory": { - "code": "Sub", - "description": "Sub cat" - }, - "requirementTypeMainCategory": { - "code": "Main", - "description": "Main cat" - }, - "adRequirementTypeMainCategory": { - "code": "AdMain", - "description": "AdMain cat" - }, - "adRequirementTypeSubCategory": { - "code": "AdSub", - "description": "AdSub cat" - }, - "terminationReason": { - "code": "R1", - "description": "Released" - }, - "length": 3, - "lengthUnit": "months", - "restrictive": false, - "softDeleted": false - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/documentsForOrderCcd.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/documentsForOrderCcd.json deleted file mode 100644 index 2f1ab3efe1..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/documentsForOrderCcd.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "documents": [], - "convictions": [ - { - "convictionId": "83", - "documents": [ - { - "id": "alfrescoId2", - "documentName": "filename2.txt", - "type": { - "code": "CONVICTION_TESTDOCUMENT", - "description": "Sentence related" - }, - "lastModifiedAt": "2024-08-08T15:56:01.88685", - "createdAt": "2024-08-08T15:56:02.88684", - "parentPrimaryKeyId": 84, - "reportDocumentDates": {} - }, - { - "id": "alfrescoId", - "documentName": "filename.txt", - "type": { - "code": "CONVICTION_DOCUMENT", - "description": "Sentence related" - }, - "lastModifiedAt": "2024-08-08T15:56:02.88685", - "createdAt": "2024-08-08T15:56:02.88684", - "parentPrimaryKeyId": 83, - "reportDocumentDates": {} - } - ] - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/documentsForOrderComApi.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/documentsForOrderComApi.json deleted file mode 100644 index 7459d25f95..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/documentsForOrderComApi.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "documents": [], - "convictions": [ - { - "convictionId": "83", - "documents": [ - { - "id": "alfrescoId", - "documentName": "filename.txt", - "type": { - "code": "CONVICTION_DOCUMENT", - "description": "Sentence related" - }, - "lastModifiedAt": "2024-08-08T15:56:02.88685", - "createdAt": "2024-08-08T15:56:02.88684", - "parentPrimaryKeyId": 83, - "reportDocumentDates": {} - }, - { - "id": "alfrescoId2", - "documentName": "filename2.txt", - "type": { - "code": "CONVICTION_TESTDOCUMENT", - "description": "Sentence related" - }, - "lastModifiedAt": "2024-08-08T15:56:01.88685", - "createdAt": "2024-08-08T15:56:02.88684", - "parentPrimaryKeyId": 84, - "reportDocumentDates": {} - } - ] - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/forCompare.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/forCompare.json deleted file mode 100644 index f4c90aa0de..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/forCompare.json +++ /dev/null @@ -1,162 +0,0 @@ -{ - "surname": "Bertrand", - "dateOfBirth": "2000-07-19", - "gender": "Male", - "offenderId": 2500343964, - "title": "Mr", - "firstName": "Aadland", - "middleNames": [ - "Hope" - ], - "sausages": { - "test": "Testing" - }, - "offenderAliases": [ - { - "dateOfBirth": "2022-05-17", - "firstName": "Aliasone", - "gender": "Male", - "middleNames": [ - "Midone", "Midtwo" - ], - "surname": "Bertrand" - }, - { - "dateOfBirth": "2022-05-17", - "firstName": "Aliastwo", - "gender": "Male", - "middleNames": ["Midthree"], - "surname": "Bertrand" - } - ], - "otherIds": { - "crn": "C123456", - "pncNumber": "2004/0712343H", - "croNumber": "123456/04A", - "nomsNumber": "G9542VP", - "mostRecentPrisonerNumber": "V74111" - }, - "contactDetails": { - "addresses": [ - { - "from": "2017-09-13", - "noFixedAbode": false, - "addressNumber": "22", - "streetName": "Montague Road", - "town": "Leicester", - "postcode": "LE2 1TG", - "status": { - "code": "MA", - "description": "Postal", - "shouldNotBeHere": "Something" - } - }, - { - "from": "2019-09-13", - "noFixedAbode": false, - "addressNumber": "19", - "streetName": "Junction Road", - "district": "Blackheath", - "town": "Sheffield", - "county": "South Yorkshire", - "postcode": "S10 2NA", - "status": { - "code": "M", - "description": "Main" - } - } - ] - }, - "offenderProfile": { - "offenderLanguages": {}, - "remandStatus": "Bail - Unconditional", - "previousConviction": { - "convictionDate": "2019-09-01", - "detail": { - "documentName": "PRE-CONS.pdf" - } - } - }, - "offenderManagers": [ - { - "trustOfficer": { - "forenames": "Unallocated", - "surname": "Staff" - }, - "staff": { - "forenames": "Temperance", - "surname": "Brennan" - }, - "partitionArea": "National Data", - "softDeleted": false, - "team": { - "description": "OMIC OMU A", - "telephone": "0151 222 3333", - "localDeliveryUnit": { - "code": "LDU_CODE", - "description": "LDU Description" - }, - "district": { - "code": "N02OMIC", - "description": "OMiC POM Responsibility" - }, - "borough": { - "code": "N02ALL", - "description": "All NPS North East" - } - }, - "probationArea": { - "code": "N02", - "description": "NPS North East", - "nps": true - }, - "fromDate": "2019-09-20", - "active": false, - "allocationReason": { - "code": "TIN", - "description": "Transfer In" - } - }, - { - "trustOfficer": { - "forenames": "Unallocated", - "surname": "Staff" - }, - "staff": { - "forenames": "Temperance", - "surname": "Brennan" - }, - "partitionArea": "National Data", - "softDeleted": false, - "team": { - "description": "OMIC OMU A ", - "district": { - "code": "N02OMIC", - "description": "OMiC POM Responsibility" - }, - "borough": { - "code": "N02ALL", - "description": "All NPS North East" - } - }, - "probationArea": { - "code": "N02", - "description": "NPS North East", - "nps": true - }, - "fromDate": "2019-09-30", - "active": false, - "allocationReason": { - "code": "TIN", - "description": "Transfer In" - } - } - ], - "softDeleted": false, - "currentDisposal": "1", - "partitionArea": "National Data", - "currentRestriction": false, - "restrictionMessage": "This is a restricted offender record. Please contact a system administrator", - "currentExclusion": false, - "exclusionMessage": "You are excluded from viewing this offender record. Please contact a system administrator" -} diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_attendances_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_attendances_C123456.json deleted file mode 100644 index e8c100066d..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_attendances_C123456.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "attendances": [ - { - "attended": false, - "complied": false, - "attendanceDate": "2024-08-05", - "contactId": 145, - "contactType": { - "code": "C295", - "description": "Attendance Type" - } - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_court_appearances_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_court_appearances_C123456.json deleted file mode 100644 index 2f92aa56b8..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_court_appearances_C123456.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "courtAppearances": [ - { - "courtAppearanceId": 90, - "appearanceDate": "2024-08-06T12:00:00", - "courtCode": "BRMNCC", - "courtName": "Birmingham Crown Court", - "appearanceType": { - "code": "CRN", - "description": "Crown Court" - }, - "crn": "C123456" - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_court_reports_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_court_reports_C123456.json deleted file mode 100644 index d11b9bc24f..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_court_reports_C123456.json +++ /dev/null @@ -1,25 +0,0 @@ -[ - { - "courtReportId": 125, - "offenderId": 65, - "requestedDate": "2024-08-06T18:59:19.420309", - "requiredDate": "2024-08-11T18:59:19.420318", - "allocationDate": "2024-08-06T18:59:19.420326", - "sentToCourtDate": "2024-08-06T18:59:19.420329", - "receivedByCourtDate": "2024-08-06T18:59:19.420332", - "courtReportType": { - "code": "CR1", - "description": "court report" - }, - "reportManagers": [ - { - "staff": { - "code": "N01ABBA", - "forenames": "Bob Micheal", - "surname": "Smith" - }, - "active": true - } - ] - } -] \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_documents_grouped_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_documents_grouped_C123456.json deleted file mode 100644 index ed07a63c16..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_documents_grouped_C123456.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "documents": [], - "convictions": [ - { - "convictionId": "83", - "documents": [ - { - "id": "alfrescoId", - "documentName": "filename.txt", - "type": { - "code": "CONVICTION_DOCUMENT", - "description": "Sentence related" - }, - "lastModifiedAt": "2024-08-08T15:56:02.88685", - "createdAt": "2024-08-08T15:56:02.88684", - "parentPrimaryKeyId": 83, - "reportDocumentDates": {} - } - ] - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_licence_conditions_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_licence_conditions_C123456.json deleted file mode 100644 index c8fdf77e60..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_licence_conditions_C123456.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "licenceConditions": [ - { - "licenceConditionNotes": "Licence Condition notes", - "startDate": "2024-08-07", - "commencementDate": "2024-08-07", - "commencementNotes": "commencement notes", - "terminationDate": "2024-08-07", - "terminationNotes": "termination notes", - "createdDateTime": "2024-08-07T11:36:08.308673", - "active": true, - "licenceConditionTypeMainCat": { - "code": "LicMain", - "description": "lic cond main" - }, - "licenceConditionTypeSubCat": { - "code": "LicSub", - "description": "Lic Sub cat" - } - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_nsi_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_nsi_C123456.json deleted file mode 100644 index c6eb1f3cdc..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_nsi_C123456.json +++ /dev/null @@ -1,184 +0,0 @@ -{ - "nsis": [ - { - "nsiId": 0, - "nsiType": { - "code": "NSITYPE", - "description": "NSI Type desc" - }, - "nsiOutcome": { - "code": "BRE01", - "description": "this NSI is in breach" - }, - "requirement": { - "requirementId": 93, - "requirementNotes": "notes", - "commencementDate": "2024-01-01", - "startDate": "2024-01-02", - "terminationDate": "2024-01-03", - "expectedStartDate": "2024-01-04", - "expectedEndDate": "2024-01-05", - "createdDatetime": "2023-12-31T12:00:00Z", - "active": true, - "requirementTypeSubCategory": { - "code": "Sub", - "description": "Sub cat" - }, - "requirementTypeMainCategory": { - "code": "Main", - "description": "Main cat" - }, - "adRequirementTypeMainCategory": { - "code": "AdMain", - "description": "AdMain cat" - }, - "adRequirementTypeSubCategory": { - "code": "AdSub", - "description": "AdSub cat" - }, - "terminationReason": { - "code": "R1", - "description": "Released" - }, - "length": 3, - "lengthUnit": "months", - "restrictive": false, - "softDeleted": false - }, - "nsiStatus": { - "code": "SLI01", - "description": "Active" - }, - "statusDateTime": "2024-07-01T12:00:00+01:00", - "actualStartDate": "2024-07-26", - "expectedStartDate": "2024-01-01", - "actualEndDate": "2024-07-26", - "expectedEndDate": "2024-07-25", - "referralDate": "2024-07-27", - "length": 7, - "lengthUnit": "Months", - "nsiManagers": [ - { - "probationArea": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - }, - "team": { - "code": "T1", - "description": "Team1", - "telephone": "123", - "localDeliveryUnit": { - "code": "London", - "description": "LN1" - }, - "district": { - "code": "London", - "description": "LN1" - }, - "borough": { - "code": "LN1", - "description": "Default" - }, - "teamType": { - "code": "London", - "description": "LN1" - }, - "startDate": "2024-07-26" - }, - "staff": { - "username": "JoeBloggs", - "staffCode": "N01ABBA", - "staffIdentifier": 80, - "staff": { - "forenames": "Bob Micheal", - "surname": "Smith" - }, - "teams": [], - "probationArea": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - } - }, - "startDate": "2024-07-26" - }, - { - "probationArea": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - }, - "team": { - "code": "T1", - "description": "Team1", - "telephone": "123", - "localDeliveryUnit": { - "code": "London", - "description": "LN1" - }, - "district": { - "code": "London", - "description": "LN1" - }, - "borough": { - "code": "LN1", - "description": "Default" - }, - "teamType": { - "code": "London", - "description": "LN1" - }, - "startDate": "2024-07-26" - }, - "staff": { - "username": "JoeBloggs", - "staffCode": "N01ABBA", - "staffIdentifier": 80, - "staff": { - "forenames": "Bob Micheal", - "surname": "Smith" - }, - "teams": [], - "probationArea": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - } - }, - "startDate": "2024-07-19", - "endDate": "2024-07-25" - } - ], - "notes": "notes", - "intendedProvider": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - }, - "active": true, - "softDeleted": false, - "externalReference": "external ref" - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_pss_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_pss_C123456.json deleted file mode 100644 index 7d172a74f5..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_pss_C123456.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "pssRequirements": [ - { - "type": { - "code": "PssMain", - "description": "pss main" - }, - "subType": { - "code": "PssSub", - "description": "pss sub" - }, - "active": true - }, - { - "type": { - "code": "PssMain", - "description": "pss main" - }, - "subType": { - "code": "PssSub", - "description": "pss sub" - }, - "active": false - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_registrations_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_registrations_C123456.json deleted file mode 100644 index 841586e623..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_registrations_C123456.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "registrations": [ - { - "offenderId": 68, - "register": { - "code": "F1", - "description": "Registration Flag" - }, - "type": { - "code": "T1", - "description": "Register Type 1" - }, - "riskColour": "Red", - "startDate": "2024-08-07", - "nextReviewDate": "2024-08-08", - "reviewPeriodMonths": 6, - "notes": "Notes", - "registeringTeam": { - "code": "T1 ", - "description": "Team1" - }, - "registeringOfficer": { - "code": "N01ABBA", - "forenames": "Bob Micheal", - "surname": "Smith", - "unallocated": false - }, - "registeringProbationArea": { - "code": "LN1", - "description": "London" - }, - "registerLevel": { - "code": "L1", - "description": "Registration Level" - }, - "registerCategory": { - "code": "RC1", - "description": "Registration Category" - }, - "warnUser": true, - "active": true, - "endDate": "2024-08-08", - "deregisteringNotes": "Deregistration notes", - "numberOfPreviousDeregistrations": 3 - }, - { - "offenderId": 68, - "register": { - "code": "F1", - "description": "Registration Flag" - }, - "type": { - "code": "T1", - "description": "Register Type 1" - }, - "riskColour": "Red", - "startDate": "2024-08-07", - "nextReviewDate": "2024-08-08", - "reviewPeriodMonths": 6, - "notes": "Notes", - "registeringTeam": { - "code": "T1 ", - "description": "Team1" - }, - "registeringOfficer": { - "code": "N01ABBA", - "forenames": "Bob Micheal", - "surname": "Smith", - "unallocated": false - }, - "registeringProbationArea": { - "code": "LN1", - "description": "London" - }, - "registerLevel": { - "code": "L1", - "description": "Registration Level" - }, - "registerCategory": { - "code": "RC1", - "description": "Registration Category" - }, - "warnUser": true, - "active": false, - "endDate": "2024-08-08", - "deregisteringTeam": { - "code": "T1 ", - "description": "Team1" - }, - "deregisteringOfficer": { - "code": "N01ABBA", - "forenames": "Bob Micheal", - "surname": "Smith", - "unallocated": false - }, - "deregisteringProbationArea": { - "code": "LN1", - "description": "London" - }, - "deregisteringNotes": "Deregistration notes", - "numberOfPreviousDeregistrations": 2 - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_sentence_status_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_sentence_status_C123456.json deleted file mode 100644 index 71b37d37b1..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_sentence_status_C123456.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "sentenceId": 87, - "custodialType": { - "code": "C1", - "description": "Custodial status" - }, - "sentence": { - "description": "Curfew Order" - }, - "mainOffence": { - "description": "Main Offence" - }, - "sentenceDate": "2024-08-07", - "actualReleaseDate": "2024-08-05", - "lengthUnit": "Months" -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_single_nsi_C123456.json b/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_single_nsi_C123456.json deleted file mode 100644 index fe9011a036..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/__files/get_single_nsi_C123456.json +++ /dev/null @@ -1,180 +0,0 @@ -{ - "nsiId": 0, - "nsiType": { - "code": "NSITYPE", - "description": "NSI Type desc" - }, - "nsiOutcome": { - "code": "BRE01", - "description": "this NSI is in breach" - }, - "requirement": { - "requirementId": 93, - "requirementNotes": "notes", - "commencementDate": "2024-01-01", - "startDate": "2024-01-02", - "terminationDate": "2024-01-03", - "expectedStartDate": "2024-01-04", - "expectedEndDate": "2024-01-05", - "createdDatetime": "2023-12-31T12:00:00Z", - "active": true, - "requirementTypeSubCategory": { - "code": "Sub", - "description": "Sub cat" - }, - "requirementTypeMainCategory": { - "code": "Main", - "description": "Main cat" - }, - "adRequirementTypeMainCategory": { - "code": "AdMain", - "description": "AdMain cat" - }, - "adRequirementTypeSubCategory": { - "code": "AdSub", - "description": "AdSub cat" - }, - "terminationReason": { - "code": "R1", - "description": "Released" - }, - "length": 3, - "lengthUnit": "months", - "restrictive": false, - "softDeleted": false - }, - "nsiStatus": { - "code": "SLI01", - "description": "Active" - }, - "statusDateTime": "2024-07-01T12:00:00+01:00", - "actualStartDate": "2024-07-26", - "expectedStartDate": "2024-01-01", - "actualEndDate": "2024-07-26", - "expectedEndDate": "2024-07-25", - "referralDate": "2024-07-27", - "length": 7, - "lengthUnit": "Months", - "nsiManagers": [ - { - "probationArea": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - }, - "team": { - "code": "T1", - "description": "Team1", - "telephone": "123", - "localDeliveryUnit": { - "code": "London", - "description": "LN1" - }, - "district": { - "code": "London", - "description": "LN1" - }, - "borough": { - "code": "LN1", - "description": "Default" - }, - "teamType": { - "code": "London", - "description": "LN1" - }, - "startDate": "2024-07-26" - }, - "staff": { - "username": "JoeBloggs", - "staffCode": "N01ABBA", - "staffIdentifier": 80, - "staff": { - "forenames": "Bob Micheal", - "surname": "Smith" - }, - "teams": [], - "probationArea": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - } - }, - "startDate": "2024-07-26" - }, - { - "probationArea": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - }, - "team": { - "code": "T1", - "description": "Team1", - "telephone": "123", - "localDeliveryUnit": { - "code": "London", - "description": "LN1" - }, - "district": { - "code": "London", - "description": "LN1" - }, - "borough": { - "code": "LN1", - "description": "Default" - }, - "teamType": { - "code": "London", - "description": "LN1" - }, - "startDate": "2024-07-26" - }, - "staff": { - "username": "JoeBloggs", - "staffCode": "N01ABBA", - "staffIdentifier": 80, - "staff": { - "forenames": "Bob Micheal", - "surname": "Smith" - }, - "teams": [], - "probationArea": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - } - }, - "startDate": "2024-07-19", - "endDate": "2024-07-25" - } - ], - "notes": "notes", - "intendedProvider": { - "probationAreaId": 78, - "code": "N52", - "description": "West Midlands Region", - "organisation": { - "code": "ORG1", - "description": "Org 1" - } - }, - "active": true, - "softDeleted": false, - "externalReference": "external ref" -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/mappings/GET_offender.json b/projects/court-case-and-delius/src/dev/resources/simulations/mappings/GET_offender.json deleted file mode 100644 index 3f7ab1676d..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/mappings/GET_offender.json +++ /dev/null @@ -1,126 +0,0 @@ - -{ - "mappings": [ - { - "request": { - "method": "GET", - "urlPath": "/secure/offenders/crn/Y123456/all" - }, - "response": { - "status": 403, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "GET_offender_all_Y123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPath": "/secure/offenders/crn/C123456/allOffenderManagers", - "headers": { - "Content-Type": { - "equalTo": "application/json;charset=UTF-8" - } - } - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "GET_offender_all_offender_managers_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPath": "/secure/offenders/crn/C123456/all", - "headers": { - "Content-Type": { - "equalTo": "application/json;charset=UTF-8" - } - } - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "GET_offender_all_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPath": "/secure/offenders/crn/U123456/all", - "headers": { - "Content-Type": { - "equalTo": "application/json;charset=UTF-8" - } - } - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "GET_offender_all_U123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPath": "/secure/offenders/crn/C123456", - "headers": { - "Content-Type": { - "equalTo": "application/json;charset=UTF-8" - } - } - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "GET_offender_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPath": "/secure/offenders/crn/U123456", - "headers": { - "Content-Type": { - "equalTo": "application/json;charset=UTF-8" - } - } - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "GET_offender_U123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPath": "/secure/offenders/crn/CRNXXX/all", - "headers" : { - "Content-Type": { - "equalTo": "application/json;charset=UTF-8" - } - } - }, - "response": { - "status": 404, - "headers": { - "Content-Type": "application/json" - }, - "body": "{\"status\": 404, \"developerMessage\": \"Offender with CRN 'CRNXXX' not found\"}" - } - } - ] -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-convictions.json b/projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-convictions.json deleted file mode 100644 index 32bef0d0b5..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-convictions.json +++ /dev/null @@ -1,198 +0,0 @@ -{ - "mappings": [ - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}/sentenceStatus" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_sentence_status_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}/licenceConditions" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_licence_conditions_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}/courtReports" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_court_reports_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}/courtAppearances" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_court_appearances_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}/attendancesFilter" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_attendances_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}/pssRequirements" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_pss_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}/requirements" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "GET_requirements_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}/nsis" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_nsi_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}/nsis/{nsiId}" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_single_nsi_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "GET_convictions_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/convictions/{convictionId}" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "GET_conviction_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/{convictionId}/requirements" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "jsonBody":{ - "requirements": [ - { - "requirementId": 93, - "requirementNotes": "notes difference", - "commencementDate": "2024-01-01", - "startDate": "2024-01-02", - "terminationDate": "2024-01-03", - "expectedStartDate": "2024-01-04", - "expectedEndDate": "2024-01-05", - "createdDatetime": "2023-12-31T12:00:00", - "active": true, - "requirementTypeSubCategory": { - "code": "Sub", - "description": "Sub cat" - }, - "requirementTypeMainCategory": { - "code": "Main", - "description": "Main cat" - }, - "adRequirementTypeMainCategory": { - "code": "AdMain", - "description": "AdMain cat" - }, - "adRequirementTypeSubCategory": { - "code": "AdSub", - "description": "AdSub cat" - }, - "terminationReason": { - "code": "R1", - "description": "Released" - }, - "length": 3, - "lengthUnit": "months", - "restrictive": false, - "softDeleted": false - } - ] - } - } - } - ] -} diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-documents.json b/projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-documents.json deleted file mode 100644 index 80691be5d1..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-documents.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "mappings": [ - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/documents/grouped" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_documents_grouped_C123456.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/X123456/documents/grouped" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "documentsForOrderComApi.json" - } - }, - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/documents/alfrescoId" - }, - "response": { - "headers": { - "content-type": "application/msword;charset=UTF-8", - "content-length": "14812", - "content-disposition": "attachment; filename=\"doc1\"; filename*=UTF-8''doc1", - "accept-ranges": "bytes", - "content-range": "bytes 0-14811/14812", - "cache-control": "max-age=0, must-revalidate", - "etag": "1699630109776", - "last-modified": "Fri, 10 Nov 2023 15:28:29 GMT", - "Custom-Alfresco-Header": "should be ignored" - }, - "status": 200, - "bodyFileName": "document.pdf" - } - }, - { - "request": { - "method": "GET", - "urlPath": "/alfresco/fetch/alfrescoId" - }, - "response": { - "headers": { - "content-type": "application/msword;charset=UTF-8", - "content-length": "14812", - "content-disposition": "attachment; filename=\"doc1\"; filename*=UTF-8''doc1", - "accept-ranges": "bytes", - "content-range": "bytes 0-14811/14812", - "cache-control": "max-age=0, must-revalidate", - "etag": "1699630109776", - "last-modified": "Fri, 10 Nov 2023 15:28:29 GMT", - "Custom-Alfresco-Header": "should be ignored" - }, - "status": 200, - "bodyFileName": "document.pdf" - } - } - ] -} diff --git a/projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-registrations.json b/projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-registrations.json deleted file mode 100644 index d3226e7a4a..0000000000 --- a/projects/court-case-and-delius/src/dev/resources/simulations/mappings/get-registrations.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "mappings": [ - { - "request": { - "method": "GET", - "urlPathTemplate": "/secure/offenders/crn/{crn}/registrations" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json" - }, - "bodyFileName": "get_registrations_C123456.json" - } - } - ] -} diff --git a/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProxyIntegrationTest.kt b/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProxyIntegrationTest.kt deleted file mode 100644 index 9d59602255..0000000000 --- a/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProxyIntegrationTest.kt +++ /dev/null @@ -1,377 +0,0 @@ -package uk.gov.justice.digital.hmpps - -import com.fasterxml.jackson.databind.ObjectMapper -import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.equalTo -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import org.mockito.kotlin.any -import org.mockito.kotlin.doReturn -import org.mockito.kotlin.whenever -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.boot.test.mock.mockito.SpyBean -import org.springframework.test.context.TestPropertySource -import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post -import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath -import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -import org.springframework.util.ResourceUtils -import uk.gov.justice.digital.hmpps.api.proxy.CompareAllReport -import uk.gov.justice.digital.hmpps.api.proxy.CompareReport -import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.NSI_TYPE -import uk.gov.justice.digital.hmpps.data.generator.SentenceGenerator -import uk.gov.justice.digital.hmpps.flags.FeatureFlags -import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.contentAsJson -import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken - -@AutoConfigureMockMvc -@TestPropertySource(properties = ["lao-access.ignore-exclusions = false", "lao-access.ignore-restrictions = true"]) -@SpringBootTest(webEnvironment = RANDOM_PORT) -internal class ProxyIntegrationTest { - - @SpyBean - lateinit var mapper: ObjectMapper - - @Autowired - lateinit var mockMvc: MockMvc - - @MockBean - lateinit var featureFlags: FeatureFlags - - @BeforeEach - fun setup() { - whenever(featureFlags.enabled("ccd-offender-detail-enabled")).thenReturn(false) - whenever(featureFlags.enabled("ccd-offender-summary-enabled")).thenReturn(false) - whenever(featureFlags.enabled("ccd-offender-managers-enabled")).thenReturn(false) - } - - @Test - fun `proxies to community api for offenders all`() { - mockMvc - .perform(get("/secure/offenders/crn/C123456/all").withToken()) - .andExpect(status().is2xxSuccessful) - .andExpect(jsonPath("$.otherIds.crn").value("C123456")) - } - - @Test - fun `proxies to community api for offenders allOffenderManagers`() { - mockMvc - .perform(get("/secure/offenders/crn/C123456/allOffenderManagers?includeProbationAreaTeams=true").withToken()) - .andExpect(status().is2xxSuccessful) - } - - @Test - fun `proxies to community api for offenders summary`() { - mockMvc - .perform(get("/secure/offenders/crn/C123456").withToken()) - .andExpect(status().is2xxSuccessful) - .andExpect(jsonPath("$.contactDetails.addresses[0].town").value("Leicester")) - } - - @Test - fun `proxies to community api with error`() { - mockMvc - .perform(get("/secure/offenders/crn/CRNXXX/all").withToken()) - .andExpect(status().isNotFound) - .andExpect(jsonPath("$.developerMessage").value("Offender with CRN 'CRNXXX' not found")) - } - - @Test - fun `compare new endpoints with community api endpoints`() { - - val forCompare = ResourceUtils.getFile("classpath:simulations/__files/forCompare.json") - .inputStream().readBytes().toString(Charsets.UTF_8) - - doReturn(forCompare).`when`(mapper).writeValueAsString(any()) - val res = mockMvc.perform( - post("/secure/compare") - .contentType("application/json;charset=utf-8") - .content( - """ - { - "params": { - "crn": "C123456" - }, - "uri": "OFFENDER_DETAIL" - } - """ - ) - .withToken() - ).andExpect(status().is2xxSuccessful).andReturn().response.contentAsJson() - - assertThat(res.endPointName, equalTo("OFFENDER_DETAIL")) - assertThat(res.success, equalTo(false)) - } - - @Test - fun `compare new endpoints with community api endpoints ignoring array order`() { - - val forCompare = ResourceUtils.getFile("classpath:simulations/__files/documentsForOrderCcd.json") - .inputStream().readBytes().toString(Charsets.UTF_8) - - doReturn(forCompare).`when`(mapper).writeValueAsString(any()) - val res = mockMvc.perform( - post("/secure/compare") - .contentType("application/json;charset=utf-8") - .content( - """ - { - "params": { - "crn": "X123456", - "type": null, - "subtype": null - }, - "uri": "DOCUMENTS_GROUPED" - } - """ - ) - .withToken() - ).andExpect(status().is2xxSuccessful).andReturn().response.contentAsJson() - - assertThat(res.endPointName, equalTo("DOCUMENTS_GROUPED")) - assertThat(res.success, equalTo(true)) - } - - @Test - fun `compare new endpoints with community api endpoints multiple parameters`() { - - val res = mockMvc.perform( - post("/secure/compare") - .contentType("application/json;charset=utf-8") - .content( - """ - { - "params": { - "crn": "C123456", - "convictionId": ${SentenceGenerator.CURRENTLY_MANAGED.id}, - "activeOnly": true, - "excludeSoftDeleted": true - }, - "uri": "CONVICTION_REQUIREMENTS" - } - """ - ) - .withToken() - ).andExpect(status().is2xxSuccessful).andReturn().response.contentAsJson() - - assertThat(res.endPointName, equalTo("CONVICTION_REQUIREMENTS")) - assertThat(res.success, equalTo(false)) - } - - @Test - fun `compare new endpoints with community api endpoints for pss`() { - - val res = mockMvc.perform( - post("/secure/compare") - .contentType("application/json;charset=utf-8") - .content( - """ - { - "params": { - "crn": "C123456", - "convictionId": ${SentenceGenerator.CURRENTLY_MANAGED.id} - }, - "uri": "CONVICTION_BY_ID_PSS" - } - """ - ) - .withToken() - ).andExpect(status().is2xxSuccessful).andReturn().response.contentAsJson() - - assertThat(res.endPointName, equalTo("CONVICTION_BY_ID_PSS")) - assertThat(res.success, equalTo(true)) - } - - @Test - fun `compare new endpoints with community api endpoints with an array of string as a parameter`() { - - val res = mockMvc.perform( - post("/secure/compare") - .contentType("application/json;charset=utf-8") - .content( - """ - { - "params": { - "crn": "C123456", - "convictionId": ${SentenceGenerator.CURRENTLY_MANAGED.id}, - "nsiCodes": "${NSI_TYPE.code},${NSI_TYPE.code}" - }, - "uri": "CONVICTION_BY_ID_NSIS" - } - """ - ) - .withToken() - ).andExpect(status().is2xxSuccessful).andReturn().response.contentAsJson() - - assertThat(res.endPointName, equalTo("CONVICTION_BY_ID_NSIS")) - } - - @Test - fun `compare new endpoints with community api endpoints with json arrays`() { - - val res = mockMvc.perform( - post("/secure/compare") - .contentType("application/json;charset=utf-8") - .content( - """ - { - "params": {"crn": "C123456", "includeProbationAreaTeams": false }, - "uri": "OFFENDER_MANAGERS" - } - """ - ) - .withToken() - ).andExpect(status().is2xxSuccessful).andReturn().response.contentAsJson() - - assertThat(res.endPointName, equalTo("OFFENDER_MANAGERS")) - assertThat(res.success, equalTo(false)) - } - - @Test - fun `compare multiple endpoints with mutliple crns and multiple parameters`() { - val res = mockMvc.perform( - post("/secure/compareAll") - .contentType("application/json;charset=utf-8") - .content( - """ - { - "pageNumber": 1, - "pageSize": 1, - "crns": [ "C123456", "P123456"], - "uriConfig": { - "OFFENDER_DETAIL": {}, - "OFFENDER_SUMMARY": {}, - "OFFENDER_MANAGERS": { - "includeProbationAreaTeams": false - }, - "CONVICTIONS": { - "activeOnly": false - }, - "CONVICTION_BY_ID": { - "convictionId": "?" - }, - "CONVICTION_REQUIREMENTS": { - "convictionId": "?", - "activeOnly": true, - "excludeSoftDeleted": true - }, - "CONVICTION_BY_ID_ATTENDANCES": { - "convictionId": "?", - "activeOnly": true - }, - "CONVICTION_BY_ID_NSIS": { - "convictionId": "?", - "nsiCodes": "?" - }, - "CONVICTION_BY_NSIS_ID": { - "convictionId": "?", - "nsiId": "?" - }, - "CONVICTION_BY_ID_PSS": { - "convictionId": "?" - }, - "CONVICTION_BY_ID_COURT_APPEARANCES": { - "convictionId": "?", - "activeOnly": true - }, - "CONVICTION_BY_ID_COURT_REPORTS": { - "convictionId": "?", - "activeOnly": true - }, - "CONVICTION_BY_ID_LICENCE_CONDITIONS": { - "convictionId": "?", - "activeOnly": true - }, - "CONVICTION_BY_ID_SENTENCE_STATUS": { - "convictionId": "?", - "activeOnly": true - }, - "DOCUMENTS_GROUPED": { - "type": null, - "subtype": null - }, - "REGISTRATIONS": { - "activeOnly": false - } - } - } - """ - ) - .withToken() - ).andExpect(status().is2xxSuccessful).andReturn().response.contentAsJson() - - assertThat(res.totalNumberOfRequests, equalTo(16)) - assertThat(res.totalNumberOfCrns, equalTo(2)) - assertThat(res.currentPageNumber, equalTo(1)) - } - - @Test - fun `compare when test data is not available`() { - val res = mockMvc.perform( - post("/secure/compareAll") - .contentType("application/json;charset=utf-8") - .content( - """ - { - "pageNumber": 2, - "pageSize": 1, - "crns": [ "C123456", "U123456"], - "uriConfig": { - "OFFENDER_DETAIL": {}, - "OFFENDER_SUMMARY": {}, - "CONVICTION_BY_ID": { - "convictionId": "?" - }, - "CONVICTION_REQUIREMENTS": { - "convictionId": "?", - "activeOnly": true, - "excludeSoftDeleted": true - }, - "CONVICTION_BY_ID_NSIS": { - "convictionId": "?", - "nsiCodes": "?" - }, - "CONVICTION_BY_ID_PSS": { - "convictionId": "?" - } - } - } - """ - ) - .withToken() - ).andExpect(status().is2xxSuccessful).andReturn().response.contentAsJson() - - assertThat(res.totalNumberOfRequests, equalTo(2)) - assertThat(res.totalNumberOfCrns, equalTo(2)) - assertThat(res.currentPageNumber, equalTo(2)) - assertThat(res.unableToBeExecuted, equalTo(4)) - } - - @Test - fun `compare when lao case`() { - val res = mockMvc.perform( - post("/secure/compareAll") - .contentType("application/json;charset=utf-8") - .content( - """ - { - "pageNumber": 1, - "pageSize": 1, - "crns": [ "Y123456"], - "uriConfig": { - "OFFENDER_DETAIL": {} - } - } - """ - ) - .withToken() - ).andExpect(status().isOk).andReturn().response.contentAsJson() - - assertThat(res.totalNumberOfRequests, equalTo(1)) - } -} diff --git a/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProxyToNewIntegrationTest.kt b/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProxyToNewIntegrationTest.kt deleted file mode 100644 index e47f33cda4..0000000000 --- a/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProxyToNewIntegrationTest.kt +++ /dev/null @@ -1,85 +0,0 @@ -package uk.gov.justice.digital.hmpps - -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import org.mockito.kotlin.any -import org.mockito.kotlin.eq -import org.mockito.kotlin.verify -import org.mockito.kotlin.whenever -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor -import org.springframework.test.web.servlet.MockMvc -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get -import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath -import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -import uk.gov.justice.digital.hmpps.flags.FeatureFlags -import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken - -@AutoConfigureMockMvc -@SpringBootTest(webEnvironment = RANDOM_PORT) -internal class ProxyToNewIntegrationTest { - @Autowired - lateinit var mockMvc: MockMvc - - @Autowired - lateinit var taskExecutor: ThreadPoolTaskExecutor - - @MockBean - lateinit var featureFlags: FeatureFlags - - @MockBean - lateinit var telemetryService: TelemetryService - - @BeforeEach - fun setup() { - whenever(featureFlags.enabled("ccd-offender-detail-enabled")).thenReturn(true) - whenever(featureFlags.enabled("ccd-offender-summary-enabled")).thenReturn(true) - } - - @Test - fun `proxies to community api for offenders all`() { - - mockMvc - .perform(get("/secure/offenders/crn/C123456/all").withToken()) - .andExpect(status().is2xxSuccessful) - .andExpect(jsonPath("$.otherIds.crn").value("C123456")) - - whileTrue { taskExecutor.threadPoolExecutor.completedTaskCount == 0L } - verify(telemetryService).trackEvent(eq("ComparisonFailureEvent"), any(), any()) - } - - @Test - fun `proxies to community api for offenders summary`() { - mockMvc - .perform(get("/secure/offenders/crn/C123456").withToken()) - .andExpect(status().is2xxSuccessful) - .andExpect(jsonPath("$.contactDetails.emailAddresses[0]").value("test@test.none")) - } - - @Test - fun `document download proxies to community api for download document`() { - whenever(featureFlags.enabled("ccd-download-document")).thenReturn(false) - mockMvc.perform( - get("/secure/offenders/crn/C123456/documents/alfrescoId") - .withToken() - ).andExpect(status().is2xxSuccessful) - } - - @Test - fun `document download uses court case service for download document`() { - whenever(featureFlags.enabled("ccd-download-document")).thenReturn(true) - mockMvc.perform( - get("/secure/offenders/crn/C123456/documents/alfrescoId") - .withToken() - ).andExpect(status().is2xxSuccessful) - } - - private fun whileTrue(action: () -> Boolean) { - while (action.invoke()); - } -} diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiClient.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiClient.kt deleted file mode 100644 index 9e5dc5cd3c..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiClient.kt +++ /dev/null @@ -1,12 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -import org.springframework.core.io.Resource -import org.springframework.http.ResponseEntity -import org.springframework.web.bind.annotation.RequestHeader -import org.springframework.web.service.annotation.HttpExchange -import java.net.URI - -interface CommunityApiClient { - @HttpExchange(method = "GET", contentType = "application/json; charset=utf-8") - fun proxy(url: URI, @RequestHeader headers: Map): ResponseEntity -} diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiController.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiController.kt deleted file mode 100644 index 9e94a035de..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiController.kt +++ /dev/null @@ -1,480 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -import com.fasterxml.jackson.databind.ObjectMapper -import jakarta.servlet.http.HttpServletRequest -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import org.springframework.core.io.Resource -import org.springframework.data.domain.PageRequest -import org.springframework.http.HttpHeaders -import org.springframework.http.ResponseEntity -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor -import org.springframework.security.access.prepost.PreAuthorize -import org.springframework.web.bind.annotation.* -import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody -import uk.gov.justice.digital.hmpps.api.resource.ConvictionResource -import uk.gov.justice.digital.hmpps.api.resource.DocumentResource -import uk.gov.justice.digital.hmpps.api.resource.ProbationRecordResource -import uk.gov.justice.digital.hmpps.api.resource.RegistrationResource -import uk.gov.justice.digital.hmpps.flags.FeatureFlags -import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import java.util.concurrent.CompletableFuture - -@RestController -@PreAuthorize("hasRole('PROBATION_API__COURT_CASE__CASE_DETAIL')") -@RequestMapping("secure") -class CommunityApiController( - private val probationRecordResource: ProbationRecordResource, - private val featureFlags: FeatureFlags, - private val communityApiService: CommunityApiService, - private val convictionResource: ConvictionResource, - private val registrationResource: RegistrationResource, - private val documentResource: DocumentResource, - private val taskExecutor: ThreadPoolTaskExecutor, - private val personRepository: PersonEventRepository, - private val telemetryService: TelemetryService, - private val mapper: ObjectMapper -) { - companion object { - val log: Logger = LoggerFactory.getLogger(this::class.java) - } - - @GetMapping("/offenders/crn/{crn}/all") - fun offenderDetail(request: HttpServletRequest, @PathVariable crn: String): Any { - - sendComparisonReport(mapOf("crn" to crn), Uri.OFFENDER_DETAIL, request) - - if (featureFlags.enabled("ccd-offender-detail-enabled")) { - return probationRecordResource.getOffenderDetail(crn) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}") - fun offenderSummary(request: HttpServletRequest, @PathVariable crn: String): Any { - - sendComparisonReport(mapOf("crn" to crn), Uri.OFFENDER_SUMMARY, request) - - if (featureFlags.enabled("ccd-offender-summary-enabled")) { - return probationRecordResource.getOffenderDetailSummary(crn) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/allOffenderManagers") - fun offenderManagers( - request: HttpServletRequest, - @PathVariable crn: String, - @RequestParam(defaultValue = "false", required = false) includeProbationAreaTeams: Boolean - ): Any { - - sendComparisonReport( - mapOf("crn" to crn, "includeProbationAreaTeams" to includeProbationAreaTeams), - Uri.OFFENDER_MANAGERS, - request - ) - - if (featureFlags.enabled("ccd-offender-managers-enabled")) { - return probationRecordResource.getAllOffenderManagers(crn, includeProbationAreaTeams) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions") - fun convictions( - request: HttpServletRequest, - @PathVariable crn: String, - @RequestParam(defaultValue = "false", required = false) activeOnly: Boolean - ): Any { - - sendComparisonReport(mapOf("crn" to crn, "activeOnly" to activeOnly), Uri.CONVICTIONS, request) - - if (featureFlags.enabled("ccd-convictions-enabled")) { - return convictionResource.getConvictionsForOffenderByCrn(crn, activeOnly) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}") - fun convictionForOffenderByCrnAndConvictionId( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long - ): Any? { - - sendComparisonReport(mapOf("crn" to crn, "convictionId" to convictionId), Uri.CONVICTION_BY_ID, request) - - if (featureFlags.enabled("ccd-conviction-by-id-enabled")) { - return convictionResource.getConvictionForOffenderByCrnAndConvictionId(crn, convictionId) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/requirements") - fun convictionRequirements( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long, - @RequestParam(required = false, defaultValue = "true") activeOnly: Boolean, - @RequestParam(required = false, defaultValue = "true") excludeSoftDeleted: Boolean - ): Any { - - sendComparisonReport( - mapOf("crn" to crn) + - mapOf( - "convictionId" to convictionId, - "activeOnly" to activeOnly, - "excludeSoftDeleted" to excludeSoftDeleted - ), Uri.CONVICTION_REQUIREMENTS, request - ) - - if (featureFlags.enabled("ccd-conviction-requirements-enabled")) { - return convictionResource.getRequirementsForConviction(crn, convictionId, activeOnly, excludeSoftDeleted) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/nsis") - fun nsisByCrnAndConvictionId( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long, - @RequestParam(required = true) nsiCodes: List, - ): Any { - - sendComparisonReport( - mapOf( - "crn" to crn, - "convictionId" to convictionId, - "nsiCodes" to nsiCodes - ), Uri.CONVICTION_BY_ID_NSIS, request - ) - - if (featureFlags.enabled("ccd-conviction-nsis-enabled")) { - return convictionResource.getNsisByCrnAndConvictionId(crn, convictionId, nsiCodes) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/attendancesFilter") - fun convictionByIdAttendances( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long, - ): Any { - - sendComparisonReport( - mapOf( - "crn" to crn, - "convictionId" to convictionId - ), Uri.CONVICTION_BY_ID_ATTENDANCES, request - ) - - if (featureFlags.enabled("ccd-conviction-by-id-attendances")) { - return convictionResource.getConvictionAttendances(crn, convictionId) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/nsis/{nsiId}") - fun nsisByNisId( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long, - @PathVariable nsiId: Long, - ): Any { - - sendComparisonReport( - mapOf( - "crn" to crn, - "convictionId" to convictionId, - "nsiId" to nsiId - ), Uri.CONVICTION_BY_NSIS_ID, request - ) - - if (featureFlags.enabled("ccd-conviction-nsis-by-id-enabled")) { - return convictionResource.getNsiByNsiId(crn, convictionId, nsiId) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/pssRequirements") - fun pssByCrnAndConvictionId( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long, - ): Any { - - sendComparisonReport( - mapOf( - "crn" to crn, - "convictionId" to convictionId - ), Uri.CONVICTION_BY_ID_PSS, request - ) - - if (featureFlags.enabled("ccd-conviction-pss-enabled")) { - return convictionResource.getPssRequirementsByConvictionId(crn, convictionId) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/courtAppearances") - fun convictionByIdCourtAppearances( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long, - ): Any { - - sendComparisonReport( - mapOf( - "crn" to crn, - "convictionId" to convictionId - ), Uri.CONVICTION_BY_ID_COURT_APPEARANCES, request - ) - - if (featureFlags.enabled("ccd-conviction-by-id-court-appearances")) { - return convictionResource.getConvictionCourtAppearances(crn, convictionId) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/courtReports") - fun convictionByIdCourtReports( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long, - ): Any { - - sendComparisonReport( - mapOf( - "crn" to crn, - "convictionId" to convictionId - ), Uri.CONVICTION_BY_ID_COURT_REPORTS, request - ) - - if (featureFlags.enabled("ccd-conviction-by-id-court-reports")) { - return convictionResource.getConvictionCourtReports(crn, convictionId) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/licenceConditions") - fun convictionByIdLicenceConditions( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long, - ): Any { - - sendComparisonReport( - mapOf( - "crn" to crn, - "convictionId" to convictionId - ), Uri.CONVICTION_BY_ID_LICENCE_CONDITIONS, request - ) - - if (featureFlags.enabled("ccd-conviction-by-id-licence-conditions")) { - return convictionResource.getConvictionLicenceConditions(crn, convictionId) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/sentenceStatus") - fun convictionByIdSentenceStatus( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable convictionId: Long, - ): Any { - - sendComparisonReport( - mapOf( - "crn" to crn, - "convictionId" to convictionId - ), Uri.CONVICTION_BY_ID_SENTENCE_STATUS, request - ) - - if (featureFlags.enabled("ccd-conviction-by-id-sentence-status")) { - return convictionResource.getConvictionSentenceStatus(crn, convictionId) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/documents/grouped") - fun documentsGrouped( - request: HttpServletRequest, - @PathVariable crn: String, - @RequestParam(required = false) type: String?, - @RequestParam(required = false) subtype: String? - ): Any { - - val params = mutableMapOf() - type?.let { params["type"] = it } - subtype?.let { params["subtype"] = it } - sendComparisonReport( - params, Uri.DOCUMENTS_GROUPED, request - ) - - if (featureFlags.enabled("ccd-document-grouped")) { - return documentResource.getOffenderDocumentsGrouped(crn, type, subtype) - } - return proxy(request) - } - - @GetMapping("/offenders/crn/{crn}/documents/{documentId}") - fun downloadDocument( - request: HttpServletRequest, - @PathVariable crn: String, - @PathVariable documentId: String - ): ResponseEntity { - - if (featureFlags.enabled("ccd-download-document")) { - return documentResource.getOffenderDocumentById(crn, documentId) - } - - val proxied = proxy(request) - val streamingResponseBody = - StreamingResponseBody { output -> proxied.body!!.inputStream.use { it.copyTo(output) } } - return ResponseEntity - .status(proxied.statusCode) - .headers(proxied.headers) - .body(streamingResponseBody) - } - - @GetMapping("/offenders/crn/{crn}/registrations") - fun registrations( - request: HttpServletRequest, - @PathVariable crn: String, - @RequestParam(defaultValue = "false", required = false) activeOnly: Boolean - ): Any { - sendComparisonReport(mapOf("crn" to crn, "activeOnly" to activeOnly), Uri.REGISTRATIONS, request) - - if (featureFlags.enabled("ccd-registrations-enabled")) { - return registrationResource.getOffenderRegistrations(crn, activeOnly) - } - return proxy(request) - } - - fun proxy(request: HttpServletRequest): ResponseEntity { - val headers = request.headerNames.asSequence().associateWith { request.getHeader(it) }.toMutableMap() - val fullUri = - if (request.queryString != null) request.requestURI + '?' + request.queryString else request.requestURI - return communityApiService.proxy(fullUri, headers) - } - - @PostMapping("/compare") - fun compare(@RequestBody compare: Compare, request: HttpServletRequest): CompareReport { - val headers = mapOf(HttpHeaders.AUTHORIZATION to request.getHeader(HttpHeaders.AUTHORIZATION)) - return communityApiService.compare(compare, headers, showValues = true) - } - - @PostMapping("/compareAll") - fun compareAll(@RequestBody compare: CompareAll, request: HttpServletRequest): CompareAllReport { - val headers = mapOf(HttpHeaders.AUTHORIZATION to request.getHeader(HttpHeaders.AUTHORIZATION)) - val pageable = PageRequest.of(compare.pageNumber - 1, compare.pageSize) - val personList = - if (compare.crns.isNullOrEmpty()) personRepository.findAllCrns(pageable) else personRepository.findByCrnIn( - compare.crns, - pageable - ) - - val reports = personList.content.flatMap { person -> - val convictionId = person.events.filter { it.disposal != null }.maxOfOrNull { it.id } - val nsiCodes = person.nsis.filter { it.eventId == convictionId }.map { it.type.code.trim() } - val nsiId = person.nsis.firstOrNull()?.id - val futures = runAll(person.crn, convictionId, nsiCodes, nsiId, compare, headers).toTypedArray() - CompletableFuture.allOf(*futures).join() - futures.map { it.join() }.toList() - } - - val executed = reports.filter { it.testExecuted == true } - val successful = reports.filter { it.success && it.testExecuted == true } - val unsuccessful = reports.filter { !it.success } - val executionFailures = reports.filter { it.testExecuted == false } - val distinctEndpointsExecuted = executed.groupBy(CompareReport::endPointName) - val covered = distinctEndpointsExecuted.map { it.key + " covered " + it.value.size + " times" } - val requestedButNotCovered = compare.uriConfig.entries.map { it.key }.toSet() - .filter { e -> !distinctEndpointsExecuted.map { it.key }.toSet().contains(e) } - - return CompareAllReport( - totalNumberOfCrns = personList.totalElements.toInt(), - totalPages = personList.totalPages, - currentPageNumber = compare.pageNumber, - totalNumberOfRequests = reports.size - executionFailures.size, - numberOfSuccessfulRequests = successful.size, - numberOfUnsuccessfulRequests = unsuccessful.size, - unableToBeExecuted = executionFailures.size, - failureReports = unsuccessful, - endpointsCovered = covered, - endpointsRequestedButNotCovered = requestedButNotCovered - ) - } - - fun setParams(map: Map, convictionId: Long?, nsiCodes: List, nsiId: Long?): Map { - val new = map.toMutableMap() - if (map.containsKey("nsiId") && nsiId != null) { - new["nsiId"] = nsiId - } - if (map.containsKey("convictionId") && convictionId != null) { - new["convictionId"] = convictionId - } - if (map.containsKey("nsiCodes")) { - new["nsiCodes"] = nsiCodes.joinToString(",") - } - return new - } - - fun runAll( - crn: String, - convictionId: Long?, - nsiCodes: List, - nsiId: Long?, - compare: CompareAll, - headers: Map - ): List> { - return compare.uriConfig.entries.map { - val params = setParams(it.value, convictionId, nsiCodes, nsiId) - CompletableFuture.supplyAsync( - { - communityApiService.compare( - Compare(params = mapOf("crn" to crn) + params, uri = it.key), - headers, - showValues = true - ) - }, taskExecutor - ) - } - } - - fun sendComparisonReport(params: Map, uri: Uri, request: HttpServletRequest) { - CompletableFuture.supplyAsync({ - val headers = mapOf(HttpHeaders.AUTHORIZATION to request.getHeader(HttpHeaders.AUTHORIZATION)) - val compare = Compare(params = params, uri = uri.name) - val report = communityApiService.compare(compare, headers) - telemetryService.comparisonFailureEvent( - params["crn"].toString(), - compare, - report - ) - }, taskExecutor) - } - - fun TelemetryService.comparisonFailureEvent( - crn: String, - compare: Compare, - compareReport: CompareReport - ) { - if (!compareReport.success) { - val comparePayload = mapper.writeValueAsString(compare) - trackEvent( - "ComparisonFailureEvent", - mapOf( - "crn" to crn, - "endpointName" to compareReport.endPointName, - "url" to compareReport.url!!, - "compareUrl" to "/secure/compare", - "comparePayload" to comparePayload - ) - ) - } - } -} - diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiService.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiService.kt deleted file mode 100644 index 2feb57ac99..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CommunityApiService.kt +++ /dev/null @@ -1,140 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -import com.fasterxml.jackson.databind.ObjectMapper -import org.skyscreamer.jsonassert.JSONAssert -import org.skyscreamer.jsonassert.JSONCompareMode -import org.springframework.beans.factory.annotation.Value -import org.springframework.context.ApplicationContext -import org.springframework.core.io.ByteArrayResource -import org.springframework.core.io.Resource -import org.springframework.http.ResponseEntity -import org.springframework.security.access.AccessDeniedException -import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Propagation -import org.springframework.transaction.annotation.Transactional -import org.springframework.web.client.HttpStatusCodeException -import uk.gov.justice.digital.hmpps.api.resource.advice.CommunityApiControllerAdvice -import uk.gov.justice.digital.hmpps.exception.InvalidRequestException -import uk.gov.justice.digital.hmpps.exception.NotFoundException -import java.lang.reflect.InvocationTargetException -import java.net.URI -import kotlin.reflect.KParameter - -@Service -class CommunityApiService( - @Value("\${community-api.url}") private val communityApiUrl: String, - private val mapper: ObjectMapper, - private val communityApiClient: CommunityApiClient, - private val applicationContext: ApplicationContext, - private val controllerAdvice: CommunityApiControllerAdvice -) { - - fun getCcdJson(compare: Compare): String { - val uri = Uri.valueOf(compare.uri) - val instance = applicationContext.getBean(uri.ccdInstance) - val function = instance::class.members.firstOrNull { it.name == uri.ccdFunction } - val functionParams = function?.parameters?.drop(1)?.associateBy({ it }, { - generateValue(it, compare.params, uri.urlParams) - })!! - val paramsFunc = function.parameters - val params = mapOf(paramsFunc[0] to instance) + functionParams - - val response = try { - function.callBy(params) - } catch (ex: InvocationTargetException) { - when (val cause = ex.cause) { - is AccessDeniedException -> controllerAdvice.handleAccessDenied(cause).body - is NotFoundException -> controllerAdvice.handleNotFound(cause).body - is InvalidRequestException -> controllerAdvice.handleInvalidRequest(cause).body - else -> throw ComparisonException(ex.cause?.message) - } - } - return mapper.writeValueAsString(response) - } - - fun generateValue(param: KParameter, originalValue: Map<*, *>, paramNames: List): Any? { - var value = originalValue.values.toList()[param.index - 1] - if (value == "?" || value == "") { - val name = paramNames[param.index - 1] - throw DataNotAvailableException(name) - } - if (param.type.classifier == List::class) { - value = value.toString().split(",") - } - return value - } - - @Transactional(propagation = Propagation.REQUIRES_NEW) - fun compare(compare: Compare, headers: Map, showValues: Boolean = false): CompareReport { - - val uri = Uri.valueOf(compare.uri) - val comApiUri = compare.params.entries.fold(uri.comApiUrl) { path, (key, value) -> - if (value != null) { - path.replace( - "{$key}", - value.toString() - ) - } else { - path.replace("$key={$key}", "") - } - }.replace(" ", "%20") - - val ccdJsonString = try { - getCcdJson(compare) - } catch (ex: Exception) { - when (ex) { - is DataNotAvailableException, is ComparisonException -> { - return CompareReport( - endPointName = uri.name, - url = comApiUri, - message = ex.message!! + " for ${compare.params["crn"]}", - success = false - ) - } - - else -> throw ex - } - } - - val comApiJsonString = proxy(comApiUri, headers.toMutableMap()).body!! - - try { - JSONAssert.assertEquals( - ccdJsonString, - String(comApiJsonString.contentAsByteArray), - JSONCompareMode.NON_EXTENSIBLE - ) - return CompareReport( - endPointName = uri.name, - url = comApiUri, - message = "Json is equal", - success = true, - testExecuted = true - ) - } catch (ex: AssertionError) { - // Differences found other than the order - return CompareReport( - endPointName = uri.name, - url = comApiUri, - message = ex.message!!, - success = false, - testExecuted = true - ) - } - } - - fun proxy(requestUri: String, headers: MutableMap): ResponseEntity { - - return try { - val resp = communityApiClient.proxy(URI.create(communityApiUrl + requestUri), headers) - CommunityApiController.log.info("returned status ${resp.statusCode} from community-api") - return resp - } catch (ex: HttpStatusCodeException) { - CommunityApiController.log.error("Exception thrown when calling ${communityApiUrl + requestUri}. community-api returned ${ex.message}") - ResponseEntity.status(ex.statusCode) - .headers(ex.responseHeaders) - .body(ByteArrayResource(ex.responseBodyAsByteArray)) - } - } -} - diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/Compare.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/Compare.kt deleted file mode 100644 index a8f69e9198..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/Compare.kt +++ /dev/null @@ -1,6 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -data class Compare( - val params: Map, - val uri: String -) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareAll.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareAll.kt deleted file mode 100644 index 6b8505d819..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareAll.kt +++ /dev/null @@ -1,8 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -data class CompareAll( - val crns: List?, - val uriConfig: Map>, - val pageNumber: Int = 1, - val pageSize: Int = 10 -) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareAllReport.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareAllReport.kt deleted file mode 100644 index 7d354224ea..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareAllReport.kt +++ /dev/null @@ -1,14 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -data class CompareAllReport( - val totalNumberOfCrns: Int, - val totalPages: Int, - val currentPageNumber: Int, - val totalNumberOfRequests: Int, - val numberOfSuccessfulRequests: Int, - val numberOfUnsuccessfulRequests: Int, - val unableToBeExecuted: Int, - val failureReports: List, - val endpointsCovered: List = emptyList(), - val endpointsRequestedButNotCovered: List = emptyList(), -) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareReport.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareReport.kt deleted file mode 100644 index 3c15faaca0..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/CompareReport.kt +++ /dev/null @@ -1,9 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -data class CompareReport( - val endPointName: String, - val message: String, - val url: String? = null, - val testExecuted: Boolean? = false, - val success: Boolean -) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/DataNotAvailableException.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/DataNotAvailableException.kt deleted file mode 100644 index d867b1bc8a..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/DataNotAvailableException.kt +++ /dev/null @@ -1,7 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -class DataNotAvailableException(param: String) : - RuntimeException("No Data available for param $param") - -class ComparisonException(message: String?) : - RuntimeException("Calling new api failed with $message") \ No newline at end of file diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/PersonEvent.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/PersonEvent.kt deleted file mode 100644 index 3c53d07889..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/PersonEvent.kt +++ /dev/null @@ -1,44 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -import jakarta.persistence.* -import org.hibernate.annotations.Immutable -import org.hibernate.annotations.SQLRestriction -import org.springframework.data.domain.Page -import org.springframework.data.domain.Pageable -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.data.jpa.repository.Query -import uk.gov.justice.digital.hmpps.integrations.delius.event.conviction.entity.Event -import uk.gov.justice.digital.hmpps.integrations.delius.event.nsi.Nsi - -@Immutable -@Entity -@Table(name = "offender") -@SQLRestriction("soft_deleted = 0") -class PersonEvent( - @Id - @Column(name = "offender_id") - val id: Long, - - @Column(columnDefinition = "char(7)") - val crn: String, - - @OneToMany(mappedBy = "offenderId") - val events: List, - - @OneToMany(mappedBy = "personId") - val nsis: List, - - @Column(updatable = false, columnDefinition = "number") - val softDeleted: Boolean = false, -) - -interface PersonEventRepository : JpaRepository { - - @Query( - """ - select pe from PersonEvent pe - """ - ) - fun findAllCrns(pageable: Pageable): Page - fun findByCrnIn(crns: List, pageable: Pageable): Page -} diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/README.md b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/README.md deleted file mode 100644 index bc18ebf993..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Community API Proxy - -The Community API controller has the same endpoints as community API. -This performs a JSON comparison between the new versions of the API and the commumity API endpoints and sends to App INsights. - -## Comparison Endpoint -The Community API controller has a paged POST secure/compareAll endpoint. -This takes a bearer token that must contain both the ROLE_COMMUNITY and ROLE_PROBATION_API__COURT_CASE__CASE_DETAIL roles. - -This takes the following payload, where all endpoints can be specified. -The crns section is optional. If no crns are specified, then all crns (controlled by the page size and page number) are retrieved from the database. -The params marked with "?" will be automatically populated from the database. - - { - "pageNumber": 1, - "pageSize": 1, - "crns": [ "C123456", "P123456"], - "uriConfig": { - "OFFENDER_DETAIL": {}, - "OFFENDER_SUMMARY": {}, - "OFFENDER_MANAGERS": { - "includeProbationAreaTeams": false - }, - "CONVICTIONS": { - "activeOnly": false - }, - "CONVICTION_BY_ID": { - "convictionId": "?" - }, - "CONVICTION_REQUIREMENTS": { - "convictionId": "?", - "activeOnly": true, - "excludeSoftDeleted": true - }, - "CONVICTION_BY_ID_NSIS": { - "convictionId": "?", - "nsiCodes": "?" - }, - "CONVICTION_BY_ID_PSS": { - "convictionId": "?" - } - } - } \ No newline at end of file diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/Uri.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/Uri.kt deleted file mode 100644 index 8201fc941a..0000000000 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/proxy/Uri.kt +++ /dev/null @@ -1,101 +0,0 @@ -package uk.gov.justice.digital.hmpps.api.proxy - -enum class Uri( - val comApiUrl: String, - val ccdInstance: String, - val ccdFunction: String, - val urlParams: List -) { - OFFENDER_DETAIL("/secure/offenders/crn/{crn}/all", "probationRecordResource", "getOffenderDetail", listOf("crn")), - OFFENDER_SUMMARY( - "/secure/offenders/crn/{crn}", - "probationRecordResource", - "getOffenderDetailSummary", - listOf("crn") - ), - OFFENDER_MANAGERS( - "/secure/offenders/crn/{crn}/allOffenderManagers?includeProbationAreaTeams={includeProbationAreaTeams}", - "probationRecordResource", - "getAllOffenderManagers", - listOf("crn", "includeProbationAreaTeams") - ), - CONVICTIONS( - "/secure/offenders/crn/{crn}/convictions?activeOnly={activeOnly}", - "convictionResource", - "getConvictionsForOffenderByCrn", - listOf("crn", "activeOnly") - ), - CONVICTION_BY_ID( - "/secure/offenders/crn/{crn}/convictions/{convictionId}", - "convictionResource", - "getConvictionForOffenderByCrnAndConvictionId", - listOf("crn", "convictionId") - ), - CONVICTION_REQUIREMENTS( - "/secure/offenders/crn/{crn}/convictions/{convictionId}/requirements?activeOnly={activeOnly}&excludeSoftDeleted={excludeSoftDeleted}", - "convictionResource", - "getRequirementsForConviction", - listOf("crn", "convictionId", "activeOnly", "excludeSoftDeleted"), - ), - CONVICTION_BY_ID_NSIS( - "/secure/offenders/crn/{crn}/convictions/{convictionId}/nsis?nsiCodes={nsiCodes}", - "convictionResource", - "getNsisByCrnAndConvictionId", - listOf("crn", "convictionId", "nsiCodes"), - ), - CONVICTION_BY_ID_ATTENDANCES( - "/secure/offenders/crn/{crn}/convictions/{convictionId}/attendancesFilter", - "convictionResource", - "getConvictionAttendances", - listOf("crn", "convictionId"), - ), - CONVICTION_BY_NSIS_ID( - "/secure/offenders/crn/{crn}/convictions/{convictionId}/nsis/{nsiId}", - "convictionResource", - "getNsiByNsiId", - listOf("crn", "convictionId", "nsiId"), - ), - CONVICTION_BY_ID_PSS( - "/secure/offenders/crn/{crn}/convictions/{convictionId}/pssRequirements", - "convictionResource", - "getPssRequirementsByConvictionId", - listOf("crn", "convictionId"), - ), - CONVICTION_BY_ID_COURT_APPEARANCES( - "/secure/offenders/crn/{crn}/convictions/{convictionId}/courtAppearances", - "convictionResource", - "getConvictionCourtAppearances", - listOf("crn", "convictionId"), - ), - CONVICTION_BY_ID_COURT_REPORTS( - "/secure/offenders/crn/{crn}/convictions/{convictionId}/courtReports", - "convictionResource", - "getConvictionCourtReports", - listOf("crn", "convictionId"), - ), - CONVICTION_BY_ID_LICENCE_CONDITIONS( - "/secure/offenders/crn/{crn}/convictions/{convictionId}/licenceConditions", - "convictionResource", - "getConvictionLicenceConditions", - listOf("crn", "convictionId"), - ), - CONVICTION_BY_ID_SENTENCE_STATUS( - "/secure/offenders/crn/{crn}/convictions/{convictionId}/sentenceStatus", - "convictionResource", - "getConvictionSentenceStatus", - listOf("crn", "convictionId"), - ), - DOCUMENTS_GROUPED( - "/secure/offenders/crn/{crn}/documents/grouped?type={type}&subtype={subtype}", - "documentResource", - "getOffenderDocumentsGrouped", - listOf("crn", "type", "subtype"), - ), - REGISTRATIONS( - "/secure/offenders/crn/{crn}/registrations?activeOnly={activeOnly}", - "registrationResource", - "getOffenderRegistrations", - listOf("crn", "activeOnly"), - ), - DUMMY("/dummy", "dummyResource", "getDummy", listOf("crn")), -} \ No newline at end of file diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/resource/CommunityApiController.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/resource/CommunityApiController.kt new file mode 100644 index 0000000000..e11662d004 --- /dev/null +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/resource/CommunityApiController.kt @@ -0,0 +1,134 @@ +package uk.gov.justice.digital.hmpps.api.resource + +import jakarta.servlet.http.HttpServletRequest +import org.springframework.security.access.prepost.PreAuthorize +import org.springframework.web.bind.annotation.* + +@RestController +@PreAuthorize("hasRole('PROBATION_API__COURT_CASE__CASE_DETAIL')") +@RequestMapping("secure") +class CommunityApiController( + private val probationRecordResource: ProbationRecordResource, + private val convictionResource: ConvictionResource, + private val registrationResource: RegistrationResource, + private val documentResource: DocumentResource +) { + @GetMapping("/offenders/crn/{crn}/all") + fun offenderDetail(request: HttpServletRequest, @PathVariable crn: String) = + probationRecordResource.getOffenderDetail(crn) + + @GetMapping("/offenders/crn/{crn}") + fun offenderSummary(request: HttpServletRequest, @PathVariable crn: String) = + probationRecordResource.getOffenderDetailSummary(crn) + + @GetMapping("/offenders/crn/{crn}/allOffenderManagers") + fun offenderManagers( + request: HttpServletRequest, + @PathVariable crn: String, + @RequestParam(defaultValue = "false", required = false) includeProbationAreaTeams: Boolean + ) = probationRecordResource.getAllOffenderManagers(crn, includeProbationAreaTeams) + + @GetMapping("/offenders/crn/{crn}/convictions") + fun convictions( + request: HttpServletRequest, + @PathVariable crn: String, + @RequestParam(defaultValue = "false", required = false) activeOnly: Boolean + ) = convictionResource.getConvictionsForOffenderByCrn(crn, activeOnly) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}") + fun convictionForOffenderByCrnAndConvictionId( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long + ) = convictionResource.getConvictionForOffenderByCrnAndConvictionId(crn, convictionId) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/requirements") + fun convictionRequirements( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long, + @RequestParam(required = false, defaultValue = "true") activeOnly: Boolean, + @RequestParam(required = false, defaultValue = "true") excludeSoftDeleted: Boolean + ) = convictionResource.getRequirementsForConviction(crn, convictionId, activeOnly, excludeSoftDeleted) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/nsis") + fun nsisByCrnAndConvictionId( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long, + @RequestParam(required = true) nsiCodes: List, + ) = convictionResource.getNsisByCrnAndConvictionId(crn, convictionId, nsiCodes) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/attendancesFilter") + fun convictionByIdAttendances( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long, + ) = convictionResource.getConvictionAttendances(crn, convictionId) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/nsis/{nsiId}") + fun nsisByNisId( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long, + @PathVariable nsiId: Long, + ) = convictionResource.getNsiByNsiId(crn, convictionId, nsiId) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/pssRequirements") + fun pssByCrnAndConvictionId( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long, + ) = convictionResource.getPssRequirementsByConvictionId(crn, convictionId) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/courtAppearances") + fun convictionByIdCourtAppearances( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long, + ) = convictionResource.getConvictionCourtAppearances(crn, convictionId) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/courtReports") + fun convictionByIdCourtReports( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long, + ) = convictionResource.getConvictionCourtReports(crn, convictionId) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/licenceConditions") + fun convictionByIdLicenceConditions( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long, + ) = convictionResource.getConvictionLicenceConditions(crn, convictionId) + + @GetMapping("/offenders/crn/{crn}/convictions/{convictionId}/sentenceStatus") + fun convictionByIdSentenceStatus( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable convictionId: Long, + ) = convictionResource.getConvictionSentenceStatus(crn, convictionId) + + @GetMapping("/offenders/crn/{crn}/documents/grouped") + fun documentsGrouped( + request: HttpServletRequest, + @PathVariable crn: String, + @RequestParam(required = false) type: String?, + @RequestParam(required = false) subtype: String? + ) = documentResource.getOffenderDocumentsGrouped(crn, type, subtype) + + @GetMapping("/offenders/crn/{crn}/documents/{documentId}") + fun downloadDocument( + request: HttpServletRequest, + @PathVariable crn: String, + @PathVariable documentId: String + ) = documentResource.getOffenderDocumentById(crn, documentId) + + @GetMapping("/offenders/crn/{crn}/registrations") + fun registrations( + request: HttpServletRequest, + @PathVariable crn: String, + @RequestParam(defaultValue = "false", required = false) activeOnly: Boolean + ) = registrationResource.getOffenderRegistrations(crn, activeOnly) +} + diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/RestClientConfig.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/RestClientConfig.kt index b058522872..847c4fad27 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/RestClientConfig.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/RestClientConfig.kt @@ -3,7 +3,6 @@ package uk.gov.justice.digital.hmpps.config import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.web.client.RestClient -import uk.gov.justice.digital.hmpps.api.proxy.CommunityApiClient import uk.gov.justice.digital.hmpps.config.security.createClient import uk.gov.justice.digital.hmpps.integrations.courtcase.CourtCaseClient @@ -15,7 +14,4 @@ class RestClientConfig(private val oauth2Client: RestClient, private val restCli @Bean fun proxyClient() = restClientBuilder.build() - - @Bean - fun communityApiClient() = createClient(proxyClient()) } From d9bfdb0f1bdb95cd8b13cde98cd913fb53181f9c Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Mon, 21 Oct 2024 13:15:29 +0100 Subject: [PATCH 2/2] PI-2585 Remove unused feature flags (#4325) --- .../justice/digital/hmpps/IntegrationTest.kt | 23 ++------- .../digital/hmpps/messaging/Handler.kt | 4 +- .../hmpps/service/AssessmentService.kt | 8 +-- .../hmpps/service/LicenceConditionApplier.kt | 50 +++++-------------- .../service/LicenceConditionApplierTest.kt | 47 +---------------- .../hmpps/ReferAndMonitorIntegrationTest.kt | 15 ++---- .../digital/hmpps/service/NsiService.kt | 6 +-- .../digital/hmpps/service/NsiServiceTest.kt | 4 -- .../service/RepositoryExtensionMethodTests.kt | 4 -- .../hmpps/data/AllocationsDataLoader.kt | 1 - .../data/generator/ContactTypeGenerator.kt | 1 - .../hmpps/AllocateEventIntegrationTest.kt | 47 ++++------------- .../delius/contact/ContactContext.kt | 1 - .../hmpps/service/AllocateEventService.kt | 30 +---------- .../hmpps/service/AllocateEventServiceTest.kt | 4 -- 15 files changed, 38 insertions(+), 207 deletions(-) diff --git a/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index e2c6275a4f..796d2d5b9f 100644 --- a/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -7,7 +7,10 @@ import org.hamcrest.core.IsEqual.equalTo import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyMap -import org.mockito.kotlin.* +import org.mockito.kotlin.check +import org.mockito.kotlin.eq +import org.mockito.kotlin.timeout +import org.mockito.kotlin.verify import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.context.SpringBootTest @@ -18,7 +21,6 @@ import uk.gov.justice.digital.hmpps.data.entity.IapsPersonRepository import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator import uk.gov.justice.digital.hmpps.data.generator.RegistrationGenerator -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity.OasysAssessmentRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactType @@ -64,28 +66,11 @@ internal class IntegrationTest { @MockBean lateinit var telemetryService: TelemetryService - @MockBean - lateinit var featureFlags: FeatureFlags - lateinit var transactionTemplate: TransactionTemplate @BeforeEach fun setUp() { transactionTemplate = TransactionTemplate(transactionManager) - whenever(featureFlags.enabled(any())).thenReturn(true) - } - - @Test - fun `contact date is set to current date when flag is off`() { - whenever(featureFlags.enabled("assessment-summary-contact-date")).thenReturn(false) - val message = notification("assessment-summary-produced-${PersonGenerator.NO_RISK.crn}") - channelManager.getChannel(queueName).publishAndWait(prepNotification(message, wireMockServer.port())) - - val person = personRepository.getByCrn(PersonGenerator.NO_RISK.crn) - - val contact = contactRepository.findAll() - .single { it.person.id == person.id && it.type.code == ContactType.Code.OASYS_ASSESSMENT.value } - assertThat(contact.date, equalTo(LocalDate.now())) } @Test diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 6296bd801e..d919ac8d1c 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -7,7 +7,6 @@ import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.oasys.OrdsClient import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification @@ -24,13 +23,12 @@ class Handler( override val converter: NotificationConverter, private val ordsClient: OrdsClient, private val assessmentSubmitted: AssessmentSubmitted, - private val featureFlags: FeatureFlags, private val telemetryService: TelemetryService ) : NotificationHandler { @Publish(messages = [Message(title = AssessmentSummaryProduced, payload = Schema(HmppsDomainEvent::class))]) override fun handle(notification: Notification) { try { - if (notification.message.eventType == AssessmentSummaryProduced && featureFlags.enabled("assessment-summary-produced")) { + if (notification.message.eventType == AssessmentSummaryProduced) { telemetryService.notificationReceived(notification) notification.message.detailUrl ?.let { ordsClient.getAssessmentSummary(URI.create(it)) } diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AssessmentService.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AssessmentService.kt index 63548ded9d..427ba375ef 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AssessmentService.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AssessmentService.kt @@ -2,7 +2,6 @@ package uk.gov.justice.digital.hmpps.service import org.springframework.stereotype.Service import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity.OasysAssessment import uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity.OasysAssessmentRepository import uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity.SentencePlan @@ -26,7 +25,6 @@ class AssessmentService( private val oasysAssessmentRepository: OasysAssessmentRepository, private val eventRepository: EventRepository, private val contactService: ContactService, - private val featureFlags: FeatureFlags, ) { fun recordAssessment(person: Person, summary: AssessmentSummary) { val previousAssessment = oasysAssessmentRepository.findByOasysId(summary.assessmentPk.toString()) @@ -36,14 +34,12 @@ class AssessmentService( ?: throw IgnorableMessageException("No single active custodial event") val event = eventRepository.getByNumber(person.id, eventNumber) val manager = checkNotNull(person.manager) { "Community Manager Not Found" } - val contactDate = - if (featureFlags.enabled("assessment-summary-contact-date")) summary.dateCompleted else LocalDate.now() val contact = previousAssessment?.contact?.withDateTeamAndStaff( - contactDate, + summary.dateCompleted, manager.teamId, manager.staffId ) ?: contactService.createContact( - summary.contactDetail(contactDate), + summary.contactDetail(summary.dateCompleted), person, event ) diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplier.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplier.kt index 516a52c0c8..8148f08274 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplier.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplier.kt @@ -3,7 +3,6 @@ package uk.gov.justice.digital.hmpps.service import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import uk.gov.justice.digital.hmpps.audit.service.OptimisationTables -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.cvl.ActivatedLicence import uk.gov.justice.digital.hmpps.integrations.cvl.AdditionalLicenceCondition import uk.gov.justice.digital.hmpps.integrations.cvl.telemetryProperties @@ -38,7 +37,6 @@ class LicenceConditionApplier( private val licenceConditionService: LicenceConditionService, private val contactService: ContactService, private val optimisationTables: OptimisationTables, - private val featureFlags: FeatureFlags ) { @Transactional fun applyLicenceConditions( @@ -58,41 +56,19 @@ class LicenceConditionApplier( ) optimisationTables.rebuild(com.person.id) - return when (featureFlags.enabled("cvl-multiple-sentences")) { - true -> - when (sentences.size) { - 0 -> listOf(ActionResult.Ignored("No Custodial Sentences", properties)) - else -> sentences.maxBy { it.disposal.expectedEndDate() } - .let { - applyLicenceConditions( - SentencedCase( - com, - it.disposal, - licenceConditionService.findByDisposalId(it.disposal.id) - ), - activatedLicence, - occurredAt - ) - } - } - - false -> when (sentences.size) { - 0 -> listOf(ActionResult.Ignored("No Custodial Sentences", properties)) - 1 -> sentences.flatMap { - applyLicenceConditions( - SentencedCase(com, it.disposal, licenceConditionService.findByDisposalId(it.disposal.id)), - activatedLicence, - occurredAt - ) - } - - else -> listOf( - ActionResult.Ignored( - "Multiple Custodial Sentences", - properties - ) - ) - } + return if (sentences.isEmpty()) { + listOf(ActionResult.Ignored("No Custodial Sentences", properties)) + } else { + val latestSentence = sentences.maxBy { it.disposal.expectedEndDate() } + applyLicenceConditions( + SentencedCase( + com, + latestSentence.disposal, + licenceConditionService.findByDisposalId(latestSentence.disposal.id) + ), + activatedLicence, + occurredAt + ) } } diff --git a/projects/create-and-vary-a-licence-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplierTest.kt b/projects/create-and-vary-a-licence-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplierTest.kt index c8a1f3e528..801d44da6f 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplierTest.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/LicenceConditionApplierTest.kt @@ -16,7 +16,6 @@ import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.LC_STANDARD_CATEGORY import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.LC_STANDARD_SUB_CATEGORY import uk.gov.justice.digital.hmpps.data.generator.SentenceGenerator -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.cvl.ActivatedLicence import uk.gov.justice.digital.hmpps.integrations.cvl.ApConditions import uk.gov.justice.digital.hmpps.integrations.cvl.Conditions @@ -54,9 +53,6 @@ internal class LicenceConditionApplierTest { @Mock internal lateinit var optimisationTables: OptimisationTables - @Mock - internal lateinit var featureFlags: FeatureFlags - @InjectMocks internal lateinit var licenceConditionApplier: LicenceConditionApplier @@ -136,49 +132,9 @@ internal class LicenceConditionApplierTest { ) } - @Test - fun `when multiple active custodial sentence it is logged to telemetry feature flag set to false`() { - val crn = "M728831" - val person = PersonGenerator.generatePerson(crn) - val activatedLicence = ActivatedLicence( - crn, - LocalDate.now(), - Conditions(ApConditions(listOf(), listOf(), listOf())) - ) - val occurredAt = ZonedDateTime.now() - whenever(personManagerRepository.findByPersonCrn(crn)).thenReturn(PersonGenerator.DEFAULT_CM) - whenever(custodyRepository.findCustodialSentences(crn)).thenReturn( - listOf( - SentenceGenerator.generate(SentenceGenerator.generateEvent("1", person), endDate = LocalDate.now()), - SentenceGenerator.generate(SentenceGenerator.generateEvent("2", person), endDate = LocalDate.now()) - ) - ) - - whenever(featureFlags.enabled("cvl-multiple-sentences")).thenReturn(false) - - val ex = licenceConditionApplier.applyLicenceConditions( - crn, - activatedLicence, - occurredAt - ) - assertThat( - ex.first(), equalTo( - ActionResult.Ignored( - "Multiple Custodial Sentences", - mapOf( - "crn" to crn, - "startDate" to activatedLicence.startDate.toString(), - "occurredAt" to occurredAt.toString(), - "sentenceCount" to "2" - ) - ) - ) - ) - } - @ParameterizedTest @ValueSource(strings = ["endDate", "enteredEndDate"]) - fun `when multiple active custodial sentence create CVL where end date is populated feature flag set to true`(field: String) { + fun `when multiple active custodial sentence create CVL where end date is populated`(field: String) { val crn = "M728831" val person = PersonGenerator.generatePerson(crn) val activatedLicence = ActivatedLicence( @@ -188,7 +144,6 @@ internal class LicenceConditionApplierTest { ) val occurredAt = ZonedDateTime.now() whenever(personManagerRepository.findByPersonCrn(crn)).thenReturn(PersonGenerator.DEFAULT_CM) - whenever(featureFlags.enabled("cvl-multiple-sentences")).thenReturn(true) var sentence2: Custody? = null var sentence4: Custody? = null diff --git a/projects/refer-and-monitor-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferAndMonitorIntegrationTest.kt b/projects/refer-and-monitor-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferAndMonitorIntegrationTest.kt index cac0f96210..3399dedb6b 100644 --- a/projects/refer-and-monitor-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferAndMonitorIntegrationTest.kt +++ b/projects/refer-and-monitor-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferAndMonitorIntegrationTest.kt @@ -4,10 +4,12 @@ import com.github.tomakehurst.wiremock.WireMockServer import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.containsString import org.hamcrest.Matchers.equalTo -import org.junit.jupiter.api.* import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.MethodOrderer +import org.junit.jupiter.api.Order +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.TestMethodOrder import org.mockito.kotlin.verify -import org.mockito.kotlin.whenever import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.context.SpringBootTest @@ -16,7 +18,6 @@ import uk.gov.justice.digital.hmpps.data.generator.ContactGenerator import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.datetime.EuropeLondon -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.EnforcementRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.Contact @@ -64,14 +65,6 @@ internal class ReferAndMonitorIntegrationTest { @Autowired lateinit var eventRepository: EventRepository - @MockBean - lateinit var featureFlags: FeatureFlags - - @BeforeEach - fun setup() { - whenever(featureFlags.enabled("referral-withdrawal-reason")).thenReturn(true) - } - @Test @Order(1) fun `session appointment feedback submitted failed to comply`() { diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt index c2e8222517..f3c6a19f14 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt @@ -6,7 +6,6 @@ import uk.gov.justice.digital.hmpps.api.model.ReferralStarted import uk.gov.justice.digital.hmpps.audit.service.AuditableService import uk.gov.justice.digital.hmpps.audit.service.AuditedInteractionService import uk.gov.justice.digital.hmpps.exception.ReferralNotFoundException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.audit.BusinessInteractionCode.MANAGE_NSI import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactOutcomeRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository @@ -40,7 +39,6 @@ class NsiService( private val contactTypeRepository: ContactTypeRepository, private val contactOutcomeRepository: ContactOutcomeRepository, private val createNsi: CreateNsi, - private val featureFlags: FeatureFlags, ) : AuditableService(auditedInteractionService) { @Transactional @@ -77,9 +75,7 @@ class NsiService( fun terminateNsi(termination: NsiTermination) = audit(MANAGE_NSI) { audit -> val nsi = findNsi(termination) val status = nsiStatusRepository.getByCode(END.value) - val outcomeCode = termination.withdrawalOutcome?.name - ?.takeIf { featureFlags.enabled("referral-withdrawal-reason") } - ?: termination.endType.outcome + val outcomeCode = termination.withdrawalOutcome?.name ?: termination.endType.outcome val outcome = nsiOutcomeRepository.nsiOutcome(outcomeCode) audit["offenderId"] = nsi.person.id diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/NsiServiceTest.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/NsiServiceTest.kt index a55cae257b..d6b332ecee 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/NsiServiceTest.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/NsiServiceTest.kt @@ -13,7 +13,6 @@ import uk.gov.justice.digital.hmpps.api.model.ReferralStarted import uk.gov.justice.digital.hmpps.audit.service.AuditedInteractionService import uk.gov.justice.digital.hmpps.data.generator.ContactGenerator import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactOutcomeRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactTypeRepository @@ -59,9 +58,6 @@ internal class NsiServiceTest { @Mock lateinit var telemetryService: TelemetryService - @Mock - lateinit var featureFlags: FeatureFlags - @InjectMocks lateinit var nsiService: NsiService diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/RepositoryExtensionMethodTests.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/RepositoryExtensionMethodTests.kt index bdb1aa4ab3..8c009316e5 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/RepositoryExtensionMethodTests.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/RepositoryExtensionMethodTests.kt @@ -15,7 +15,6 @@ import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.exception.NotFoundException import uk.gov.justice.digital.hmpps.exception.ReferralNotFoundException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactOutcomeRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactTypeRepository @@ -62,9 +61,6 @@ internal class RepositoryExtensionMethodTests { @Mock lateinit var telemetryService: TelemetryService - @Mock - lateinit var featureFlags: FeatureFlags - @InjectMocks lateinit var nsiService: NsiService diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/AllocationsDataLoader.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/AllocationsDataLoader.kt index 411219c74e..96b28156c0 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/AllocationsDataLoader.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/AllocationsDataLoader.kt @@ -112,7 +112,6 @@ class AllocationsDataLoader( ContactTypeGenerator.INITIAL_APPOINTMENT_ON_DOORSTEP, ContactTypeGenerator.INITIAL_APPOINTMENT_HOME_VISIT, ContactTypeGenerator.INITIAL_APPOINTMENT_BY_VIDEO, - ContactTypeGenerator.CASE_ALLOCATION_DECISION_EVIDENCE, ContactTypeGenerator.CASE_ALLOCATION_SPO_OVERSIGHT ) ) diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactTypeGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactTypeGenerator.kt index 4d30bc2326..5cbfc45238 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactTypeGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactTypeGenerator.kt @@ -12,7 +12,6 @@ object ContactTypeGenerator { val INITIAL_APPOINTMENT_ON_DOORSTEP = generate(ContactTypeCode.INITIAL_APPOINTMENT_ON_DOORSTEP.value) val INITIAL_APPOINTMENT_HOME_VISIT = generate(ContactTypeCode.INITIAL_APPOINTMENT_HOME_VISIT.value) val INITIAL_APPOINTMENT_BY_VIDEO = generate(ContactTypeCode.INITIAL_APPOINTMENT_BY_VIDEO.value) - val CASE_ALLOCATION_DECISION_EVIDENCE = generate(ContactTypeCode.CASE_ALLOCATION_DECISION_EVIDENCE.value) val CASE_ALLOCATION_SPO_OVERSIGHT = generate(ContactTypeCode.CASE_ALLOCATION_SPO_OVERSIGHT.value) fun generate( diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateEventIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateEventIntegrationTest.kt index faa5e96f0c..7f368f367e 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateEventIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateEventIntegrationTest.kt @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test import org.mockito.kotlin.any import org.mockito.kotlin.eq import org.mockito.kotlin.verify -import org.mockito.kotlin.whenever import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.context.SpringBootTest @@ -17,7 +16,6 @@ import org.springframework.data.repository.findByIdOrNull import uk.gov.justice.digital.hmpps.data.generator.EventGenerator import uk.gov.justice.digital.hmpps.data.generator.OrderManagerGenerator import uk.gov.justice.digital.hmpps.data.generator.StaffGenerator -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactTypeCode import uk.gov.justice.digital.hmpps.integrations.delius.event.Event @@ -47,9 +45,6 @@ class AllocateEventIntegrationTest { @MockBean private lateinit var telemetryService: TelemetryService - @MockBean - private lateinit var featureFlags: FeatureFlags - @Autowired private lateinit var contactRepository: ContactRepository @@ -65,7 +60,6 @@ class AllocateEventIntegrationTest { event, 1, StaffGenerator.SPO_STAFF.id, - false ) verify(telemetryService).trackEvent( @@ -103,7 +97,6 @@ class AllocateEventIntegrationTest { event, 2, StaffGenerator.STAFF_WITH_USER.id, - false ) val insertedPm = orderManagerRepository.findActiveManagerAtDate(event.id, ZonedDateTime.now().minusDays(2)) @@ -122,10 +115,7 @@ class AllocateEventIntegrationTest { } @Test - fun `spo contact is created when feature flag is enabled`() { - - whenever(featureFlags.enabled("produce-spod03-contact")).thenReturn(true) - + fun `spo contact is created`() { val event = EventGenerator.DEFAULT val firstOm = orderManagerRepository.save( @@ -141,7 +131,6 @@ class AllocateEventIntegrationTest { event, 1, StaffGenerator.STAFF_WITH_USER.id, - true ) verify(telemetryService).trackEvent( @@ -162,8 +151,7 @@ class AllocateEventIntegrationTest { existingOm: OrderManager, event: Event, originalOmCount: Int, - staffId: Long, - spoEnabled: Boolean + staffId: Long ) { val allocationEvent = prepMessage(messageName, wireMockServer.port()) channelManager.getChannel(queueName).publishAndWait(allocationEvent) @@ -176,28 +164,15 @@ class AllocateEventIntegrationTest { val updatedOmCount = orderManagerRepository.findAll().count { it.eventId == event.id } assertThat(updatedOmCount, equalTo(originalOmCount + 1)) - if (spoEnabled) { - val spoContact = contactRepository.findAll() - .firstOrNull { it.eventId == oldOm.eventId && it.type.code == ContactTypeCode.CASE_ALLOCATION_SPO_OVERSIGHT.value } + val spoContact = contactRepository.findAll() + .firstOrNull { it.eventId == oldOm.eventId && it.type.code == ContactTypeCode.CASE_ALLOCATION_SPO_OVERSIGHT.value } - assertNotNull(spoContact) - assertThat(spoContact!!.staffId, equalTo(staffId)) - assertThat( - spoContact.isSensitive, - equalTo((allocationDetail as AllocationDetail.EventAllocation).sensitiveOversightNotes) - ) - assertThat(spoContact.notes, equalTo(allocationDetail.spoOversightNotes)) - } else { - val cadeContact = contactRepository.findAll() - .firstOrNull { it.eventId == oldOm.eventId && it.type.code == ContactTypeCode.CASE_ALLOCATION_DECISION_EVIDENCE.value } - - assertNotNull(cadeContact) - assertThat(cadeContact!!.staffId, equalTo(staffId)) - assertThat( - cadeContact.isSensitive, - equalTo((allocationDetail as AllocationDetail.EventAllocation).sensitive) - ) - assertThat(cadeContact.notes, equalTo(allocationDetail.notes)) - } + assertNotNull(spoContact) + assertThat(spoContact!!.staffId, equalTo(staffId)) + assertThat( + spoContact.isSensitive, + equalTo((allocationDetail as AllocationDetail.EventAllocation).sensitiveOversightNotes ?: true) + ) + assertThat(spoContact.notes, equalTo(allocationDetail.spoOversightNotes)) } } diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/ContactContext.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/ContactContext.kt index 777925ada6..c1bc01260f 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/ContactContext.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/ContactContext.kt @@ -16,6 +16,5 @@ enum class ContactTypeCode(val value: String) { INITIAL_APPOINTMENT_ON_DOORSTEP("CODI"), INITIAL_APPOINTMENT_HOME_VISIT("COHV"), INITIAL_APPOINTMENT_BY_VIDEO("COVI"), - CASE_ALLOCATION_DECISION_EVIDENCE("CADE"), CASE_ALLOCATION_SPO_OVERSIGHT("SPOD03") } diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventService.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventService.kt index ae14877b76..4aca8a7bd4 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventService.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventService.kt @@ -7,7 +7,6 @@ import uk.gov.justice.digital.hmpps.audit.service.OptimisationTables import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException import uk.gov.justice.digital.hmpps.exception.NotActiveException import uk.gov.justice.digital.hmpps.exception.NotFoundException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.allocations.AllocationValidator import uk.gov.justice.digital.hmpps.integrations.delius.allocations.ManagerService import uk.gov.justice.digital.hmpps.integrations.delius.audit.BusinessInteractionCode @@ -29,7 +28,6 @@ class AllocateEventService( private val transferReasonRepository: TransferReasonRepository, private val optimisationTables: OptimisationTables, private val staffRepository: StaffRepository, - private val featureFlags: FeatureFlags ) : ManagerService(auditedInteractionService, orderManagerRepository) { @Transactional @@ -90,39 +88,13 @@ class AllocateEventService( ) ) - if (featureFlags.enabled("produce-spod03-contact")) { - createSPOContact(allocationDetail, event, newOrderManager, spoStaff) - } else { - createCadeContact(allocationDetail, event, newOrderManager, spoStaff) - } + createSPOContact(allocationDetail, event, newOrderManager, spoStaff) if (event.hasAccreditedProgrammeRequirement()) { eventRepository.updateIaps(event.id) } } - fun createCadeContact( - allocationDetail: EventAllocation, - event: Event, - orderManager: OrderManager, - spoStaff: Staff? - ) { - contactRepository.save( - Contact( - type = contactTypeRepository.findByCodeOrThrow(ContactTypeCode.CASE_ALLOCATION_DECISION_EVIDENCE.value), - personId = event.person.id, - eventId = event.id, - date = orderManager.startDate.toLocalDate(), - startTime = orderManager.startDate, - teamId = orderManager.team.id, - staffId = spoStaff?.id ?: orderManager.staff.id, - providerId = orderManager.provider.id, - notes = allocationDetail.notes, - isSensitive = allocationDetail.sensitive ?: false - ) - ) - } - fun createSPOContact( allocationDetail: EventAllocation, event: Event, diff --git a/projects/workforce-allocations-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventServiceTest.kt b/projects/workforce-allocations-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventServiceTest.kt index 53ab26430b..c7413b0747 100644 --- a/projects/workforce-allocations-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventServiceTest.kt +++ b/projects/workforce-allocations-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/AllocateEventServiceTest.kt @@ -22,7 +22,6 @@ import uk.gov.justice.digital.hmpps.data.generator.TransferReasonGenerator import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException import uk.gov.justice.digital.hmpps.exception.NotActiveException import uk.gov.justice.digital.hmpps.exception.NotFoundException -import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.allocations.AllocationValidator import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactTypeRepository @@ -64,9 +63,6 @@ internal class AllocateEventServiceTest { @Mock private lateinit var staffRepository: StaffRepository - @Mock - private lateinit var featureFlags: FeatureFlags - @InjectMocks private lateinit var allocateEventService: AllocateEventService