From 866ef5a355fbed1ff5bd2d85309a146645ec9b00 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 16:29:17 +0000 Subject: [PATCH 01/42] Bump the minor group with 5 updates Bumps the minor group with 5 updates: | Package | From | To | | --- | --- | --- | | [org.springframework.boot](https://github.com/spring-projects/spring-boot) | `3.3.5` | `3.4.0` | | software.amazon.awssdk:aws-query-protocol | `2.29.15` | `2.29.20` | | software.amazon.awssdk:sts | `2.29.15` | `2.29.20` | | [com.microsoft.graph:microsoft-graph](https://github.com/microsoftgraph/msgraph-sdk-java) | `6.20.0` | `6.21.0` | | [org.springdoc:springdoc-openapi-starter-webmvc-ui](https://github.com/springdoc/springdoc-openapi) | `2.6.0` | `2.7.0` | Updates `org.springframework.boot` from 3.3.5 to 3.4.0 - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v3.3.5...v3.4.0) Updates `software.amazon.awssdk:aws-query-protocol` from 2.29.15 to 2.29.20 Updates `software.amazon.awssdk:sts` from 2.29.15 to 2.29.20 Updates `com.microsoft.graph:microsoft-graph` from 6.20.0 to 6.21.0 - [Release notes](https://github.com/microsoftgraph/msgraph-sdk-java/releases) - [Changelog](https://github.com/microsoftgraph/msgraph-sdk-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/microsoftgraph/msgraph-sdk-java/compare/v6.20.0...v6.21.0) Updates `org.springdoc:springdoc-openapi-starter-webmvc-ui` from 2.6.0 to 2.7.0 - [Release notes](https://github.com/springdoc/springdoc-openapi/releases) - [Changelog](https://github.com/springdoc/springdoc-openapi/blob/main/CHANGELOG.md) - [Commits](https://github.com/springdoc/springdoc-openapi/compare/v2.6.0...v2.7.0) --- updated-dependencies: - dependency-name: org.springframework.boot dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor - dependency-name: software.amazon.awssdk:aws-query-protocol dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor - dependency-name: software.amazon.awssdk:sts dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor - dependency-name: com.microsoft.graph:microsoft-graph dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor - dependency-name: org.springdoc:springdoc-openapi-starter-webmvc-ui dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor ... Signed-off-by: dependabot[bot] --- build.gradle.kts | 2 +- settings.gradle.kts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d5682eed7b..cc97ce7780 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ plugins { kotlin("jvm") version "2.0.21" kotlin("plugin.spring") version "2.0.21" apply false kotlin("plugin.jpa") version "2.0.21" apply false - id("org.springframework.boot") version "3.3.5" apply false + id("org.springframework.boot") version "3.4.0" apply false id("io.spring.dependency-management") version "1.1.6" apply false id("com.gorylenko.gradle-git-properties") version "2.4.2" apply false id("com.google.cloud.tools.jib") apply false diff --git a/settings.gradle.kts b/settings.gradle.kts index c73ea07547..3b9f479bf5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -74,16 +74,16 @@ dependencyResolutionManagement { create("libs") { library("asyncapi", "org.openfolder:kotlin-asyncapi-spring-web:3.0.3") library("aws-autoconfigure", "io.awspring.cloud:spring-cloud-aws-autoconfigure:3.2.1") - library("aws-query-protocol", "software.amazon.awssdk:aws-query-protocol:2.29.15") + library("aws-query-protocol", "software.amazon.awssdk:aws-query-protocol:2.29.20") library("aws-sns", "io.awspring.cloud:spring-cloud-aws-starter-sns:3.2.1") library("aws-sqs", "io.awspring.cloud:spring-cloud-aws-starter-sqs:3.2.1") library("aws-starter", "io.awspring.cloud:spring-cloud-aws-starter:3.2.1") - library("aws-sts", "software.amazon.awssdk:sts:2.29.15") + library("aws-sts", "software.amazon.awssdk:sts:2.29.20") library("azure-app-insights", "com.microsoft.azure:applicationinsights-web:3.6.2") library("azure-identity", "com.azure:azure-identity:1.14.2") library("flipt", "io.flipt:flipt-java:1.1.1") library("html2md", "com.vladsch.flexmark:flexmark-html2md-converter:0.64.8") - library("microsoft-graph", "com.microsoft.graph:microsoft-graph:6.20.0") + library("microsoft-graph", "com.microsoft.graph:microsoft-graph:6.21.0") library("mockito-inline", "org.mockito:mockito-inline:5.2.0") library("mockito-kotlin", "org.mockito.kotlin:mockito-kotlin:5.4.0") library("notify", "uk.gov.service.notify:notifications-java-client:5.2.1-RELEASE") @@ -92,7 +92,7 @@ dependencyResolutionManagement { "io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations:2.10.0" ) library("sentry", "io.sentry:sentry-spring-boot-starter-jakarta:7.18.0") - library("springdoc", "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0") + library("springdoc", "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0") library("wiremock", "org.wiremock:wiremock-standalone:3.9.2") bundle( From ef929646e710797f9098f304f4ec6e0c5d4d2990 Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Thu, 28 Nov 2024 10:38:15 +0000 Subject: [PATCH 02/42] Upgrade to Spring Boot 3.4 --- .../accredited_programmes_and_oasys.run.xml | 33 +++-------- .../appointment_reminders_and_delius.run.xml | 33 +++-------- .../approved_premises_and_delius.run.xml | 33 +++-------- .../approved_premises_and_oasys.run.xml | 33 +++-------- .../runConfigurations/arns_and_delius.run.xml | 33 +++-------- ...ssess-for-early-release-and-delius.run.xml | 33 +++-------- .../assessment_summary_and_delius.run.xml | 33 +++-------- .../runConfigurations/cas2_and_delius.run.xml | 33 +++-------- .../runConfigurations/cas3_and_delius.run.xml | 33 +++-------- .../common_platform_and_delius.run.xml | 33 +++-------- .../core_person_record_and_delius.run.xml | 33 +++-------- .../court_case_and_delius.run.xml | 33 +++-------- ...eate_and_vary_a_licence_and_delius.run.xml | 33 +++-------- .../custody_key_dates_and_delius.run.xml | 33 +++-------- .../domain_events_and_delius.run.xml | 33 +++-------- .../runConfigurations/dps_and_delius.run.xml | 33 +++-------- ...tive_proposal_framework_and_delius.run.xml | 33 +++-------- .../external_api_and_delius.run.xml | 33 +++-------- .../hdc_licences_and_delius.run.xml | 33 +++-------- .../hmpps_auth_and_delius.run.xml | 33 +++-------- .../runConfigurations/ims_and_delius.run.xml | 33 +++-------- .../justice_email_and_delius.run.xml | 33 +++-------- .../make_recall_decisions_and_delius.run.xml | 33 +++-------- .../manage_offences_and_delius.run.xml | 33 +++-------- .../manage_pom_cases_and_delius.run.xml | 33 +++-------- .../manage_supervision_and_delius.run.xml | 33 +++-------- .../manage_supervision_and_oasys.run.xml | 33 +++-------- .../oasys_and_delius.run.xml | 33 +++-------- .../offender_events_and_delius.run.xml | 33 +++-------- .../runConfigurations/opd_and_delius.run.xml | 33 +++-------- .../pathfinder_and_delius.run.xml | 33 +++-------- .../pre_sentence_reports_to_delius.run.xml | 33 +++-------- .../prison_case_notes_to_probation.run.xml | 33 +++-------- .../prison_custody_status_to_delius.run.xml | 33 +++-------- .../prison_education_and_delius.run.xml | 33 +++-------- .../prison_identifier_and_delius.run.xml | 33 +++-------- .../prisoner_profile_and_delius.run.xml | 33 +++-------- .../probation_search_and_delius.run.xml | 33 +++-------- .../refer_and_monitor_and_delius.run.xml | 33 +++-------- .../resettlement_passport_and_delius.run.xml | 33 +++-------- .../risk_assessment_scores_to_delius.run.xml | 33 +++-------- .../sentence_plan_and_delius.run.xml | 33 +++-------- .../sentence_plan_and_oasys.run.xml | 33 +++-------- .../runConfigurations/soc_and_delius.run.xml | 33 +++-------- ...subject_access_requests_and_delius.run.xml | 33 +++-------- .../runConfigurations/tier_to_delius.run.xml | 33 +++-------- .../unpaid_work_and_delius.run.xml | 33 +++-------- .../workforce_allocations_to_delius.run.xml | 33 +++-------- .../digital/hmpps/config/BuildInfoConfig.kt | 3 + .../digital/hmpps/test/MockMvcExtensions.kt | 5 +- .../hmpps/wiremock/WireMockInitialiser.kt | 4 +- .../main/resources/META-INF/spring.factories | 1 + .../hmpps/wiremock/WireMockInitialiserTest.kt | 56 ------------------- .../digital/hmpps/alfresco/AlfrescoClient.kt | 2 +- .../StreamingHeadersSecurityConfigurer.kt | 2 +- .../digital/hmpps/entity/PrisonStaff.kt | 2 + .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../src/main/resources/application.yml | 3 +- .../justice/digital/hmpps/IntegrationTest.kt | 8 +-- .../src/main/resources/application.yml | 3 - .../hmpps/data/generator/AddressGenerator.kt | 4 +- .../hmpps/MessagingIntegrationInactiveTest.kt | 4 +- .../digital/hmpps/MessagingIntegrationTest.kt | 4 +- .../delius/approvedpremises/entity/Address.kt | 3 + .../referral/entity/Referral.kt | 4 ++ .../referral/entity/Residence.kt | 13 +---- .../integrations/delius/contact/Contact.kt | 15 +---- .../delius/contact/alert/ContactAlert.kt | 11 +--- .../delius/document/entity/DocumentEntity.kt | 2 + .../nonstatutoryintervention/entity/Nsi.kt | 4 ++ .../entity/NsiManager.kt | 15 ++--- .../integrations/delius/person/Person.kt | 7 +-- .../delius/person/ProbationCase.kt | 6 ++ .../delius/person/address/PersonAddress.kt | 31 +++++----- .../person/manager/probation/PersonManager.kt | 10 ++-- .../delius/person/offence/entity/Offence.kt | 3 + .../registration/entity/Registration.kt | 10 ++-- .../digital/hmpps/service/AddressService.kt | 1 - .../hmpps/service/ApprovedPremisesService.kt | 6 +- .../src/main/resources/application.yml | 3 - .../service/ApprovedPremisesServiceTest.kt | 3 +- .../src/main/resources/application.yml | 2 - .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/entity/Person.kt | 7 +-- .../digital/hmpps/entity/PersonManager.kt | 3 + .../src/main/resources/application.yml | 3 - .../digital/hmpps/data/entity/IapsPerson.kt | 7 +-- .../justice/digital/hmpps/IntegrationTest.kt | 6 +- .../assessment/entity/OasysAssessment.kt | 3 + .../delius/assessment/entity/SentencePlan.kt | 5 ++ .../delius/contact/entity/Contact.kt | 2 + .../delius/person/entity/Disposal.kt | 3 + .../delius/person/entity/Event.kt | 8 +-- .../delius/person/entity/Person.kt | 4 ++ .../delius/person/entity/Registration.kt | 5 ++ .../delius/person/entity/Requirement.kt | 3 + .../src/main/resources/application.yml | 4 +- .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../digital/hmpps/NotFoundIntegrationTest.kt | 4 +- .../justice/digital/hmpps/entity/Contact.kt | 3 + .../justice/digital/hmpps/entity/Person.kt | 7 +-- .../digital/hmpps/entity/PersonManager.kt | 8 +-- .../src/main/resources/application.yml | 3 - .../digital/hmpps/CASIntegrationTest.kt | 4 +- .../integrations/delius/entity/Contact.kt | 17 ++---- .../integrations/delius/entity/Person.kt | 2 + .../delius/entity/PersonAddress.kt | 14 +---- .../delius/entity/PersonManager.kt | 8 +-- .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/IntegrationTest.kt | 14 ++--- .../integrations/delius/entity/Person.kt | 5 ++ .../delius/entity/PersonAddress.kt | 7 ++- .../delius/entity/PersonManager.kt | 3 + .../src/main/resources/application.yml | 3 - .../integration/delius/entity/Disposal.kt | 4 ++ .../hmpps/integration/delius/entity/Person.kt | 2 + .../src/main/resources/application.yml | 2 - .../hmpps/CourtCaseNotesIntegrationTest.kt | 8 +-- .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../delius/contact/entity/Attendance.kt | 3 + .../delius/contact/entity/CaseNote.kt | 17 ++---- .../integrations/delius/entity/Document.kt | 7 +-- .../delius/entity/Registration.kt | 4 ++ .../event/conviction/entity/Requirement.kt | 3 + .../courtappearance/entity/CourtAppearance.kt | 5 ++ .../integrations/delius/event/entity/Event.kt | 6 ++ .../delius/event/entity/LicenceCondition.kt | 3 + .../delius/event/entity/MainOffence.kt | 3 + .../delius/event/entity/Requirement.kt | 3 + .../integrations/delius/event/nsi/Nsi.kt | 5 ++ .../delius/event/sentence/entity/Disposal.kt | 9 +++ .../event/sentence/entity/Institution.kt | 4 +- .../delius/person/entity/Disability.kt | 2 + .../delius/person/entity/Person.kt | 7 +++ .../delius/person/entity/PersonManager.kt | 4 ++ .../delius/person/entity/PrisonManager.kt | 3 + .../delius/person/entity/Provision.kt | 2 + .../delius/provider/entity/ProbationArea.kt | 3 + .../delius/provider/entity/Staff.kt | 2 + .../src/main/resources/application.yml | 3 - .../hmpps/LicenceActivatedIntegrationTest.kt | 4 +- .../delius/contact.entity/Contact.kt | 2 + .../delius/manager/entity/PersonManager.kt | 3 + .../delius/person/entity/Person.kt | 7 +-- .../sentence/entity/LicenceCondition.kt | 6 ++ .../delius/sentence/entity/Sentence.kt | 7 +++ .../src/main/resources/application.yml | 4 +- .../justice/digital/hmpps/IntegrationTest.kt | 16 ++---- .../digital/hmpps/KeyDateControllerTest.kt | 4 +- .../integrations/delius/custody/BaseEntity.kt | 5 +- .../delius/custody/date/Sentence.kt | 15 +++-- .../delius/custody/date/contact/Contact.kt | 17 ++---- .../integrations/delius/person/Person.kt | 7 +-- .../src/main/resources/application.yml | 3 - .../hmpps/PublishingIntegrationTest.kt | 4 +- .../delius/person/entity/Person.kt | 7 +-- .../src/main/resources/application.yml | 4 +- .../digital/hmpps/entity/CourtAppearance.kt | 8 +-- .../justice/digital/hmpps/entity/Document.kt | 7 +-- .../gov/justice/digital/hmpps/entity/Event.kt | 16 ++---- .../justice/digital/hmpps/entity/Offence.kt | 10 +--- .../justice/digital/hmpps/entity/Person.kt | 8 +-- .../src/main/resources/application.yml | 3 - .../hmpps/epf/entity/CourtAppearance.kt | 4 +- .../justice/digital/hmpps/epf/entity/Event.kt | 7 +++ .../hmpps/epf/entity/OgrsAssessment.kt | 7 +-- .../digital/hmpps/epf/entity/Person.kt | 4 ++ .../digital/hmpps/epf/entity/PrisonManager.kt | 10 ++-- .../hmpps/epf/entity/ResponsibleOfficer.kt | 3 + .../src/main/resources/application.yml | 3 - .../delius/entity/CourtAppearance.kt | 8 +-- .../hmpps/integration/delius/entity/Event.kt | 14 ++--- .../integration/delius/entity/Offence.kt | 12 ++-- .../hmpps/integration/delius/entity/Person.kt | 3 + .../delius/entity/RegistrationEntity.kt | 3 + .../src/main/resources/application.yml | 3 - .../hmpps/entity/CommunityManagerEntity.kt | 10 ++-- .../justice/digital/hmpps/entity/Person.kt | 8 +-- .../digital/hmpps/entity/PrisonManager.kt | 10 ++-- .../src/main/resources/application.yml | 3 - .../src/main/resources/application.yml | 3 - .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../justice/digital/hmpps/entity/Contact.kt | 2 + .../digital/hmpps/entity/PersonManager.kt | 3 + .../src/main/resources/application.yml | 2 - .../hmpps/RecommendationIntegrationTest.kt | 4 +- .../delius/casesummary/Address.kt | 10 +--- .../delius/casesummary/Contact.kt | 14 ++--- .../integrations/delius/casesummary/Event.kt | 22 ++++---- .../integrations/delius/casesummary/Person.kt | 9 +-- .../delius/casesummary/PersonManager.kt | 10 ++-- .../delius/casesummary/Registration.kt | 10 ++-- .../delius/casesummary/Release.kt | 3 + .../delius/document/entity/Document.kt | 3 + .../recommendation/contact/entity/Contact.kt | 2 + .../recommendation/person/entity/Person.kt | 8 ++- .../delius/user/access/entity/Person.kt | 10 +--- .../src/main/resources/application.yml | 3 - .../hmpps/data/generator/DataGenerator.kt | 7 +-- .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../digital/hmpps/entity/DetailedOffence.kt | 34 ++++------- .../digital/hmpps/entity/ReferenceOffence.kt | 2 +- .../src/main/resources/application.yml | 3 - .../hmpps/service/OffenceServiceTest.kt | 5 +- .../AllocationMessagingIntegrationTest.kt | 10 ++-- .../hmpps/HandoverMessagingIntegrationTest.kt | 4 +- .../delius/allocation/entity/event/Event.kt | 2 + .../entity/event/keydate/KeyDate.kt | 13 +---- .../delius/contact/entity/Contact.kt | 15 +---- .../delius/person/entity/Person.kt | 4 ++ .../registration/entity/Registration.kt | 3 + .../delius/provider/entity/PrisonManager.kt | 18 ++---- .../delius/provider/entity/Staff.kt | 4 +- .../src/main/resources/application.yml | 3 - .../integrations/delius/compliance/Nsi.kt | 3 + .../delius/overview/entity/Contact.kt | 5 +- .../delius/overview/entity/Disability.kt | 2 + .../delius/overview/entity/Event.kt | 8 +++ .../delius/overview/entity/Person.kt | 2 + .../overview/entity/PersonalCircumstance.kt | 2 + .../delius/overview/entity/Provision.kt | 2 + .../delius/overview/entity/Registration.kt | 3 + .../delius/overview/entity/Requirement.kt | 7 ++- .../delius/personalDetails/entity/Address.kt | 5 +- .../entity/PersonalContactEntity.kt | 2 + .../integrations/delius/risk/Registration.kt | 5 ++ .../sentence/entity/AdditionalSentence.kt | 2 + .../delius/sentence/entity/Appointment.kt | 4 +- .../delius/sentence/entity/CourtAppearance.kt | 4 +- .../delius/sentence/entity/Custody.kt | 3 + .../sentence/entity/LicenceCondition.kt | 3 + .../delius/sentence/entity/OffenderManager.kt | 3 + .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/IntegrationTest.kt | 6 +- .../src/main/resources/application.yml | 3 +- .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../delius/person/entity/Person.kt | 3 + .../delius/person/entity/PersonAddress.kt | 2 + .../delius/provider/entity/Institution.kt | 2 + .../registration/entity/Registration.kt | 4 ++ .../delius/sentence.entity/Sentence.kt | 8 +++ .../src/main/resources/application.yml | 4 +- .../justice/digital/hmpps/IntegrationTest.kt | 8 +-- .../src/main/resources/application.yml | 2 - .../digital/hmpps/OpdIntegrationTest.kt | 4 +- .../delius/contact.entity/Contact.kt | 15 +---- .../hmpps/integrations/delius/entity/Event.kt | 9 ++- .../hmpps/integrations/delius/entity/Nsi.kt | 19 +++---- .../integrations/delius/entity/Person.kt | 4 ++ .../src/main/resources/application.yml | 3 - .../hmpps/entity/ConvictionEventEntity.kt | 9 +++ .../hmpps/entity/CourtAppearanceEntity.kt | 7 ++- .../digital/hmpps/entity/DetailEntity.kt | 5 ++ .../justice/digital/hmpps/entity/KeyDate.kt | 3 + .../gov/justice/digital/hmpps/entity/Nsi.kt | 3 + .../justice/digital/hmpps/entity/Release.kt | 11 ++-- .../src/main/resources/application.yml | 3 - .../hmpps/PsrCompletedIntegrationTest.kt | 8 +-- .../hmpps/PsrContextIntegrationTest.kt | 4 +- .../delius/courtreport/CourtReport.kt | 12 ++-- .../integrations/delius/document/Document.kt | 8 +-- .../src/main/resources/application.yml | 3 - .../digital/hmpps/CaseNotesIntegrationTest.kt | 8 +-- .../integrations/delius/entity/CaseNote.kt | 21 ++----- .../hmpps/integrations/delius/entity/Event.kt | 21 ++++--- .../hmpps/integrations/delius/entity/Nsi.kt | 16 ++---- .../integrations/delius/entity/Offender.kt | 5 +- .../hmpps/integrations/delius/entity/Staff.kt | 4 +- .../src/main/resources/application.yml | 3 - .../digital/hmpps/PcstdIntegrationTestBase.kt | 6 +- .../delius/contact/entity/Contact.kt | 15 +---- .../delius/contact/entity/ContactAlert.kt | 11 +--- .../delius/custody/entity/Custody.kt | 2 + .../delius/event/entity/Disposal.kt | 15 ++--- .../integrations/delius/event/entity/Event.kt | 12 ++-- .../delius/event/entity/OrderManager.kt | 9 ++- .../entity/LicenceCondition.kt | 13 ++--- .../entity/LicenceConditionManager.kt | 10 ++-- .../entity/LicenceConditionTransfer.kt | 12 +--- .../delius/person/entity/Person.kt | 3 + .../manager/prison/entity/PrisonManager.kt | 15 ++--- .../manager/probation/entity/PersonManager.kt | 3 + .../delius/recall/entity/Recall.kt | 14 +---- .../delius/release/entity/Release.kt | 15 +---- .../src/main/resources/application.yml | 4 +- .../digital/hmpps/entity/CommunityManager.kt | 3 + .../justice/digital/hmpps/entity/Person.kt | 7 +-- .../src/main/resources/application.yml | 3 - .../digital/hmpps/MergeIntegrationTest.kt | 4 +- .../hmpps/PrisonMatchingIntegrationTest.kt | 14 ++--- .../hmpps/ProbationMatchingIntegrationTest.kt | 13 ++--- .../hmpps/entity/AdditionalIdentifier.kt | 2 + .../justice/digital/hmpps/entity/Contact.kt | 2 + .../gov/justice/digital/hmpps/entity/Event.kt | 6 ++ .../digital/hmpps/entity/OrderManager.kt | 4 ++ .../justice/digital/hmpps/entity/Person.kt | 2 + .../src/main/resources/application.yml | 4 +- .../documents/entity/CourtAppearance.kt | 2 + .../delius/documents/entity/Document.kt | 7 +-- .../delius/documents/entity/Event.kt | 5 ++ .../delius/documents/entity/Offence.kt | 2 + .../delius/documents/entity/Person.kt | 2 + .../delius/manager/entity/CommunityManager.kt | 13 ++--- .../src/main/resources/application.yml | 4 +- .../justice/digital/hmpps/IntegrationTest.kt | 8 +-- .../src/main/resources/application.yml | 3 - .../hmpps/ReferAndMonitorIntegrationTest.kt | 4 +- .../delius/contact/entity/Contact.kt | 18 ++---- .../delius/event/entity/Disposal.kt | 11 ++-- .../integrations/delius/event/entity/Event.kt | 17 +++--- .../delius/person/entity/Disability.kt | 8 +-- .../delius/person/entity/Person.kt | 11 ++-- .../delius/person/entity/PersonAddress.kt | 10 +--- .../person/manager/entity/PersonManager.kt | 13 ++--- .../delius/referral/entity/Nsi.kt | 21 +++---- .../delius/referral/entity/Requirement.kt | 3 + .../src/main/resources/application.yml | 4 +- .../gov/justice/digital/hmpps/entity/Alert.kt | 2 + .../digital/hmpps/entity/Appointment.kt | 2 + .../justice/digital/hmpps/entity/CaseNote.kt | 2 + .../gov/justice/digital/hmpps/entity/Nsi.kt | 11 ++-- .../digital/hmpps/entity/NsiManager.kt | 3 + .../digital/hmpps/entity/PersonManager.kt | 3 + .../digital/hmpps/entity/Registration.kt | 10 ++-- .../gov/justice/digital/hmpps/entity/Staff.kt | 4 +- .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../integrations/delius/entity/Contact.kt | 16 +----- .../hmpps/integrations/delius/entity/Event.kt | 21 ++++--- .../delius/entity/OGRSAssessment.kt | 14 +---- .../integrations/delius/entity/Person.kt | 2 + .../delius/entity/PersonManager.kt | 10 ++-- .../src/main/resources/application.yml | 3 - .../digital/hmpps/service/entity/Contact.kt | 4 +- .../digital/hmpps/service/entity/Custody.kt | 9 +-- .../digital/hmpps/service/entity/Disposal.kt | 3 + .../digital/hmpps/service/entity/Event.kt | 10 ++-- .../digital/hmpps/service/entity/Person.kt | 12 ++-- .../hmpps/service/entity/Requirement.kt | 7 ++- .../src/main/resources/application.yml | 3 - .../src/main/resources/application.yml | 2 - .../hmpps/entity/ConvictionEventEntity.kt | 9 +++ .../hmpps/entity/CourtAppearanceEntity.kt | 7 ++- .../digital/hmpps/entity/DetailEntity.kt | 5 ++ .../justice/digital/hmpps/entity/KeyDate.kt | 3 + .../gov/justice/digital/hmpps/entity/Nsi.kt | 3 + .../justice/digital/hmpps/entity/Release.kt | 11 ++-- .../src/main/resources/application.yml | 3 - .../hmpps/GetPersonByCRNIntegrationTest.kt | 4 +- .../digital/hmpps/UserIntegrationTest.kt | 4 +- .../justice/digital/hmpps/entity/Person.kt | 7 +-- .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/IntegrationTest.kt | 6 +- .../hmpps/controller/entity/CaseEntity.kt | 9 +-- .../hmpps/controller/entity/EventEntity.kt | 14 ++--- .../controller/entity/OASYSAssessment.kt | 7 +-- .../hmpps/controller/entity/OGRSAssessment.kt | 9 +-- .../controller/entity/RegistrationEntity.kt | 10 ++-- .../controller/entity/RequirementEntity.kt | 15 ++--- .../integrations/delius/contact/Contact.kt | 14 +---- .../delius/management/ManagementTier.kt | 3 + .../integrations/delius/nsi/entity/Nsi.kt | 10 ++-- .../integrations/delius/person/Person.kt | 10 +--- .../delius/person/PersonManager.kt | 10 ++-- .../src/main/resources/application.yml | 3 - .../AssessmentCompleteIntegrationTest.kt | 4 +- .../casedetails/entity/CaseAddress.kt | 11 ++-- .../casedetails/entity/CaseEntity.kt | 2 + .../casedetails/entity/DisabilityEntity.kt | 9 +-- .../casedetails/entity/MainOffence.kt | 24 ++++---- .../casedetails/entity/ProvisionEntity.kt | 9 +-- .../personaldetails/entity/Person.kt | 9 +-- .../common/entity/AddressEntity.kt | 9 ++- .../common/entity/PersonalCircumstanceBase.kt | 9 +-- .../common/entity/PersonalContactBase.kt | 8 +-- .../common/entity/contact/Contact.kt | 15 +---- .../common/entity/person/PersonManager.kt | 10 ++-- .../common/entity/person/PersonWithManager.kt | 8 +-- .../hmpps/integrations/document/Document.kt | 14 ++--- .../src/main/resources/application.yml | 3 - .../digital/hmpps/data/entity/Custody.kt | 12 ++-- .../hmpps/AllocateEventIntegrationTest.kt | 4 +- .../hmpps/AllocatePersonIntegrationTest.kt | 4 +- .../AllocateRequirementIntegrationTest.kt | 4 +- .../hmpps/AllocationDemandIntegrationTest.kt | 4 +- .../delius/allocations/entity/BaseEntity.kt | 5 +- .../allocations/entity/ManagerBaseEntity.kt | 9 ++- .../allocations/entity/OrderTransfer.kt | 9 ++- .../allocations/entity/PersonTransfer.kt | 9 ++- .../allocations/entity/RequirementTransfer.kt | 9 ++- .../delius/caseview/CaseViewOffence.kt | 14 ++--- .../delius/caseview/CaseViewPerson.kt | 9 +-- .../delius/caseview/CaseViewPersonAddress.kt | 12 ++-- .../delius/caseview/CaseViewRequirement.kt | 7 ++- .../delius/caseview/CaseViewSentence.kt | 12 ++-- .../integrations/delius/contact/Contact.kt | 17 ++---- .../delius/courtappearance/CourtAppearance.kt | 11 ++-- .../delius/document/entity/DocEvent.kt | 18 +++--- .../delius/document/entity/DocPerson.kt | 9 ++- .../document/entity/InstitutionalReport.kt | 10 ++-- .../hmpps/integrations/delius/event/Event.kt | 9 ++- .../delius/event/ogrs/OASYSAssessment.kt | 7 +-- .../delius/event/ogrs/OGRSAssessment.kt | 9 +-- .../delius/event/requirement/Requirement.kt | 7 ++- .../delius/event/sentence/Disposal.kt | 11 ++-- .../integrations/delius/person/Person.kt | 7 +-- .../registration/entity/Registration.kt | 4 ++ .../src/main/resources/application.yml | 4 +- .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../src/main/resources/application.yml | 3 - .../justice/digital/hmpps/IntegrationTest.kt | 4 +- .../src/main/resources/application.yml | 2 - templates/runConfiguration.xml | 33 +++-------- 420 files changed, 1523 insertions(+), 2650 deletions(-) create mode 100644 libs/dev-tools/src/main/resources/META-INF/spring.factories delete mode 100644 libs/dev-tools/src/test/kotlin/uk/gov/justice/digital/hmpps/wiremock/WireMockInitialiserTest.kt diff --git a/.idea/runConfigurations/accredited_programmes_and_oasys.run.xml b/.idea/runConfigurations/accredited_programmes_and_oasys.run.xml index bf7bbc1897..b3febc844f 100644 --- a/.idea/runConfigurations/accredited_programmes_and_oasys.run.xml +++ b/.idea/runConfigurations/accredited_programmes_and_oasys.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/appointment_reminders_and_delius.run.xml b/.idea/runConfigurations/appointment_reminders_and_delius.run.xml index e2cfe07e16..eeca3fe9bf 100644 --- a/.idea/runConfigurations/appointment_reminders_and_delius.run.xml +++ b/.idea/runConfigurations/appointment_reminders_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/approved_premises_and_delius.run.xml b/.idea/runConfigurations/approved_premises_and_delius.run.xml index a87527aa98..6d129dcc24 100644 --- a/.idea/runConfigurations/approved_premises_and_delius.run.xml +++ b/.idea/runConfigurations/approved_premises_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/approved_premises_and_oasys.run.xml b/.idea/runConfigurations/approved_premises_and_oasys.run.xml index e3b0fe3af6..07997e2045 100644 --- a/.idea/runConfigurations/approved_premises_and_oasys.run.xml +++ b/.idea/runConfigurations/approved_premises_and_oasys.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/arns_and_delius.run.xml b/.idea/runConfigurations/arns_and_delius.run.xml index a579830fe2..855d855e6b 100644 --- a/.idea/runConfigurations/arns_and_delius.run.xml +++ b/.idea/runConfigurations/arns_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/assess-for-early-release-and-delius.run.xml b/.idea/runConfigurations/assess-for-early-release-and-delius.run.xml index 80e0aa569f..a79eb82075 100644 --- a/.idea/runConfigurations/assess-for-early-release-and-delius.run.xml +++ b/.idea/runConfigurations/assess-for-early-release-and-delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/assessment_summary_and_delius.run.xml b/.idea/runConfigurations/assessment_summary_and_delius.run.xml index 810393bf40..e917bd52b9 100644 --- a/.idea/runConfigurations/assessment_summary_and_delius.run.xml +++ b/.idea/runConfigurations/assessment_summary_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/cas2_and_delius.run.xml b/.idea/runConfigurations/cas2_and_delius.run.xml index e1c9faec50..742dbf949d 100644 --- a/.idea/runConfigurations/cas2_and_delius.run.xml +++ b/.idea/runConfigurations/cas2_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/cas3_and_delius.run.xml b/.idea/runConfigurations/cas3_and_delius.run.xml index 6d4e5dabb6..d779034e83 100644 --- a/.idea/runConfigurations/cas3_and_delius.run.xml +++ b/.idea/runConfigurations/cas3_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/common_platform_and_delius.run.xml b/.idea/runConfigurations/common_platform_and_delius.run.xml index 4274fea1ee..c7d99de3db 100644 --- a/.idea/runConfigurations/common_platform_and_delius.run.xml +++ b/.idea/runConfigurations/common_platform_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/core_person_record_and_delius.run.xml b/.idea/runConfigurations/core_person_record_and_delius.run.xml index 3ddceaed5c..2a4fbc7e41 100644 --- a/.idea/runConfigurations/core_person_record_and_delius.run.xml +++ b/.idea/runConfigurations/core_person_record_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/court_case_and_delius.run.xml b/.idea/runConfigurations/court_case_and_delius.run.xml index e2e705ea25..9245950a4c 100644 --- a/.idea/runConfigurations/court_case_and_delius.run.xml +++ b/.idea/runConfigurations/court_case_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/create_and_vary_a_licence_and_delius.run.xml b/.idea/runConfigurations/create_and_vary_a_licence_and_delius.run.xml index 27ac3418f9..46d6bcacbf 100644 --- a/.idea/runConfigurations/create_and_vary_a_licence_and_delius.run.xml +++ b/.idea/runConfigurations/create_and_vary_a_licence_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/custody_key_dates_and_delius.run.xml b/.idea/runConfigurations/custody_key_dates_and_delius.run.xml index 302d699cce..3bd30fe154 100644 --- a/.idea/runConfigurations/custody_key_dates_and_delius.run.xml +++ b/.idea/runConfigurations/custody_key_dates_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/domain_events_and_delius.run.xml b/.idea/runConfigurations/domain_events_and_delius.run.xml index 8a6ea5dd09..cd5902e594 100644 --- a/.idea/runConfigurations/domain_events_and_delius.run.xml +++ b/.idea/runConfigurations/domain_events_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/dps_and_delius.run.xml b/.idea/runConfigurations/dps_and_delius.run.xml index a28166adf1..2ca8940ac7 100644 --- a/.idea/runConfigurations/dps_and_delius.run.xml +++ b/.idea/runConfigurations/dps_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/effective_proposal_framework_and_delius.run.xml b/.idea/runConfigurations/effective_proposal_framework_and_delius.run.xml index 67d920489c..895984f9a6 100644 --- a/.idea/runConfigurations/effective_proposal_framework_and_delius.run.xml +++ b/.idea/runConfigurations/effective_proposal_framework_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/external_api_and_delius.run.xml b/.idea/runConfigurations/external_api_and_delius.run.xml index 0262a01409..e17228d3e0 100644 --- a/.idea/runConfigurations/external_api_and_delius.run.xml +++ b/.idea/runConfigurations/external_api_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/hdc_licences_and_delius.run.xml b/.idea/runConfigurations/hdc_licences_and_delius.run.xml index 781e2dfec1..97a08a2548 100644 --- a/.idea/runConfigurations/hdc_licences_and_delius.run.xml +++ b/.idea/runConfigurations/hdc_licences_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/hmpps_auth_and_delius.run.xml b/.idea/runConfigurations/hmpps_auth_and_delius.run.xml index 150b08fc88..94c0982430 100644 --- a/.idea/runConfigurations/hmpps_auth_and_delius.run.xml +++ b/.idea/runConfigurations/hmpps_auth_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/ims_and_delius.run.xml b/.idea/runConfigurations/ims_and_delius.run.xml index 88c0fdb739..0a3c918a56 100644 --- a/.idea/runConfigurations/ims_and_delius.run.xml +++ b/.idea/runConfigurations/ims_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/justice_email_and_delius.run.xml b/.idea/runConfigurations/justice_email_and_delius.run.xml index c8608046b1..8a34c622bf 100644 --- a/.idea/runConfigurations/justice_email_and_delius.run.xml +++ b/.idea/runConfigurations/justice_email_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/make_recall_decisions_and_delius.run.xml b/.idea/runConfigurations/make_recall_decisions_and_delius.run.xml index 3206d17862..3b8bf99081 100644 --- a/.idea/runConfigurations/make_recall_decisions_and_delius.run.xml +++ b/.idea/runConfigurations/make_recall_decisions_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/manage_offences_and_delius.run.xml b/.idea/runConfigurations/manage_offences_and_delius.run.xml index f1a72cee3f..9227db5a0d 100644 --- a/.idea/runConfigurations/manage_offences_and_delius.run.xml +++ b/.idea/runConfigurations/manage_offences_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/manage_pom_cases_and_delius.run.xml b/.idea/runConfigurations/manage_pom_cases_and_delius.run.xml index c935693fc3..ab174b9a06 100644 --- a/.idea/runConfigurations/manage_pom_cases_and_delius.run.xml +++ b/.idea/runConfigurations/manage_pom_cases_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/manage_supervision_and_delius.run.xml b/.idea/runConfigurations/manage_supervision_and_delius.run.xml index a7c2d1a87f..dfdf506c34 100644 --- a/.idea/runConfigurations/manage_supervision_and_delius.run.xml +++ b/.idea/runConfigurations/manage_supervision_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/manage_supervision_and_oasys.run.xml b/.idea/runConfigurations/manage_supervision_and_oasys.run.xml index 7381628cde..494e1ea91b 100644 --- a/.idea/runConfigurations/manage_supervision_and_oasys.run.xml +++ b/.idea/runConfigurations/manage_supervision_and_oasys.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/oasys_and_delius.run.xml b/.idea/runConfigurations/oasys_and_delius.run.xml index ad218f51ec..f94140cfb6 100644 --- a/.idea/runConfigurations/oasys_and_delius.run.xml +++ b/.idea/runConfigurations/oasys_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/offender_events_and_delius.run.xml b/.idea/runConfigurations/offender_events_and_delius.run.xml index 2cdefe3240..fdb9cb9945 100644 --- a/.idea/runConfigurations/offender_events_and_delius.run.xml +++ b/.idea/runConfigurations/offender_events_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/opd_and_delius.run.xml b/.idea/runConfigurations/opd_and_delius.run.xml index d639900072..dd3784ecbb 100644 --- a/.idea/runConfigurations/opd_and_delius.run.xml +++ b/.idea/runConfigurations/opd_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/pathfinder_and_delius.run.xml b/.idea/runConfigurations/pathfinder_and_delius.run.xml index 258ed1a5da..0c05443826 100644 --- a/.idea/runConfigurations/pathfinder_and_delius.run.xml +++ b/.idea/runConfigurations/pathfinder_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/pre_sentence_reports_to_delius.run.xml b/.idea/runConfigurations/pre_sentence_reports_to_delius.run.xml index 6baba08dd5..eab397509d 100644 --- a/.idea/runConfigurations/pre_sentence_reports_to_delius.run.xml +++ b/.idea/runConfigurations/pre_sentence_reports_to_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/prison_case_notes_to_probation.run.xml b/.idea/runConfigurations/prison_case_notes_to_probation.run.xml index 64d2461698..969e56e034 100644 --- a/.idea/runConfigurations/prison_case_notes_to_probation.run.xml +++ b/.idea/runConfigurations/prison_case_notes_to_probation.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/prison_custody_status_to_delius.run.xml b/.idea/runConfigurations/prison_custody_status_to_delius.run.xml index c2ccf609ee..f30e649f1e 100644 --- a/.idea/runConfigurations/prison_custody_status_to_delius.run.xml +++ b/.idea/runConfigurations/prison_custody_status_to_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/prison_education_and_delius.run.xml b/.idea/runConfigurations/prison_education_and_delius.run.xml index 98f006e1cd..08e6090868 100644 --- a/.idea/runConfigurations/prison_education_and_delius.run.xml +++ b/.idea/runConfigurations/prison_education_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/prison_identifier_and_delius.run.xml b/.idea/runConfigurations/prison_identifier_and_delius.run.xml index 14bf2279a0..2addd2dcf6 100644 --- a/.idea/runConfigurations/prison_identifier_and_delius.run.xml +++ b/.idea/runConfigurations/prison_identifier_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/prisoner_profile_and_delius.run.xml b/.idea/runConfigurations/prisoner_profile_and_delius.run.xml index 64e4dd5721..fe7d9531d9 100644 --- a/.idea/runConfigurations/prisoner_profile_and_delius.run.xml +++ b/.idea/runConfigurations/prisoner_profile_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/probation_search_and_delius.run.xml b/.idea/runConfigurations/probation_search_and_delius.run.xml index cec87429f9..73b7944d23 100644 --- a/.idea/runConfigurations/probation_search_and_delius.run.xml +++ b/.idea/runConfigurations/probation_search_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/refer_and_monitor_and_delius.run.xml b/.idea/runConfigurations/refer_and_monitor_and_delius.run.xml index 92b961f7aa..b0eb2891a9 100644 --- a/.idea/runConfigurations/refer_and_monitor_and_delius.run.xml +++ b/.idea/runConfigurations/refer_and_monitor_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/resettlement_passport_and_delius.run.xml b/.idea/runConfigurations/resettlement_passport_and_delius.run.xml index 5b5ea06437..fe316e2601 100644 --- a/.idea/runConfigurations/resettlement_passport_and_delius.run.xml +++ b/.idea/runConfigurations/resettlement_passport_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/risk_assessment_scores_to_delius.run.xml b/.idea/runConfigurations/risk_assessment_scores_to_delius.run.xml index 58728c3325..89096167ce 100644 --- a/.idea/runConfigurations/risk_assessment_scores_to_delius.run.xml +++ b/.idea/runConfigurations/risk_assessment_scores_to_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/sentence_plan_and_delius.run.xml b/.idea/runConfigurations/sentence_plan_and_delius.run.xml index 48d60bb7ad..0de21fe417 100644 --- a/.idea/runConfigurations/sentence_plan_and_delius.run.xml +++ b/.idea/runConfigurations/sentence_plan_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/sentence_plan_and_oasys.run.xml b/.idea/runConfigurations/sentence_plan_and_oasys.run.xml index c7e58f08d5..ab0f9f00f4 100644 --- a/.idea/runConfigurations/sentence_plan_and_oasys.run.xml +++ b/.idea/runConfigurations/sentence_plan_and_oasys.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/soc_and_delius.run.xml b/.idea/runConfigurations/soc_and_delius.run.xml index b6d911b0a1..c54e3a9400 100644 --- a/.idea/runConfigurations/soc_and_delius.run.xml +++ b/.idea/runConfigurations/soc_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/subject_access_requests_and_delius.run.xml b/.idea/runConfigurations/subject_access_requests_and_delius.run.xml index 1136ecbc65..0e327ccb2e 100644 --- a/.idea/runConfigurations/subject_access_requests_and_delius.run.xml +++ b/.idea/runConfigurations/subject_access_requests_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/tier_to_delius.run.xml b/.idea/runConfigurations/tier_to_delius.run.xml index d9b97282d3..e2d4cf4b87 100644 --- a/.idea/runConfigurations/tier_to_delius.run.xml +++ b/.idea/runConfigurations/tier_to_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/unpaid_work_and_delius.run.xml b/.idea/runConfigurations/unpaid_work_and_delius.run.xml index 20fbe345a8..c0819f2b0f 100644 --- a/.idea/runConfigurations/unpaid_work_and_delius.run.xml +++ b/.idea/runConfigurations/unpaid_work_and_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/.idea/runConfigurations/workforce_allocations_to_delius.run.xml b/.idea/runConfigurations/workforce_allocations_to_delius.run.xml index b627aac06c..9f408787d4 100644 --- a/.idea/runConfigurations/workforce_allocations_to_delius.run.xml +++ b/.idea/runConfigurations/workforce_allocations_to_delius.run.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file diff --git a/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/config/BuildInfoConfig.kt b/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/config/BuildInfoConfig.kt index 9ef8415c32..256232c919 100644 --- a/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/config/BuildInfoConfig.kt +++ b/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/config/BuildInfoConfig.kt @@ -1,6 +1,7 @@ package uk.gov.justice.digital.hmpps.config import org.springframework.beans.factory.annotation.Value +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.boot.info.BuildProperties import org.springframework.boot.info.GitProperties import org.springframework.context.annotation.Bean @@ -15,10 +16,12 @@ import java.util.* @Configuration class BuildInfoConfig { @Bean + @ConditionalOnProperty("build.info") fun buildProperties(@Value("\${build.info:#{null}}") info: String?) = info?.let { BuildProperties(loadFrom(it, "build.")) } @Bean + @ConditionalOnProperty("git.info") fun gitProperties(@Value("\${git.info:#{null}}") info: String?) = info?.let { GitProperties(loadFrom(it, "git.")) } diff --git a/libs/dev-tools/src/main/kotlin/uk/gov/justice/digital/hmpps/test/MockMvcExtensions.kt b/libs/dev-tools/src/main/kotlin/uk/gov/justice/digital/hmpps/test/MockMvcExtensions.kt index 05740a7ca9..2d46599fcc 100644 --- a/libs/dev-tools/src/main/kotlin/uk/gov/justice/digital/hmpps/test/MockMvcExtensions.kt +++ b/libs/dev-tools/src/main/kotlin/uk/gov/justice/digital/hmpps/test/MockMvcExtensions.kt @@ -11,6 +11,7 @@ import com.fasterxml.jackson.module.kotlin.readValue import org.springframework.http.HttpHeaders import org.springframework.http.MediaType import org.springframework.mock.web.MockHttpServletResponse +import org.springframework.test.json.JsonCompareMode import org.springframework.test.web.servlet.ResultActions import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content @@ -37,7 +38,7 @@ object MockMvcExtensions { inline fun MockHttpServletResponse.contentAsJson(): T = objectMapper.readValue(this.contentAsString) - inline fun ResultActions.andExpectJson(obj: T, strict: Boolean = false) = + inline fun ResultActions.andExpectJson(obj: T, compareMode: JsonCompareMode = JsonCompareMode.LENIENT) = this.andExpect(header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().json(objectMapper.writeValueAsString(obj), strict)) + .andExpect(content().json(objectMapper.writeValueAsString(obj), compareMode)) } diff --git a/libs/dev-tools/src/main/kotlin/uk/gov/justice/digital/hmpps/wiremock/WireMockInitialiser.kt b/libs/dev-tools/src/main/kotlin/uk/gov/justice/digital/hmpps/wiremock/WireMockInitialiser.kt index aaaaa89bc8..9f12528ef0 100644 --- a/libs/dev-tools/src/main/kotlin/uk/gov/justice/digital/hmpps/wiremock/WireMockInitialiser.kt +++ b/libs/dev-tools/src/main/kotlin/uk/gov/justice/digital/hmpps/wiremock/WireMockInitialiser.kt @@ -17,6 +17,8 @@ class WireMockInitialiser : ApplicationContextInitializer() - whenever(ctx.environment).thenReturn(env) - whenever(env.activeProfiles).thenReturn(arrayOf("integration-test")) - whenever(env.systemProperties).thenReturn(systemProperties) - whenever(ctx.beanFactory).thenReturn(beanFactory) - - wireMockInitialiser.initialize(ctx) - - val wiremockCaptor = ArgumentCaptor.forClass(WireMockServer::class.java) - verify(beanFactory).registerSingleton(eq("wireMockServer"), wiremockCaptor.capture()) - - val wireMockServer = wiremockCaptor.value - assertNotNull(wireMockServer) - assertThat(ctx.environment.systemProperties["wiremock.port"], equalTo(wireMockServer.port().toString())) - } -} diff --git a/libs/document-management/src/main/kotlin/uk/gov/justice/digital/hmpps/alfresco/AlfrescoClient.kt b/libs/document-management/src/main/kotlin/uk/gov/justice/digital/hmpps/alfresco/AlfrescoClient.kt index dc0af65e35..670961174d 100644 --- a/libs/document-management/src/main/kotlin/uk/gov/justice/digital/hmpps/alfresco/AlfrescoClient.kt +++ b/libs/document-management/src/main/kotlin/uk/gov/justice/digital/hmpps/alfresco/AlfrescoClient.kt @@ -48,7 +48,7 @@ class AlfrescoClient( else -> throw RuntimeException("Failed to download document. Alfresco responded with ${res.statusCode}.") } - }, false) + }, false) ?: throw NotFoundException("Document content", "alfrescoId", id) private fun HttpHeaders.copy(key: String, res: ConvertibleClientHttpResponse) { res.headers[key]?.also { this[key] = it } diff --git a/libs/document-management/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/StreamingHeadersSecurityConfigurer.kt b/libs/document-management/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/StreamingHeadersSecurityConfigurer.kt index 236e914182..4e567f9ba8 100644 --- a/libs/document-management/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/StreamingHeadersSecurityConfigurer.kt +++ b/libs/document-management/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/StreamingHeadersSecurityConfigurer.kt @@ -1,7 +1,7 @@ package uk.gov.justice.digital.hmpps.config.security import org.springframework.context.annotation.Configuration -import org.springframework.security.config.annotation.ObjectPostProcessor +import org.springframework.security.config.ObjectPostProcessor import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.web.header.HeaderWriterFilter diff --git a/libs/prison-staff/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PrisonStaff.kt b/libs/prison-staff/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PrisonStaff.kt index b830c53414..4d07d89c39 100644 --- a/libs/prison-staff/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PrisonStaff.kt +++ b/libs/prison-staff/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PrisonStaff.kt @@ -1,6 +1,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -43,6 +44,7 @@ class PrisonStaff( val lastModifiedDate: ZonedDateTime = ZonedDateTime.now(), @Column(name = "private", columnDefinition = "NUMBER", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var privateStaff: Boolean = false, @CreatedBy diff --git a/projects/accredited-programmes-and-oasys/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/accredited-programmes-and-oasys/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 5435332782..63ef10ff35 100644 --- a/projects/accredited-programmes-and-oasys/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/accredited-programmes-and-oasys/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -8,7 +8,7 @@ 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.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -25,7 +25,7 @@ internal class IntegrationTest { @Autowired lateinit var mockMvc: MockMvc - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/accredited-programmes-and-oasys/src/main/resources/application.yml b/projects/accredited-programmes-and-oasys/src/main/resources/application.yml index 51d54b512f..e61c850196 100644 --- a/projects/accredited-programmes-and-oasys/src/main/resources/application.yml +++ b/projects/accredited-programmes-and-oasys/src/main/resources/application.yml @@ -1,5 +1,4 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_empty @@ -35,7 +34,7 @@ info.productId: HMPPS518 # https://developer-portal.hmpps.service.justice.gov.uk spring.config.activate.on-profile: [ "dev", "integration-test" ] server.shutdown: immediate -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true integrations: ords: diff --git a/projects/appointment-reminders-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/appointment-reminders-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index f7429130a0..996f68c753 100644 --- a/projects/appointment-reminders-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/appointment-reminders-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -9,7 +9,7 @@ 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.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content @@ -30,13 +30,13 @@ internal class IntegrationTest { @Autowired lateinit var unpaidWorkAppointmentsService: UnpaidWorkAppointmentsService - @MockBean + @MockitoBean lateinit var upwAppointmentRepository: UpwAppointmentRepository - @MockBean + @MockitoBean lateinit var notificationClient: NotificationClient - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/appointment-reminders-and-delius/src/main/resources/application.yml b/projects/appointment-reminders-and-delius/src/main/resources/application.yml index dcccd3a6b6..be764b5b6a 100644 --- a/projects/appointment-reminders-and-delius/src/main/resources/application.yml +++ b/projects/appointment-reminders-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -47,7 +45,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser govuk-notify.api-key: test diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt index 13cbc1e1a7..402a5a1959 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt @@ -196,9 +196,7 @@ object AddressGenerator { county: String? = null, postcode: String? = null, telephoneNumber: String? = null, - id: Long = IdGenerator.getAndIncrement() ) = PersonAddress( - id, personId, type, status, @@ -209,6 +207,6 @@ object AddressGenerator { town, county, postcode, - telephoneNumber + telephoneNumber, ) } diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt index a5e1d8b5a7..660f73cf2c 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt @@ -16,7 +16,7 @@ import org.springframework.beans.factory.annotation.Value 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.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.* import uk.gov.justice.digital.hmpps.datetime.EuropeLondon import uk.gov.justice.digital.hmpps.integrations.approvedpremises.EventDetails @@ -64,7 +64,7 @@ internal class MessagingIntegrationInactiveTest { @Autowired lateinit var personAddressRepository: PersonAddressRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt index 2c2b1c004e..ad779ff56a 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt @@ -17,7 +17,7 @@ import org.springframework.beans.factory.annotation.Value 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.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.* import uk.gov.justice.digital.hmpps.datetime.EuropeLondon import uk.gov.justice.digital.hmpps.integrations.approvedpremises.EventDetails @@ -71,7 +71,7 @@ internal class MessagingIntegrationTest { @Autowired lateinit var personAddressRepository: PersonAddressRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/entity/Address.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/entity/Address.kt index 12b11f652b..02b54b0876 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/entity/Address.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/entity/Address.kt @@ -1,9 +1,11 @@ package uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.entity import jakarta.persistence.Column +import jakarta.persistence.Convert import jakarta.persistence.Entity import jakarta.persistence.Id import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -21,5 +23,6 @@ class Address( val postcode: String?, val telephoneNumber: String?, @Column(updatable = false, columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/referral/entity/Referral.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/referral/entity/Referral.kt index 66c0df7804..3bed39959f 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/referral/entity/Referral.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/referral/entity/Referral.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referr import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -99,6 +100,7 @@ class Referral( val id: Long = 0 @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false @Version @@ -151,9 +153,11 @@ class Event( val personId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/referral/entity/Residence.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/referral/entity/Residence.kt index a4bc04f338..5e3e420bdd 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/referral/entity/Residence.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/approvedpremises/referral/entity/Residence.kt @@ -1,16 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.Lob -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -45,6 +37,7 @@ class Residence( var moveOnCategoryId: Long? = null @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false @Id diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt index 0cdd6edb65..3d6c300135 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt @@ -1,17 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -99,6 +89,7 @@ class Contact( var lastUpdatedUserId: Long = 0, @Column(nullable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(nullable = false) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/alert/ContactAlert.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/alert/ContactAlert.kt index 642e346eea..4380ead288 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/alert/ContactAlert.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/alert/ContactAlert.kt @@ -1,13 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.alert -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.domain.support.AuditingEntityListener @Entity @@ -42,5 +36,6 @@ class ContactAlert( val personManagerId: Long, @Column(name = "trust_provider_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean = false ) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocumentEntity.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocumentEntity.kt index fa11be4094..2bbdd54bbf 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocumentEntity.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocumentEntity.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.document.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.person.Person import java.time.ZonedDateTime @@ -45,5 +46,6 @@ class DocumentEntity( val lastUpdatedUserId: Long = 0, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nonstatutoryintervention/entity/Nsi.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nonstatutoryintervention/entity/Nsi.kt index 3d58c7f1e4..a2103fc8ac 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nonstatutoryintervention/entity/Nsi.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nonstatutoryintervention/entity/Nsi.kt @@ -1,6 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.nonstatutoryintervention.entity import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -62,6 +63,7 @@ class Nsi( val externalReference: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val pendingTransfer: Boolean = false, @JoinColumn(name = "nsi_outcome_id") @@ -85,9 +87,11 @@ class Nsi( var lastUpdatedUserId: Long = 0, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) { diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nonstatutoryintervention/entity/NsiManager.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nonstatutoryintervention/entity/NsiManager.kt index 5cb2d906b8..3587d0cb2f 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nonstatutoryintervention/entity/NsiManager.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nonstatutoryintervention/entity/NsiManager.kt @@ -1,17 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.nonstatutoryintervention.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -83,9 +74,11 @@ class NsiManager( val partitionAreaId: Long = 0, // this is no longer used but the Delius database still requires it to be populated @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt index e96b6cb01c..b7751540a4 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -19,5 +17,6 @@ class Person( val crn: String, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ProbationCase.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ProbationCase.kt index 3fc6ab05b3..91da9646c8 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ProbationCase.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ProbationCase.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceData @@ -61,15 +62,18 @@ class ProbationCase( val genderIdentityDescription: String?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentExclusion: Boolean?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentRestriction: Boolean?, @OneToMany(mappedBy = "person") val communityManagers: List, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -94,9 +98,11 @@ class CommunityManager( val team: CommunityManagerTeam, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/address/PersonAddress.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/address/PersonAddress.kt index b9c016324d..a5ce85678d 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/address/PersonAddress.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/address/PersonAddress.kt @@ -1,16 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.address -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -26,10 +17,6 @@ import java.time.ZonedDateTime @EntityListeners(AuditingEntityListener::class) @SequenceGenerator(name = "offender_address_id_generator", sequenceName = "offender_address_id_seq", allocationSize = 1) class PersonAddress( - @Id - @Column(name = "offender_address_id") - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "offender_address_id_generator") - val id: Long, @Column(name = "offender_id") val personId: Long, @ManyToOne @@ -53,7 +40,8 @@ class PersonAddress( val typeVerified: Boolean? = false, val startDate: LocalDate = LocalDate.now(), var endDate: LocalDate? = null, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @CreatedDate @@ -73,5 +61,14 @@ class PersonAddress( var lastUpdatedUserId: Long = 0, @Column(nullable = false) - val partitionAreaId: Long = 0 + val partitionAreaId: Long = 0, + + @Id + @Column(name = "offender_address_id") + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "offender_address_id_generator") + val id: Long? = null, + + @Version + @Column(name = "row_version", nullable = false) + val version: Long = 0, ) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/probation/PersonManager.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/probation/PersonManager.kt index 2914f65884..04f4b8c495 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/probation/PersonManager.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/probation/PersonManager.kt @@ -1,12 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.manager.probation -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.staff.Staff import uk.gov.justice.digital.hmpps.integrations.delius.team.Team @@ -30,8 +26,10 @@ class PersonManager( val team: Team, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/offence/entity/Offence.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/offence/entity/Offence.kt index 7861f9def7..d85aac2bb3 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/offence/entity/Offence.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/offence/entity/Offence.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.offence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.Event @@ -38,6 +39,7 @@ class MainOffence( val date: LocalDate, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -63,6 +65,7 @@ class AdditionalOffence( val date: LocalDate?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/registration/entity/Registration.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/registration/entity/Registration.kt index 5d965e0ffc..d90114c203 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/registration/entity/Registration.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/registration/entity/Registration.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.registration.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceData @@ -39,9 +35,11 @@ class Registration( val date: LocalDate, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deregistered: Boolean, val lastUpdatedDatetime: ZonedDateTime, diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AddressService.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AddressService.kt index 628737b809..1ec2126639 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AddressService.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/AddressService.kt @@ -37,7 +37,6 @@ class AddressService( } private fun ApprovedPremises.arrival(person: Person, details: PersonArrived) = PersonAddress( - 0, person.id, referenceDataRepository.approvedPremisesAddressType(), referenceDataRepository.mainAddressStatus(), diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ApprovedPremisesService.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ApprovedPremisesService.kt index 2e5d15f4cb..b370234fe1 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ApprovedPremisesService.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ApprovedPremisesService.kt @@ -118,8 +118,8 @@ class ApprovedPremisesService( val person = personRepository.getByCrn(event.crn()) val ap = approvedPremisesRepository.getApprovedPremises(details.premises.legacyApCode) nsiService.personArrived(person, details, ap)?.let { (previousAddress, newAddress) -> - notifier.addressCreated(person.crn, newAddress.id, newAddress.status.description) - previousAddress?.let { notifier.addressUpdated(person.crn, it.id, it.status.description) } + notifier.addressCreated(person.crn, newAddress.id!!, newAddress.status.description) + previousAddress?.let { notifier.addressUpdated(person.crn, it.id!!, it.status.description) } } } @@ -128,7 +128,7 @@ class ApprovedPremisesService( val person = personRepository.getByCrn(event.crn()) val ap = approvedPremisesRepository.getApprovedPremises(details.premises.legacyApCode) nsiService.personDeparted(person, details, ap)?.let { updatedAddress -> - notifier.addressUpdated(person.crn, updatedAddress.id, updatedAddress.status.description) + notifier.addressUpdated(person.crn, updatedAddress.id!!, updatedAddress.status.description) } } } diff --git a/projects/approved-premises-and-delius/src/main/resources/application.yml b/projects/approved-premises-and-delius/src/main/resources/application.yml index 0cb9bb95cd..746e313e16 100644 --- a/projects/approved-premises-and-delius/src/main/resources/application.yml +++ b/projects/approved-premises-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -62,7 +60,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue messaging.producer.topic: domain-events diff --git a/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/ApprovedPremisesServiceTest.kt b/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/ApprovedPremisesServiceTest.kt index 11cfee464b..5c7c1043bd 100644 --- a/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/ApprovedPremisesServiceTest.kt +++ b/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/ApprovedPremisesServiceTest.kt @@ -45,6 +45,7 @@ import uk.gov.justice.digital.hmpps.messaging.crn import uk.gov.justice.digital.hmpps.messaging.url import uk.gov.justice.digital.hmpps.prepEvent import uk.gov.justice.digital.hmpps.security.ServiceContext +import uk.gov.justice.digital.hmpps.set import uk.gov.justice.digital.hmpps.user.AuditUserService import java.time.LocalDate import java.time.ZonedDateTime @@ -309,7 +310,7 @@ internal class ApprovedPremisesServiceTest { givenAddressTypes(listOf(ReferenceDataGenerator.AP_ADDRESS_TYPE)) givenAuditUser() givenReferral(person, details.eventDetails.bookingId) - whenever(personAddressRepository.save(any())).thenAnswer { it.arguments[0] } + whenever(personAddressRepository.save(any())).thenAnswer { it.arguments[0].apply { set("id", 0L) } } approvedPremisesService.personArrived(personArrivedEvent) diff --git a/projects/approved-premises-and-oasys/src/main/resources/application.yml b/projects/approved-premises-and-oasys/src/main/resources/application.yml index 8ed800626e..57b1a91cdb 100644 --- a/projects/approved-premises-and-oasys/src/main/resources/application.yml +++ b/projects/approved-premises-and-oasys/src/main/resources/application.yml @@ -1,5 +1,4 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_empty @@ -37,7 +36,6 @@ spring.config.activate.on-profile: [ "dev", "integration-test" ] server.shutdown: immediate wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser ords: client-id: approved-premises-and-oasys diff --git a/projects/arns-and-delius/src/main/resources/application.yml b/projects/arns-and-delius/src/main/resources/application.yml index 84cc96ef46..3dd2b97f33 100644 --- a/projects/arns-and-delius/src/main/resources/application.yml +++ b/projects/arns-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -44,7 +42,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/assess-for-early-release-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt b/projects/assess-for-early-release-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt index e1cd658bc8..af68a9b229 100644 --- a/projects/assess-for-early-release-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt +++ b/projects/assess-for-early-release-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -17,6 +15,7 @@ class Person( val crn: String, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/assess-for-early-release-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt b/projects/assess-for-early-release-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt index 6b6ec03fa3..3bda4f91cb 100644 --- a/projects/assess-for-early-release-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt +++ b/projects/assess-for-early-release-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -30,9 +31,11 @@ class PersonManager( val staff: Staff, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Id diff --git a/projects/assess-for-early-release-and-delius/src/main/resources/application.yml b/projects/assess-for-early-release-and-delius/src/main/resources/application.yml index 0a4dd92c9e..2d3517d7da 100644 --- a/projects/assess-for-early-release-and-delius/src/main/resources/application.yml +++ b/projects/assess-for-early-release-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -51,7 +49,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/IapsPerson.kt b/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/IapsPerson.kt index c21ef5dfa1..192ad0f6b3 100644 --- a/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/IapsPerson.kt +++ b/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/IapsPerson.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.data.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository @Immutable @@ -16,6 +14,7 @@ class IapsPerson( val personId: Long, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val iapsFlag: Boolean ) 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 f7f5f21955..143eb82114 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 @@ -14,7 +14,7 @@ import org.mockito.kotlin.* import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import org.springframework.transaction.PlatformTransactionManager import org.springframework.transaction.support.TransactionTemplate import uk.gov.justice.digital.hmpps.data.entity.IapsPersonRepository @@ -79,10 +79,10 @@ internal class IntegrationTest { @Autowired lateinit var objectMapper: ObjectMapper - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService - @MockBean + @MockitoBean lateinit var featureFlags: FeatureFlags lateinit var transactionTemplate: TransactionTemplate diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/assessment/entity/OasysAssessment.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/assessment/entity/OasysAssessment.kt index a876ac9d6e..40206e137a 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/assessment/entity/OasysAssessment.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/assessment/entity/OasysAssessment.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity import jakarta.persistence.* import org.hibernate.annotations.NotFound import org.hibernate.annotations.NotFoundAction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.domain.support.AuditingEntityListener import org.springframework.data.jpa.repository.EntityGraph @@ -80,6 +81,7 @@ class OasysAssessment( val ovpScore2: Long?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id @@ -143,6 +145,7 @@ class SectionScore( var score: Long, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/assessment/entity/SentencePlan.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/assessment/entity/SentencePlan.kt index 2a97144c13..0eeff3b6eb 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/assessment/entity/SentencePlan.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/assessment/entity/SentencePlan.kt @@ -1,6 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.assessment.entity import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.Person import java.io.Serializable @@ -21,6 +22,7 @@ class SentencePlan( val objective: String, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version @@ -75,6 +77,7 @@ class Need( val person: Person, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version @@ -97,6 +100,7 @@ class Text( val person: Person, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version @@ -119,6 +123,7 @@ class WorkSummary( val person: Person, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt index 7107e619a5..d9c40f7984 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.domain.support.AuditingEntityListener import org.springframework.data.jpa.repository.JpaRepository @@ -35,6 +36,7 @@ class Contact( val alert: Boolean? = false, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disposal.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disposal.kt index a4d578c64e..8adce067f7 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disposal.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disposal.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Entity @Immutable @@ -15,9 +16,11 @@ class Disposal( val type: DisposalType, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Event.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Event.kt index e85c44260e..9a2296fd3f 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Event.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Event.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.OneToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException @@ -25,9 +23,11 @@ class Event( val disposal: Disposal?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt index ab336650f4..4bd6686d7a 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Modifying @@ -18,6 +19,7 @@ class Person( val crn: String, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id @@ -49,9 +51,11 @@ class PersonManager( val staffId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Registration.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Registration.kt index 2fc8905d08..25fef7ce42 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Registration.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Registration.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.domain.support.AuditingEntityListener import org.springframework.data.jpa.repository.EntityGraph @@ -52,6 +53,7 @@ class Registration( val notes: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id @@ -61,6 +63,7 @@ class Registration( ) : AuditableEntity() { @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var deregistered: Boolean = false private set @@ -154,6 +157,7 @@ class RegistrationReview( val completed: Boolean = false, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id @@ -189,6 +193,7 @@ class DeRegistration( val staffId: Long, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Requirement.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Requirement.kt index b013ccd290..cf22dbdda3 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Requirement.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Requirement.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData @Immutable @@ -26,9 +27,11 @@ class Requirement( val subCategory: ReferenceData?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/assessment-summary-and-delius/src/main/resources/application.yml b/projects/assessment-summary-and-delius/src/main/resources/application.yml index 9800eec564..f0e53b7db7 100644 --- a/projects/assessment-summary-and-delius/src/main/resources/application.yml +++ b/projects/assessment-summary-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -49,7 +47,7 @@ spring: jpa.hibernate.ddl-auto: create-drop seed.database: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true messaging.consumer.queue: message-queue diff --git a/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index ebc1c47a6b..fd67870454 100644 --- a/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -11,9 +11,9 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.boot.test.system.CapturedOutput import org.springframework.boot.test.system.OutputCaptureExtension +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.datetime.EuropeLondon import uk.gov.justice.digital.hmpps.entity.ContactRepository import uk.gov.justice.digital.hmpps.entity.ContactType.Companion.REFERRAL_SUBMITTED @@ -39,7 +39,7 @@ internal class IntegrationTest { @Autowired lateinit var contactRepository: ContactRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/NotFoundIntegrationTest.kt b/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/NotFoundIntegrationTest.kt index f2ec89edff..888871160f 100644 --- a/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/NotFoundIntegrationTest.kt +++ b/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/NotFoundIntegrationTest.kt @@ -12,9 +12,9 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.boot.test.system.CapturedOutput import org.springframework.boot.test.system.OutputCaptureExtension +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.telemetry.TelemetryService @@ -30,7 +30,7 @@ internal class NotFoundIntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt index cb69f0032a..6b9c5bac90 100644 --- a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt +++ b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -73,6 +74,7 @@ class Contact( var lastUpdatedUserId: Long = 0, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, // The following fields are not used, but must be set: @@ -81,6 +83,7 @@ class Contact( val trustProviderTeamId: Long = teamId, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean = false, ) diff --git a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt index 4c37a18fb4..e55de7235b 100644 --- a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt +++ b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -21,6 +19,7 @@ class Person( val crn: String, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt index 67a2cd0b8e..160867858c 100644 --- a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt +++ b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -28,9 +26,11 @@ class PersonManager( val probationAreaId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/cas2-and-delius/src/main/resources/application.yml b/projects/cas2-and-delius/src/main/resources/application.yml index 89d62acd7f..a964575265 100644 --- a/projects/cas2-and-delius/src/main/resources/application.yml +++ b/projects/cas2-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -50,7 +48,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue diff --git a/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt b/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt index e33016b105..eca9212329 100644 --- a/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt +++ b/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt @@ -15,7 +15,7 @@ import org.springframework.beans.factory.annotation.Value 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.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.ProviderGenerator import uk.gov.justice.digital.hmpps.datetime.DeliusDateTimeFormatter import uk.gov.justice.digital.hmpps.datetime.EuropeLondon @@ -56,7 +56,7 @@ internal class CASIntegrationTest { @Autowired lateinit var personRepository: PersonRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Contact.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Contact.kt index a7450eb15f..f1f1e4c112 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Contact.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Contact.kt @@ -1,19 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.LastModifiedBy @@ -85,12 +74,14 @@ class Contact( val trustProviderTeamId: Long = teamId, @Column(updatable = false, columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean = false, @Column(updatable = false) val partitionAreaId: Long = 0L, @Column(updatable = false, columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt index 4c4b30fa92..905f61da4a 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Lock import org.springframework.data.jpa.repository.Query @@ -21,6 +22,7 @@ class Person( val nomsNumber: String?, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonAddress.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonAddress.kt index 2a34fc8bfa..88c0ac66a2 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonAddress.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonAddress.kt @@ -1,16 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -55,6 +46,7 @@ class PersonAddress( var startDate: LocalDate = LocalDate.now(), var endDate: LocalDate? = null, @Column(updatable = false, columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @CreatedDate diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt index e751d4b9b3..4b8f462e5f 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt @@ -1,9 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -28,9 +26,11 @@ class PersonManager( override val probationAreaId: Long, @Column(name = "active_flag", columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) : ManagerIds diff --git a/projects/cas3-and-delius/src/main/resources/application.yml b/projects/cas3-and-delius/src/main/resources/application.yml index 6675ac92f7..8e5dce7357 100644 --- a/projects/cas3-and-delius/src/main/resources/application.yml +++ b/projects/cas3-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -50,7 +48,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue messaging.producer.topic: domain-events diff --git a/projects/common-platform-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/common-platform-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 6276947a5a..0fe0dc3ba7 100644 --- a/projects/common-platform-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/common-platform-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -13,8 +13,8 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.boot.test.mock.mockito.SpyBean +import org.springframework.test.context.bean.override.mockito.MockitoBean +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean import uk.gov.justice.digital.hmpps.audit.entity.AuditedInteraction import uk.gov.justice.digital.hmpps.audit.service.AuditedInteractionService import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator @@ -51,19 +51,19 @@ internal class IntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService - @SpyBean + @MockitoSpyBean lateinit var auditedInteractionService: AuditedInteractionService - @SpyBean + @MockitoSpyBean lateinit var personRepository: PersonRepository - @SpyBean + @MockitoSpyBean lateinit var addressRepository: PersonAddressRepository - @SpyBean + @MockitoSpyBean lateinit var personService: PersonService @BeforeEach diff --git a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt index e7ceabe2bb..1eb4b58b85 100644 --- a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt +++ b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -64,15 +65,19 @@ class Person( val mobileNumber: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "current_disposal", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentDisposal: Boolean = false, @Column(name = "current_restriction", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentRestriction: Boolean = false, @Column(name = "pending_transfer", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val pendingTransfer: Boolean = false, @Column diff --git a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonAddress.kt b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonAddress.kt index ba29020bce..b77a143b65 100644 --- a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonAddress.kt +++ b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonAddress.kt @@ -1,6 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -32,7 +33,8 @@ class PersonAddress( @Column(name = "partition_area_id", nullable = false) val partitionAreaId: Long = 0, - @Column(name = "soft_deleted", updatable = false, columnDefinition = "NUMBER") + @Column(name = "soft_deleted", updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "row_version") @@ -94,7 +96,8 @@ class PersonAddress( @LastModifiedBy var lastUpdatedUserId: Long = 0, - @Column(name = "awaiting_assessment", columnDefinition = "NUMBER", nullable = false) + @Column(name = "awaiting_assessment", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val awaitingAssessment: Boolean = false, @ManyToOne diff --git a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt index 36ace96365..6524147e40 100644 --- a/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt +++ b/projects/common-platform-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -43,6 +44,7 @@ class PersonManager( val version: Long = 0, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @ManyToOne @@ -64,6 +66,7 @@ class PersonManager( val provider: Provider, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @CreatedDate diff --git a/projects/common-platform-and-delius/src/main/resources/application.yml b/projects/common-platform-and-delius/src/main/resources/application.yml index 400dd58880..da687f9b77 100644 --- a/projects/common-platform-and-delius/src/main/resources/application.yml +++ b/projects/common-platform-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -53,7 +51,6 @@ messaging.producer.topic: domain-events seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue diff --git a/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Disposal.kt b/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Disposal.kt index e48bddf201..f073c98052 100644 --- a/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Disposal.kt +++ b/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Disposal.kt @@ -1,10 +1,12 @@ package uk.gov.justice.digital.hmpps.integration.delius.entity import jakarta.persistence.Column +import jakarta.persistence.Convert import jakarta.persistence.Entity import jakarta.persistence.Id import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import java.time.LocalDate @@ -23,9 +25,11 @@ class Disposal( val startDate: LocalDate, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Person.kt b/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Person.kt index ca82aae94b..f8f811b38e 100644 --- a/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Person.kt +++ b/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable import org.springframework.data.jpa.repository.EntityGraph @@ -78,6 +79,7 @@ data class Person( val restrictionMessage: String?, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/core-person-record-and-delius/src/main/resources/application.yml b/projects/core-person-record-and-delius/src/main/resources/application.yml index abdc991a32..4664ebdea3 100644 --- a/projects/core-person-record-and-delius/src/main/resources/application.yml +++ b/projects/core-person-record-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE diff --git a/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CourtCaseNotesIntegrationTest.kt b/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CourtCaseNotesIntegrationTest.kt index 17b0e90e66..44e7e4489e 100644 --- a/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CourtCaseNotesIntegrationTest.kt +++ b/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CourtCaseNotesIntegrationTest.kt @@ -11,8 +11,8 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.boot.test.mock.mockito.SpyBean +import org.springframework.test.context.bean.override.mockito.MockitoBean +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean import uk.gov.justice.digital.hmpps.audit.repository.AuditedInteractionRepository import uk.gov.justice.digital.hmpps.data.generator.CourtCaseNoteMessageGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator @@ -35,13 +35,13 @@ class CaseNotesIntegrationTest { @Autowired private lateinit var caseNoteRepository: CaseNoteRepository - @MockBean + @MockitoBean private lateinit var telemetryService: TelemetryService @Autowired lateinit var wireMockserver: WireMockServer - @SpyBean + @MockitoSpyBean lateinit var air: AuditedInteractionRepository @Test diff --git a/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index fc748a6b32..5ef510d4f9 100644 --- a/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/court-case-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -8,7 +8,7 @@ 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.test.context.bean.override.mockito.MockitoBean 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 @@ -29,7 +29,7 @@ internal class IntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @ParameterizedTest diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Attendance.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Attendance.kt index 6fe4a68dcd..50466a2200 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Attendance.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Attendance.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -26,6 +27,7 @@ class Contact( val date: LocalDate, @Column(name = "enforcement", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val enforcementContact: Boolean? = null, @Column(name = "event_id") @@ -44,6 +46,7 @@ class Contact( val outcome: AttendanceOutcome? = null, @Column(columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/CaseNote.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/CaseNote.kt index d104a1ec4e..4886d9ae61 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/CaseNote.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/CaseNote.kt @@ -1,19 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.LastModifiedBy @@ -84,6 +73,7 @@ class CaseNote( val trustProviderTeamId: Long = teamId, @Column(updatable = false, columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean = false, @Column(updatable = false) @@ -93,6 +83,7 @@ class CaseNote( val eventId: Long? = null, @Column(updatable = false, columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Document.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Document.kt index 9a4c0274e9..ef33c059a6 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Document.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Document.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.api.model.DocumentType @@ -54,6 +52,7 @@ class DocumentEntity( val lastUpdated: ZonedDateTime, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Registration.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Registration.kt index f49c847c52..7374ddd8ed 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Registration.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Registration.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.registration.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -55,9 +56,11 @@ class Registration( val deRegistrations: List = emptyList(), @Column(name = "deregistered", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deRegistered: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Column(name = "created_datetime") @@ -131,6 +134,7 @@ class DeRegistration( val createdDateTime: LocalDateTime, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/conviction/entity/Requirement.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/conviction/entity/Requirement.kt index acd559d4af..a802544e5a 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/conviction/entity/Requirement.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/conviction/entity/Requirement.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.conviction.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.api.model.KeyValue @@ -75,9 +76,11 @@ class Requirement( val rarCount: Long? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @ManyToOne diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/courtappearance/entity/CourtAppearance.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/courtappearance/entity/CourtAppearance.kt index 9110907277..496a3f9f25 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/courtappearance/entity/CourtAppearance.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/courtappearance/entity/CourtAppearance.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.courtappearance.e import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData @@ -28,6 +29,7 @@ class CourtAppearance( val appearanceDate: LocalDateTime, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @ManyToOne(fetch = FetchType.LAZY) @@ -180,6 +182,7 @@ class CourtReport( val reportManagers: List = listOf(), @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false, @Id @@ -201,9 +204,11 @@ class ReportManager( val staff: Staff? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean, @Id diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt index b78bc92168..b1c5273749 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -30,6 +31,7 @@ class Event( val mainOffence: MainOffence? = null, @Column(name = "in_breach", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val inBreach: Boolean, @Column(name = "breach_end") @@ -42,9 +44,11 @@ class Event( val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -132,6 +136,7 @@ class OrderManager( val staff: Staff?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @ManyToOne @@ -147,6 +152,7 @@ class OrderManager( val endDate: ZonedDateTime?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/LicenceCondition.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/LicenceCondition.kt index 912a4f6f49..7c837aa3c4 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/LicenceCondition.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/LicenceCondition.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity.Disposal @@ -53,9 +54,11 @@ class LicenceCondition( val id: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/MainOffence.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/MainOffence.kt index f0874b3ba1..b47a64c26c 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/MainOffence.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/MainOffence.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData import java.time.LocalDateTime @@ -45,6 +46,7 @@ class MainOffence( val updated: ZonedDateTime, @Column(updatable = false, columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -70,6 +72,7 @@ class AdditionalOffence( val date: LocalDateTime?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, val offenceCount: Long? = null, diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Requirement.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Requirement.kt index 19923de1ff..03bcab4e77 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Requirement.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Requirement.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity.Disposal @@ -57,9 +58,11 @@ class Requirement( val length: Long? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/nsi/Nsi.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/nsi/Nsi.kt index 874af095cd..da2b92c611 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/nsi/Nsi.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/nsi/Nsi.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.nsi import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -82,9 +83,11 @@ class Nsi( val id: Long = 0, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @OneToOne @@ -153,9 +156,11 @@ class NsiManager( val probationArea: ProbationAreaEntity, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/entity/Disposal.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/entity/Disposal.kt index c4b6694226..17a4eef63d 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/entity/Disposal.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/entity/Disposal.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -52,6 +53,7 @@ class Disposal( val terminationReason: ReferenceData?, @Column(name = "upw", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val upw: Boolean = false, val effectiveLength: Long? = null, @@ -69,9 +71,11 @@ class Disposal( val enteredSentenceEndDate: LocalDate? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @OneToOne(mappedBy = "disposal") @@ -98,6 +102,7 @@ class Release( val date: LocalDateTime, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -214,6 +219,7 @@ class Custody( val status: ReferenceData, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, val prisonerNumber: String?, @@ -257,9 +263,11 @@ class PssRequirement( val subCategory: PssRequirementSubCat?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id @@ -321,6 +329,7 @@ class AdditionalSentence( val notes: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/entity/Institution.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/entity/Institution.kt index c3fb13a5fb..abfffa3d94 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/entity/Institution.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/entity/Institution.kt @@ -2,9 +2,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter -import uk.gov.justice.digital.hmpps.api.model.Institution -import uk.gov.justice.digital.hmpps.api.model.keyValueOf import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData import java.io.Serializable @@ -27,6 +26,7 @@ class Institution( val establishmentType: ReferenceData?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val private: Boolean?, val nomisCdeCode: String? diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disability.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disability.kt index d162269df9..0db819f060 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disability.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disability.kt @@ -4,6 +4,7 @@ import jakarta.persistence.* import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData import java.time.LocalDate import java.time.ZonedDateTime @@ -40,6 +41,7 @@ class Disability( val finishDate: LocalDate? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt index ef58765cd6..ee2b344593 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -107,6 +108,7 @@ class Person( val requiresInterpreter: Boolean? = false, @Column(name = "current_disposal", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentDisposal: Boolean, @Column(name = "current_remand_status") @@ -149,9 +151,11 @@ class Person( val allowSms: Boolean? = false, @Column(name = "current_exclusion", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentExclusion: Boolean = false, @Column(name = "current_restriction", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentRestriction: Boolean = false, @Column(name = "current_highest_risk_colour") @@ -171,6 +175,7 @@ class Person( val restrictionMessage: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @OneToMany(mappedBy = "person") @@ -206,6 +211,7 @@ class OffenderAlias( val secondName: String? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, val surname: String, @@ -262,6 +268,7 @@ class PersonAddress( val endDate: LocalDate? = null, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, val createdDatetime: ZonedDateTime = ZonedDateTime.now(), diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PersonManager.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PersonManager.kt index b074a91379..449a5982ed 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PersonManager.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PersonManager.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.ProbationAreaEntity import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.Staff @@ -36,6 +37,7 @@ class PersonManager( val staffEmployeeId: Long, @Column(name = "trust_provider_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean, @ManyToOne @@ -89,9 +91,11 @@ class PersonManager( val endDate: LocalDate? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false ) { diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PrisonManager.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PrisonManager.kt index 9b5047f606..85b7aece7b 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PrisonManager.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PrisonManager.kt @@ -1,6 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -45,6 +46,7 @@ class PrisonManager( val responsibleOfficers: List = emptyList(), @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id @@ -56,6 +58,7 @@ class PrisonManager( var endDate: ZonedDateTime? = null @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true @CreatedBy diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Provision.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Provision.kt index 0a70705a18..b2ba390b04 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Provision.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Provision.kt @@ -5,6 +5,7 @@ import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData import java.time.LocalDate @@ -42,6 +43,7 @@ class Provision( val finishDate: LocalDate? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/ProbationArea.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/ProbationArea.kt index 1a04f662a6..3958343e47 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/ProbationArea.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/ProbationArea.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.provider.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.entity.Institution @@ -20,6 +21,7 @@ class ProbationAreaEntity( val code: String, @Column(name = "private", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val privateSector: Boolean, @ManyToOne @@ -173,6 +175,7 @@ class Organisation( val description: String, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val activeFlag: Boolean, ) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Staff.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Staff.kt index 1617991867..a93b003350 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Staff.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Staff.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.provider.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData import java.time.LocalDate import kotlin.jvm.Transient @@ -104,6 +105,7 @@ class Team( val probationArea: ProbationAreaEntity, @Column(name = "private", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val private: Boolean = false ) diff --git a/projects/court-case-and-delius/src/main/resources/application.yml b/projects/court-case-and-delius/src/main/resources/application.yml index 645c0db0b9..046741629c 100644 --- a/projects/court-case-and-delius/src/main/resources/application.yml +++ b/projects/court-case-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -65,7 +63,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: events diff --git a/projects/create-and-vary-a-licence-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/LicenceActivatedIntegrationTest.kt b/projects/create-and-vary-a-licence-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/LicenceActivatedIntegrationTest.kt index b72960b636..0bfd2d1494 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/LicenceActivatedIntegrationTest.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/LicenceActivatedIntegrationTest.kt @@ -9,7 +9,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.SentenceGenerator import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactType @@ -42,7 +42,7 @@ class LicenceActivatedIntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact.entity/Contact.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact.entity/Contact.kt index 57fb677220..6937276632 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact.entity/Contact.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact.entity/Contact.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -40,6 +41,7 @@ class Contact( val notes: String?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/manager/entity/PersonManager.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/manager/entity/PersonManager.kt index 4e0683f52a..d7d8ab9e76 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/manager/entity/PersonManager.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/manager/entity/PersonManager.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.manager.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -34,9 +35,11 @@ class PersonManager( val staff: Staff, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Id diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt index 825d5b7646..51c9a1eb95 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -17,6 +15,7 @@ class Person( val crn: String, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt index 00de40cc2f..24f7821979 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -42,12 +43,15 @@ class LicenceCondition( val cvlText: String?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val pendingTransfer: Boolean = false, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version @@ -108,9 +112,11 @@ class LicenceConditionManager( val allocationReason: ReferenceData?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Sentence.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Sentence.kt index d020b35b3b..461d323403 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Sentence.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Sentence.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.Person @@ -25,6 +26,7 @@ class Custody( val keyDates: List, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -42,9 +44,11 @@ class Disposal( val event: Event, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Column(name = "notional_end_date") @@ -76,9 +80,11 @@ class Event( val disposal: Disposal?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -103,6 +109,7 @@ class KeyDate( val date: LocalDate, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/resources/application.yml b/projects/create-and-vary-a-licence-and-delius/src/main/resources/application.yml index d5b93247de..7e25887055 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/resources/application.yml +++ b/projects/create-and-vary-a-licence-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -61,7 +59,7 @@ spring: base-dn: ${spring.ldap.base} seed.database: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true oauth2: client-id: create-and-vary-a-licence-and-delius diff --git a/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index f41e6421e9..52a4019119 100644 --- a/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -1,22 +1,16 @@ package uk.gov.justice.digital.hmpps import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.equalTo -import org.hamcrest.Matchers.hasKey -import org.hamcrest.Matchers.not +import org.hamcrest.Matchers.* import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyMap -import org.mockito.kotlin.check -import org.mockito.kotlin.eq -import org.mockito.kotlin.times -import org.mockito.kotlin.verify -import org.mockito.kotlin.whenever +import org.mockito.kotlin.* import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.test.annotation.DirtiesContext +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.SentenceGenerator.DEFAULT_CUSTODY @@ -43,7 +37,7 @@ internal class IntegrationTest { @Autowired lateinit var channelManager: HmppsChannelManager - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired @@ -52,7 +46,7 @@ internal class IntegrationTest { @Autowired lateinit var custodyRepository: CustodyRepository - @MockBean + @MockitoBean lateinit var featureFlags: FeatureFlags private val sedDate = "2025-09-10" diff --git a/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/KeyDateControllerTest.kt b/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/KeyDateControllerTest.kt index cb1649592e..40d870ba1d 100644 --- a/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/KeyDateControllerTest.kt +++ b/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/KeyDateControllerTest.kt @@ -15,7 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -45,7 +45,7 @@ internal class KeyDateControllerTest { @Autowired lateinit var custodyRepository: CustodyRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/BaseEntity.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/BaseEntity.kt index 3aaf0136bb..85a226028b 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/BaseEntity.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/BaseEntity.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps.integrations.delius.custody import jakarta.persistence.Column +import jakarta.persistence.Convert import jakarta.persistence.MappedSuperclass import jakarta.persistence.Version +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -14,7 +16,8 @@ abstract class BaseEntity { val partitionAreaId = 0 - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false @Column(name = "row_version", nullable = false) diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/Sentence.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/Sentence.kt index 35b58f5260..30add7c858 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/Sentence.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/Sentence.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.custody.date import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.reference.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.person.Person import java.time.LocalDate @@ -23,7 +24,8 @@ class Event( @Column val firstReleaseDate: LocalDate? = null, - @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false) + @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @OneToOne(mappedBy = "event") @@ -33,7 +35,8 @@ class Event( @SQLRestriction("active_flag = 1 and soft_deleted = 0") val manager: OrderManager? = null, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -52,10 +55,12 @@ class Disposal( @JoinColumn(name = "disposal_type_id") val type: DisposalType, - @Column(name = "active_flag", updatable = false, columnDefinition = "NUMBER") + @Column(name = "active_flag", updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -95,6 +100,7 @@ class Custody( val keyDates: List = listOf(), @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -121,5 +127,6 @@ class OrderManager( val staffId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true ) diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/contact/Contact.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/contact/Contact.kt index dd9c7247ed..f46398e9fc 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/contact/Contact.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/contact/Contact.kt @@ -1,18 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.custody.date.contact -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.domain.support.AuditingEntityListener import uk.gov.justice.digital.hmpps.integrations.delius.custody.BaseEntity @@ -65,7 +55,8 @@ class Contact( @Column(updatable = false) val trustProviderTeamId: Long = teamId, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean = false, @Convert(converter = YesNoConverter::class) diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt index 6efc61ff99..85c833030a 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -22,5 +20,6 @@ class Person( val nomsId: String?, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/custody-key-dates-and-delius/src/main/resources/application.yml b/projects/custody-key-dates-and-delius/src/main/resources/application.yml index 8106d13465..da50b40d38 100644 --- a/projects/custody-key-dates-and-delius/src/main/resources/application.yml +++ b/projects/custody-key-dates-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -55,7 +53,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging: consumer.queue: message-queue diff --git a/projects/domain-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PublishingIntegrationTest.kt b/projects/domain-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PublishingIntegrationTest.kt index 3797a7b85a..13acf3be73 100644 --- a/projects/domain-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PublishingIntegrationTest.kt +++ b/projects/domain-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PublishingIntegrationTest.kt @@ -12,7 +12,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.DomainEventGenerator import uk.gov.justice.digital.hmpps.integrations.delius.DomainEventRepository import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent @@ -31,7 +31,7 @@ internal class PublishingIntegrationTest { @Autowired lateinit var domainEventRepository: DomainEventRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/domain-events-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt b/projects/domain-events-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt index b9dfd2feb9..0f1e414f89 100644 --- a/projects/domain-events-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt +++ b/projects/domain-events-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import java.time.LocalDate @@ -37,6 +35,7 @@ class Person( val dateOfBirth: LocalDate, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/domain-events-and-delius/src/main/resources/application.yml b/projects/domain-events-and-delius/src/main/resources/application.yml index c46d11cf15..25fa2b57d1 100644 --- a/projects/domain-events-and-delius/src/main/resources/application.yml +++ b/projects/domain-events-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -49,7 +47,7 @@ poller.fixed-delay: 2000 messaging.producer.topic: domain-events -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true domain-events: base-url: http://localhost:${wiremock.port} diff --git a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearance.kt b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearance.kt index aa19388740..bba998be6a 100644 --- a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearance.kt +++ b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearance.kt @@ -1,12 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.ZonedDateTime @Entity @@ -32,5 +29,6 @@ class CourtAppearance( val outcome: ReferenceData? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Document.kt b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Document.kt index 7ad2f3fd97..23f600146f 100644 --- a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Document.kt +++ b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Document.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.Instant @@ -46,6 +44,7 @@ class DocumentEntity( val lastUpdatedUserId: Long = 0, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Event.kt b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Event.kt index 640bfbcbcd..a4817e429f 100644 --- a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Event.kt +++ b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Event.kt @@ -1,17 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.JoinColumns -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import java.time.LocalDate @@ -40,9 +32,11 @@ class Event( val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -73,9 +67,11 @@ class Disposal( val custody: Custody? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Offence.kt b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Offence.kt index a08dfa45fd..db7b93c3fe 100644 --- a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Offence.kt +++ b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Offence.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Entity @Immutable @@ -27,6 +22,7 @@ class MainOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt index 1446de7746..0a797c121c 100644 --- a/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt +++ b/projects/dps-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt @@ -1,12 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.OneToMany -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -41,6 +38,7 @@ class Person( val events: List, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/dps-and-delius/src/main/resources/application.yml b/projects/dps-and-delius/src/main/resources/application.yml index b67a17140e..e9bdc74963 100644 --- a/projects/dps-and-delius/src/main/resources/application.yml +++ b/projects/dps-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -47,7 +45,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/CourtAppearance.kt b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/CourtAppearance.kt index 72e65373b7..8529ab0037 100644 --- a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/CourtAppearance.kt +++ b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/CourtAppearance.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.epf.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.domain.PageRequest import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -42,7 +43,8 @@ class CourtAppearance( @ManyToOne val court: Court, - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/Event.kt b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/Event.kt index ca779e5b2a..6330c6d653 100644 --- a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/Event.kt +++ b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/Event.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.epf.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -30,9 +31,11 @@ class Event( val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -55,9 +58,11 @@ class Disposal( val custody: Custody? = null, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -71,6 +76,7 @@ class Custody( val disposal: Disposal, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -95,6 +101,7 @@ class KeyDate( var date: LocalDate, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/OgrsAssessment.kt b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/OgrsAssessment.kt index d5dcbc1183..8bffbce91d 100644 --- a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/OgrsAssessment.kt +++ b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/OgrsAssessment.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.epf.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import java.time.LocalDate @@ -23,6 +21,7 @@ class OgrsAssessment( val score: Long?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/Person.kt b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/Person.kt index 15871343ca..6dfba2dee6 100644 --- a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/Person.kt +++ b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.epf.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -43,15 +44,18 @@ class Person( val surname: String, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentExclusion: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentRestriction: Boolean, @Column(name = "dynamic_rsr_score", columnDefinition = "number(5,2)") val dynamicRsrScore: Double?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/PrisonManager.kt b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/PrisonManager.kt index 4878e16a52..ad0df64d23 100644 --- a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/PrisonManager.kt +++ b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/PrisonManager.kt @@ -1,12 +1,8 @@ package uk.gov.justice.digital.hmpps.epf.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.Immutable @Entity @@ -23,8 +19,10 @@ class PrisonManager( val provider: Provider, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true ) diff --git a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/ResponsibleOfficer.kt b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/ResponsibleOfficer.kt index 7ea05c6d62..e003c6d989 100644 --- a/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/ResponsibleOfficer.kt +++ b/projects/effective-proposal-framework-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/epf/entity/ResponsibleOfficer.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.epf.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import java.time.ZonedDateTime @@ -44,9 +45,11 @@ class PersonManager( val provider: Provider, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Id diff --git a/projects/effective-proposal-framework-and-delius/src/main/resources/application.yml b/projects/effective-proposal-framework-and-delius/src/main/resources/application.yml index 57710b0631..bef2a010d0 100644 --- a/projects/effective-proposal-framework-and-delius/src/main/resources/application.yml +++ b/projects/effective-proposal-framework-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -44,7 +42,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/CourtAppearance.kt b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/CourtAppearance.kt index 2fc564667c..e1cb6c7bad 100644 --- a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/CourtAppearance.kt +++ b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/CourtAppearance.kt @@ -1,12 +1,9 @@ package uk.gov.justice.digital.hmpps.integration.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.ZonedDateTime @Entity @@ -37,6 +34,7 @@ data class CourtAppearance( val plea: ReferenceData?, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Event.kt b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Event.kt index 6500ed27f6..1c0f4a7d42 100644 --- a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Event.kt +++ b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Event.kt @@ -1,15 +1,9 @@ package uk.gov.justice.digital.hmpps.integration.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate @Entity @@ -43,9 +37,11 @@ data class Event( val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -76,9 +72,11 @@ data class Disposal( val lengthUnits: ReferenceData?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Offence.kt b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Offence.kt index fee784cc9e..d996339612 100644 --- a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Offence.kt +++ b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Offence.kt @@ -1,15 +1,9 @@ package uk.gov.justice.digital.hmpps.integration.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import java.time.LocalDate @@ -36,6 +30,7 @@ data class MainOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -62,6 +57,7 @@ data class AdditionalOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Person.kt b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Person.kt index a331441514..9c2e662e84 100644 --- a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Person.kt +++ b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -21,6 +22,7 @@ data class Person( val nomsId: String?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -61,6 +63,7 @@ class PersonManager( val staff: Staff, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Id diff --git a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/RegistrationEntity.kt b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/RegistrationEntity.kt index 15d229c2a5..1a64e2e6c8 100644 --- a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/RegistrationEntity.kt +++ b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/RegistrationEntity.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -38,9 +39,11 @@ class RegistrationEntity( val notes: String?, @Column(name = "deregistered", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deRegistered: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/external-api-and-delius/src/main/resources/application.yml b/projects/external-api-and-delius/src/main/resources/application.yml index 94786907c1..574810c1fb 100644 --- a/projects/external-api-and-delius/src/main/resources/application.yml +++ b/projects/external-api-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -49,7 +47,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CommunityManagerEntity.kt b/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CommunityManagerEntity.kt index 9f41f269bf..05e483a7c7 100644 --- a/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CommunityManagerEntity.kt +++ b/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CommunityManagerEntity.kt @@ -1,12 +1,8 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Entity @Immutable @@ -29,8 +25,10 @@ class CommunityManagerEntity( val team: Team, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true ) diff --git a/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt b/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt index 4d38bc3a4b..cdcf8f89ce 100644 --- a/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt +++ b/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt @@ -1,12 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.OneToMany -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Entity @Immutable @@ -28,5 +25,6 @@ class Person( val prisonManagers: List = listOf(), @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PrisonManager.kt b/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PrisonManager.kt index a45dd3238d..25f7140ec7 100644 --- a/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PrisonManager.kt +++ b/projects/hdc-licences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PrisonManager.kt @@ -1,12 +1,8 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Entity @Immutable @@ -25,8 +21,10 @@ class PrisonManager( val staff: StaffEntity, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true ) diff --git a/projects/hdc-licences-and-delius/src/main/resources/application.yml b/projects/hdc-licences-and-delius/src/main/resources/application.yml index b509423485..7a8d23df59 100644 --- a/projects/hdc-licences-and-delius/src/main/resources/application.yml +++ b/projects/hdc-licences-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -52,7 +50,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/hmpps-auth-and-delius/src/main/resources/application.yml b/projects/hmpps-auth-and-delius/src/main/resources/application.yml index d804ef5347..aec71b4d6b 100644 --- a/projects/hmpps-auth-and-delius/src/main/resources/application.yml +++ b/projects/hmpps-auth-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -53,7 +51,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/ims-and-delius/src/main/resources/application.yml b/projects/ims-and-delius/src/main/resources/application.yml index d00b4a9084..9f8e7082e2 100644 --- a/projects/ims-and-delius/src/main/resources/application.yml +++ b/projects/ims-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -51,7 +49,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/justice-email-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/justice-email-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 161b2e216c..53fe2e05ee 100644 --- a/projects/justice-email-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/justice-email-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -11,7 +11,7 @@ import org.mockito.kotlin.eq import org.mockito.kotlin.verify import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.Data import uk.gov.justice.digital.hmpps.entity.Contact import uk.gov.justice.digital.hmpps.entity.ContactRepository @@ -31,7 +31,7 @@ internal class IntegrationTest { @Autowired lateinit var contactRepository: ContactRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt index 41085d1686..07d0c683d4 100644 --- a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt +++ b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -49,6 +50,7 @@ class Contact( val startTime: ZonedDateTime = ZonedDateTime.now(), @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt index 99626d8301..187963b2f2 100644 --- a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt +++ b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -29,9 +30,11 @@ class PersonManager( val providerId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/justice-email-and-delius/src/main/resources/application.yml b/projects/justice-email-and-delius/src/main/resources/application.yml index 1d59bfc682..65f9253687 100644 --- a/projects/justice-email-and-delius/src/main/resources/application.yml +++ b/projects/justice-email-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE diff --git a/projects/make-recall-decisions-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/RecommendationIntegrationTest.kt b/projects/make-recall-decisions-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/RecommendationIntegrationTest.kt index 6d358676c4..1144f948c7 100644 --- a/projects/make-recall-decisions-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/RecommendationIntegrationTest.kt +++ b/projects/make-recall-decisions-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/RecommendationIntegrationTest.kt @@ -11,7 +11,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.UserGenerator import uk.gov.justice.digital.hmpps.integrations.delius.recommendation.contact.entity.Contact @@ -33,7 +33,7 @@ internal class RecommendationIntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Address.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Address.kt index c63c8337da..d0ba664b79 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Address.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Address.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.casesummary -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -55,6 +50,7 @@ class Address( val noFixedAbode: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Contact.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Contact.kt index e88b5bf7f4..4d181339fd 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Contact.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Contact.kt @@ -1,18 +1,11 @@ package uk.gov.justice.digital.hmpps.integrations.delius.casesummary -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.NotFound import org.hibernate.annotations.NotFoundAction import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -61,6 +54,7 @@ class Contact( val sensitive: Boolean?, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -79,6 +73,7 @@ class ContactType( val description: String, @Column(name = "sgc_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val systemGenerated: Boolean ) @@ -124,6 +119,7 @@ class ContactDocument( val tableName: String = "CONTACT", @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Event.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Event.kt index 4d3e65e27d..2efa983bb6 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Event.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Event.kt @@ -1,17 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.casesummary -import jakarta.persistence.CascadeType -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData @@ -42,9 +34,11 @@ class Event( val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -89,9 +83,11 @@ class Disposal( val licenceConditions: List = emptyList(), @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -133,6 +129,7 @@ class Custody( val licenceExpiryDate: Set = emptySet(), @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -157,6 +154,7 @@ class KeyDate( var date: LocalDate, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -181,6 +179,7 @@ class MainOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -205,6 +204,7 @@ class AdditionalOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -252,9 +252,11 @@ class LicenceCondition( val notes: String?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Person.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Person.kt index ead7b94b53..5c592316a8 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Person.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Person.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.casesummary -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -66,6 +62,7 @@ class Person( val primaryLanguage: ReferenceData? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/PersonManager.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/PersonManager.kt index edf53836e4..5fab4d38bf 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/PersonManager.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/PersonManager.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.casesummary -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.Provider @@ -37,9 +33,11 @@ class PersonManager( val provider: Provider, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true ) diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Registration.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Registration.kt index b2cb29c291..3651a6ec6c 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Registration.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Registration.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.casesummary -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -45,9 +41,11 @@ class Registration( val date: LocalDate, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deregistered: Boolean = false ) diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Release.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Release.kt index a3662c9216..9707e6d1fd 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Release.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/casesummary/Release.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.casesummary import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import java.time.LocalDate @@ -30,6 +31,7 @@ class Release( val institution: Institution? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -50,6 +52,7 @@ class Recall( val release: Release, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Document.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Document.kt index 80b771376c..3ff97f9e29 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Document.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/Document.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.document.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.Instant import java.time.ZonedDateTime @@ -47,6 +48,7 @@ class DocumentEntity( val lastUpdatedUserId: Long, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id @@ -79,5 +81,6 @@ class Person( val crn: String, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recommendation/contact/entity/Contact.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recommendation/contact/entity/Contact.kt index c5e0f2fabd..af1ee4b6a4 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recommendation/contact/entity/Contact.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recommendation/contact/entity/Contact.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.recommendation.contact. import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -57,6 +58,7 @@ class Contact( val alert: Boolean? = false, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false, @Column(name = "row_version") diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recommendation/person/entity/Person.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recommendation/person/entity/Person.kt index fca1bd9c9b..d6a3b6b6fe 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recommendation/person/entity/Person.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recommendation/person/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.recommendation.person.e import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData @Immutable @@ -17,7 +18,8 @@ class Person( @Column(columnDefinition = "CHAR(7)") val crn: String, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @OneToOne(mappedBy = "person") @@ -51,6 +53,7 @@ class PersonManager( val staffId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true ) @@ -67,7 +70,8 @@ class AdditionalIdentifier( @Column(name = "identifier") val mergedFromCrn: String, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @ManyToOne diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/user/access/entity/Person.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/user/access/entity/Person.kt index 7dd896c6d8..6e35e194b2 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/user/access/entity/Person.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/user/access/entity/Person.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.user.access.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.ZonedDateTime @Immutable @@ -36,6 +31,7 @@ class Person( val restrictionMessage: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/make-recall-decisions-and-delius/src/main/resources/application.yml b/projects/make-recall-decisions-and-delius/src/main/resources/application.yml index 430830dd16..bc5b955aa9 100644 --- a/projects/make-recall-decisions-and-delius/src/main/resources/application.yml +++ b/projects/make-recall-decisions-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -63,7 +61,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue diff --git a/projects/manage-offences-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/DataGenerator.kt b/projects/manage-offences-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/DataGenerator.kt index c0b70142c8..a3a84e36df 100644 --- a/projects/manage-offences-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/DataGenerator.kt +++ b/projects/manage-offences-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/DataGenerator.kt @@ -11,7 +11,6 @@ object DataGenerator { val COURT_CATEGORY = ReferenceData(IdGenerator.getAndIncrement(), "CS", "Summary Non-motoring", COURT_CATEGORY_SET) val EXISTING_DETAILED_OFFENCE = DetailedOffence( - id = IdGenerator.getAndIncrement(), code = "AB06001", description = "Obstruct person acting in execution of the regulations - 09155", category = COURT_CATEGORY, @@ -48,8 +47,7 @@ object DataGenerator { form20Code: String? = null, schedule15SexualOffence: Boolean? = false, schedule15ViolentOffence: Boolean? = false, - childAbduction: Boolean? = false, - id: Long = IdGenerator.getAndIncrement() + childAbduction: Boolean? = false ) = ReferenceOffence( code, description, @@ -63,7 +61,6 @@ object DataGenerator { form20Code, schedule15SexualOffence, schedule15ViolentOffence, - childAbduction, - id + childAbduction ) } diff --git a/projects/manage-offences-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/manage-offences-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 79024f7710..43a4431962 100644 --- a/projects/manage-offences-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/manage-offences-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -8,7 +8,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.entity.OffenceRepository import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager @@ -23,7 +23,7 @@ internal class IntegrationTest { @Autowired lateinit var channelManager: HmppsChannelManager - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailedOffence.kt b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailedOffence.kt index ff1e5f13d7..92255e27cf 100644 --- a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailedOffence.kt +++ b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailedOffence.kt @@ -1,17 +1,7 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue +import jakarta.persistence.* import jakarta.persistence.GenerationType.SEQUENCE -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -26,15 +16,6 @@ import java.time.ZonedDateTime @EntityListeners(AuditingEntityListener::class) @SequenceGenerator(name = "detailed_offence_id_seq", sequenceName = "detailed_offence_id_seq", allocationSize = 1) class DetailedOffence( - @Id - @Column(name = "detailed_offence_id") - @GeneratedValue(strategy = SEQUENCE, generator = "detailed_offence_id_seq") - val id: Long = 0, - - @Version - @Column(name = "row_version") - var version: Long = 0, - @Column(name = "cja_code", columnDefinition = "varchar2(10)") var code: String, // Criminal Justice System code @@ -61,7 +42,7 @@ class DetailedOffence( @ManyToOne @JoinColumn(name = "court_category_id") - var category: ReferenceData, + var category: ReferenceData?, @Convert(converter = YesNoConverter::class) @Column(name = "schedule15_sexual_offence") @@ -85,5 +66,14 @@ class DetailedOffence( var createdDatetime: ZonedDateTime? = null, @LastModifiedDate - var lastUpdatedDatetime: ZonedDateTime? = null + var lastUpdatedDatetime: ZonedDateTime? = null, + + @Id + @Column(name = "detailed_offence_id") + @GeneratedValue(strategy = SEQUENCE, generator = "detailed_offence_id_seq") + val id: Long? = null, + + @Version + @Column(name = "row_version") + var version: Long = 0, ) diff --git a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ReferenceOffence.kt b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ReferenceOffence.kt index b7daece06f..043817eaf3 100644 --- a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ReferenceOffence.kt +++ b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ReferenceOffence.kt @@ -56,7 +56,7 @@ class ReferenceOffence( @Id @GeneratedValue(strategy = SEQUENCE, generator = "offence_id_seq") @Column(name = "offence_id") - val id: Long = 0 + val id: Long? = null ) { @Version diff --git a/projects/manage-offences-and-delius/src/main/resources/application.yml b/projects/manage-offences-and-delius/src/main/resources/application.yml index 73194bdcad..bb96d7f54e 100644 --- a/projects/manage-offences-and-delius/src/main/resources/application.yml +++ b/projects/manage-offences-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -50,7 +48,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue diff --git a/projects/manage-offences-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/OffenceServiceTest.kt b/projects/manage-offences-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/OffenceServiceTest.kt index d9f336bd60..74faecf075 100644 --- a/projects/manage-offences-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/OffenceServiceTest.kt +++ b/projects/manage-offences-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/OffenceServiceTest.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.service import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo +import org.hamcrest.Matchers.nullValue import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.extension.ExtendWith @@ -60,12 +61,12 @@ internal class OffenceServiceTest { offenceService.createOffence(offence) verify(detailedOffenceRepository).save(check { - assertThat(it.id, equalTo(0)) + assertThat(it.id, nullValue()) assertThat(it.code, equalTo(offence.code)) assertThat(it.category, equalTo(COURT_CATEGORY)) }) verify(offenceRepository).save(check { - assertThat(it.id, equalTo(0)) + assertThat(it.id, nullValue()) assertThat(it.code, equalTo(offence.homeOfficeCode)) assertThat(it.description, equalTo("${offence.homeOfficeDescription} - ${offence.homeOfficeCode}")) assertThat(it.mainCategoryCode, equalTo(HIGH_LEVEL_OFFENCE.mainCategoryCode)) diff --git a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt index 94bbd7484a..0af8f57432 100644 --- a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt +++ b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt @@ -17,9 +17,9 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.boot.test.mock.mockito.SpyBean import org.springframework.data.repository.findByIdOrNull +import org.springframework.test.context.bean.override.mockito.MockitoBean +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.ProviderGenerator import uk.gov.justice.digital.hmpps.entity.PrisonStaff @@ -45,13 +45,13 @@ internal class AllocationMessagingIntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService - @SpyBean + @MockitoSpyBean lateinit var staffRepository: PrisonStaffRepository - @SpyBean + @MockitoSpyBean lateinit var prisonManagerRepository: PrisonManagerRepository @Autowired diff --git a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/HandoverMessagingIntegrationTest.kt b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/HandoverMessagingIntegrationTest.kt index 513cea3632..6751611d1f 100644 --- a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/HandoverMessagingIntegrationTest.kt +++ b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/HandoverMessagingIntegrationTest.kt @@ -10,7 +10,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.integrations.delius.allocation.entity.event.CustodyRepository @@ -39,7 +39,7 @@ internal class HandoverMessagingIntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/Event.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/Event.kt index 523aa474d5..5b3a0e0a35 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/Event.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/Event.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.allocation.entity.event import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository @Immutable @@ -59,6 +60,7 @@ class Custody( val disposal: Disposal, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/keydate/KeyDate.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/keydate/KeyDate.kt index ffa56138e1..fa57d9f66b 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/keydate/KeyDate.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/keydate/KeyDate.kt @@ -1,16 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.allocation.entity.event.keydate -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -47,6 +39,7 @@ class KeyDate( val partitionAreaId = 0 @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false @Column(name = "row_version") diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt index 1da94c78fb..688ef807a4 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt @@ -1,18 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -51,6 +41,7 @@ class Contact( val staffId: Long, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt index 59fae31e1b..319d40fd45 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Lock @@ -32,6 +33,7 @@ class Person( val currentTier: ReferenceData? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @OneToMany(mappedBy = "person") @@ -69,9 +71,11 @@ class PersonManager( override val probationArea: ProbationArea, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/registration/entity/Registration.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/registration/entity/Registration.kt index c5cbe78180..0affbea196 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/registration/entity/Registration.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/registration/entity/Registration.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity.registrat import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.domain.Page import org.springframework.data.domain.PageRequest import org.springframework.data.domain.Pageable @@ -42,9 +43,11 @@ class Registration( val category: ReferenceData?, @Column(name = "deregistered", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deRegistered: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Column(name = "created_datetime") diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/PrisonManager.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/PrisonManager.kt index e637c92adf..ea3c1f1115 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/PrisonManager.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/PrisonManager.kt @@ -1,19 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.provider.entity -import jakarta.persistence.CascadeType -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.FetchType -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -71,6 +59,7 @@ class PrisonManager( val responsibleOfficers: MutableList = mutableListOf(), @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) : Manager { @Column @@ -82,6 +71,7 @@ class PrisonManager( } @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true @CreatedBy diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Staff.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Staff.kt index ba1eac7eb9..d14ebf38ed 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Staff.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/provider/entity/Staff.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.provider.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -40,7 +41,8 @@ class Staff( ) { fun isUnallocated() = code.endsWith("U") - @Column(name = "private", columnDefinition = "NUMBER", nullable = false) + @Column(name = "private", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var privateStaff: Boolean = false @CreatedDate diff --git a/projects/manage-pom-cases-and-delius/src/main/resources/application.yml b/projects/manage-pom-cases-and-delius/src/main/resources/application.yml index ae30966362..4faf99dc02 100644 --- a/projects/manage-pom-cases-and-delius/src/main/resources/application.yml +++ b/projects/manage-pom-cases-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -59,7 +57,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging: consumer.queue: message-queue diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/compliance/Nsi.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/compliance/Nsi.kt index b8512e04d6..4da0beee4c 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/compliance/Nsi.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/compliance/Nsi.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.compliance import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import java.time.LocalDate @@ -37,9 +38,11 @@ class Nsi( val id: Long = 0, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) { fun startDate(): LocalDate? = actualStartDate ?: expectedStartDate diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt index 09166db7aa..ad5138175b 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.overview.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -95,7 +96,8 @@ class Contact( @JoinColumn(name = "last_updated_user_id") val lastUpdatedUser: User, - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, val partitionAreaId: Long = 0 @@ -156,6 +158,7 @@ class ContactType( val categories: List = emptyList(), @Column(name = "sgc_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val systemGenerated: Boolean = false, @Column(name = "national_standards_contact") diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Disability.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Disability.kt index 312266bcdb..501d6e1caf 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Disability.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Disability.kt @@ -5,6 +5,7 @@ import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.user.entity.User @@ -42,6 +43,7 @@ class Disability( val finishDate: LocalDate? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Event.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Event.kt index 61ff39be88..29219dec8a 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Event.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Event.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.overview.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData @@ -33,12 +34,14 @@ class Event( val eventNumber: String, @Column(name = "in_breach", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val inBreach: Boolean, @OneToOne(mappedBy = "event") val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @OneToOne(mappedBy = "event") @@ -51,6 +54,7 @@ class Event( val notes: String?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "created_datetime") @@ -110,9 +114,11 @@ class Disposal( val terminationDate: LocalDate? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -167,6 +173,7 @@ class MainOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -194,6 +201,7 @@ class AdditionalOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt index e458d10379..cd076453ef 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.overview.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -82,6 +83,7 @@ class Person( val requiresInterpreter: Boolean? = false, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/PersonalCircumstance.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/PersonalCircumstance.kt index 1d37af9eb8..7f012bdb99 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/PersonalCircumstance.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/PersonalCircumstance.kt @@ -5,6 +5,7 @@ import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -51,6 +52,7 @@ class PersonalCircumstance( val endDate: LocalDate? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Provision.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Provision.kt index da7b912d83..5459e150c9 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Provision.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Provision.kt @@ -5,6 +5,7 @@ import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.user.entity.User @@ -42,6 +43,7 @@ class Provision( val finishDate: LocalDate? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Registration.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Registration.kt index a4ab486798..4f68ea329b 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Registration.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Registration.kt @@ -5,6 +5,7 @@ import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository @Immutable @@ -22,9 +23,11 @@ class Registration( val type: RegisterType, @Column(name = "deregistered", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deRegistered: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Requirement.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Requirement.kt index de094edf77..e7f6e9b142 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Requirement.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Requirement.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.overview.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.api.model.overview.Rar @@ -45,10 +46,12 @@ class Requirement( @JoinColumn(name = "rqmnt_type_main_category_id") val mainCategory: RequirementMainCategory?, - @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false) + @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(columnDefinition = "NUMBER") + @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Address.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Address.kt index a002f5f2fe..7cc6fd985b 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Address.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Address.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.personalDetails.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -53,6 +54,7 @@ class PersonAddress( val lastUpdatedUser: User, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Lob @@ -94,6 +96,7 @@ class ContactAddress( @JoinColumn(name = "last_updated_user_id") val lastUpdatedUser: User, - @Column(columnDefinition = "NUMBER") + @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) \ No newline at end of file diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/PersonalContactEntity.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/PersonalContactEntity.kt index deb159c665..e322d96d21 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/PersonalContactEntity.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/PersonalContactEntity.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.personalDetails.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -67,6 +68,7 @@ class PersonalContactEntity( val notes: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/risk/Registration.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/risk/Registration.kt index 5159405673..1b8c462bb8 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/risk/Registration.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/risk/Registration.kt @@ -5,6 +5,7 @@ import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -29,6 +30,7 @@ class RiskFlag( val type: RegisterType, @Column(name = "deregistered", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deRegistered: Boolean, @Column(name = "registration_notes", columnDefinition = "clob") @@ -52,6 +54,7 @@ class RiskFlag( val reviews: List = emptyList(), @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -89,6 +92,7 @@ class RegistrationReview( val completed: Boolean?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Column(name = "created_datetime") @@ -123,6 +127,7 @@ class DeRegistration( val staff: Staff, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/AdditionalSentence.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/AdditionalSentence.kt index d10b3dd85b..efe9ab1036 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/AdditionalSentence.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/AdditionalSentence.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Event import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData @@ -26,6 +27,7 @@ class AdditionalSentence( val notes: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @ManyToOne diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Appointment.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Appointment.kt index 18e67ba657..1bf5fe7fe2 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Appointment.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Appointment.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -67,7 +68,8 @@ class Appointment( val licConditionId: Long? = null, - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/CourtAppearance.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/CourtAppearance.kt index f6428ec223..3f78022434 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/CourtAppearance.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/CourtAppearance.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Event import java.time.LocalDate @@ -25,6 +26,7 @@ class CourtAppearance( @JoinColumn(name = "event_id") val event: Event, - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Custody.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Custody.kt index 7d85ad6981..cb316af2c6 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Custody.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/Custody.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.Disposal import java.time.ZonedDateTime @@ -26,6 +27,7 @@ class Custody( val releases: List = listOf(), @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) { fun mostRecentRelease() = releases.maxWithOrNull(compareBy({ it.date }, { it.createdDateTime })) @@ -54,5 +56,6 @@ class Release( val createdDateTime: ZonedDateTime, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt index ab181801d0..3d44b5b54d 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData @@ -38,9 +39,11 @@ class LicenceCondition( val notes: String?, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/OffenderManager.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/OffenderManager.kt index c6073acd28..b4650da728 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/OffenderManager.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/OffenderManager.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -38,9 +39,11 @@ class OffenderManager( val endDate: LocalDate?, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, ) diff --git a/projects/manage-supervision-and-delius/src/main/resources/application.yml b/projects/manage-supervision-and-delius/src/main/resources/application.yml index 4992fe5e6a..87d1ca16b4 100644 --- a/projects/manage-supervision-and-delius/src/main/resources/application.yml +++ b/projects/manage-supervision-and-delius/src/main/resources/application.yml @@ -1,12 +1,10 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: order_by: @@ -55,7 +53,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/manage-supervision-and-oasys/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/manage-supervision-and-oasys/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index c8bccb62ee..5a2e02cfc5 100644 --- a/projects/manage-supervision-and-oasys/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/manage-supervision-and-oasys/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -6,12 +6,12 @@ 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.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken import uk.gov.justice.digital.hmpps.telemetry.TelemetryService +import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @AutoConfigureMockMvc @SpringBootTest(webEnvironment = RANDOM_PORT) @@ -22,7 +22,7 @@ internal class IntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/manage-supervision-and-oasys/src/main/resources/application.yml b/projects/manage-supervision-and-oasys/src/main/resources/application.yml index e0fe29163f..7569f33d96 100644 --- a/projects/manage-supervision-and-oasys/src/main/resources/application.yml +++ b/projects/manage-supervision-and-oasys/src/main/resources/application.yml @@ -1,5 +1,4 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null @@ -34,7 +33,7 @@ info.productId: HMPPS518 # https://developer-portal.hmpps.service.justice.gov.uk spring.config.activate.on-profile: [ "dev", "integration-test" ] server.shutdown: immediate -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true integrations: ords: diff --git a/projects/oasys-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/oasys-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index fb4fcc85e2..25fb91da4b 100644 --- a/projects/oasys-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/oasys-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -12,7 +12,7 @@ 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.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -32,7 +32,7 @@ internal class IntegrationTest { @Autowired lateinit var mockMvc: MockMvc - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/person/entity/Person.kt b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/person/entity/Person.kt index d714072d72..f8ae6f8e07 100644 --- a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/person/entity/Person.kt +++ b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/person/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -19,6 +20,7 @@ class Person( val crn: String, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -78,6 +80,7 @@ class PersonDetail( val religion: ReferenceData?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/person/entity/PersonAddress.kt b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/person/entity/PersonAddress.kt index 4ce1066f8c..2a4dfea69d 100644 --- a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/person/entity/PersonAddress.kt +++ b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/person/entity/PersonAddress.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -41,6 +42,7 @@ class PersonAddress( val endDate: LocalDate?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/provider/entity/Institution.kt b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/provider/entity/Institution.kt index f2d879e95b..54bc5f2bad 100644 --- a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/provider/entity/Institution.kt +++ b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/provider/entity/Institution.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.provider.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import uk.gov.justice.digital.hmpps.integration.delius.reference.entity.ReferenceData @@ -26,6 +27,7 @@ class Institution( val establishment: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val private: Boolean?, @Id diff --git a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/registration/entity/Registration.kt b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/registration/entity/Registration.kt index 6cace2a8a4..cbbedd4045 100644 --- a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/registration/entity/Registration.kt +++ b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/registration/entity/Registration.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.registration.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -57,9 +58,11 @@ class Registration( val reviews: List, @Column(name = "deregistered", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deRegistered: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Column(name = "created_datetime") @@ -127,6 +130,7 @@ class RegistrationReview( val completed: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Column(name = "created_datetime") diff --git a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/sentence.entity/Sentence.kt b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/sentence.entity/Sentence.kt index a6c694ed1c..9d96ac4761 100644 --- a/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/sentence.entity/Sentence.kt +++ b/projects/oasys-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/sentence.entity/Sentence.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.sentence.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integration.delius.person.entity.Person import uk.gov.justice.digital.hmpps.integration.delius.provider.entity.Institution @@ -30,6 +31,7 @@ class Custody( val releases: List = listOf(), @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -49,9 +51,11 @@ class Disposal( val event: Event, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -72,9 +76,11 @@ class Event( val disposal: Disposal?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -109,6 +115,7 @@ class Release( val recall: Recall?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Column(name = "created_datetime") @@ -139,6 +146,7 @@ class Recall( val notes: String?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/oasys-and-delius/src/main/resources/application.yml b/projects/oasys-and-delius/src/main/resources/application.yml index 7e8f59a6a4..83387bf082 100644 --- a/projects/oasys-and-delius/src/main/resources/application.yml +++ b/projects/oasys-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -43,7 +41,7 @@ spring: jpa.hibernate.ddl-auto: create-drop seed.database: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/offender-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/offender-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index b516699c74..d0ebda31d9 100644 --- a/projects/offender-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/offender-events-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -10,8 +10,8 @@ import org.mockito.kotlin.* import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.boot.test.mock.mockito.SpyBean +import org.springframework.test.context.bean.override.mockito.MockitoBean +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean import uk.gov.justice.digital.hmpps.data.generator.OffenderDeltaGenerator import uk.gov.justice.digital.hmpps.integrations.delius.offender.OffenderDelta import uk.gov.justice.digital.hmpps.integrations.delius.offender.OffenderDeltaRepository @@ -30,10 +30,10 @@ internal class IntegrationTest { @Autowired lateinit var offenderDeltaRepository: OffenderDeltaRepository - @SpyBean + @MockitoSpyBean lateinit var offenderDeltaService: OffenderDeltaService - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @ParameterizedTest diff --git a/projects/offender-events-and-delius/src/main/resources/application.yml b/projects/offender-events-and-delius/src/main/resources/application.yml index 02583ab57c..a90f2bb99b 100644 --- a/projects/offender-events-and-delius/src/main/resources/application.yml +++ b/projects/offender-events-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE diff --git a/projects/opd-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/OpdIntegrationTest.kt b/projects/opd-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/OpdIntegrationTest.kt index 0016d6aa65..28799e8942 100644 --- a/projects/opd-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/OpdIntegrationTest.kt +++ b/projects/opd-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/OpdIntegrationTest.kt @@ -13,7 +13,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactType @@ -32,7 +32,7 @@ internal class OpdIntegrationTest { @Autowired lateinit var channelManager: HmppsChannelManager - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact.entity/Contact.kt b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact.entity/Contact.kt index 6c2035f25b..97b8ac446d 100644 --- a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact.entity/Contact.kt +++ b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact.entity/Contact.kt @@ -1,18 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -52,6 +42,7 @@ class Contact( val staffId: Long, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt index 1dbb03ace9..31a14a8de8 100644 --- a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt +++ b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt @@ -1,12 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository @Immutable @@ -19,9 +16,11 @@ class Event( val person: Person, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Nsi.kt b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Nsi.kt index 5d7f7c9aaf..dc94731e54 100644 --- a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Nsi.kt +++ b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Nsi.kt @@ -1,19 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -61,9 +51,11 @@ class Nsi( val intendedProviderId: Long? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val pendingTransfer: Boolean = false, @Id @@ -92,6 +84,7 @@ class Nsi( private set @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true private set @@ -129,9 +122,11 @@ class NsiManager( val startDate: ZonedDateTime, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column diff --git a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt index a9fab81ef6..e26d9adefd 100644 --- a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt +++ b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -20,6 +21,7 @@ class Person( val nomsId: String?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -46,9 +48,11 @@ class PersonManager( val staffId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/opd-and-delius/src/main/resources/application.yml b/projects/opd-and-delius/src/main/resources/application.yml index 01cac76996..1de9e85c83 100644 --- a/projects/opd-and-delius/src/main/resources/application.yml +++ b/projects/opd-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -40,7 +38,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue diff --git a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ConvictionEventEntity.kt b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ConvictionEventEntity.kt index e2206f45bf..65a85b0055 100644 --- a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ConvictionEventEntity.kt +++ b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ConvictionEventEntity.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.domain.PageRequest import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -36,9 +37,11 @@ class ConvictionEventEntity( val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -58,6 +61,7 @@ class ConvictionEventPerson( val nomsNumber: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -92,9 +96,11 @@ class Disposal( val custody: Custody? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) { fun expectedEndDate() = enteredEndDate ?: notionalEndDate @@ -130,6 +136,7 @@ class MainOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -151,6 +158,7 @@ class AdditionalOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -193,6 +201,7 @@ class ConvictionCourtAppearanceEntity( val appearanceDate: LocalDate, @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearanceEntity.kt b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearanceEntity.kt index 039db2482f..875c6b90d1 100644 --- a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearanceEntity.kt +++ b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearanceEntity.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.LocalDate @@ -48,7 +49,8 @@ class CourtAppearanceEntity( @ManyToOne val court: Court, - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -66,9 +68,11 @@ class CourtAppearanceEventEntity( val courtAppearancePerson: CourtAppearancePerson, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -88,6 +92,7 @@ class CourtAppearancePerson( val nomsNumber: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailEntity.kt b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailEntity.kt index f454a88ca6..54bb06c3ac 100644 --- a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailEntity.kt +++ b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailEntity.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -57,9 +58,11 @@ class DetailPerson( val thirdName: String? = null, @Column(name = "current_disposal", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentDisposal: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -90,6 +93,7 @@ class PersonManager( val team: Team, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true ) @@ -196,6 +200,7 @@ class PersonAlias( val gender: ReferenceData, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/KeyDate.kt b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/KeyDate.kt index bae9287845..6407cba525 100644 --- a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/KeyDate.kt +++ b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/KeyDate.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.LocalDate @@ -33,6 +34,7 @@ class Custody( val disposal: Disposal, @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -56,6 +58,7 @@ class KeyDate( var date: LocalDate, @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt index a2f2b8aa7b..6e02a3f0ef 100644 --- a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt +++ b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.LocalDate @@ -29,9 +30,11 @@ class Nsi( val eventId: Long? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Release.kt b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Release.kt index ca1f76badc..ff0ce7df2d 100644 --- a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Release.kt +++ b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Release.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import java.time.LocalDate @@ -40,6 +35,7 @@ class DetailRelease( val date: LocalDate, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -76,6 +72,7 @@ class Recall( val reason: RecallReason, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/pathfinder-and-delius/src/main/resources/application.yml b/projects/pathfinder-and-delius/src/main/resources/application.yml index 29eb87ec22..4dc6c376af 100644 --- a/projects/pathfinder-and-delius/src/main/resources/application.yml +++ b/projects/pathfinder-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -52,7 +50,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrCompletedIntegrationTest.kt b/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrCompletedIntegrationTest.kt index 42e39b21c4..a8f0012443 100644 --- a/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrCompletedIntegrationTest.kt +++ b/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrCompletedIntegrationTest.kt @@ -10,8 +10,8 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.boot.test.mock.mockito.SpyBean +import org.springframework.test.context.bean.override.mockito.MockitoBean +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean import uk.gov.justice.digital.hmpps.data.generator.DocumentGenerator import uk.gov.justice.digital.hmpps.integrations.alfresco.AlfrescoUploadClient import uk.gov.justice.digital.hmpps.integrations.delius.document.DocumentRepository @@ -28,7 +28,7 @@ class PsrCompletedIntegrationTest { @Autowired private lateinit var channelManager: HmppsChannelManager - @MockBean + @MockitoBean private lateinit var telemetryService: TelemetryService @Autowired @@ -37,7 +37,7 @@ class PsrCompletedIntegrationTest { @Autowired private lateinit var documentRepository: DocumentRepository - @SpyBean + @MockitoSpyBean private lateinit var alfrescoUploadClient: AlfrescoUploadClient @Test diff --git a/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrContextIntegrationTest.kt b/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrContextIntegrationTest.kt index 998fd1e3fd..0c79161b9a 100644 --- a/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrContextIntegrationTest.kt +++ b/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrContextIntegrationTest.kt @@ -8,7 +8,7 @@ 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.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -30,7 +30,7 @@ class PsrContextIntegrationTest { @Autowired lateinit var objectMapper: ObjectMapper - @MockBean + @MockitoBean lateinit var courtReportRepository: CourtReportRepository @Test diff --git a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/courtreport/CourtReport.kt b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/courtreport/CourtReport.kt index 8c32d51f31..784c597fa7 100644 --- a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/courtreport/CourtReport.kt +++ b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/courtreport/CourtReport.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.courtreport -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.FetchType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.person.Person @Immutable @@ -28,6 +24,7 @@ class CourtReport( val appearance: CourtAppearance, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -44,6 +41,7 @@ class CourtAppearance( val event: Event, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -59,8 +57,10 @@ class Event( val number: String, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/Document.kt b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/Document.kt index 45022e408f..8e0e517a0a 100644 --- a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/Document.kt +++ b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/Document.kt @@ -1,10 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.document -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import java.time.ZonedDateTime @Entity @@ -51,6 +48,7 @@ class Document( var rowVersion: Long = 0, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "partition_area_id") diff --git a/projects/pre-sentence-reports-to-delius/src/main/resources/application.yml b/projects/pre-sentence-reports-to-delius/src/main/resources/application.yml index fd3cd1627a..96dbac2423 100644 --- a/projects/pre-sentence-reports-to-delius/src/main/resources/application.yml +++ b/projects/pre-sentence-reports-to-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -57,7 +55,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: pre-sentence-report-events diff --git a/projects/prison-case-notes-to-probation/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CaseNotesIntegrationTest.kt b/projects/prison-case-notes-to-probation/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CaseNotesIntegrationTest.kt index 22b124bea4..e684198bab 100644 --- a/projects/prison-case-notes-to-probation/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CaseNotesIntegrationTest.kt +++ b/projects/prison-case-notes-to-probation/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CaseNotesIntegrationTest.kt @@ -15,8 +15,8 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean -import org.springframework.boot.test.mock.mockito.SpyBean +import org.springframework.test.context.bean.override.mockito.MockitoBean +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean import uk.gov.justice.digital.hmpps.audit.repository.AuditedInteractionRepository import uk.gov.justice.digital.hmpps.data.generator.* import uk.gov.justice.digital.hmpps.datetime.DeliusDateTimeFormatter @@ -44,13 +44,13 @@ class CaseNotesIntegrationTest { @Autowired private lateinit var staffRepository: StaffRepository - @MockBean + @MockitoBean private lateinit var telemetryService: TelemetryService @Autowired lateinit var wireMockserver: WireMockServer - @SpyBean + @MockitoSpyBean lateinit var air: AuditedInteractionRepository @Test diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/CaseNote.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/CaseNote.kt index 1d65e9f0b7..661fcf35c3 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/CaseNote.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/CaseNote.kt @@ -1,20 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.Hibernate import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.LastModifiedBy @@ -96,13 +85,15 @@ data class CaseNote( @Column(updatable = false) val trustProviderTeamId: Long = teamId, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean = false, @Column(updatable = false) val partitionAreaId: Long = 0L, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false ) { override fun equals(other: Any?): Boolean { diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt index db1bba1dad..e19165fb30 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.Hibernate import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -22,10 +17,12 @@ data class Event( @OneToOne(mappedBy = "event") val disposal: Disposal? = null, - @Column(name = "active_flag", updatable = false, columnDefinition = "NUMBER") + @Column(name = "active_flag", updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false ) { override fun equals(other: Any?): Boolean { @@ -59,10 +56,12 @@ class Disposal( @JoinColumn(name = "disposal_type_id", updatable = false) val disposalType: DisposalType, - @Column(name = "active_flag", updatable = false, columnDefinition = "NUMBER") + @Column(name = "active_flag", updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Nsi.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Nsi.kt index 5fe863e7f7..5a10ee0caa 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Nsi.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Nsi.kt @@ -1,14 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EnumType -import jakarta.persistence.Enumerated -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate @Immutable @@ -27,10 +21,12 @@ class Nsi( val offenderId: Long, val eventId: Long? = null, - @Column(name = "active_flag", updatable = false, columnDefinition = "NUMBER") + @Column(name = "active_flag", updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false ) diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Offender.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Offender.kt index f7caf1c77f..c3537cf9d1 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Offender.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Offender.kt @@ -1,9 +1,11 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity import jakarta.persistence.Column +import jakarta.persistence.Convert import jakarta.persistence.Entity import jakarta.persistence.Id import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -16,6 +18,7 @@ class Offender( @Column(name = "noms_number", columnDefinition = "char(7)") val nomsId: String, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Staff.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Staff.kt index 48a5a59807..459058f7f6 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Staff.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Staff.kt @@ -1,6 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -32,7 +33,8 @@ class Staff( @Column(name = "probation_area_id") val probationAreaId: Long, - @Column(name = "private", columnDefinition = "NUMBER", nullable = false) + @Column(name = "private", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var privateStaff: Boolean = false, @Column(name = "start_date", updatable = false) diff --git a/projects/prison-case-notes-to-probation/src/main/resources/application.yml b/projects/prison-case-notes-to-probation/src/main/resources/application.yml index 38b74da5f5..6fa12bad9e 100644 --- a/projects/prison-case-notes-to-probation/src/main/resources/application.yml +++ b/projects/prison-case-notes-to-probation/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -52,7 +50,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: events diff --git a/projects/prison-custody-status-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PcstdIntegrationTestBase.kt b/projects/prison-custody-status-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PcstdIntegrationTestBase.kt index d18cbd7993..3c9474f0da 100644 --- a/projects/prison-custody-status-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PcstdIntegrationTestBase.kt +++ b/projects/prison-custody-status-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PcstdIntegrationTestBase.kt @@ -11,7 +11,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.InstitutionGenerator import uk.gov.justice.digital.hmpps.datetime.EuropeLondon import uk.gov.justice.digital.hmpps.flags.FeatureFlags @@ -83,10 +83,10 @@ open class PcstdIntegrationTestBase { @Autowired internal lateinit var licenceConditionRepository: LicenceConditionRepository - @MockBean + @MockitoBean internal lateinit var telemetryService: TelemetryService - @MockBean + @MockitoBean internal lateinit var featureFlags: FeatureFlags internal fun withBooking(booking: Booking, lastMovement: Movement = booking.lastMovement()) { diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt index 4af4ba782c..b8366d8f2d 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt @@ -1,17 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.LastModifiedBy @@ -91,6 +81,7 @@ class Contact( var lastUpdatedUserId: Long = 0, @Column(nullable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(nullable = false) diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/ContactAlert.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/ContactAlert.kt index 9809fe5f1e..8045445663 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/ContactAlert.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/ContactAlert.kt @@ -1,13 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.domain.support.AuditingEntityListener import org.springframework.data.jpa.repository.JpaRepository @@ -43,6 +37,7 @@ class ContactAlert( val personManagerId: Long, @Column(name = "trust_provider_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean = false ) diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/entity/Custody.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/entity/Custody.kt index a3ab72bd8c..d3f85cb82e 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/entity/Custody.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/entity/Custody.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.custody.entity import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -53,6 +54,7 @@ class Custody( var locationChangeDate: LocalDate?, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @OneToMany(mappedBy = "custody") diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Disposal.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Disposal.kt index 9cf8b00c2f..2f8ea670f5 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Disposal.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Disposal.kt @@ -1,13 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.custody.entity.Custody import java.time.ZonedDateTime @@ -38,10 +33,12 @@ class Disposal( @OneToOne(mappedBy = "disposal") var custody: Custody? = null, - @Column(name = "active_flag", updatable = false, columnDefinition = "NUMBER") + @Column(name = "active_flag", updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt index 787746a4e5..f4f33da14b 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt @@ -1,13 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.OneToOne -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Modifying import org.springframework.data.jpa.repository.Query @@ -32,9 +26,11 @@ class Event( var disposal: Disposal? = null, @Column(name = "active_flag", updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/OrderManager.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/OrderManager.kt index 8ec8c0f5e8..a21b5c527a 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/OrderManager.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/OrderManager.kt @@ -1,12 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException import uk.gov.justice.digital.hmpps.integrations.delius.manager.Manager @@ -33,9 +30,11 @@ class OrderManager( override val probationAreaId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) : Manager() diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceCondition.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceCondition.kt index 503de038b5..5d27d49d78 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceCondition.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceCondition.kt @@ -1,15 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.licencecondition.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -45,6 +38,7 @@ class LicenceCondition( val manager: LicenceConditionManager? = null, @Column(name = "pending_transfer", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var pendingTransfer: Boolean? = null, @ManyToOne @@ -71,6 +65,7 @@ class LicenceCondition( var lastUpdatedDatetime: ZonedDateTime = ZonedDateTime.now(), @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceConditionManager.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceConditionManager.kt index 331e417a4a..6fafa35739 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceConditionManager.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceConditionManager.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.licencecondition.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.manager.Manager @Entity @@ -33,8 +29,10 @@ class LicenceConditionManager( override val probationAreaId: Long, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) : Manager() diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceConditionTransfer.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceConditionTransfer.kt index 1d90f660eb..7769ba06fa 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceConditionTransfer.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/licencecondition/entity/LicenceConditionTransfer.kt @@ -1,15 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.licencecondition.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -84,6 +77,7 @@ class LicenceConditionTransfer( val masterTransferId: Long? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @CreatedBy diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt index 45aeafbdd3..cd24673d85 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -24,6 +25,7 @@ class Person( val nomsNumber: String, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -54,6 +56,7 @@ class AdditionalIdentifier( val name: ReferenceData, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/prison/entity/PrisonManager.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/prison/entity/PrisonManager.kt index ab56951908..c381d76bf2 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/prison/entity/PrisonManager.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/prison/entity/PrisonManager.kt @@ -1,16 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.manager.prison.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -67,9 +58,11 @@ class PrisonManager( val probationArea: ProbationArea, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true, @Column diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/probation/entity/PersonManager.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/probation/entity/PersonManager.kt index 6ba110861a..b752715f25 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/probation/entity/PersonManager.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/probation/entity/PersonManager.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.manager.probatio import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.Person @@ -39,9 +40,11 @@ class PersonManager( val probationArea: ProbationArea, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recall/entity/Recall.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recall/entity/Recall.kt index a3cd089a25..79ea6aee3d 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recall/entity/Recall.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/recall/entity/Recall.kt @@ -1,17 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.recall.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -55,6 +46,7 @@ class Recall( val partitionAreaId: Long = 0, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @CreatedBy diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/release/entity/Release.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/release/entity/Release.kt index cda595f184..2217addaf5 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/release/entity/Release.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/release/entity/Release.kt @@ -1,18 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.release.entity -import jakarta.persistence.Column -import jakarta.persistence.Embedded -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -68,6 +58,7 @@ class Release( val partitionAreaId: Long = 0, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(nullable = false, updatable = false) diff --git a/projects/prison-custody-status-to-delius/src/main/resources/application.yml b/projects/prison-custody-status-to-delius/src/main/resources/application.yml index 35f9a624ac..0bf1d0ace1 100644 --- a/projects/prison-custody-status-to-delius/src/main/resources/application.yml +++ b/projects/prison-custody-status-to-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -54,7 +52,7 @@ seed.database: true messaging.consumer.queue: prison-custody-status-events -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true integrations: prison-api: diff --git a/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CommunityManager.kt b/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CommunityManager.kt index aa5684d4c2..b74728ddbd 100644 --- a/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CommunityManager.kt +++ b/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CommunityManager.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Entity @Immutable @@ -22,8 +23,10 @@ data class CommunityManager( val staff: Staff, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true ) diff --git a/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt b/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt index 6d8dfa8834..a3002dea6a 100644 --- a/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt +++ b/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Entity @Immutable @@ -20,5 +18,6 @@ data class Person( val prisonerId: String, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/prison-education-and-delius/src/main/resources/application.yml b/projects/prison-education-and-delius/src/main/resources/application.yml index 8ffff5658f..cf925dacca 100644 --- a/projects/prison-education-and-delius/src/main/resources/application.yml +++ b/projects/prison-education-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -49,7 +47,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MergeIntegrationTest.kt b/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MergeIntegrationTest.kt index eece2daaeb..76e4d31b5f 100644 --- a/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MergeIntegrationTest.kt +++ b/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MergeIntegrationTest.kt @@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Value 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.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator.PERSON_WITH_NOMS import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.telemetry.TelemetryService @@ -25,7 +25,7 @@ internal class MergeIntegrationTest { @Autowired lateinit var channelManager: HmppsChannelManager - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PrisonMatchingIntegrationTest.kt b/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PrisonMatchingIntegrationTest.kt index 3563f038dc..fb139f96bf 100644 --- a/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PrisonMatchingIntegrationTest.kt +++ b/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PrisonMatchingIntegrationTest.kt @@ -12,9 +12,9 @@ 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.data.repository.findByIdOrNull +import org.springframework.test.context.bean.override.mockito.MockitoBean +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -33,19 +33,19 @@ internal class PrisonMatchingIntegrationTest { @Autowired lateinit var mockMvc: MockMvc - @SpyBean + @MockitoSpyBean lateinit var personRepository: PersonRepository - @SpyBean + @MockitoSpyBean lateinit var custodyRepository: CustodyRepository - @SpyBean + @MockitoSpyBean lateinit var additionalIdentifierRepository: AdditionalIdentifierRepository - @SpyBean + @MockitoSpyBean lateinit var contactRepository: ContactRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationMatchingIntegrationTest.kt b/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationMatchingIntegrationTest.kt index 32b0cb0fb8..f306cdc679 100644 --- a/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationMatchingIntegrationTest.kt +++ b/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationMatchingIntegrationTest.kt @@ -12,10 +12,9 @@ import org.springframework.beans.factory.annotation.Value 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.annotation.DirtiesContext -import org.springframework.test.context.TestPropertySource +import org.springframework.test.context.bean.override.mockito.MockitoBean +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean import uk.gov.justice.digital.hmpps.entity.AdditionalIdentifierRepository import uk.gov.justice.digital.hmpps.entity.CustodyRepository import uk.gov.justice.digital.hmpps.entity.PersonRepository @@ -35,16 +34,16 @@ internal class ProbationMatchingIntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @SpyBean + @MockitoSpyBean lateinit var personRepository: PersonRepository - @SpyBean + @MockitoSpyBean lateinit var custodyRepository: CustodyRepository - @SpyBean + @MockitoSpyBean lateinit var additionalIdentifierRepository: AdditionalIdentifierRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/AdditionalIdentifier.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/AdditionalIdentifier.kt index 29f25f46ef..84c1b7b496 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/AdditionalIdentifier.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/AdditionalIdentifier.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -34,6 +35,7 @@ class AdditionalIdentifier( val partitionAreaId: Long = 0, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt index c1c826533e..ed46978664 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -49,6 +50,7 @@ class Contact( val startTime: ZonedDateTime = ZonedDateTime.now(), @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Event.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Event.kt index 8d11adaf3c..4182d42d52 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Event.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Event.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -26,9 +27,11 @@ class Event( val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -56,9 +59,11 @@ class Disposal( val custody: Custody? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -82,6 +87,7 @@ class Custody( val disposal: Disposal, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/OrderManager.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/OrderManager.kt index 203b4d684b..fc95fd60df 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/OrderManager.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/OrderManager.kt @@ -1,10 +1,12 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.Column +import jakarta.persistence.Convert import jakarta.persistence.Entity import jakarta.persistence.Id import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -29,9 +31,11 @@ class OrderManager( val providerId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt index 0899761bb5..b8c3fe68af 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt @@ -4,6 +4,7 @@ import jakarta.persistence.* import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -70,6 +71,7 @@ class Person( val version: Long = 0, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(nullable = false, updatable = false) diff --git a/projects/prison-identifier-and-delius/src/main/resources/application.yml b/projects/prison-identifier-and-delius/src/main/resources/application.yml index 5406c0cfae..d48bf7db68 100644 --- a/projects/prison-identifier-and-delius/src/main/resources/application.yml +++ b/projects/prison-identifier-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_empty jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -59,7 +57,7 @@ messaging: producer.topic: domain-events seed.database: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true integrations: prison-api.url: http://localhost:${wiremock.port}/prison-api diff --git a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/CourtAppearance.kt b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/CourtAppearance.kt index 411b13ea0d..06ac64f67f 100644 --- a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/CourtAppearance.kt +++ b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/CourtAppearance.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.documents.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.reference.entity.ReferenceData import java.time.ZonedDateTime @@ -26,6 +27,7 @@ class CourtAppearance( val outcome: ReferenceData?, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Document.kt b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Document.kt index ae141f7f41..9b78dd4cfa 100644 --- a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Document.kt +++ b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Document.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.documents.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.Instant @@ -43,6 +41,7 @@ class DocumentEntity( val lastUpdatedUserId: Long, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Event.kt b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Event.kt index 25bbaad8b5..372f438c85 100644 --- a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Event.kt +++ b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Event.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.documents.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import uk.gov.justice.digital.hmpps.integrations.delius.reference.entity.ReferenceData import java.time.LocalDate @@ -29,9 +30,11 @@ class Event( val disposal: Disposal?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -63,9 +66,11 @@ class Disposal( val custody: Custody?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Offence.kt b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Offence.kt index 3c9e5106ad..766cc52e58 100644 --- a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Offence.kt +++ b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Offence.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.documents.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Entity @Immutable @@ -18,6 +19,7 @@ class MainOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Person.kt b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Person.kt index f4fa83097d..4863b11cdc 100644 --- a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Person.kt +++ b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/documents/entity/Person.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.documents.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -34,6 +35,7 @@ class Person( val events: List, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/manager/entity/CommunityManager.kt b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/manager/entity/CommunityManager.kt index b443c9364a..a62d2f06bd 100644 --- a/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/manager/entity/CommunityManager.kt +++ b/projects/prisoner-profile-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/manager/entity/CommunityManager.kt @@ -1,16 +1,12 @@ package uk.gov.justice.digital.hmpps.integrations.delius.manager.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException +import kotlin.jvm.Transient @Immutable @Entity @@ -31,9 +27,11 @@ class CommunityManager( val staff: Staff, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -54,6 +52,7 @@ class ManagedPerson( val nomsId: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/prisoner-profile-and-delius/src/main/resources/application.yml b/projects/prisoner-profile-and-delius/src/main/resources/application.yml index 4b6bd8537b..efa444bf2c 100644 --- a/projects/prisoner-profile-and-delius/src/main/resources/application.yml +++ b/projects/prisoner-profile-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -50,7 +48,7 @@ spring: ldap.embedded.base-dn: ${spring.ldap.base} seed.database: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/probation-search-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/probation-search-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 989c3a9355..14aab56b76 100644 --- a/projects/probation-search-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/probation-search-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -10,8 +10,8 @@ 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.bean.override.mockito.MockitoBean +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -34,10 +34,10 @@ internal class IntegrationTest { @Autowired lateinit var mockMvc: MockMvc - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService - @SpyBean + @MockitoSpyBean lateinit var air: AuditedInteractionRepository @Test diff --git a/projects/probation-search-and-delius/src/main/resources/application.yml b/projects/probation-search-and-delius/src/main/resources/application.yml index f38dc8f149..b3686a5576 100644 --- a/projects/probation-search-and-delius/src/main/resources/application.yml +++ b/projects/probation-search-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -45,7 +43,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG 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 3399dedb6b..8bcdf31708 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 @@ -13,7 +13,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean 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 @@ -47,7 +47,7 @@ internal class ReferAndMonitorIntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt index 0f7a25d807..8f15171e19 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt @@ -1,20 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -108,6 +97,7 @@ class Contact( var lastUpdatedUserId: Long = 0, @Column(nullable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, val partitionAreaId: Long = 0 @@ -136,6 +126,7 @@ class Contact( private set @Column(name = "hours_credited", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var hoursCredited: Double? = null private set @@ -276,6 +267,7 @@ class Enforcement( val partitionAreaId: Long = 0, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "row_version") diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Disposal.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Disposal.kt index 234c77eb2b..06f9063283 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Disposal.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Disposal.kt @@ -1,13 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -36,9 +31,11 @@ class Disposal( val notionalEndDate: LocalDate? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt index 9f83220861..c850f2cb0d 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/entity/Event.kt @@ -1,19 +1,14 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.exception.NotFoundException import java.time.LocalDate -import java.util.Optional +import java.util.* @Entity @Table(name = "event") @@ -31,6 +26,7 @@ class Event( var ftcCount: Long, @Column(name = "in_breach", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val inBreach: Boolean, @Column(name = "breach_end") @@ -40,9 +36,11 @@ class Event( val mainOffence: MainOffence?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -63,7 +61,8 @@ class MainOffence( @JoinColumn(name = "offence_id") val offence: Offence, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disability.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disability.kt index 9ddb207859..dce97b9d0a 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disability.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Disability.kt @@ -1,12 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceData import java.time.LocalDate @@ -33,6 +30,7 @@ class Disability( val endDate: LocalDate?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt index ce3e43f8b1..e43d67e14d 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/Person.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -32,6 +27,7 @@ class Person( val restrictionMessage: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id @@ -86,6 +82,7 @@ class PersonDetail( val disabilities: List, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PersonAddress.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PersonAddress.kt index 7f55b2677f..e62c441cd1 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PersonAddress.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/entity/PersonAddress.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -46,6 +41,7 @@ class PersonAddress( val endDate: LocalDate?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/entity/PersonManager.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/entity/PersonManager.kt index e933ea1df8..62ec8a96f9 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/entity/PersonManager.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/entity/PersonManager.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person.manager.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -39,9 +34,11 @@ class PersonManager( val responsibleOfficer: ResponsibleOfficer?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id @@ -74,9 +71,11 @@ class PrisonManager( val telephoneNumber: String?, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/referral/entity/Nsi.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/referral/entity/Nsi.kt index 23cd965d36..9517f1d6c8 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/referral/entity/Nsi.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/referral/entity/Nsi.kt @@ -1,20 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.referral.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -76,6 +65,7 @@ class Nsi( var rarCount: Long? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val pendingTransfer: Boolean = false, @Id @@ -100,9 +90,11 @@ class Nsi( var lastUpdatedUserId: Long = 0, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) { fun withManager(manager: NsiManager): Nsi { @@ -159,9 +151,11 @@ class NsiManager( var lastUpdatedUserId: Long = 0, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column @@ -220,6 +214,7 @@ class NsiStatusHistory( val notes: String? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/referral/entity/Requirement.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/referral/entity/Requirement.kt index 34b8cab415..b866c46a5f 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/referral/entity/Requirement.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/referral/entity/Requirement.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.referral.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -21,9 +22,11 @@ class Requirement( val disposalId: Long, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/refer-and-monitor-and-delius/src/main/resources/application.yml b/projects/refer-and-monitor-and-delius/src/main/resources/application.yml index 366e7d9931..54a4ccfff9 100644 --- a/projects/refer-and-monitor-and-delius/src/main/resources/application.yml +++ b/projects/refer-and-monitor-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -59,7 +57,7 @@ spring: ldap.embedded.base-dn: ${spring.ldap.base} seed.database: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true messaging.consumer.queue: message-queue diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Alert.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Alert.kt index 15b9c52755..f263edd96c 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Alert.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Alert.kt @@ -1,6 +1,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository @Entity @@ -27,6 +28,7 @@ class Alert( val personManagerId: Long, @Column(name = "trust_provider_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean = false, @Version diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Appointment.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Appointment.kt index 6c1425a5dc..271315b1f7 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Appointment.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Appointment.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -69,6 +70,7 @@ class Appointment( val outcome: AppointmentOutcome? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Version diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CaseNote.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CaseNote.kt index 20b3212572..4d1cdb3eb5 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CaseNote.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CaseNote.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.LastModifiedBy @@ -79,6 +80,7 @@ class CaseNote( val eventId: Long? = null, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt index 5b1ac1882a..1ea43b9c1c 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedDate import org.springframework.data.domain.PageRequest import org.springframework.data.jpa.repository.JpaRepository @@ -56,9 +51,11 @@ class Nsi( var createdDatetime: ZonedDateTime = ZonedDateTime.now(), @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/NsiManager.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/NsiManager.kt index 56c0852308..f62aa6becc 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/NsiManager.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/NsiManager.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -31,9 +32,11 @@ class NsiManager( val probationArea: ProbationArea, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt index 648d0b0f4f..6436e37b4e 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonManager.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -27,9 +28,11 @@ class PersonManager( val probationAreaId: Long, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Id diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Registration.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Registration.kt index 21a02208e1..54108291ed 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Registration.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Registration.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import java.time.LocalDate @@ -41,9 +37,11 @@ class Registration( val reviewDate: LocalDate?, @Column(name = "deregistered", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deRegistered: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Staff.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Staff.kt index 6b9100a01c..ea30ebe3c6 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Staff.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Staff.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -39,7 +40,8 @@ class Staff( @Column(name = "last_updated_datetime") val lastModifiedDate: ZonedDateTime = ZonedDateTime.now(), - @Column(name = "private", columnDefinition = "NUMBER", nullable = false) + @Column(name = "private", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var privateStaff: Boolean = false, @CreatedBy diff --git a/projects/resettlement-passport-and-delius/src/main/resources/application.yml b/projects/resettlement-passport-and-delius/src/main/resources/application.yml index 2012d4e11c..7996f22ae3 100644 --- a/projects/resettlement-passport-and-delius/src/main/resources/application.yml +++ b/projects/resettlement-passport-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -50,7 +48,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/risk-assessment-scores-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/risk-assessment-scores-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 0273f8214d..ae5326a8be 100644 --- a/projects/risk-assessment-scores-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/risk-assessment-scores-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -8,7 +8,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.exception.ConflictException import uk.gov.justice.digital.hmpps.integrations.delius.RiskAssessmentService @@ -36,7 +36,7 @@ internal class IntegrationTest { @Autowired private lateinit var channelManager: HmppsChannelManager - @MockBean + @MockitoBean private lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Contact.kt b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Contact.kt index b6281c2b73..30181b06f7 100644 --- a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Contact.kt +++ b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Contact.kt @@ -1,19 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -79,6 +68,7 @@ class Contact( var createdByUserId: Long = 0, @Column(nullable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(nullable = false) diff --git a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt index 2a0f77a482..e92af929cb 100644 --- a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt +++ b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Event.kt @@ -1,15 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.LockModeType -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Lock import org.springframework.data.jpa.repository.Query @@ -38,9 +32,11 @@ class Event( val mainOffence: MainOffence? = null, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) @@ -62,10 +58,12 @@ class Disposal( @Column(name = "disposal_date", nullable = false) val disposalDate: ZonedDateTime, - @Column(name = "active_flag", updatable = false, columnDefinition = "NUMBER") + @Column(name = "active_flag", updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -104,7 +102,8 @@ class MainOffence( @Column(name = "offence_count") val offenceCount: Int, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/OGRSAssessment.kt b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/OGRSAssessment.kt index f8e8c245bb..38fe090ea3 100644 --- a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/OGRSAssessment.kt +++ b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/OGRSAssessment.kt @@ -1,17 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.OneToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -64,6 +55,7 @@ class OGRSAssessment( var lastUpdatedDatetime: ZonedDateTime? = null, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column diff --git a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt index a13e52467e..26bda6d44c 100644 --- a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt +++ b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Person.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException import java.time.LocalDate @@ -44,6 +45,7 @@ class Person( val dateOfBirth: LocalDate, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column diff --git a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt index c8900a3689..535a255fe5 100644 --- a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt +++ b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/PersonManager.kt @@ -1,12 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -31,9 +27,11 @@ class PersonManager( val staff: Staff, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/risk-assessment-scores-to-delius/src/main/resources/application.yml b/projects/risk-assessment-scores-to-delius/src/main/resources/application.yml index 8a6d555bc5..220518eb20 100644 --- a/projects/risk-assessment-scores-to-delius/src/main/resources/application.yml +++ b/projects/risk-assessment-scores-to-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -42,7 +40,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue diff --git a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Contact.kt b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Contact.kt index 1ecb8b2a90..31ad7c2e1e 100644 --- a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Contact.kt +++ b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Contact.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.service.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -55,7 +56,8 @@ class Contact( @JoinColumn(name = "rqmnt_id") val requirement: Requirement? = null, - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false ) diff --git a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Custody.kt b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Custody.kt index e695ea9eae..397210ccec 100644 --- a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Custody.kt +++ b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Custody.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.service.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -26,5 +22,6 @@ class Custody( val disposal: Disposal, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Disposal.kt b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Disposal.kt index 413db8236c..20b9e82947 100644 --- a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Disposal.kt +++ b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Disposal.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.service.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.LocalDate @@ -36,9 +37,11 @@ class Disposal( val enteredSentenceEndDate: LocalDate? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) { fun expectedEndDate() = enteredSentenceEndDate ?: endDate diff --git a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Event.kt b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Event.kt index 0751969a8b..7f7a39f114 100644 --- a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Event.kt +++ b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Event.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.service.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -27,9 +23,11 @@ class Event( var disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Person.kt b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Person.kt index c69d9081ef..2eb7960e74 100644 --- a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Person.kt +++ b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Person.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.service.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException import uk.gov.justice.digital.hmpps.model.Name @@ -54,6 +49,7 @@ class Person( val tier: ReferenceData?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) { val manager @@ -87,9 +83,11 @@ class PersonManager( val team: Team, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Id diff --git a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Requirement.kt b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Requirement.kt index 8ffa2915a4..0fdf19a70f 100644 --- a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Requirement.kt +++ b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/Requirement.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.service.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -25,10 +26,12 @@ class Requirement( @JoinColumn(name = "rqmnt_type_main_category_id") val mainCategory: RequirementMainCategory?, - @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false) + @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(columnDefinition = "NUMBER") + @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/sentence-plan-and-delius/src/main/resources/application.yml b/projects/sentence-plan-and-delius/src/main/resources/application.yml index 1fd61c2024..4c9b4df97d 100644 --- a/projects/sentence-plan-and-delius/src/main/resources/application.yml +++ b/projects/sentence-plan-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -44,7 +42,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/sentence-plan-and-oasys/src/main/resources/application.yml b/projects/sentence-plan-and-oasys/src/main/resources/application.yml index d4dbbb5b8a..11c744050e 100644 --- a/projects/sentence-plan-and-oasys/src/main/resources/application.yml +++ b/projects/sentence-plan-and-oasys/src/main/resources/application.yml @@ -1,5 +1,4 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_empty @@ -25,7 +24,6 @@ spring.config.activate.on-profile: [ "dev", "integration-test" ] server.shutdown: immediate wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser ords: client-id: sentence-plan-and-oasys diff --git a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ConvictionEventEntity.kt b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ConvictionEventEntity.kt index e2206f45bf..65a85b0055 100644 --- a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ConvictionEventEntity.kt +++ b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ConvictionEventEntity.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.domain.PageRequest import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -36,9 +37,11 @@ class ConvictionEventEntity( val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -58,6 +61,7 @@ class ConvictionEventPerson( val nomsNumber: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -92,9 +96,11 @@ class Disposal( val custody: Custody? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) { fun expectedEndDate() = enteredEndDate ?: notionalEndDate @@ -130,6 +136,7 @@ class MainOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -151,6 +158,7 @@ class AdditionalOffence( val offence: Offence, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -193,6 +201,7 @@ class ConvictionCourtAppearanceEntity( val appearanceDate: LocalDate, @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearanceEntity.kt b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearanceEntity.kt index 039db2482f..875c6b90d1 100644 --- a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearanceEntity.kt +++ b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/CourtAppearanceEntity.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.LocalDate @@ -48,7 +49,8 @@ class CourtAppearanceEntity( @ManyToOne val court: Court, - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -66,9 +68,11 @@ class CourtAppearanceEventEntity( val courtAppearancePerson: CourtAppearancePerson, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -88,6 +92,7 @@ class CourtAppearancePerson( val nomsNumber: String? = null, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailEntity.kt b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailEntity.kt index f454a88ca6..54bb06c3ac 100644 --- a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailEntity.kt +++ b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/DetailEntity.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -57,9 +58,11 @@ class DetailPerson( val thirdName: String? = null, @Column(name = "current_disposal", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val currentDisposal: Boolean, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -90,6 +93,7 @@ class PersonManager( val team: Team, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true ) @@ -196,6 +200,7 @@ class PersonAlias( val gender: ReferenceData, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Id diff --git a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/KeyDate.kt b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/KeyDate.kt index a6b1475267..77ca753cee 100644 --- a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/KeyDate.kt +++ b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/KeyDate.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.LocalDate @@ -33,6 +34,7 @@ class Custody( val disposal: Disposal, @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -56,6 +58,7 @@ class KeyDate( var date: LocalDate, @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt index a2f2b8aa7b..6e02a3f0ef 100644 --- a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt +++ b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Nsi.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.LocalDate @@ -29,9 +30,11 @@ class Nsi( val eventId: Long? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Release.kt b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Release.kt index ca1f76badc..ff0ce7df2d 100644 --- a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Release.kt +++ b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Release.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import java.time.LocalDate @@ -40,6 +35,7 @@ class DetailRelease( val date: LocalDate, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -76,6 +72,7 @@ class Recall( val reason: RecallReason, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/soc-and-delius/src/main/resources/application.yml b/projects/soc-and-delius/src/main/resources/application.yml index 9232d7ccff..100fe7091c 100644 --- a/projects/soc-and-delius/src/main/resources/application.yml +++ b/projects/soc-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -44,7 +42,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/subject-access-requests-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/GetPersonByCRNIntegrationTest.kt b/projects/subject-access-requests-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/GetPersonByCRNIntegrationTest.kt index fca93c1815..281fdff434 100644 --- a/projects/subject-access-requests-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/GetPersonByCRNIntegrationTest.kt +++ b/projects/subject-access-requests-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/GetPersonByCRNIntegrationTest.kt @@ -6,7 +6,7 @@ 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.test.context.bean.override.mockito.MockitoBean 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 @@ -26,7 +26,7 @@ internal class GetPersonByCRNIntegrationTest { val crn = PERSON1.crn - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/subject-access-requests-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/UserIntegrationTest.kt b/projects/subject-access-requests-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/UserIntegrationTest.kt index b796306e8f..f15044ceb7 100644 --- a/projects/subject-access-requests-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/UserIntegrationTest.kt +++ b/projects/subject-access-requests-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/UserIntegrationTest.kt @@ -5,6 +5,7 @@ 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.test.json.JsonCompareMode import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -28,7 +29,8 @@ internal class UserIntegrationTest { User("SubjectAccessRequestsAndDelius", "Service"), User("username1", "surname1"), User("username2", "surname2") - ), strict = true + ), + JsonCompareMode.STRICT ) } } diff --git a/projects/subject-access-requests-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt b/projects/subject-access-requests-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt index b61669bec3..bb5b34ed2f 100644 --- a/projects/subject-access-requests-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt +++ b/projects/subject-access-requests-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -34,6 +32,7 @@ class Person( val surname: String, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) diff --git a/projects/subject-access-requests-and-delius/src/main/resources/application.yml b/projects/subject-access-requests-and-delius/src/main/resources/application.yml index 6eedbe51fc..28c3a6a5ed 100644 --- a/projects/subject-access-requests-and-delius/src/main/resources/application.yml +++ b/projects/subject-access-requests-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -44,7 +42,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/projects/tier-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/tier-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 0f97640fd0..221a411506 100644 --- a/projects/tier-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/tier-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -12,7 +12,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.repository.ContactDevRepository import uk.gov.justice.digital.hmpps.data.repository.ManagementTierDevRepository import uk.gov.justice.digital.hmpps.data.repository.ManagementTierWithEndDateDevRepository @@ -53,10 +53,10 @@ internal class IntegrationTest { @Autowired private lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean private lateinit var telemetryService: TelemetryService - @MockBean + @MockitoBean private lateinit var featureFlags: FeatureFlags @Test diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/CaseEntity.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/CaseEntity.kt index 4a62e151db..a0ed6b007c 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/CaseEntity.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/CaseEntity.kt @@ -1,12 +1,8 @@ package uk.gov.justice.digital.hmpps.controller.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceData @@ -25,6 +21,7 @@ class CaseEntity( val crn: String, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @ManyToOne diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/EventEntity.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/EventEntity.kt index 440d510481..797bbf9da0 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/EventEntity.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/EventEntity.kt @@ -1,15 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import java.time.LocalDate @@ -34,12 +28,14 @@ class EventEntity( val disposal: Disposal? = null, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(name = "in_breach") val inBreach: Boolean = false, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -65,9 +61,11 @@ class Disposal( val terminationDate: LocalDate? = null, @Column(name = "active_flag", updatable = false, columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(updatable = false, columnDefinition = "NUMBER") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/OASYSAssessment.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/OASYSAssessment.kt index 96d5d4ece1..112447c854 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/OASYSAssessment.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/OASYSAssessment.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate import java.time.ZonedDateTime @@ -31,6 +29,7 @@ class OASYSAssessment( override val lastModifiedDateTime: ZonedDateTime, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) : Assessment diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/OGRSAssessment.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/OGRSAssessment.kt index bd871041cd..06d0fc1bb5 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/OGRSAssessment.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/OGRSAssessment.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate import java.time.ZonedDateTime @@ -34,6 +30,7 @@ class OGRSAssessment( override val lastModifiedDateTime: ZonedDateTime, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) : Assessment diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/RegistrationEntity.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/RegistrationEntity.kt index b362c4f98a..a26d36a543 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/RegistrationEntity.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/RegistrationEntity.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.ReferenceData import java.time.LocalDate @@ -36,9 +32,11 @@ class RegistrationEntity( val date: LocalDate, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deregistered: Boolean = false ) diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/RequirementEntity.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/RequirementEntity.kt index 24f3a47967..d5bf1779dc 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/RequirementEntity.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/entity/RequirementEntity.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository @@ -29,10 +24,12 @@ class RequirementEntity( @JoinColumn(name = "rqmnt_type_main_category_id") val mainCategory: RequirementMainCategory?, - @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false) + @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt index afc9e01a8a..09c76301ef 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt @@ -1,16 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -74,6 +65,7 @@ class Contact( var lastUpdatedUserId: Long = 0, @Column(nullable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(nullable = false) diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/management/ManagementTier.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/management/ManagementTier.kt index 01b3d466dc..1814212f7a 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/management/ManagementTier.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/management/ManagementTier.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.management import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.LastModifiedBy import org.springframework.data.jpa.domain.support.AuditingEntityListener @@ -22,6 +23,7 @@ data class ManagementTier( val partitionAreaId: Long = 0L, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column @@ -53,6 +55,7 @@ data class ManagementTierWithEndDate( val partitionAreaId: Long = 0L, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nsi/entity/Nsi.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nsi/entity/Nsi.kt index b554ef0ebe..7d9b5bd0ea 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nsi/entity/Nsi.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/nsi/entity/Nsi.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.nsi.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query import uk.gov.justice.digital.hmpps.integrations.delius.nsi.EnforcementActivityCode @@ -38,6 +34,7 @@ class Nsi( val outcome: ReferenceData?, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) @@ -51,6 +48,7 @@ class NsiEvent( val id: Long, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt index 84f3d6c198..dc4c7f60f0 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt @@ -1,13 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.FetchType -import jakarta.persistence.Id -import jakarta.persistence.OneToMany -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -45,6 +40,7 @@ class Person( val version: Long = 0, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @OneToMany(mappedBy = "person", fetch = FetchType.EAGER) diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt index 9bc0e0d745..31d4624154 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt @@ -1,12 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.probationarea.ProbationArea @Entity @@ -26,8 +22,10 @@ class PersonManager( val probationArea: ProbationArea, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/tier-to-delius/src/main/resources/application.yml b/projects/tier-to-delius/src/main/resources/application.yml index 31b566ab12..e95a7a502a 100644 --- a/projects/tier-to-delius/src/main/resources/application.yml +++ b/projects/tier-to-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: # hibernate.ddl-auto: validate # TODO re-enable this after "tier-end-date" feature flag is enabled - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -56,7 +54,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue integrations.tier.url: http://localhost:${wiremock.port}/hmpps-tier diff --git a/projects/unpaid-work-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AssessmentCompleteIntegrationTest.kt b/projects/unpaid-work-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AssessmentCompleteIntegrationTest.kt index 6bcac57d34..2deca889e3 100644 --- a/projects/unpaid-work-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AssessmentCompleteIntegrationTest.kt +++ b/projects/unpaid-work-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AssessmentCompleteIntegrationTest.kt @@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Value 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.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import uk.gov.justice.digital.hmpps.data.generator.CaseGenerator import uk.gov.justice.digital.hmpps.integrations.common.entity.contact.ContactRepository @@ -42,7 +42,7 @@ internal class AssessmentCompleteIntegrationTest { @Autowired lateinit var documentRepository: DocumentRepository - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/CaseAddress.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/CaseAddress.kt index 5dc0f05598..552a03e15b 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/CaseAddress.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/CaseAddress.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.casedetails.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.common.entity.ReferenceData @Immutable @@ -33,7 +29,8 @@ class CaseAddress( val county: String?, val postcode: String?, val telephoneNumber: String?, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @ManyToOne @JoinColumn(name = "address_status_id") diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/CaseEntity.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/CaseEntity.kt index 7fd7105653..e97afef270 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/CaseEntity.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/CaseEntity.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.controller.casedetails.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import uk.gov.justice.digital.hmpps.integrations.common.entity.ReferenceData import java.time.LocalDate @@ -20,6 +21,7 @@ class CaseEntity( val crn: String, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "first_name", length = 35) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/DisabilityEntity.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/DisabilityEntity.kt index 14359eea31..7c0021acf4 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/DisabilityEntity.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/DisabilityEntity.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.casedetails.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.common.entity.ReferenceData import java.time.LocalDate @@ -42,5 +38,6 @@ class DisabilityEntity( val endDate: LocalDate? = null, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/MainOffence.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/MainOffence.kt index 65952e1fc4..20d2e63e88 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/MainOffence.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/MainOffence.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.casedetails.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate @Immutable @@ -23,7 +18,8 @@ class Event( @Column(name = "offender_id", nullable = false) val offenderId: Long, - @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false) + @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "event_number", nullable = false) @@ -35,7 +31,8 @@ class Event( @OneToOne(mappedBy = "event") val mainOffence: MainOffence? = null, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -54,10 +51,12 @@ class Disposal( val disposalDate: LocalDate, - @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false) + @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -78,7 +77,8 @@ class MainOffence( @JoinColumn(name = "offence_id") val offence: Offence, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/ProvisionEntity.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/ProvisionEntity.kt index a00b18e711..4bed34c002 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/ProvisionEntity.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/ProvisionEntity.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.casedetails.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.common.entity.ReferenceData import java.time.LocalDate @@ -42,6 +38,7 @@ class ProvisionEntity( val endDate: LocalDate? = null, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/personaldetails/entity/Person.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/personaldetails/entity/Person.kt index bc207addc7..3b65762b78 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/personaldetails/entity/Person.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/personaldetails/entity/Person.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.personaldetails.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.FetchType -import jakarta.persistence.Id -import jakarta.persistence.OneToMany -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -22,6 +18,7 @@ class Person( val crn: String, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @OneToMany(mappedBy = "person", fetch = FetchType.EAGER) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/AddressEntity.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/AddressEntity.kt index c818578d3d..deeb8dcf97 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/AddressEntity.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/AddressEntity.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.common.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -24,6 +22,7 @@ class AddressEntity( val county: String?, val postcode: String?, val telephoneNumber: String?, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/PersonalCircumstanceBase.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/PersonalCircumstanceBase.kt index 8cd1b27a2e..45dc858579 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/PersonalCircumstanceBase.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/PersonalCircumstanceBase.kt @@ -1,12 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.common.entity -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.MappedSuperclass +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import java.time.LocalDate @@ -35,6 +31,7 @@ open class PersonalCircumstanceBase( val endDate: LocalDate? = null, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Convert(converter = YesNoConverter::class) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/PersonalContactBase.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/PersonalContactBase.kt index 66ed2b25e4..95f254268b 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/PersonalContactBase.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/PersonalContactBase.kt @@ -1,11 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.common.entity -import jakarta.persistence.Column -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.MappedSuperclass +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate @MappedSuperclass @@ -44,6 +41,7 @@ open class PersonalContactBase( val endDate: LocalDate? = null, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/contact/Contact.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/contact/Contact.kt index c7aab4a148..9148d0b842 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/contact/Contact.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/contact/Contact.kt @@ -1,17 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.common.entity.contact -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate @@ -90,6 +80,7 @@ class Contact( var lastUpdatedUserId: Long = 0, @Column(nullable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(nullable = false) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/person/PersonManager.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/person/PersonManager.kt index 5ae3b0e858..43f342a8e6 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/person/PersonManager.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/person/PersonManager.kt @@ -1,12 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.common.entity.person -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.common.entity.staff.Staff import uk.gov.justice.digital.hmpps.integrations.common.entity.team.Team @@ -31,8 +27,10 @@ class PersonManager( val team: Team, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/person/PersonWithManager.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/person/PersonWithManager.kt index f1d04a5105..91075f316d 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/person/PersonWithManager.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/common/entity/person/PersonWithManager.kt @@ -1,12 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.common.entity.person -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.OneToMany -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -27,6 +24,7 @@ class PersonWithManager( val surname: String, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @OneToMany(mappedBy = "person") diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/document/Document.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/document/Document.kt index aa240d5bb4..b22b81f8ca 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/document/Document.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/document/Document.kt @@ -1,14 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.document -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table -import jakarta.persistence.Version +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -61,7 +54,8 @@ class Document( @Version var rowVersion: Long = 0, - @Column(columnDefinition = "NUMBER") + @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(columnDefinition = "char(1)") diff --git a/projects/unpaid-work-and-delius/src/main/resources/application.yml b/projects/unpaid-work-and-delius/src/main/resources/application.yml index eb9a95e550..2c8ec41af0 100644 --- a/projects/unpaid-work-and-delius/src/main/resources/application.yml +++ b/projects/unpaid-work-and-delius/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -55,7 +53,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/Custody.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/Custody.kt index 86f1c2121b..e66173a816 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/Custody.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/entity/Custody.kt @@ -1,15 +1,9 @@ package uk.gov.justice.digital.hmpps.data.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToMany -import jakarta.persistence.OneToOne -import jakarta.persistence.Version +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.Disposal import java.time.LocalDate @@ -38,6 +32,7 @@ class Custody( val disposal: Disposal, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -61,5 +56,6 @@ class KeyDate( var date: LocalDate, @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) 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 7f368f367e..95d14fb5c0 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 @@ -11,8 +11,8 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.data.repository.findByIdOrNull +import org.springframework.test.context.bean.override.mockito.MockitoBean 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 @@ -42,7 +42,7 @@ class AllocateEventIntegrationTest { @Autowired private lateinit var orderManagerRepository: OrderManagerRepository - @MockBean + @MockitoBean private lateinit var telemetryService: TelemetryService @Autowired diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocatePersonIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocatePersonIntegrationTest.kt index d8ac15c5f5..c1326d80d3 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocatePersonIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocatePersonIntegrationTest.kt @@ -10,8 +10,8 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.data.repository.findByIdOrNull +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonManagerGenerator import uk.gov.justice.digital.hmpps.data.generator.ResponsibleOfficerGenerator @@ -40,7 +40,7 @@ class AllocatePersonIntegrationTest { @Autowired private lateinit var responsibleOfficerRepository: ResponsibleOfficerRepository - @MockBean + @MockitoBean private lateinit var telemetryService: TelemetryService @Test diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateRequirementIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateRequirementIntegrationTest.kt index 4a326aadc6..88c5ef51db 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateRequirementIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateRequirementIntegrationTest.kt @@ -10,8 +10,8 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean import org.springframework.data.repository.findByIdOrNull +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.RequirementGenerator import uk.gov.justice.digital.hmpps.data.generator.RequirementManagerGenerator import uk.gov.justice.digital.hmpps.integrations.delius.event.requirement.Requirement @@ -38,7 +38,7 @@ class AllocateRequirementIntegrationTest { @Autowired private lateinit var requirementManagerRepository: RequirementManagerRepository - @MockBean + @MockitoBean private lateinit var telemetryService: TelemetryService @Test diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt index a85c7bed98..a6fe7680c4 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt @@ -8,7 +8,7 @@ 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.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean 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 @@ -29,7 +29,7 @@ class AllocationDemandIntegrationTest { @Autowired lateinit var mockMvc: MockMvc - @MockBean + @MockitoBean lateinit var allocationDemandRepository: AllocationDemandRepository @Test diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/BaseEntity.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/BaseEntity.kt index 3a29b2569a..36fd8a4dac 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/BaseEntity.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/BaseEntity.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity import jakarta.persistence.Column +import jakarta.persistence.Convert import jakarta.persistence.MappedSuperclass import jakarta.persistence.Version +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.annotation.CreatedBy import org.springframework.data.annotation.CreatedDate import org.springframework.data.annotation.LastModifiedBy @@ -12,7 +14,8 @@ import java.time.ZonedDateTime @MappedSuperclass abstract class BaseEntity { - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false @Column(name = "row_version", nullable = false) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/ManagerBaseEntity.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/ManagerBaseEntity.kt index 606a60ad08..cc95a28e8b 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/ManagerBaseEntity.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/ManagerBaseEntity.kt @@ -1,9 +1,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity -import jakarta.persistence.Column -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.MappedSuperclass +import jakarta.persistence.* +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.provider.Provider import uk.gov.justice.digital.hmpps.integrations.delius.provider.Staff import uk.gov.justice.digital.hmpps.integrations.delius.provider.Team @@ -34,7 +32,8 @@ abstract class ManagerBaseEntity : BaseEntity() { @Column(name = "allocation_date", nullable = false) lateinit var startDate: ZonedDateTime - @Column(name = "active_flag", columnDefinition = "NUMBER") + @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) var active: Boolean = true @Column(name = "end_date") diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/OrderTransfer.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/OrderTransfer.kt index 3affb32263..438b142124 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/OrderTransfer.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/OrderTransfer.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -20,6 +18,7 @@ class OrderTransfer( @Column(name = "transfer_status_id") val statusId: Long, - @Column(columnDefinition = "NUMBER", nullable = false) + @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/PersonTransfer.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/PersonTransfer.kt index 857d23c570..0a48ed1ed1 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/PersonTransfer.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/PersonTransfer.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -20,6 +18,7 @@ class PersonTransfer( @Column(name = "transfer_status_id") val statusId: Long, - @Column(columnDefinition = "NUMBER", nullable = false) + @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/RequirementTransfer.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/RequirementTransfer.kt index 05480bb7a5..9a180822d0 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/RequirementTransfer.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocations/entity/RequirementTransfer.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -20,6 +18,7 @@ class RequirementTransfer( @Column(name = "transfer_status_id") val statusId: Long, - @Column(columnDefinition = "NUMBER", nullable = false) + @Column(columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewOffence.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewOffence.kt index c1426252d2..23b9e3cf54 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewOffence.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewOffence.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.caseview -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -27,7 +23,8 @@ class CaseViewMainOffence( @JoinColumn(name = "offence_id") val offence: CaseViewOffence, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -47,7 +44,8 @@ class CaseViewAdditionalOffence( @JoinColumn(name = "offence_id") val offence: CaseViewOffence, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewPerson.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewPerson.kt index e406b18acb..1000d3a83a 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewPerson.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewPerson.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.caseview -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -41,6 +37,7 @@ class CaseViewPerson( @Column(columnDefinition = "char(13)") val pncNumber: String? = null, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewPersonAddress.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewPersonAddress.kt index de2aa53209..c5abb5e0db 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewPersonAddress.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewPersonAddress.kt @@ -1,14 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.caseview -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.ReferenceData import java.time.LocalDate @@ -45,6 +40,7 @@ class CaseViewPersonAddress( val typeVerified: Boolean? = false, val startDate: LocalDate = LocalDate.now(), val endDate: LocalDate? = null, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewRequirement.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewRequirement.kt index db26f98f1d..6c6ba32b66 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewRequirement.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewRequirement.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.caseview import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.ReferenceData @@ -39,10 +40,12 @@ class CaseViewRequirement( @SQLRestriction("active_flag = 1") val managers: List, - @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false) + @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) { fun currentManager() = managers.first() diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewSentence.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewSentence.kt index 8e4f1a2d57..332427ca41 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewSentence.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/caseview/CaseViewSentence.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.caseview -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate @Entity @@ -24,9 +20,11 @@ class CaseViewDisposal( val event: CaseViewEvent, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) @@ -46,9 +44,11 @@ class CaseViewEvent( val number: String, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt index 6eee589f60..8cdf3c13c0 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/Contact.kt @@ -1,18 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.contact -import jakarta.persistence.Column -import jakarta.persistence.Convert -import jakarta.persistence.Entity -import jakarta.persistence.EntityListeners -import jakarta.persistence.GeneratedValue -import jakarta.persistence.GenerationType -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.Lob -import jakarta.persistence.ManyToOne -import jakarta.persistence.SequenceGenerator -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.domain.support.AuditingEntityListener import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.BaseEntity @@ -70,7 +60,8 @@ class Contact( @Column(updatable = false) val trustProviderTeamId: Long = teamId, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val trustProviderFlag: Boolean = false, @Column(updatable = false) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/courtappearance/CourtAppearance.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/courtappearance/CourtAppearance.kt index fe77be80fd..0a7f441a09 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/courtappearance/CourtAppearance.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/courtappearance/CourtAppearance.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.courtappearance -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.domain.PageRequest import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -42,7 +38,8 @@ class CourtAppearance( val outcomeId: Long, - @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) + @Column(name = "soft_deleted", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) var softDeleted: Boolean = false ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocEvent.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocEvent.kt index d3789abdf3..ba4249bb01 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocEvent.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocEvent.kt @@ -1,13 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.document.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.person.Person @Immutable @@ -22,7 +17,8 @@ class DocEvent( @JoinColumn(name = "offender_id", nullable = false) val person: Person, - @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false) + @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "event_number", nullable = false) @@ -51,10 +47,12 @@ class DocDisposal( @JoinColumn(name = "disposal_type_id", updatable = false) val type: DocDisposalType, - @Column(name = "active_flag", updatable = false, columnDefinition = "NUMBER") + @Column(name = "active_flag", updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPerson.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPerson.kt index ae98ea394b..e81d4c0b35 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPerson.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/DocPerson.kt @@ -1,10 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.document.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -18,6 +16,7 @@ class DocPerson( @Column(columnDefinition = "CHAR(7)") val crn: String, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/InstitutionalReport.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/InstitutionalReport.kt index 989c08697f..9e43b55b6b 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/InstitutionalReport.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/entity/InstitutionalReport.kt @@ -1,11 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.document.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.ReferenceData import java.time.LocalDate @@ -26,7 +23,8 @@ class InstitutionalReport( @Column(name = "date_completed") val dateCompleted: LocalDate? = null, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column(name = "custody_id") diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/Event.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/Event.kt index c14ed2dee1..8d285ffd0f 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/Event.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/Event.kt @@ -1,11 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.person.Person @Immutable @@ -23,8 +20,10 @@ class Event( val person: Person, @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/ogrs/OASYSAssessment.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/ogrs/OASYSAssessment.kt index aac8c9fe8f..663141ec8b 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/ogrs/OASYSAssessment.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/ogrs/OASYSAssessment.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.ogrs -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate import java.time.ZonedDateTime @@ -34,6 +32,7 @@ class OASYSAssessment( override val lastModifiedDateTime: ZonedDateTime, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) : Assessment diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/ogrs/OGRSAssessment.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/ogrs/OGRSAssessment.kt index ebe9b03669..36d645712c 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/ogrs/OGRSAssessment.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/ogrs/OGRSAssessment.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.ogrs -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.event.Event import java.time.LocalDate import java.time.ZonedDateTime @@ -35,6 +31,7 @@ class OGRSAssessment( override val lastModifiedDateTime: ZonedDateTime, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) : Assessment diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/Requirement.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/Requirement.kt index 8b597bc9cb..e87aef67ca 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/Requirement.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/Requirement.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.requirement import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.event.sentence.Disposal import uk.gov.justice.digital.hmpps.integrations.delius.person.Person @@ -36,10 +37,12 @@ class Requirement( @JoinColumn(name = "rqmnt_type_sub_category_id") val subCategory: ReferenceData?, - @Column(name = "active_flag", columnDefinition = "NUMBER", nullable = false) + @Column(name = "active_flag", columnDefinition = "number", nullable = false) + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, - @Column(updatable = false, columnDefinition = "NUMBER") + @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/Disposal.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/Disposal.kt index 97732f41b0..fa3b00ec76 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/Disposal.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/Disposal.kt @@ -1,13 +1,8 @@ package uk.gov.justice.digital.hmpps.integrations.delius.event.sentence -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.OneToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.event.Event import java.time.ZonedDateTime @@ -44,9 +39,11 @@ class Disposal( val entryLengthUnit: ReferenceData? = null, @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean = true, @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @Column diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt index 9333241dd5..c651153605 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/Person.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.person -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter @Immutable @Entity @@ -36,6 +34,7 @@ class Person( val surname: String, @Column(updatable = false, columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, val exclusionMessage: String? = null, diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/registration/entity/Registration.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/registration/entity/Registration.kt index 1001dc86c1..c1d9ea19e7 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/registration/entity/Registration.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/registration/entity/Registration.kt @@ -5,6 +5,7 @@ import org.hibernate.annotations.Fetch import org.hibernate.annotations.FetchMode import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.person.Person import java.time.LocalDate @@ -37,9 +38,11 @@ class Registration( val deRegistrations: List, @Column(name = "deregistered", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deRegistered: Boolean, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, ) { val endDate: LocalDate? @@ -79,5 +82,6 @@ class DeRegistration( val registration: Registration, @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean ) diff --git a/projects/workforce-allocations-to-delius/src/main/resources/application.yml b/projects/workforce-allocations-to-delius/src/main/resources/application.yml index e8e7e0ff9f..73d4922f69 100644 --- a/projects/workforce-allocations-to-delius/src/main/resources/application.yml +++ b/projects/workforce-allocations-to-delius/src/main/resources/application.yml @@ -1,12 +1,10 @@ # Default config -server.shutdown: graceful spring: mvc.async.request-timeout: 5m # for report download jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -62,7 +60,7 @@ spring: validation.enabled: false seed.database: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser +wiremock.enabled: true messaging.consumer.queue: workforce-allocations-events diff --git a/templates/projects/api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/templates/projects/api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index c8bccb62ee..8dc965d618 100644 --- a/templates/projects/api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/templates/projects/api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -6,7 +6,7 @@ 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.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -22,7 +22,7 @@ internal class IntegrationTest { @Autowired lateinit var wireMockServer: WireMockServer - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/templates/projects/api-client-and-server/src/main/resources/application.yml b/templates/projects/api-client-and-server/src/main/resources/application.yml index 84ec4fd640..af12c532ca 100644 --- a/templates/projects/api-client-and-server/src/main/resources/application.yml +++ b/templates/projects/api-client-and-server/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -55,7 +53,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser oauth2: client-id: $SERVICE_NAME diff --git a/templates/projects/api-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/templates/projects/api-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index d9006c74c5..2adefa8eea 100644 --- a/templates/projects/api-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/templates/projects/api-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -5,7 +5,7 @@ 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.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -18,7 +18,7 @@ internal class IntegrationTest { @Autowired lateinit var mockMvc: MockMvc - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/templates/projects/api-server/src/main/resources/application.yml b/templates/projects/api-server/src/main/resources/application.yml index 9bcff00bfc..f680c1123f 100644 --- a/templates/projects/api-server/src/main/resources/application.yml +++ b/templates/projects/api-server/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -44,7 +42,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser logging.level: uk.gov.justice.digital.hmpps: DEBUG diff --git a/templates/projects/message-listener-with-api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/templates/projects/message-listener-with-api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 60d06af963..99e7815b61 100644 --- a/templates/projects/message-listener-with-api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/templates/projects/message-listener-with-api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Value 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.test.context.bean.override.mockito.MockitoBean import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @@ -32,7 +32,7 @@ internal class IntegrationTest { @Autowired lateinit var mockMvc: MockMvc - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/templates/projects/message-listener-with-api-client-and-server/src/main/resources/application.yml b/templates/projects/message-listener-with-api-client-and-server/src/main/resources/application.yml index 792a47e611..9fe9f886cc 100644 --- a/templates/projects/message-listener-with-api-client-and-server/src/main/resources/application.yml +++ b/templates/projects/message-listener-with-api-client-and-server/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -55,7 +53,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue diff --git a/templates/projects/message-listener-with-api-client/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/templates/projects/message-listener-with-api-client/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 2c6461b551..9a80a46748 100644 --- a/templates/projects/message-listener-with-api-client/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/templates/projects/message-listener-with-api-client/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -6,7 +6,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager @@ -22,7 +22,7 @@ internal class IntegrationTest { @Autowired lateinit var channelManager: HmppsChannelManager - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/templates/projects/message-listener-with-api-client/src/main/resources/application.yml b/templates/projects/message-listener-with-api-client/src/main/resources/application.yml index 1021120ff6..53b104452f 100644 --- a/templates/projects/message-listener-with-api-client/src/main/resources/application.yml +++ b/templates/projects/message-listener-with-api-client/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE @@ -50,7 +48,6 @@ spring: seed.database: true wiremock.enabled: true -context.initializer.classes: uk.gov.justice.digital.hmpps.wiremock.WireMockInitialiser messaging.consumer.queue: message-queue diff --git a/templates/projects/message-listener/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/templates/projects/message-listener/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 2c6461b551..9a80a46748 100644 --- a/templates/projects/message-listener/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/templates/projects/message-listener/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -6,7 +6,7 @@ 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 -import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.test.context.bean.override.mockito.MockitoBean import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager @@ -22,7 +22,7 @@ internal class IntegrationTest { @Autowired lateinit var channelManager: HmppsChannelManager - @MockBean + @MockitoBean lateinit var telemetryService: TelemetryService @Test diff --git a/templates/projects/message-listener/src/main/resources/application.yml b/templates/projects/message-listener/src/main/resources/application.yml index d12d2aa42b..7d9099e272 100644 --- a/templates/projects/message-listener/src/main/resources/application.yml +++ b/templates/projects/message-listener/src/main/resources/application.yml @@ -1,11 +1,9 @@ # Default config -server.shutdown: graceful spring: jackson: default-property-inclusion: non_null jpa: hibernate.ddl-auto: validate - database-platform: org.hibernate.dialect.OracleDialect properties: hibernate: timezone.default_storage: NORMALIZE diff --git a/templates/runConfiguration.xml b/templates/runConfiguration.xml index 75a9d1e251..77ece0b9e3 100644 --- a/templates/runConfiguration.xml +++ b/templates/runConfiguration.xml @@ -1,29 +1,10 @@ - - - - - - - true - true - false - false - + + \ No newline at end of file From 5caae8a39b599655df240d834449e8cb6cf07194 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Tue, 3 Dec 2024 18:26:54 +0000 Subject: [PATCH 03/42] move test data creation into test, due to optimistic locking error when tests are run as whole, rather than individually. --- .../justice/digital/hmpps/data/DataLoader.kt | 12 +----- .../hmpps/MessagingIntegrationInactiveTest.kt | 6 +++ .../digital/hmpps/MessagingIntegrationTest.kt | 6 +++ .../ReferralControllerIntegrationTest.kt | 42 ++++++++++++++++--- 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 09596d71c0..08220a56b2 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -12,7 +12,6 @@ import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.Approve import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.entity.Address import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.EventRepository import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.MoveOnCategoryRepository -import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ReferralRepository import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ReferralSourceRepository import uk.gov.justice.digital.hmpps.integrations.delius.caseload.CaseloadRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.outcome.ContactOutcomeRepository @@ -22,7 +21,6 @@ import uk.gov.justice.digital.hmpps.integrations.delius.location.OfficeLocationR import uk.gov.justice.digital.hmpps.integrations.delius.nonstatutoryintervention.entity.* import uk.gov.justice.digital.hmpps.integrations.delius.person.BoroughRepository import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonRepository -import uk.gov.justice.digital.hmpps.integrations.delius.person.address.PersonAddressRepository import uk.gov.justice.digital.hmpps.integrations.delius.person.manager.probation.PersonManagerRepository import uk.gov.justice.digital.hmpps.integrations.delius.person.registration.entity.RegisterType import uk.gov.justice.digital.hmpps.integrations.delius.person.registration.entity.RegistrationRepository @@ -55,7 +53,6 @@ class DataLoader( private val teamRepository: TeamRepository, private val personRepository: PersonRepository, private val personManagerRepository: PersonManagerRepository, - private val personAddressRepository: PersonAddressRepository, private val eventRepository: EventRepository, private val contactTypeRepository: ContactTypeRepository, private val contactOutcomeRepository: ContactOutcomeRepository, @@ -64,12 +61,10 @@ class DataLoader( private val transferReasonRepository: TransferReasonRepository, private val caseloadRepository: CaseloadRepository, private val registrationRepository: RegistrationRepository, - private val referralRepository: ReferralRepository, private val probationCaseDataLoader: ProbationCaseDataLoader, private val lduRepository: LduRepository, private val staffUserRepository: StaffUserRepository, private val boroughRepository: BoroughRepository, - private val referralBookingDataLoader: ReferralBookingDataLoader, private val documentDataLoader: DocumentDataLoader, ) : ApplicationListener { @@ -171,9 +166,6 @@ class DataLoader( ) ) - AddressGenerator.PERSON_ADDRESS = personAddressRepository.save(AddressGenerator.PERSON_ADDRESS) - AddressGenerator.INACTIVE_PERSON_ADDRESS = - personAddressRepository.save(AddressGenerator.INACTIVE_PERSON_ADDRESS) eventRepository.save(PersonGenerator.EVENT) eventRepository.save(PersonGenerator.INACTIVE_EVENT) registrationRepository.save( @@ -219,10 +211,8 @@ class DataLoader( ) eventRepository.save(ANOTHER_EVENT) - referralRepository.save(ReferralGenerator.EXISTING_REFERRAL) - + personRepository.save(PersonGenerator.PERSON_WITH_BOOKING) probationCaseDataLoader.loadData() - referralBookingDataLoader.loadData() documentDataLoader.loadData() } } diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt index 660f73cf2c..e6c0cbc668 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt @@ -79,6 +79,10 @@ internal class MessagingIntegrationInactiveTest { @Autowired private lateinit var staffRepository: StaffRepository + fun setUpTestSpecificData() { + personAddressRepository.save(AddressGenerator.INACTIVE_PERSON_ADDRESS) + } + @Test fun `application submission with an inactive event creates an alert contact`() { // Given an application-submitted event @@ -129,6 +133,8 @@ internal class MessagingIntegrationInactiveTest { @Test @Order(1) fun `booking made with inactive event creates referral and contact`() { + setUpTestSpecificData() + // Given a booking-made event val event = prepEvent("booking-made-inactive", wireMockServer.port()) diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt index ad779ff56a..e9bf510892 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt @@ -94,6 +94,10 @@ internal class MessagingIntegrationTest { } while (message != null) } + fun setUpTestSpecificData() { + personAddressRepository.save(AddressGenerator.PERSON_ADDRESS) + } + @Test fun `application submission creates an alert contact`() { // Given an application-submitted event @@ -145,6 +149,8 @@ internal class MessagingIntegrationTest { @Test @Order(1) fun `booking made creates referral and contact`() { + setUpTestSpecificData() + // Given a booking-made event val event = prepEvent("booking-made", wireMockServer.port()) diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt index f0f599273e..6436839e72 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt @@ -16,6 +16,8 @@ import uk.gov.justice.digital.hmpps.data.generator.ApprovedPremisesGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.ReferralGenerator import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.Referral +import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ReferralRepository +import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ResidenceRepository import uk.gov.justice.digital.hmpps.model.ApReferral import uk.gov.justice.digital.hmpps.model.ApprovedPremises import uk.gov.justice.digital.hmpps.model.ExistingReferrals @@ -30,8 +32,16 @@ class ReferralControllerIntegrationTest { @Autowired lateinit var mockMvc: MockMvc + @Autowired + lateinit var referralRepository: ReferralRepository + + @Autowired + lateinit var residenceRepository: ResidenceRepository + + @Test fun `existing referrals for a crn are returned successfully`() { + referralRepository.save(ReferralGenerator.EXISTING_REFERRAL) val person = PersonGenerator.DEFAULT val res = mockMvc .perform(get("/probation-case/${person.crn}/referrals").withToken()) @@ -41,9 +51,30 @@ class ReferralControllerIntegrationTest { assertThat(res.referrals.size, equalTo(1)) } - @ParameterizedTest + @ParameterizedTest() @MethodSource("bookingDetails") - fun `referral detail is returned correctly`(bookingId: String, detail: ReferralDetail) { + fun `referral detail is returned correctly`(bookingId: String, detail: ReferralDetail, loadData: Boolean) { + if (loadData) { + referralRepository.save(ReferralGenerator.BOOKING_WITHOUT_ARRIVAL) + ReferralGenerator.BOOKING_ARRIVED = referralRepository.save(ReferralGenerator.BOOKING_ARRIVED) + ReferralGenerator.BOOKING_DEPARTED = referralRepository.save(ReferralGenerator.BOOKING_DEPARTED) + ReferralGenerator.ARRIVAL = residenceRepository.save( + ReferralGenerator.generateResidence( + PersonGenerator.PERSON_WITH_BOOKING, + ReferralGenerator.BOOKING_ARRIVED, + arrivalDateTime = ReferralGenerator.ARRIVAL.arrivalDate, + ) + ) + ReferralGenerator.DEPARTURE = residenceRepository.save( + ReferralGenerator.generateResidence( + PersonGenerator.PERSON_WITH_BOOKING, + ReferralGenerator.BOOKING_DEPARTED, + arrivalDateTime = ReferralGenerator.DEPARTURE.arrivalDate, + departureDateTime = ReferralGenerator.DEPARTURE.departureDate + ) + ) + } + val person = PersonGenerator.PERSON_WITH_BOOKING val res = mockMvc .perform(get("/probation-case/${person.crn}/referrals/$bookingId").withToken()) @@ -51,6 +82,7 @@ class ReferralControllerIntegrationTest { .andReturn().response.contentAsJson() assertThat(res, equalTo(detail)) + } companion object { @@ -69,19 +101,19 @@ class ReferralControllerIntegrationTest { @JvmStatic fun bookingDetails() = listOf( - Arguments.of(ReferralGenerator.BOOKING_ID, ReferralGenerator.BOOKING_WITHOUT_ARRIVAL.detail()), + Arguments.of(ReferralGenerator.BOOKING_ID, ReferralGenerator.BOOKING_WITHOUT_ARRIVAL.detail(), true), Arguments.of( ReferralGenerator.ARRIVED_ID, ReferralGenerator.BOOKING_ARRIVED.detail( ReferralGenerator.ARRIVAL.arrivalDate - ) + ), false ), Arguments.of( ReferralGenerator.DEPARTED_ID, ReferralGenerator.BOOKING_DEPARTED.detail( ReferralGenerator.DEPARTURE.arrivalDate, ReferralGenerator.DEPARTURE.departureDate - ) + ), false ) ) } From d12ed0658dbf08310286f0a970b7ac68b8c25e25 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Wed, 4 Dec 2024 09:30:06 +0000 Subject: [PATCH 04/42] delete class no longer used --- .../hmpps/data/ReferralBookingDataLoader.kt | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt deleted file mode 100644 index b8b88495b4..0000000000 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt +++ /dev/null @@ -1,37 +0,0 @@ -package uk.gov.justice.digital.hmpps.data - -import org.springframework.stereotype.Component -import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator -import uk.gov.justice.digital.hmpps.data.generator.ReferralGenerator -import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ReferralRepository -import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ResidenceRepository -import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonRepository - -@Component -class ReferralBookingDataLoader( - private val personRepository: PersonRepository, - private val referralRepository: ReferralRepository, - private val residenceRepository: ResidenceRepository -) { - fun loadData() { - personRepository.save(PersonGenerator.PERSON_WITH_BOOKING) - referralRepository.save(ReferralGenerator.BOOKING_WITHOUT_ARRIVAL) - ReferralGenerator.BOOKING_ARRIVED = referralRepository.save(ReferralGenerator.BOOKING_ARRIVED) - ReferralGenerator.BOOKING_DEPARTED = referralRepository.save(ReferralGenerator.BOOKING_DEPARTED) - ReferralGenerator.ARRIVAL = residenceRepository.save( - ReferralGenerator.generateResidence( - PersonGenerator.PERSON_WITH_BOOKING, - ReferralGenerator.BOOKING_ARRIVED, - arrivalDateTime = ReferralGenerator.ARRIVAL.arrivalDate, - ) - ) - ReferralGenerator.DEPARTURE = residenceRepository.save( - ReferralGenerator.generateResidence( - PersonGenerator.PERSON_WITH_BOOKING, - ReferralGenerator.BOOKING_DEPARTED, - arrivalDateTime = ReferralGenerator.DEPARTURE.arrivalDate, - departureDateTime = ReferralGenerator.DEPARTURE.departureDate - ) - ) - } -} \ No newline at end of file From af270be5aa5233cd961ce2bf44f8f7b23cbe9419 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Wed, 4 Dec 2024 17:32:32 +0000 Subject: [PATCH 05/42] remove id, as this stops hibernate calling sequence.nextval --- .../justice/digital/hmpps/data/generator/ContactGenerator.kt | 5 ++--- .../digital/hmpps/data/generator/RegistrationGenerator.kt | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt b/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt index b40d68bcd2..d8697bf2ca 100644 --- a/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt +++ b/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt @@ -12,9 +12,8 @@ object ContactGenerator { type: ContactType, eventId: Long? = null, alert: Boolean? = false, - softDeleted: Boolean = false, - id: Long = IdGenerator.getAndIncrement() - ) = Contact(type, person, eventId, null, alert, softDeleted, id) + softDeleted: Boolean = false + ) = Contact(type, person, eventId, null, alert, softDeleted) fun generateType(code: String, id: Long = IdGenerator.getAndIncrement()) = ContactType(code, id) } \ No newline at end of file diff --git a/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RegistrationGenerator.kt b/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RegistrationGenerator.kt index c3f1f1104d..a810234933 100644 --- a/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RegistrationGenerator.kt +++ b/projects/assessment-summary-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RegistrationGenerator.kt @@ -36,8 +36,7 @@ object RegistrationGenerator { nextReviewDate: LocalDate? = type.reviewPeriod?.let { date.plusMonths(it) }, notes: String? = null, softDeleted: Boolean = false, - id: Long = IdGenerator.getAndIncrement() - ) = Registration(personId, date, contact, teamId, staffId, type, level, nextReviewDate, notes, softDeleted, id) + ) = Registration(personId, date, contact, teamId, staffId, type, level, nextReviewDate, notes, softDeleted) fun generateType( code: String, From 38f503a830ff6c4672f99b32f37f9fa56be07540 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Wed, 4 Dec 2024 17:57:21 +0000 Subject: [PATCH 06/42] remove id from data generator, as this stops hibernate calling sequence.nextval --- .../hmpps/data/generator/CourtCaseNoteGenerator.kt | 1 - .../integrations/delius/contact/entity/CaseNote.kt | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/projects/court-case-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CourtCaseNoteGenerator.kt b/projects/court-case-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CourtCaseNoteGenerator.kt index 9ee01b0373..cc656b07ab 100644 --- a/projects/court-case-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CourtCaseNoteGenerator.kt +++ b/projects/court-case-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CourtCaseNoteGenerator.kt @@ -6,7 +6,6 @@ import java.time.ZonedDateTime object CourtCaseNoteGenerator { val CASE_NOTE = CaseNote( - IdGenerator.getAndIncrement(), "2222", PersonGenerator.CURRENTLY_MANAGED.id, ContactTypeGenerator.CONTACT_TYPE, diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/CaseNote.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/CaseNote.kt index 4886d9ae61..d862f710c9 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/CaseNote.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/CaseNote.kt @@ -14,12 +14,6 @@ import java.time.ZonedDateTime @Entity @Table(name = "contact") class CaseNote( - @Id - @Column(name = "contact_id", updatable = false) - @SequenceGenerator(name = "contact_id_seq", sequenceName = "contact_id_seq", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "contact_id_seq") - val id: Long = 0, - val externalReference: String, @Column(updatable = false) @@ -84,7 +78,13 @@ class CaseNote( @Column(updatable = false, columnDefinition = "NUMBER") @Convert(converter = NumericBooleanConverter::class) - var softDeleted: Boolean = false + var softDeleted: Boolean = false, + + @Id + @Column(name = "contact_id", updatable = false) + @SequenceGenerator(name = "contact_id_seq", sequenceName = "contact_id_seq", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "contact_id_seq") + val id: Long = 0, ) @Immutable From 9e821adae3ca650903a1d0d43e04c69fa0e3da96 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Thu, 5 Dec 2024 09:44:01 +0000 Subject: [PATCH 07/42] remove id from data generator, as this stops hibernate calling sequence.nextval. --- .../justice/digital/hmpps/data/DataLoader.kt | 26 ++++++++++--------- .../hmpps/data/generator/KeyDateGenerator.kt | 2 +- .../custody/date/CustodyDateUpdateService.kt | 2 +- .../delius/custody/date/KeyDate.kt | 13 +++++----- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 3f6b063e0f..268427a6ca 100644 --- a/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -15,8 +15,10 @@ import uk.gov.justice.digital.hmpps.data.generator.SentenceGenerator.generateOrd import uk.gov.justice.digital.hmpps.data.repository.* import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.Custody import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.CustodyRepository +import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.KeyDate import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.KeyDateRepository import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.contact.ContactTypeRepository +import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.reference.ReferenceData import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.reference.ReferenceDataRepository import uk.gov.justice.digital.hmpps.integrations.delius.person.Person import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonRepository @@ -53,7 +55,7 @@ class DataLoader( ) ) referenceDataRepository.save(ReferenceDataGenerator.DEFAULT_CUSTODY_STATUS) - referenceDataRepository.saveAll(ReferenceDataGenerator.KEY_DATE_TYPES.values) + val keyDateTypes = referenceDataRepository.saveAll(ReferenceDataGenerator.KEY_DATE_TYPES.values) contactTypeRepository.save(ContactTypeGenerator.EDSS) disposalTypeRepository.save(SentenceGenerator.DEFAULT_DISPOSAL_TYPE) @@ -74,32 +76,32 @@ class DataLoader( listOf( KeyDateGenerator.generate( DEFAULT_CUSTODY, - ReferenceDataGenerator.KEY_DATE_TYPES["PED"]!!, + keyDateTypes[2], //PED LocalDate.parse("2022-10-26"), false ), KeyDateGenerator.generate( DEFAULT_CUSTODY, - ReferenceDataGenerator.KEY_DATE_TYPES["LED"]!!, + keyDateTypes[0], //LED LocalDate.parse("2024-09-10"), false ), KeyDateGenerator.generate( DEFAULT_CUSTODY, - ReferenceDataGenerator.KEY_DATE_TYPES["SED"]!!, + keyDateTypes[3], //["SED"]!!, LocalDate.parse("2024-08-10"), false ) ) ) - createPersonWithKeyDates(PersonGenerator.DEFAULT, "58340A") + createPersonWithKeyDates(PersonGenerator.DEFAULT, "58340A", keyDateTypes) - createPersonWithKeyDates(PersonGenerator.PERSON_WITH_KEYDATES, "38340A") + createPersonWithKeyDates(PersonGenerator.PERSON_WITH_KEYDATES, "38340A", keyDateTypes) - createPersonWithKeyDates(PersonGenerator.PERSON_WITH_KEYDATES_BY_CRN, "48340A") + createPersonWithKeyDates(PersonGenerator.PERSON_WITH_KEYDATES_BY_CRN, "48340A", keyDateTypes) } - private fun createPersonWithKeyDates(personRef: Person, bookingRef: String): Custody { + private fun createPersonWithKeyDates(personRef: Person, bookingRef: String, keyDateTypes: List): Custody { val person = personRepository.save(personRef) val event = eventRepository.save(generateEvent(person, "1")) orderManagerRepository.save(generateOrderManager(event)) @@ -112,11 +114,11 @@ class DataLoader( ) ) keyDateRepository.saveAll( - ReferenceDataGenerator.KEY_DATE_TYPES.values.map { - if (it.code == "LED") { - KeyDateGenerator.generate(custody, it, LocalDate.parse("2025-09-11"), true) + keyDateTypes.map { referenceData -> + if (referenceData.code == "LED") { + KeyDate(custody, referenceData, LocalDate.parse("2025-09-11")).also { it.softDeleted = true } } else { - KeyDateGenerator.generate(custody, it, LocalDate.parse("2025-12-11"), false) + KeyDate(custody, referenceData, LocalDate.parse("2025-12-11")).also { it.softDeleted = false } } } ) diff --git a/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/KeyDateGenerator.kt b/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/KeyDateGenerator.kt index 75e955be2f..2c7730d989 100644 --- a/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/KeyDateGenerator.kt +++ b/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/KeyDateGenerator.kt @@ -8,5 +8,5 @@ import java.time.LocalDate object KeyDateGenerator { fun generate(custody: Custody, type: ReferenceData, date: LocalDate, softDeleted: Boolean) = - KeyDate(IdGenerator.getAndIncrement(), custody, type, date).also { it.softDeleted = softDeleted } + KeyDate(custody, type, date).also { it.softDeleted = softDeleted } } diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/CustodyDateUpdateService.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/CustodyDateUpdateService.kt index 7860a0a00f..e800428b98 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/CustodyDateUpdateService.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/CustodyDateUpdateService.kt @@ -94,7 +94,7 @@ class CustodyDateUpdateService( existing.changeDate(date) } else { val kdt = referenceDataRepository.findKeyDateType(code) - KeyDate(null, this, kdt, date) + KeyDate( this, kdt, date) } } diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/KeyDate.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/KeyDate.kt index c01abb5ff5..1dc16f91da 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/KeyDate.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/KeyDate.kt @@ -15,11 +15,6 @@ import java.time.LocalDate ) class KeyDate( - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "key_date_id_seq") - @Column(name = "key_date_id") - val id: Long?, - @ManyToOne @JoinColumn(name = "custody_id") val custody: Custody? = null, @@ -29,14 +24,18 @@ class KeyDate( val type: ReferenceData, @Column(name = "key_date") - val date: LocalDate + val date: LocalDate, + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "key_date_id_seq") + @Column(name = "key_date_id") + val id: Long = 0, ) : BaseEntity() { fun changeDate(date: LocalDate): KeyDate? = if (this.date == date && !this.softDeleted) { null } else { // create new entity to allow dry run to not make changes - KeyDate(id, custody, type, date).also { + KeyDate(custody, type, date, id).also { it.createdDateTime = createdDateTime it.createdUserId = createdUserId it.version = version From 60fc5ee23f4bf08d202137edba3cad6e687f8579 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Thu, 5 Dec 2024 15:05:43 +0000 Subject: [PATCH 08/42] remove id from data generator, as this stops hibernate calling sequence.nextval. Also, move some test data creation to fix optimistic lock error when tests run in a suite. --- .../justice/digital/hmpps/data/DataLoader.kt | 25 +-------- .../hmpps/data/generator/EventGenerator.kt | 3 +- .../hmpps/data/generator/ProviderGenerator.kt | 5 +- .../AllocationMessagingIntegrationTest.kt | 6 +++ .../digital/hmpps/ApiIntegrationTest.kt | 53 ++++++++++++++++--- .../delius/allocation/entity/event/Event.kt | 12 +++-- .../entity/event/keydate/KeyDate.kt | 2 +- .../digital/hmpps/services/KeyDateService.kt | 2 +- 8 files changed, 67 insertions(+), 41 deletions(-) diff --git a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index a26a18f2f3..65371f21c4 100644 --- a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -28,7 +28,6 @@ import java.time.LocalDate @ConditionalOnProperty("seed.database") class DataLoader( private val auditUserRepository: AuditUserRepository, - private val staffUserRepository: StaffUserRepository, private val referenceDataSetRepository: ReferenceDataSetRepository, private val referenceDataRepository: ReferenceDataRepository, private val registerTypeRepository: RegisterTypeRepository, @@ -38,7 +37,6 @@ class DataLoader( private val teamRepository: TeamRepository, private val staffRepository: StaffRepository, private val personRepository: PersonRepository, - private val personManagerRepository: PersonManagerRepository, private val eventRepository: EventRepository, private val disposalRepository: DisposalRepository, private val custodyRepository: CustodyRepository, @@ -77,18 +75,8 @@ class DataLoader( districtRepository.save(ProviderGenerator.DEFAULT_DISTRICT) teamRepository.saveAll(PersonManagerGenerator.ALL.map { it.team } + ProviderGenerator.POM_TEAM + ProviderGenerator.UNALLOCATED_TEAM) - val staffMap = - staffRepository.saveAll(PersonManagerGenerator.ALL.map { it.staff } + ProviderGenerator.UNALLOCATED_STAFF) - .associateBy { it.code } - val staff = staffRepository.save(ProviderGenerator.generateStaff("Test", "Test", "Test")) - UserGenerator.DEFAULT_STAFF_USER = staffUserRepository.save( - StaffUser( - UserGenerator.DEFAULT_STAFF_USER.username, - staffMap[ProviderGenerator.DEFAULT_STAFF.code], - UserGenerator.DEFAULT_STAFF_USER.id - ) - ) + staffRepository.save(ProviderGenerator.generateStaff("Test", "Test", "Test")) personRepository.saveAll( listOf( @@ -102,17 +90,6 @@ class DataLoader( PersonGenerator.PERSON_MULTIPLE_CUSTODIAL ) ) - personManagerRepository.saveAll( - PersonManagerGenerator.ALL.map { - PersonManagerGenerator.generate( - team = it.team, - staff = staffMap[it.staff.code]!!, - person = it.person, - active = it.active, - softDeleted = it.softDeleted - ) - } - ) eventRepository.saveAll(CaseAllocationGenerator.ALL.map { it.event }) disposalRepository.saveAll(CaseAllocationGenerator.ALL.map { it.event.disposal }) diff --git a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventGenerator.kt b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventGenerator.kt index 1814b3c7ca..f782c6e23b 100644 --- a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventGenerator.kt +++ b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventGenerator.kt @@ -34,6 +34,5 @@ object EventGenerator { custody: Custody, type: ReferenceData, date: LocalDate, - id: Long = IdGenerator.getAndIncrement() - ) = KeyDate(custody.id, type, date, id) + ) = KeyDate(custody.id, type, date) } diff --git a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ProviderGenerator.kt b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ProviderGenerator.kt index d24820bde8..d776a14ec5 100644 --- a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ProviderGenerator.kt +++ b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ProviderGenerator.kt @@ -11,7 +11,7 @@ object ProviderGenerator { val DEFAULT_TEAM = generateTeam("N03DEF", district = DEFAULT_DISTRICT) val POM_TEAM = generateTeam("N03POM", district = DEFAULT_DISTRICT) val UNALLOCATED_TEAM = generateTeam("N03ALL", district = DEFAULT_DISTRICT) - val DEFAULT_STAFF = generateStaff("N03DEF0", "Default", "Staff", user = UserGenerator.DEFAULT_STAFF_USER) + val DEFAULT_STAFF = generateStaff("N03DEF0", "Default", "Staff") val UNALLOCATED_STAFF = generateStaff("N03ALLU", "Unallocated", "Staff") fun generateProvider(providerCode: String, prisonCode: String?, id: Long = IdGenerator.getAndIncrement()) = @@ -40,6 +40,5 @@ object ProviderGenerator { middleName: String? = null, user: StaffUser? = null, startDate: ZonedDateTime = ZonedDateTime.now(), - id: Long = IdGenerator.getAndIncrement() - ) = Staff(code, forename, surname, middleName, user, providerId, startDate, id).apply { user?.set("staff", this) } + ) = Staff(code, forename, surname, middleName, user, providerId, startDate).apply { user?.set("staff", this) } } diff --git a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt index 0af8f57432..8af1c3613a 100644 --- a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt +++ b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt @@ -26,6 +26,7 @@ import uk.gov.justice.digital.hmpps.entity.PrisonStaff import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactType import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.PrisonManagerRepository +import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.StaffRepository import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.repository.PrisonStaffRepository import uk.gov.justice.digital.hmpps.resourceloader.ResourceLoader.notification @@ -57,6 +58,9 @@ internal class AllocationMessagingIntegrationTest { @Autowired lateinit var contactRepository: ContactRepository + @Autowired + lateinit var staffRepo: StaffRepository + @Order(1) @Test fun `no change if not yet ready to allocate`() { @@ -169,6 +173,8 @@ internal class AllocationMessagingIntegrationTest { @Order(4) @Test fun `deallocate POM successfully`() { + staffRepo.save(ProviderGenerator.UNALLOCATED_STAFF) + val existingPom = prisonManagerRepository.findActiveManagerAtDate(PersonGenerator.DEFAULT.id, ZonedDateTime.now())!! diff --git a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt index 9c069b2c2a..4758b153be 100644 --- a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt +++ b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt @@ -13,10 +13,12 @@ import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import uk.gov.justice.digital.hmpps.api.model.* -import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator -import uk.gov.justice.digital.hmpps.data.generator.ProviderGenerator -import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator +import uk.gov.justice.digital.hmpps.data.PersonManagerRepository +import uk.gov.justice.digital.hmpps.data.StaffUserRepository +import uk.gov.justice.digital.hmpps.data.generator.* import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.Person +import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.StaffRepository +import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.StaffUser import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.contentAsJson import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @@ -27,9 +29,48 @@ internal class ApiIntegrationTest { @Autowired lateinit var mockMvc: MockMvc + @Autowired + lateinit var staffRepository: StaffRepository + + @Autowired + lateinit var staffUserRepository: StaffUserRepository + + @Autowired + lateinit var personManagerRepository: PersonManagerRepository + + fun loadTestData() { + val staffMap = staffRepository.saveAll( + PersonManagerGenerator.ALL.map { it.staff } + + ProviderGenerator.UNALLOCATED_STAFF).associateBy { it.code } + + UserGenerator.DEFAULT_STAFF_USER = staffUserRepository.save( + StaffUser( + UserGenerator.DEFAULT_STAFF_USER.username, + staffMap[ProviderGenerator.DEFAULT_STAFF.code], + UserGenerator.DEFAULT_STAFF_USER.id + ) + ) + + personManagerRepository.saveAll( + PersonManagerGenerator.ALL.map { + PersonManagerGenerator.generate( + team = it.team, + staff = staffMap[it.staff.code]!!, + person = it.person, + active = it.active, + softDeleted = it.softDeleted + ) + } + ) + } + @ParameterizedTest @MethodSource("caseIdentifiers") - fun `successful retrieval of a case record by crn or noms id`(identifier: String, person: Person) { + fun `successful retrieval of a case record by crn or noms id`(identifier: String, person: Person, loadData: Boolean) { + if (loadData) { + loadTestData() + } + val record = mockMvc .perform(get("/case-records/$identifier").withToken()) .andExpect(status().is2xxSuccessful) @@ -66,8 +107,8 @@ internal class ApiIntegrationTest { companion object { @JvmStatic fun caseIdentifiers() = listOf( - Arguments.of(PersonGenerator.DEFAULT.crn, PersonGenerator.DEFAULT), - Arguments.of(PersonGenerator.DEFAULT.nomsId, PersonGenerator.DEFAULT) + Arguments.of(PersonGenerator.DEFAULT.crn, PersonGenerator.DEFAULT, true), + Arguments.of(PersonGenerator.DEFAULT.nomsId, PersonGenerator.DEFAULT, false) ) } } diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/Event.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/Event.kt index 5b3a0e0a35..f63d9595aa 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/Event.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/Event.kt @@ -18,10 +18,12 @@ class Event( @OneToOne(mappedBy = "event") val disposal: Disposal? = null, - @Column(name = "active_flag") + @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, - @Column(name = "soft_deleted") + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @@ -39,10 +41,12 @@ class Disposal( @JoinColumn(name = "event_id") val event: Event, - @Column(name = "active_flag") + @Column(name = "active_flag", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val active: Boolean, - @Column(name = "soft_deleted") + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/keydate/KeyDate.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/keydate/KeyDate.kt index fa57d9f66b..ace157ee19 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/keydate/KeyDate.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/allocation/entity/event/keydate/KeyDate.kt @@ -34,7 +34,7 @@ class KeyDate( @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "key_date_id_seq") @Column(name = "key_date_id") - val id: Long? + val id: Long = 0 ) { val partitionAreaId = 0 diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/services/KeyDateService.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/services/KeyDateService.kt index 5f6b389071..cce50aa0b9 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/services/KeyDateService.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/services/KeyDateService.kt @@ -61,7 +61,7 @@ class KeyDateService( } private fun keyDate(custodyId: Long, typeCode: KeyDate.TypeCode, date: LocalDate): KeyDate = - KeyDate(custodyId, referenceDataRepository.keyDateType(typeCode.value), date, null) + KeyDate(custodyId, referenceDataRepository.keyDateType(typeCode.value), date) } enum class KeyDateMergeResult { From e1d18a37c435c6a53994b3743bbebb41d9bfb503 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Thu, 5 Dec 2024 15:36:17 +0000 Subject: [PATCH 09/42] remove id from data generator, as this stops hibernate calling sequence.nextval. --- .../hmpps/data/generator/CaseNoteGenerator.kt | 1 - .../digital/hmpps/data/generator/StaffGenerator.kt | 2 -- .../hmpps/integrations/delius/entity/CaseNote.kt | 13 +++++++------ .../hmpps/integrations/delius/entity/Staff.kt | 14 +++++++------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/projects/prison-case-notes-to-probation/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CaseNoteGenerator.kt b/projects/prison-case-notes-to-probation/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CaseNoteGenerator.kt index 502467293c..4f8ece0361 100644 --- a/projects/prison-case-notes-to-probation/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CaseNoteGenerator.kt +++ b/projects/prison-case-notes-to-probation/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/CaseNoteGenerator.kt @@ -34,7 +34,6 @@ object CaseNoteGenerator { lastModifiedDateTime: ZonedDateTime = ZonedDateTime.now() ): CaseNote { return CaseNote( - IdGenerator.getAndIncrement(), offenderId, eventId, nsiId, diff --git a/projects/prison-case-notes-to-probation/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/StaffGenerator.kt b/projects/prison-case-notes-to-probation/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/StaffGenerator.kt index a1d8c3becd..5b9ff75b67 100644 --- a/projects/prison-case-notes-to-probation/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/StaffGenerator.kt +++ b/projects/prison-case-notes-to-probation/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/StaffGenerator.kt @@ -13,11 +13,9 @@ object StaffGenerator { code: String, forename: String, surname: String, - id: Long = IdGenerator.getAndIncrement(), probationAreaId: Long = ProbationAreaGenerator.DEFAULT.id ): Staff { return Staff( - id, forename, surname, code, diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/CaseNote.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/CaseNote.kt index 661fcf35c3..5372b08907 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/CaseNote.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/CaseNote.kt @@ -14,11 +14,6 @@ import java.time.ZonedDateTime @Entity @Table(name = "contact") data class CaseNote( - @Id - @Column(name = "contact_id", updatable = false) - @SequenceGenerator(name = "contact_id_seq", sequenceName = "contact_id_seq", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "contact_id_seq") - val id: Long = 0, @Column(updatable = false) val offenderId: Long, @@ -94,7 +89,13 @@ data class CaseNote( @Column(updatable = false, columnDefinition = "number") @Convert(converter = NumericBooleanConverter::class) - var softDeleted: Boolean = false + var softDeleted: Boolean = false, + + @Id + @Column(name = "contact_id", updatable = false) + @SequenceGenerator(name = "contact_id_seq", sequenceName = "contact_id_seq", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "contact_id_seq") + val id: Long = 0, ) { override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Staff.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Staff.kt index 459058f7f6..e9b774a841 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Staff.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/entity/Staff.kt @@ -15,12 +15,6 @@ import java.time.ZonedDateTime @Table(name = "staff") class Staff( - @Id - @Column(name = "staff_id") - @SequenceGenerator(name = "staff_id_seq", sequenceName = "staff_id_seq", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "staff_id_seq") - val id: Long = 0, - @Column(name = "forename") val forename: String, @@ -58,5 +52,11 @@ class Staff( @Version @Column(name = "row_version") - var version: Long = 0 + var version: Long = 0, + + @Id + @Column(name = "staff_id") + @SequenceGenerator(name = "staff_id_seq", sequenceName = "staff_id_seq", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "staff_id_seq") + val id: Long = 0, ) From 67a58d319d6568e1ec4469ae6cc0602be6ed9f6e Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Thu, 5 Dec 2024 15:51:37 +0000 Subject: [PATCH 10/42] remove id from data generator, as this stops hibernate calling sequence.nextval. --- .../justice/digital/hmpps/data/DataLoader.kt | 2 -- .../manager/prison/entity/PrisonManager.kt | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/projects/prison-custody-status-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/prison-custody-status-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 20d3036bf7..9506c4eb09 100644 --- a/projects/prison-custody-status-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/prison-custody-status-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -144,7 +144,6 @@ class DataLoader( val teamBir = teamRepository.save(TeamGenerator.allStaff(InstitutionGenerator.MOVED_TO_WITH_POM.probationArea!!)) val prisonManager = PrisonManager( - IdGenerator.getAndIncrement(), 0, PersonGenerator.MATCHABLE_WITH_POM.id, ZonedDateTime.of(2023, 1, 1, 1, 0, 0, 0, ZoneId.systemDefault()), @@ -155,7 +154,6 @@ class DataLoader( false ) val prisonManager1 = PrisonManager( - IdGenerator.getAndIncrement(), 0, PersonGenerator.MATCHABLE_WITH_POM.id, ZonedDateTime.of(2023, 2, 1, 1, 0, 0, 0, ZoneId.systemDefault()), diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/prison/entity/PrisonManager.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/prison/entity/PrisonManager.kt index c381d76bf2..b5f59cb370 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/prison/entity/PrisonManager.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/manager/prison/entity/PrisonManager.kt @@ -21,16 +21,6 @@ import java.time.ZonedDateTime @EntityListeners(AuditingEntityListener::class) @Table(name = "prison_offender_manager") class PrisonManager( - @Id - @SequenceGenerator( - name = "prison_manager_id_generator", - sequenceName = "prison_offender_manager_id_seq", - allocationSize = 1 - ) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "prison_manager_id_generator") - @Column(name = "prison_offender_manager_id", nullable = false) - val id: Long = 0, - @Version @Column(name = "row_version", nullable = false) val version: Long = 0, @@ -82,7 +72,17 @@ class PrisonManager( @LastModifiedDate @Column(nullable = false) - var lastUpdatedDatetime: ZonedDateTime = ZonedDateTime.now() + var lastUpdatedDatetime: ZonedDateTime = ZonedDateTime.now(), + + @Id + @SequenceGenerator( + name = "prison_manager_id_generator", + sequenceName = "prison_offender_manager_id_seq", + allocationSize = 1 + ) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "prison_manager_id_generator") + @Column(name = "prison_offender_manager_id", nullable = false) + val id: Long = 0, ) interface PrisonManagerRepository : JpaRepository { From eeeac19c507e3ed02098340f4639fd1bfeabc8ee Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Thu, 5 Dec 2024 16:55:27 +0000 Subject: [PATCH 11/42] remove id from data generator, as this stops hibernate calling sequence.nextval. Also, move some test data creation to fix optimistic lock error when tests run in a suite. --- .../uk/gov/justice/digital/hmpps/data/DataLoader.kt | 4 ---- .../digital/hmpps/data/generator/ContactGenerator.kt | 4 +--- .../digital/hmpps/data/generator/NsiGenerator.kt | 6 ++---- .../digital/hmpps/ReferAndMonitorIntegrationTest.kt | 12 ++++++++++-- .../integrations/delius/contact/entity/Contact.kt | 1 - 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 5f4f7856d3..ec8648575d 100644 --- a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -279,10 +279,6 @@ class DataLoader( ) personRepository.save(PersonGenerator.FUZZY_SEARCH) - NsiGenerator.FUZZY_SEARCH = nsiRepository.save(NsiGenerator.FUZZY_SEARCH) - nsiManagerRepository.save(NsiGenerator.generateManager(NsiGenerator.FUZZY_SEARCH)) - - NsiGenerator.TERMINATED = nsiRepository.save(NsiGenerator.TERMINATED) auditUserRepository.save(UserGenerator.LIMITED_ACCESS_USER) personRepository.saveAll( diff --git a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt index 575698a7ad..3bb5f5f143 100644 --- a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt +++ b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt @@ -108,8 +108,7 @@ object ContactGenerator { rarActivity: Boolean? = null, person: Person = PersonGenerator.DEFAULT, externalReference: String? = null, - softDeleted: Boolean = false, - id: Long = IdGenerator.getAndIncrement() + softDeleted: Boolean = false ) = Contact( person, type, @@ -118,7 +117,6 @@ object ContactGenerator { endTime = endTime, nsiId = nsi?.id, eventId = nsi?.eventId, - id = id, providerId = ProviderGenerator.INTENDED_PROVIDER.id, teamId = ProviderGenerator.INTENDED_TEAM.id, staffId = ProviderGenerator.INTENDED_STAFF.id, diff --git a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/NsiGenerator.kt b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/NsiGenerator.kt index ba7a821504..47045a146d 100644 --- a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/NsiGenerator.kt +++ b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/NsiGenerator.kt @@ -69,8 +69,7 @@ object NsiGenerator { providerId: Long = ProviderGenerator.INTENDED_PROVIDER.id, notes: String? = null, active: Boolean = true, - softDeleted: Boolean = false, - id: Long = IdGenerator.getAndIncrement() + softDeleted: Boolean = false ) = Nsi( person, type, @@ -84,8 +83,7 @@ object NsiGenerator { rarCount = rarCount, notes = notes, active = active, - softDeleted = softDeleted, - id = id + softDeleted = softDeleted ) fun generateType(code: String, id: Long = IdGenerator.getAndIncrement()) = NsiType(code, id) 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 8bcdf31708..ba7b253254 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 @@ -24,6 +24,7 @@ import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.Contact import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactOutcome import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactType import uk.gov.justice.digital.hmpps.integrations.delius.event.entity.EventRepository +import uk.gov.justice.digital.hmpps.integrations.delius.referral.NsiManagerRepository import uk.gov.justice.digital.hmpps.integrations.delius.referral.NsiRepository import uk.gov.justice.digital.hmpps.integrations.delius.referral.NsiStatusHistoryRepository import uk.gov.justice.digital.hmpps.integrations.delius.referral.entity.NsiStatus @@ -65,6 +66,9 @@ internal class ReferAndMonitorIntegrationTest { @Autowired lateinit var eventRepository: EventRepository + @Autowired + lateinit var nsiManagerRepository: NsiManagerRepository + @Test @Order(1) fun `session appointment feedback submitted failed to comply`() { @@ -268,8 +272,7 @@ internal class ReferAndMonitorIntegrationTest { date = LocalDate.now().plusDays(7), startTime = ZonedDateTime.now().plusDays(7), nsi = nsi, - person = nsi.person, - id = 0 + person = nsi.person ) ) @@ -365,6 +368,11 @@ internal class ReferAndMonitorIntegrationTest { @Test fun `failure to find appointment is rejected with reason`() { + NsiGenerator.FUZZY_SEARCH = nsiRepository.save(NsiGenerator.FUZZY_SEARCH) + nsiManagerRepository.save(NsiGenerator.generateManager(NsiGenerator.FUZZY_SEARCH)) + + NsiGenerator.TERMINATED = nsiRepository.save(NsiGenerator.TERMINATED) + val notification = prepNotification( notification("session-appointment-feedback-submitted-not-found"), wireMockServer.port() diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt index 8f15171e19..a66ad53ae6 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Contact.kt @@ -126,7 +126,6 @@ class Contact( private set @Column(name = "hours_credited", columnDefinition = "number") - @Convert(converter = NumericBooleanConverter::class) var hoursCredited: Double? = null private set From 97e76de50e9791ea08a31bb37f2c72309f7f60cd Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Thu, 5 Dec 2024 17:19:15 +0000 Subject: [PATCH 12/42] remove id from data generator, as this stops hibernate calling sequence.nextval. --- .../uk/gov/justice/digital/hmpps/data/DataLoader.kt | 1 - .../digital/hmpps/data/generator/AppointmentGenerator.kt | 4 +--- .../digital/hmpps/data/generator/ProviderGenerator.kt | 3 +-- .../kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt | 8 ++++---- .../uk/gov/justice/digital/hmpps/entity/PersonAddress.kt | 4 ++++ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 368b2d72f1..899331c33f 100644 --- a/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -100,7 +100,6 @@ class DataLoader( ) ) } - fun EntityManager.saveAll(vararg any: Any) = any.forEach { merge(it) } private fun createAppointments(person: Person) { diff --git a/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AppointmentGenerator.kt b/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AppointmentGenerator.kt index ec1a9212df..d77cf40f1c 100644 --- a/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AppointmentGenerator.kt +++ b/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AppointmentGenerator.kt @@ -73,8 +73,7 @@ object AppointmentGenerator { outcome: AppointmentOutcome? = null, description: String? = null, softDeleted: Boolean = false, - version: Long = 0, - id: Long = IdGenerator.getAndIncrement() + version: Long = 0 ) = Appointment( person, type, @@ -91,6 +90,5 @@ object AppointmentGenerator { outcome, softDeleted, version, - id ) } diff --git a/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ProviderGenerator.kt b/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ProviderGenerator.kt index 994c23865b..e30d93d7ad 100644 --- a/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ProviderGenerator.kt +++ b/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ProviderGenerator.kt @@ -31,9 +31,8 @@ object ProviderGenerator { forename: String, surname: String, middleName: String? = null, - id: Long = IdGenerator.getAndIncrement(), probationAreaId: Long - ) = Staff(code, forename, surname, middleName, null, probationAreaId, id = id) + ) = Staff(code, forename, surname, middleName, null, probationAreaId) fun generateStaffUser( username: String, diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt index 5fe892c45c..6478ca6f6f 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate @Entity @@ -33,5 +31,7 @@ class Person( @Column(name = "e_mail_address") val emailAddress: String?, + @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) \ No newline at end of file diff --git a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonAddress.kt b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonAddress.kt index 1136dc6855..e0b2d631c2 100644 --- a/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonAddress.kt +++ b/projects/resettlement-passport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/PersonAddress.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -32,6 +33,9 @@ class PersonAddress( @Convert(converter = YesNoConverter::class) val noFixedAbode: Boolean? = false, var endDate: LocalDate? = null, + + @Column(columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) From ff64fed0ad95421a015b9d8e40075c7194f16419 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Fri, 6 Dec 2024 11:47:33 +0000 Subject: [PATCH 13/42] remove id from data generator, as this stops hibernate calling sequence.nextval. --- .../justice/digital/hmpps/data/CaseViewDataLoader.kt | 2 +- .../hmpps/data/ExistingAllocationsDataLoader.kt | 4 ++-- .../digital/hmpps/data/PersonAllocationDataLoader.kt | 2 +- .../digital/hmpps/data/generator/ContactGenerator.kt | 2 -- .../hmpps/data/generator/OrderManagerGenerator.kt | 6 ++---- .../hmpps/data/generator/PersonManagerGenerator.kt | 2 -- .../data/generator/RequirementManagerGenerator.kt | 2 -- .../data/generator/ResponsibleOfficerGenerator.kt | 2 -- .../hmpps/AllocationCompletedIntegrationTest.kt | 6 ++++++ .../digital/hmpps/AllocationDemandIntegrationTest.kt | 5 +++++ .../hmpps/InitialAllocationIntegrationTest.kt | 8 ++++++++ .../hmpps/integrations/delius/event/OrderManager.kt | 10 +++++----- .../delius/event/requirement/RequirementManager.kt | 12 ++++++------ .../integrations/delius/person/PersonManager.kt | 8 ++++---- .../integrations/delius/person/ResponsibleOfficer.kt | 12 ++++++------ 15 files changed, 46 insertions(+), 37 deletions(-) diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/CaseViewDataLoader.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/CaseViewDataLoader.kt index 944ddf4a03..91bd9f0a89 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/CaseViewDataLoader.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/CaseViewDataLoader.kt @@ -94,6 +94,6 @@ class CaseViewDataLoader( ) ) - contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT_CASE_VIEW) +// contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT_CASE_VIEW) } } diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ExistingAllocationsDataLoader.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ExistingAllocationsDataLoader.kt index 172cdd2dee..1a1b221545 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ExistingAllocationsDataLoader.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ExistingAllocationsDataLoader.kt @@ -15,8 +15,8 @@ class ExistingAllocationsDataLoader( ) { fun loadData() { existingAllocationsRefDataLoader.loadData() - orderManagerRepository.save(OrderManagerGenerator.UNALLOCATED) - orderManagerRepository.save(OrderManagerGenerator.INITIAL_ALLOCATION) +// orderManagerRepository.save(OrderManagerGenerator.UNALLOCATED) +// orderManagerRepository.save(OrderManagerGenerator.INITIAL_ALLOCATION) } } diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/PersonAllocationDataLoader.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/PersonAllocationDataLoader.kt index cb66f43660..f16fc1417b 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/PersonAllocationDataLoader.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/PersonAllocationDataLoader.kt @@ -74,7 +74,7 @@ class PersonAllocationDataLoader( keyDateRepository.save(KeyDateGenerator.DEFAULT) institutionalReportRepository.save(InstitutionalReportGenerator.DEFAULT) - contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT) +// contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT) courtReportRepository.save(CourtReportGenerator.DEFAULT) diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt index aada42fac5..a082a8815f 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt @@ -31,9 +31,7 @@ object ContactGenerator { staffId: Long, providerId: Long, date: ZonedDateTime = ZonedDateTime.now(), - id: Long = IdGenerator.getAndIncrement() ) = Contact( - id = id, type = type, personId = personId, eventId = eventId, diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OrderManagerGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OrderManagerGenerator.kt index bba050ac07..98b90c6e2e 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OrderManagerGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OrderManagerGenerator.kt @@ -35,7 +35,6 @@ object OrderManagerGenerator { } fun generate( - id: Long = IdGenerator.getAndIncrement(), eventId: Long = EventGenerator.DEFAULT.id, transferReasonId: Long = TransferReasonGenerator.CASE_ORDER.id, provider: Provider = ProviderGenerator.DEFAULT, @@ -48,9 +47,8 @@ object OrderManagerGenerator { lastModifiedUserId: Long = UserGenerator.AUDIT_USER.id, version: Long = 0 ) = OrderManager( - id, - eventId, - transferReasonId + eventId = eventId, + transferReasonId = transferReasonId ).build( provider, team, diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonManagerGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonManagerGenerator.kt index 1ee4ce2d9f..350ff9389a 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonManagerGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonManagerGenerator.kt @@ -13,7 +13,6 @@ object PersonManagerGenerator { var HISTORIC = generate(startDateTime = ManagerGenerator.START_DATE_TIME, personId = PersonGenerator.HISTORIC_PM.id) fun generate( - id: Long = IdGenerator.getAndIncrement(), personId: Long = PersonGenerator.DEFAULT.id, provider: Provider = ProviderGenerator.DEFAULT, team: Team = TeamGenerator.DEFAULT, @@ -25,7 +24,6 @@ object PersonManagerGenerator { lastModifiedUserId: Long = UserGenerator.AUDIT_USER.id, version: Long = 0 ) = PersonManager( - id, personId ).build( provider, diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RequirementManagerGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RequirementManagerGenerator.kt index 3a2f8007bc..101b05df50 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RequirementManagerGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RequirementManagerGenerator.kt @@ -11,7 +11,6 @@ object RequirementManagerGenerator : ManagerGenerator { var NEW = generate(requirementId = RequirementGenerator.NEW.id) var HISTORIC = generate(requirementId = RequirementGenerator.HISTORIC.id) fun generate( - id: Long = IdGenerator.getAndIncrement(), requirementId: Long = RequirementGenerator.DEFAULT.id, transferReasonId: Long = TransferReasonGenerator.COMPONENT.id, provider: Provider = ProviderGenerator.DEFAULT, @@ -24,7 +23,6 @@ object RequirementManagerGenerator : ManagerGenerator { lastModifiedUserId: Long = UserGenerator.AUDIT_USER.id, version: Long = 0 ) = RequirementManager( - id, requirementId, transferReasonId ).build( diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ResponsibleOfficerGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ResponsibleOfficerGenerator.kt index e0aa257607..008a8b909f 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ResponsibleOfficerGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ResponsibleOfficerGenerator.kt @@ -16,14 +16,12 @@ object ResponsibleOfficerGenerator { prisonManager: PrisonManager? = null, startDateTime: ZonedDateTime = communityManager?.startDate ?: ZonedDateTime.now(), endDateTime: ZonedDateTime? = null, - id: Long = IdGenerator.getAndIncrement(), createdDateTime: ZonedDateTime = ZonedDateTime.now(), lastModifiedDateTime: ZonedDateTime = ZonedDateTime.now(), createdUserId: Long = UserGenerator.AUDIT_USER.id, lastModifiedUserId: Long = UserGenerator.AUDIT_USER.id, version: Long = 0 ) = ResponsibleOfficer( - id, personId, communityManager, prisonManager, diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationCompletedIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationCompletedIntegrationTest.kt index 7765e6ee39..a165b587ed 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationCompletedIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationCompletedIntegrationTest.kt @@ -11,6 +11,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPat import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import uk.gov.justice.digital.hmpps.api.model.Mappings import uk.gov.justice.digital.hmpps.data.generator.* +import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @AutoConfigureMockMvc @@ -19,8 +20,13 @@ class AllocationCompletedIntegrationTest { @Autowired lateinit var mockMvc: MockMvc + @Autowired + lateinit var contactRepository: ContactRepository + @Test fun `successful response`() { + contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT) + val person = PersonGenerator.DEFAULT val event = EventGenerator.DEFAULT val staff = StaffGenerator.DEFAULT diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt index a6fe7680c4..1fee1bb5c4 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt @@ -17,6 +17,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import uk.gov.justice.digital.hmpps.api.model.* import uk.gov.justice.digital.hmpps.data.generator.* import uk.gov.justice.digital.hmpps.integrations.delius.allocations.AllocationDemandRepository +import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withJson import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken import java.time.LocalDate @@ -32,6 +33,9 @@ class AllocationDemandIntegrationTest { @MockitoBean lateinit var allocationDemandRepository: AllocationDemandRepository + @Autowired + lateinit var contactRepository: ContactRepository + @Test fun `get allocation demand unauthorised`() { mockMvc.perform(post("/allocation-demand").withJson(AllocationDemandRequest(listOf()))) @@ -122,6 +126,7 @@ class AllocationDemandIntegrationTest { @Test fun `allocation demand allocation staff endpoint`() { + contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT_CASE_VIEW) val person = PersonGenerator.CASE_VIEW val event = EventGenerator.CASE_VIEW val staff = StaffGenerator.DEFAULT diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/InitialAllocationIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/InitialAllocationIntegrationTest.kt index 6de456023f..b280be8b65 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/InitialAllocationIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/InitialAllocationIntegrationTest.kt @@ -9,6 +9,8 @@ import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.MvcResult import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.* +import uk.gov.justice.digital.hmpps.data.generator.OrderManagerGenerator +import uk.gov.justice.digital.hmpps.integrations.delius.event.OrderManagerRepository import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @AutoConfigureMockMvc @@ -17,8 +19,14 @@ class InitialAllocationIntegrationTest { @Autowired lateinit var mockMvc: MockMvc + @Autowired + lateinit var orderManagerRepository: OrderManagerRepository + @Test fun `returns csv report`() { + orderManagerRepository.save(OrderManagerGenerator.UNALLOCATED) + orderManagerRepository.save(OrderManagerGenerator.INITIAL_ALLOCATION) + mockMvc .perform(get("/initial-allocations.csv").accept("text/csv").withToken()) .andExpect(request().asyncStarted()) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/OrderManager.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/OrderManager.kt index 6ccd8eb2ad..8dbf893fc6 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/OrderManager.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/OrderManager.kt @@ -16,12 +16,12 @@ import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.Manag @Table(name = "order_manager") @SequenceGenerator(name = "order_manager_id_seq", sequenceName = "order_manager_id_seq", allocationSize = 1) class OrderManager( + var eventId: Long = 0, + + var transferReasonId: Long = 0, + @Id @Column(name = "order_manager_id") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "order_manager_id_seq") - var id: Long = 0, - - var eventId: Long = 0, - - var transferReasonId: Long = 0 + var id: Long = 0 ) : ManagerBaseEntity() diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/RequirementManager.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/RequirementManager.kt index cb06b203a3..2b2d68948f 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/RequirementManager.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/RequirementManager.kt @@ -20,13 +20,13 @@ import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.Manag @AssociationOverride(name = "staff", joinColumns = [JoinColumn(name = "allocated_staff_id")]) @SequenceGenerator(name = "rqmnt_manager_id_seq", sequenceName = "rqmnt_manager_id_seq", allocationSize = 1) class RequirementManager( - @Id - @Column(name = "rqmnt_manager_id") - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rqmnt_manager_id_seq") - var id: Long = 0, - @Column(name = "rqmnt_id") var requirementId: Long = 0, - var transferReasonId: Long = 0 + var transferReasonId: Long = 0, + + @Id + @Column(name = "rqmnt_manager_id") + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rqmnt_manager_id_seq") + var id: Long = 0 ) : ManagerBaseEntity() diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt index fa733d1acc..10fcb5f5b9 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt @@ -19,11 +19,11 @@ import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.Manag @Table(name = "offender_manager") @SequenceGenerator(name = "offender_manager_id_seq", sequenceName = "offender_manager_id_seq", allocationSize = 1) class PersonManager( + @Column(name = "offender_id") + var personId: Long = 0, + @Id @Column(name = "offender_manager_id") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "offender_manager_id_seq") - var id: Long = 0, - - @Column(name = "offender_id") - var personId: Long = 0 + var id: Long = 0 ) : ManagerBaseEntity() diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ResponsibleOfficer.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ResponsibleOfficer.kt index bedd55de9d..01599d00da 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ResponsibleOfficer.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ResponsibleOfficer.kt @@ -28,11 +28,6 @@ import java.time.ZonedDateTime allocationSize = 1 ) class ResponsibleOfficer( - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "responsible_officer_id_generator") - @Column(name = "responsible_officer_id", nullable = false) - val id: Long = 0, - @Column(name = "offender_id") val personId: Long, @@ -61,5 +56,10 @@ class ResponsibleOfficer( var createdDatetime: ZonedDateTime? = null, @LastModifiedDate - var lastUpdatedDatetime: ZonedDateTime? = null + var lastUpdatedDatetime: ZonedDateTime? = null, + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "responsible_officer_id_generator") + @Column(name = "responsible_officer_id", nullable = false) + val id: Long = 0 ) From 25e86ac782c779558a175b60de31af921664dcb9 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Fri, 6 Dec 2024 17:32:50 +0000 Subject: [PATCH 14/42] escape ' ' required so that sql works against h2 database. If not included, generated sql is escape ''. This does not return required data against h2 database. --- .../integrations/delius/event/sentence/DisposalRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt index 009b99ee09..34325257c5 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt @@ -41,7 +41,7 @@ interface DisposalRepository : JpaRepository { and e.softDeleted = false and d.softDeleted = false and e.active = true and d.active = true and om.active = true - and s.code like '%U' + and s.code like '%U' ESCAPE ' ' """ ) fun findAllUnallocatedActiveEvents(personId: Long): List From 9c111b149a56a4b57ca0fc2ce28365d6445d42cd Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Fri, 6 Dec 2024 11:47:33 +0000 Subject: [PATCH 15/42] remove id from data generator, let hibernate call sequence.nextval. --- .../justice/digital/hmpps/data/CaseViewDataLoader.kt | 2 +- .../hmpps/data/ExistingAllocationsDataLoader.kt | 4 ++-- .../digital/hmpps/data/PersonAllocationDataLoader.kt | 2 +- .../digital/hmpps/data/generator/ContactGenerator.kt | 2 -- .../hmpps/data/generator/OrderManagerGenerator.kt | 6 ++---- .../hmpps/data/generator/PersonManagerGenerator.kt | 2 -- .../data/generator/RequirementManagerGenerator.kt | 2 -- .../data/generator/ResponsibleOfficerGenerator.kt | 2 -- .../hmpps/AllocationCompletedIntegrationTest.kt | 6 ++++++ .../digital/hmpps/AllocationDemandIntegrationTest.kt | 5 +++++ .../hmpps/InitialAllocationIntegrationTest.kt | 8 ++++++++ .../hmpps/integrations/delius/event/OrderManager.kt | 10 +++++----- .../delius/event/requirement/RequirementManager.kt | 12 ++++++------ .../integrations/delius/person/PersonManager.kt | 8 ++++---- .../integrations/delius/person/ResponsibleOfficer.kt | 12 ++++++------ 15 files changed, 46 insertions(+), 37 deletions(-) diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/CaseViewDataLoader.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/CaseViewDataLoader.kt index 944ddf4a03..91bd9f0a89 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/CaseViewDataLoader.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/CaseViewDataLoader.kt @@ -94,6 +94,6 @@ class CaseViewDataLoader( ) ) - contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT_CASE_VIEW) +// contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT_CASE_VIEW) } } diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ExistingAllocationsDataLoader.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ExistingAllocationsDataLoader.kt index 172cdd2dee..1a1b221545 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ExistingAllocationsDataLoader.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ExistingAllocationsDataLoader.kt @@ -15,8 +15,8 @@ class ExistingAllocationsDataLoader( ) { fun loadData() { existingAllocationsRefDataLoader.loadData() - orderManagerRepository.save(OrderManagerGenerator.UNALLOCATED) - orderManagerRepository.save(OrderManagerGenerator.INITIAL_ALLOCATION) +// orderManagerRepository.save(OrderManagerGenerator.UNALLOCATED) +// orderManagerRepository.save(OrderManagerGenerator.INITIAL_ALLOCATION) } } diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/PersonAllocationDataLoader.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/PersonAllocationDataLoader.kt index cb66f43660..f16fc1417b 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/PersonAllocationDataLoader.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/PersonAllocationDataLoader.kt @@ -74,7 +74,7 @@ class PersonAllocationDataLoader( keyDateRepository.save(KeyDateGenerator.DEFAULT) institutionalReportRepository.save(InstitutionalReportGenerator.DEFAULT) - contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT) +// contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT) courtReportRepository.save(CourtReportGenerator.DEFAULT) diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt index aada42fac5..a082a8815f 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt @@ -31,9 +31,7 @@ object ContactGenerator { staffId: Long, providerId: Long, date: ZonedDateTime = ZonedDateTime.now(), - id: Long = IdGenerator.getAndIncrement() ) = Contact( - id = id, type = type, personId = personId, eventId = eventId, diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OrderManagerGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OrderManagerGenerator.kt index bba050ac07..98b90c6e2e 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OrderManagerGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/OrderManagerGenerator.kt @@ -35,7 +35,6 @@ object OrderManagerGenerator { } fun generate( - id: Long = IdGenerator.getAndIncrement(), eventId: Long = EventGenerator.DEFAULT.id, transferReasonId: Long = TransferReasonGenerator.CASE_ORDER.id, provider: Provider = ProviderGenerator.DEFAULT, @@ -48,9 +47,8 @@ object OrderManagerGenerator { lastModifiedUserId: Long = UserGenerator.AUDIT_USER.id, version: Long = 0 ) = OrderManager( - id, - eventId, - transferReasonId + eventId = eventId, + transferReasonId = transferReasonId ).build( provider, team, diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonManagerGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonManagerGenerator.kt index 1ee4ce2d9f..350ff9389a 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonManagerGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonManagerGenerator.kt @@ -13,7 +13,6 @@ object PersonManagerGenerator { var HISTORIC = generate(startDateTime = ManagerGenerator.START_DATE_TIME, personId = PersonGenerator.HISTORIC_PM.id) fun generate( - id: Long = IdGenerator.getAndIncrement(), personId: Long = PersonGenerator.DEFAULT.id, provider: Provider = ProviderGenerator.DEFAULT, team: Team = TeamGenerator.DEFAULT, @@ -25,7 +24,6 @@ object PersonManagerGenerator { lastModifiedUserId: Long = UserGenerator.AUDIT_USER.id, version: Long = 0 ) = PersonManager( - id, personId ).build( provider, diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RequirementManagerGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RequirementManagerGenerator.kt index 3a2f8007bc..101b05df50 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RequirementManagerGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/RequirementManagerGenerator.kt @@ -11,7 +11,6 @@ object RequirementManagerGenerator : ManagerGenerator { var NEW = generate(requirementId = RequirementGenerator.NEW.id) var HISTORIC = generate(requirementId = RequirementGenerator.HISTORIC.id) fun generate( - id: Long = IdGenerator.getAndIncrement(), requirementId: Long = RequirementGenerator.DEFAULT.id, transferReasonId: Long = TransferReasonGenerator.COMPONENT.id, provider: Provider = ProviderGenerator.DEFAULT, @@ -24,7 +23,6 @@ object RequirementManagerGenerator : ManagerGenerator { lastModifiedUserId: Long = UserGenerator.AUDIT_USER.id, version: Long = 0 ) = RequirementManager( - id, requirementId, transferReasonId ).build( diff --git a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ResponsibleOfficerGenerator.kt b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ResponsibleOfficerGenerator.kt index e0aa257607..008a8b909f 100644 --- a/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ResponsibleOfficerGenerator.kt +++ b/projects/workforce-allocations-to-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ResponsibleOfficerGenerator.kt @@ -16,14 +16,12 @@ object ResponsibleOfficerGenerator { prisonManager: PrisonManager? = null, startDateTime: ZonedDateTime = communityManager?.startDate ?: ZonedDateTime.now(), endDateTime: ZonedDateTime? = null, - id: Long = IdGenerator.getAndIncrement(), createdDateTime: ZonedDateTime = ZonedDateTime.now(), lastModifiedDateTime: ZonedDateTime = ZonedDateTime.now(), createdUserId: Long = UserGenerator.AUDIT_USER.id, lastModifiedUserId: Long = UserGenerator.AUDIT_USER.id, version: Long = 0 ) = ResponsibleOfficer( - id, personId, communityManager, prisonManager, diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationCompletedIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationCompletedIntegrationTest.kt index 7765e6ee39..a165b587ed 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationCompletedIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationCompletedIntegrationTest.kt @@ -11,6 +11,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPat import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import uk.gov.justice.digital.hmpps.api.model.Mappings import uk.gov.justice.digital.hmpps.data.generator.* +import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @AutoConfigureMockMvc @@ -19,8 +20,13 @@ class AllocationCompletedIntegrationTest { @Autowired lateinit var mockMvc: MockMvc + @Autowired + lateinit var contactRepository: ContactRepository + @Test fun `successful response`() { + contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT) + val person = PersonGenerator.DEFAULT val event = EventGenerator.DEFAULT val staff = StaffGenerator.DEFAULT diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt index a6fe7680c4..1fee1bb5c4 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationDemandIntegrationTest.kt @@ -17,6 +17,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import uk.gov.justice.digital.hmpps.api.model.* import uk.gov.justice.digital.hmpps.data.generator.* import uk.gov.justice.digital.hmpps.integrations.delius.allocations.AllocationDemandRepository +import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withJson import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken import java.time.LocalDate @@ -32,6 +33,9 @@ class AllocationDemandIntegrationTest { @MockitoBean lateinit var allocationDemandRepository: AllocationDemandRepository + @Autowired + lateinit var contactRepository: ContactRepository + @Test fun `get allocation demand unauthorised`() { mockMvc.perform(post("/allocation-demand").withJson(AllocationDemandRequest(listOf()))) @@ -122,6 +126,7 @@ class AllocationDemandIntegrationTest { @Test fun `allocation demand allocation staff endpoint`() { + contactRepository.save(ContactGenerator.INITIAL_APPOINTMENT_CASE_VIEW) val person = PersonGenerator.CASE_VIEW val event = EventGenerator.CASE_VIEW val staff = StaffGenerator.DEFAULT diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/InitialAllocationIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/InitialAllocationIntegrationTest.kt index 6de456023f..b280be8b65 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/InitialAllocationIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/InitialAllocationIntegrationTest.kt @@ -9,6 +9,8 @@ import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.MvcResult import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.* +import uk.gov.justice.digital.hmpps.data.generator.OrderManagerGenerator +import uk.gov.justice.digital.hmpps.integrations.delius.event.OrderManagerRepository import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @AutoConfigureMockMvc @@ -17,8 +19,14 @@ class InitialAllocationIntegrationTest { @Autowired lateinit var mockMvc: MockMvc + @Autowired + lateinit var orderManagerRepository: OrderManagerRepository + @Test fun `returns csv report`() { + orderManagerRepository.save(OrderManagerGenerator.UNALLOCATED) + orderManagerRepository.save(OrderManagerGenerator.INITIAL_ALLOCATION) + mockMvc .perform(get("/initial-allocations.csv").accept("text/csv").withToken()) .andExpect(request().asyncStarted()) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/OrderManager.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/OrderManager.kt index 6ccd8eb2ad..8dbf893fc6 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/OrderManager.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/OrderManager.kt @@ -16,12 +16,12 @@ import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.Manag @Table(name = "order_manager") @SequenceGenerator(name = "order_manager_id_seq", sequenceName = "order_manager_id_seq", allocationSize = 1) class OrderManager( + var eventId: Long = 0, + + var transferReasonId: Long = 0, + @Id @Column(name = "order_manager_id") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "order_manager_id_seq") - var id: Long = 0, - - var eventId: Long = 0, - - var transferReasonId: Long = 0 + var id: Long = 0 ) : ManagerBaseEntity() diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/RequirementManager.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/RequirementManager.kt index cb06b203a3..2b2d68948f 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/RequirementManager.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/requirement/RequirementManager.kt @@ -20,13 +20,13 @@ import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.Manag @AssociationOverride(name = "staff", joinColumns = [JoinColumn(name = "allocated_staff_id")]) @SequenceGenerator(name = "rqmnt_manager_id_seq", sequenceName = "rqmnt_manager_id_seq", allocationSize = 1) class RequirementManager( - @Id - @Column(name = "rqmnt_manager_id") - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rqmnt_manager_id_seq") - var id: Long = 0, - @Column(name = "rqmnt_id") var requirementId: Long = 0, - var transferReasonId: Long = 0 + var transferReasonId: Long = 0, + + @Id + @Column(name = "rqmnt_manager_id") + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rqmnt_manager_id_seq") + var id: Long = 0 ) : ManagerBaseEntity() diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt index fa733d1acc..10fcb5f5b9 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/PersonManager.kt @@ -19,11 +19,11 @@ import uk.gov.justice.digital.hmpps.integrations.delius.allocations.entity.Manag @Table(name = "offender_manager") @SequenceGenerator(name = "offender_manager_id_seq", sequenceName = "offender_manager_id_seq", allocationSize = 1) class PersonManager( + @Column(name = "offender_id") + var personId: Long = 0, + @Id @Column(name = "offender_manager_id") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "offender_manager_id_seq") - var id: Long = 0, - - @Column(name = "offender_id") - var personId: Long = 0 + var id: Long = 0 ) : ManagerBaseEntity() diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ResponsibleOfficer.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ResponsibleOfficer.kt index bedd55de9d..01599d00da 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ResponsibleOfficer.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/person/ResponsibleOfficer.kt @@ -28,11 +28,6 @@ import java.time.ZonedDateTime allocationSize = 1 ) class ResponsibleOfficer( - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "responsible_officer_id_generator") - @Column(name = "responsible_officer_id", nullable = false) - val id: Long = 0, - @Column(name = "offender_id") val personId: Long, @@ -61,5 +56,10 @@ class ResponsibleOfficer( var createdDatetime: ZonedDateTime? = null, @LastModifiedDate - var lastUpdatedDatetime: ZonedDateTime? = null + var lastUpdatedDatetime: ZonedDateTime? = null, + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "responsible_officer_id_generator") + @Column(name = "responsible_officer_id", nullable = false) + val id: Long = 0 ) From dacaef8091b12ba997f15c1c12becbda945426a6 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Fri, 6 Dec 2024 17:32:50 +0000 Subject: [PATCH 16/42] escape ' ' required so that sql works against h2 database. If not included, generated sql is escape ''. This does not return required data against h2 database. --- .../integrations/delius/event/sentence/DisposalRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt index 009b99ee09..34325257c5 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt @@ -41,7 +41,7 @@ interface DisposalRepository : JpaRepository { and e.softDeleted = false and d.softDeleted = false and e.active = true and d.active = true and om.active = true - and s.code like '%U' + and s.code like '%U' ESCAPE ' ' """ ) fun findAllUnallocatedActiveEvents(personId: Long): List From 34e5b4d8da532c0775293209cd9b657f77052ed4 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Fri, 6 Dec 2024 22:24:58 +0000 Subject: [PATCH 17/42] update spring jpa dialect for h2 db --- .../integrations/delius/event/sentence/DisposalRepository.kt | 2 +- .../src/main/resources/application.yml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt index 34325257c5..009b99ee09 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt @@ -41,7 +41,7 @@ interface DisposalRepository : JpaRepository { and e.softDeleted = false and d.softDeleted = false and e.active = true and d.active = true and om.active = true - and s.code like '%U' ESCAPE ' ' + and s.code like '%U' """ ) fun findAllUnallocatedActiveEvents(personId: Long): List diff --git a/projects/workforce-allocations-to-delius/src/main/resources/application.yml b/projects/workforce-allocations-to-delius/src/main/resources/application.yml index 73d4922f69..facd9c9059 100644 --- a/projects/workforce-allocations-to-delius/src/main/resources/application.yml +++ b/projects/workforce-allocations-to-delius/src/main/resources/application.yml @@ -84,7 +84,9 @@ spring.config.activate.on-profile: dev --- spring.config.activate.on-profile: integration-test spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH;DB_CLOSE_ON_EXIT=FALSE - +spring: + jpa: + database-platform: org.hibernate.dialect.HSQLDialect --- spring.config.activate.on-profile: oracle spring: From bf24b41962e7542253b67df90ea28b5e1b38cd2e Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 9 Dec 2024 09:10:09 +0000 Subject: [PATCH 18/42] undo update to application.yml do to ci failure --- .../integrations/delius/event/sentence/DisposalRepository.kt | 2 +- .../src/main/resources/application.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt index 009b99ee09..34325257c5 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/sentence/DisposalRepository.kt @@ -41,7 +41,7 @@ interface DisposalRepository : JpaRepository { and e.softDeleted = false and d.softDeleted = false and e.active = true and d.active = true and om.active = true - and s.code like '%U' + and s.code like '%U' ESCAPE ' ' """ ) fun findAllUnallocatedActiveEvents(personId: Long): List diff --git a/projects/workforce-allocations-to-delius/src/main/resources/application.yml b/projects/workforce-allocations-to-delius/src/main/resources/application.yml index facd9c9059..d76845ac4c 100644 --- a/projects/workforce-allocations-to-delius/src/main/resources/application.yml +++ b/projects/workforce-allocations-to-delius/src/main/resources/application.yml @@ -86,7 +86,7 @@ spring.config.activate.on-profile: integration-test spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH;DB_CLOSE_ON_EXIT=FALSE spring: jpa: - database-platform: org.hibernate.dialect.HSQLDialect + database-platform: org.hibernate.dialect.H2Dialect --- spring.config.activate.on-profile: oracle spring: From 9867c20093fb915a60f9d869cf5fc94372499e36 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 9 Dec 2024 09:19:29 +0000 Subject: [PATCH 19/42] undo update to application.yml do to ci failure --- .../src/main/resources/application.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/projects/workforce-allocations-to-delius/src/main/resources/application.yml b/projects/workforce-allocations-to-delius/src/main/resources/application.yml index d76845ac4c..03c0963012 100644 --- a/projects/workforce-allocations-to-delius/src/main/resources/application.yml +++ b/projects/workforce-allocations-to-delius/src/main/resources/application.yml @@ -84,9 +84,6 @@ spring.config.activate.on-profile: dev --- spring.config.activate.on-profile: integration-test spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH;DB_CLOSE_ON_EXIT=FALSE -spring: - jpa: - database-platform: org.hibernate.dialect.H2Dialect --- spring.config.activate.on-profile: oracle spring: From c64b51524f0ea3c50d911e5f5da6cc18d0f2adb6 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 9 Dec 2024 17:48:19 +0000 Subject: [PATCH 20/42] add NumericBooleanConverter, to prevent local build failure --- .../digital/hmpps/integration/delius/entity/Alias.kt | 8 ++++---- .../hmpps/integration/delius/entity/PersonAddress.kt | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Alias.kt b/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Alias.kt index daf236a7b6..bafeada206 100644 --- a/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Alias.kt +++ b/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/Alias.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.integration.delius.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import java.time.LocalDate @@ -22,6 +20,8 @@ class Alias( val surname: String, @Column(name = "date_of_birth_date") val dateOfBirth: LocalDate, + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @Column(name = "alias_id") diff --git a/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/PersonAddress.kt b/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/PersonAddress.kt index 5c1f52afe2..bf542a57eb 100644 --- a/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/PersonAddress.kt +++ b/projects/core-person-record-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integration/delius/entity/PersonAddress.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.integration.delius.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import org.springframework.data.jpa.repository.EntityGraph import org.springframework.data.jpa.repository.JpaRepository @@ -29,6 +30,8 @@ class PersonAddress( val noFixedAbode: Boolean, val startDate: LocalDate, val endDate: LocalDate?, + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean, @Id @Column(name = "offender_address_id") From e440e73e4ec0d1de52a05d895f1a626416f91175 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 9 Dec 2024 17:59:19 +0000 Subject: [PATCH 21/42] add NumericBooleanConverter, to prevent local build failure --- .../kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt index 264186b850..a8e743cb3b 100644 --- a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt +++ b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Person.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import uk.gov.justice.digital.hmpps.exception.NotFoundException @@ -21,7 +19,8 @@ class Person( @Column(columnDefinition = "char(7)") val crn: String, - @Column + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) From b731653d4074fbf2a5c5eb6eff0eaf76132926aa Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Tue, 10 Dec 2024 10:29:42 +0000 Subject: [PATCH 22/42] add ESCAPE statement so that test passes with h2 db --- .../justice/digital/hmpps/ProbationAreaIntegrationTest.kt | 2 ++ .../justice/digital/hmpps/entity/ProbationAreaEntity.kt | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/projects/pathfinder-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationAreaIntegrationTest.kt b/projects/pathfinder-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationAreaIntegrationTest.kt index 9648fc499b..274c0acf5b 100644 --- a/projects/pathfinder-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationAreaIntegrationTest.kt +++ b/projects/pathfinder-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationAreaIntegrationTest.kt @@ -5,6 +5,7 @@ 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.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.result.MockMvcResultMatchers.status @@ -17,6 +18,7 @@ import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @AutoConfigureMockMvc @SpringBootTest(webEnvironment = RANDOM_PORT) +@TestPropertySource(properties = ["logging.level.org.hibernate.SQL=DEBUG", "logging.level.org.hibernate.orm.jdbc.bind=TRACE"]) internal class ProbationAreaIntegrationTest { @Autowired lateinit var mockMvc: MockMvc diff --git a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ProbationAreaEntity.kt b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ProbationAreaEntity.kt index e2cc75ae4f..4dbc4614ad 100644 --- a/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ProbationAreaEntity.kt +++ b/projects/pathfinder-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ProbationAreaEntity.kt @@ -93,8 +93,8 @@ interface ProbationAreaRepository : JpaRepository { from District d join d.borough b join b.probationArea pa - where pa.description not like 'ZZ%' - and (d.selectable = true or d.code like '%UAT' or d.code like '%UNA' or d.code like '%IAV') + where pa.description not like 'ZZ%' ESCAPE ' ' + and (d.selectable = true or d.code like '%UAT' ESCAPE ' ' or d.code like '%UNA' ESCAPE ' ' or d.code like '%IAV' ESCAPE ' ') and pa.selectable = true and (pa.establishment is null or pa.establishment <> 'Y') """ @@ -107,8 +107,8 @@ interface ProbationAreaRepository : JpaRepository { from District d join d.borough b join b.probationArea pa - where pa.description not like 'ZZ%' - and (d.selectable = true or d.code like '%UAT' or d.code like '%UNA' or d.code like '%IAV') + where pa.description not like 'ZZ%' ESCAPE ' ' + and (d.selectable = true or d.code like '%UAT' ESCAPE ' ' or d.code like '%UNA' ESCAPE ' ' or d.code like '%IAV' ESCAPE ' ') and (pa.establishment is null or pa.establishment <> 'Y') """ ) From cc558344b0ead7d9615533b143260756c5997bd0 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Tue, 10 Dec 2024 10:35:12 +0000 Subject: [PATCH 23/42] remove sql debug logging --- .../gov/justice/digital/hmpps/ProbationAreaIntegrationTest.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/pathfinder-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationAreaIntegrationTest.kt b/projects/pathfinder-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationAreaIntegrationTest.kt index 274c0acf5b..9648fc499b 100644 --- a/projects/pathfinder-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationAreaIntegrationTest.kt +++ b/projects/pathfinder-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ProbationAreaIntegrationTest.kt @@ -5,7 +5,6 @@ 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.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.result.MockMvcResultMatchers.status @@ -18,7 +17,6 @@ import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @AutoConfigureMockMvc @SpringBootTest(webEnvironment = RANDOM_PORT) -@TestPropertySource(properties = ["logging.level.org.hibernate.SQL=DEBUG", "logging.level.org.hibernate.orm.jdbc.bind=TRACE"]) internal class ProbationAreaIntegrationTest { @Autowired lateinit var mockMvc: MockMvc From 9cd91a3db18655652ac73e8f5234336429a71608 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Tue, 10 Dec 2024 10:51:17 +0000 Subject: [PATCH 24/42] add NumericBooleanConverter, to prevent local test failure --- .../main/kotlin/uk/gov/justice/digital/hmpps/entity/Address.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Address.kt b/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Address.kt index a0f77d3e39..a870e56706 100644 --- a/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Address.kt +++ b/projects/prison-education-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Address.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.hibernate.type.YesNoConverter import java.time.LocalDate @@ -30,5 +31,7 @@ class Address( @Convert(converter = YesNoConverter::class) val noFixedAbode: Boolean? = false, var endDate: LocalDate? = null, + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) From 90f3f5eb40c671de66aba524d465ac1f6b8b2658 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Tue, 10 Dec 2024 11:11:24 +0000 Subject: [PATCH 25/42] add NumericBooleanConverter, to prevent local test failure --- .../justice/digital/hmpps/service/entity/UpwAppointment.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/UpwAppointment.kt b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/UpwAppointment.kt index b245734988..40de6c7d9f 100644 --- a/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/UpwAppointment.kt +++ b/projects/sentence-plan-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/entity/UpwAppointment.kt @@ -3,6 +3,7 @@ package uk.gov.justice.digital.hmpps.service.entity import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.jpa.repository.Query @@ -16,6 +17,8 @@ class UpwAppointment( val minutesCredited: Long?, @Column(columnDefinition = "char(1)") val attended: String?, + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, @JoinColumn(name = "upw_details_id") @ManyToOne @@ -34,6 +37,8 @@ class UpwDetails( @ManyToOne val disposal: Disposal, + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, ) From 3ed5a0d33ca57dbf8cf0cbfe978da46ae07a60ab Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Tue, 10 Dec 2024 11:18:04 +0000 Subject: [PATCH 26/42] add ESCAPE statement so that test passes with h2 db --- .../justice/digital/hmpps/entity/ProbationAreaEntity.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ProbationAreaEntity.kt b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ProbationAreaEntity.kt index e2cc75ae4f..4dbc4614ad 100644 --- a/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ProbationAreaEntity.kt +++ b/projects/soc-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/ProbationAreaEntity.kt @@ -93,8 +93,8 @@ interface ProbationAreaRepository : JpaRepository { from District d join d.borough b join b.probationArea pa - where pa.description not like 'ZZ%' - and (d.selectable = true or d.code like '%UAT' or d.code like '%UNA' or d.code like '%IAV') + where pa.description not like 'ZZ%' ESCAPE ' ' + and (d.selectable = true or d.code like '%UAT' ESCAPE ' ' or d.code like '%UNA' ESCAPE ' ' or d.code like '%IAV' ESCAPE ' ') and pa.selectable = true and (pa.establishment is null or pa.establishment <> 'Y') """ @@ -107,8 +107,8 @@ interface ProbationAreaRepository : JpaRepository { from District d join d.borough b join b.probationArea pa - where pa.description not like 'ZZ%' - and (d.selectable = true or d.code like '%UAT' or d.code like '%UNA' or d.code like '%IAV') + where pa.description not like 'ZZ%' ESCAPE ' ' + and (d.selectable = true or d.code like '%UAT' ESCAPE ' ' or d.code like '%UNA' ESCAPE ' ' or d.code like '%IAV' ESCAPE ' ') and (pa.establishment is null or pa.establishment <> 'Y') """ ) From 1d9a0a953c338963c387c1c4fc83f62859b8bc52 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Tue, 10 Dec 2024 11:47:03 +0000 Subject: [PATCH 27/42] add NumericBooleanConverter, to prevent local test failure --- .../controller/casedetails/entity/AliasEntity.kt | 10 ++++------ .../casedetails/entity/RegistrationEntity.kt | 14 ++++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/AliasEntity.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/AliasEntity.kt index a904a8775f..a2e5467858 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/AliasEntity.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/AliasEntity.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.casedetails.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import java.time.LocalDate @Immutable @@ -31,5 +27,7 @@ class AliasEntity( @ManyToOne @JoinColumn(name = "offender_id", nullable = false) val case: CaseEntity, + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/RegistrationEntity.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/RegistrationEntity.kt index 04724eb3cb..ff233f979a 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/RegistrationEntity.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/casedetails/entity/RegistrationEntity.kt @@ -1,13 +1,9 @@ package uk.gov.justice.digital.hmpps.controller.casedetails.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.JoinColumn -import jakarta.persistence.ManyToOne -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import uk.gov.justice.digital.hmpps.integrations.common.entity.ReferenceData import java.time.LocalDate @@ -33,7 +29,13 @@ class RegistrationEntity( @ManyToOne @JoinColumn(name = "registration_level", updatable = false) val level: ReferenceData, + + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false, + + @Column(name = "deregistered", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val deregistered: Boolean = false ) From 177fb1fa0999551ccfb11b6ea001732194a2d57e Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Wed, 11 Dec 2024 11:31:27 +0000 Subject: [PATCH 28/42] amend sql to fix failing test against h2 db --- .../justice/digital/hmpps/SentenceIntegrationTest.kt | 12 ++++++------ .../delius/sentence/entity/LicenceCondition.kt | 2 +- .../delius/sentence/entity/SentenceRepository.kt | 8 +++++++- .../justice/digital/hmpps/service/ContactService.kt | 2 +- .../digital/hmpps/service/ContactServiceTest.kt | 8 ++++---- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentenceIntegrationTest.kt b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentenceIntegrationTest.kt index cc6987f1e5..7203103252 100644 --- a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentenceIntegrationTest.kt +++ b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentenceIntegrationTest.kt @@ -152,6 +152,12 @@ class SentenceIntegrationTest { ), "3 minutes completed (of 12 hours)", listOf( + LicenceCondition( + LC_WITHOUT_NOTES.id, + LIC_COND_MAIN_CAT.description, + imposedReleasedDate = LocalDate.now().minusDays(14), + licenceConditionNotes = listOf() + ), LicenceCondition( LC_WITH_NOTES.id, LIC_COND_MAIN_CAT.description, @@ -181,12 +187,6 @@ class SentenceIntegrationTest { ) ) ), - LicenceCondition( - LC_WITHOUT_NOTES.id, - LIC_COND_MAIN_CAT.description, - imposedReleasedDate = LocalDate.now().minusDays(14), - licenceConditionNotes = listOf() - ), LicenceCondition( LC_WITH_NOTES_WITHOUT_ADDED_BY.id, LIC_COND_MAIN_CAT.description, diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt index 3d44b5b54d..f4b861810a 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/LicenceCondition.kt @@ -55,7 +55,7 @@ interface LicenceConditionRepository : JpaRepository { JOIN FETCH lc.mainCategory mc LEFT JOIN FETCH lc.subCategory WHERE lc.disposalId = :disposalId - ORDER BY mc.description ASC + ORDER BY mc.description, lc.id ASC """ ) fun findAllByDisposalId(disposalId: Long): List diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt index fb762a48d6..102aee1ae8 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt @@ -47,7 +47,13 @@ interface OffenderManagerRepository : JpaRepository { fun countOffenderManagersByPerson(person: Person): Long - fun findOffenderManagersByPersonOrderByEndDateDesc(person: Person): List + @Query(""" + SELECT om + FROM OffenderManager om + WHERE om.person.id = :id + ORDER BY om.endDate NULLS FIRST + """) + fun findOffenderManagersByPersonOrderByEndDateDesc(id: Long): List } fun OffenderManagerRepository.getByCrn(crn: String) = diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ContactService.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ContactService.kt index 07c425ae98..11a6c4891c 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ContactService.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ContactService.kt @@ -23,7 +23,7 @@ class ContactService( fun getContacts(crn: String): ProfessionalContact { val person = personRepository.getPerson(crn) - val contacts = offenderManagerRepository.findOffenderManagersByPersonOrderByEndDateDesc(person) + val contacts = offenderManagerRepository.findOffenderManagersByPersonOrderByEndDateDesc(person.id) if (contacts.isEmpty()) { throw NotFoundException("Offender Manager records", "crn", crn) diff --git a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/ContactServiceTest.kt b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/ContactServiceTest.kt index 2aa2c6ebc9..1cdb60a930 100644 --- a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/ContactServiceTest.kt +++ b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/service/ContactServiceTest.kt @@ -67,7 +67,7 @@ class ContactServiceTest { fun `no offender manager records`() { whenever(personRepository.findByCrn(PersonGenerator.OVERVIEW.crn)).thenReturn(PersonGenerator.OVERVIEW) whenever( - offenderManagerRepository.findOffenderManagersByPersonOrderByEndDateDesc(PersonGenerator.OVERVIEW) + offenderManagerRepository.findOffenderManagersByPersonOrderByEndDateDesc(PersonGenerator.OVERVIEW.id) ).thenReturn(listOf()) val exception = assertThrows { @@ -81,7 +81,7 @@ class ContactServiceTest { verify(personRepository, times(1)).findByCrn(PersonGenerator.OVERVIEW.crn) verify(offenderManagerRepository, times(1)).findOffenderManagersByPersonOrderByEndDateDesc( - PersonGenerator.OVERVIEW + PersonGenerator.OVERVIEW.id ) verifyNoMoreInteractions(personRepository) @@ -108,7 +108,7 @@ class ContactServiceTest { whenever(personRepository.findByCrn(PersonGenerator.OVERVIEW.crn)).thenReturn(PersonGenerator.OVERVIEW) whenever( - offenderManagerRepository.findOffenderManagersByPersonOrderByEndDateDesc(PersonGenerator.OVERVIEW) + offenderManagerRepository.findOffenderManagersByPersonOrderByEndDateDesc(PersonGenerator.OVERVIEW.id) ).thenReturn( listOf(OFFENDER_MANAGER_ACTIVE, OFFENDER_MANAGER_INACTIVE) ) @@ -119,7 +119,7 @@ class ContactServiceTest { verify(personRepository, times(1)).findByCrn(PersonGenerator.OVERVIEW.crn) verify(offenderManagerRepository, times(1)).findOffenderManagersByPersonOrderByEndDateDesc( - PersonGenerator.OVERVIEW + PersonGenerator.OVERVIEW.id ) verifyNoMoreInteractions(personRepository) From 853e9626e128ae53c871c0b5395a177b06c4a7b4 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Wed, 11 Dec 2024 12:47:37 +0000 Subject: [PATCH 29/42] amend sql to fix failing test in ci --- .../integrations/delius/sentence/entity/SentenceRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt index 102aee1ae8..be13c91991 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt @@ -51,7 +51,7 @@ interface OffenderManagerRepository : JpaRepository { SELECT om FROM OffenderManager om WHERE om.person.id = :id - ORDER BY om.endDate NULLS FIRST + ORDER BY om.endDate """) fun findOffenderManagersByPersonOrderByEndDateDesc(id: Long): List } From 526bf921db842e99e54cd245cea3b39bbd7637b0 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Wed, 11 Dec 2024 16:09:08 +0000 Subject: [PATCH 30/42] update application.yml to remove null ordering and take default value of LOW - LOW is the default one, NULL values are considered as smaller than other values during sorting. --- .../src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/manage-supervision-and-delius/src/main/resources/application.yml b/projects/manage-supervision-and-delius/src/main/resources/application.yml index 87d1ca16b4..f2615f2e48 100644 --- a/projects/manage-supervision-and-delius/src/main/resources/application.yml +++ b/projects/manage-supervision-and-delius/src/main/resources/application.yml @@ -61,7 +61,7 @@ logging.level: --- spring.config.activate.on-profile: integration-test -spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle;DEFAULT_NULL_ORDERING=HIGH +spring.datasource.url: jdbc:h2:mem:./test;MODE=Oracle --- spring.config.activate.on-profile: oracle From 410ba1feb0894d6614b87ea5946edaffa5829a54 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Wed, 11 Dec 2024 17:13:01 +0000 Subject: [PATCH 31/42] update queries to fix failing test against h2 db --- .../integrations/delius/personalDetails/entity/Alias.kt | 8 ++++---- .../digital/hmpps/integrations/delius/user/entity/User.kt | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Alias.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Alias.kt index 127874d0ce..fe0405f586 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Alias.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/personalDetails/entity/Alias.kt @@ -1,11 +1,9 @@ package uk.gov.justice.digital.hmpps.integrations.delius.overview.entity -import jakarta.persistence.Column -import jakarta.persistence.Entity -import jakarta.persistence.Id -import jakarta.persistence.Table +import jakarta.persistence.* import org.hibernate.annotations.Immutable import org.hibernate.annotations.SQLRestriction +import org.hibernate.type.NumericBooleanConverter import org.springframework.data.jpa.repository.JpaRepository @Immutable @@ -26,6 +24,8 @@ class Alias( val thirdName: String? = null, @Column(name = "surname", length = 35) val surname: String, + @Column(name = "soft_deleted", columnDefinition = "number") + @Convert(converter = NumericBooleanConverter::class) val softDeleted: Boolean = false ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/user/entity/User.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/user/entity/User.kt index 09fd2c1f45..a705513ac1 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/user/entity/User.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/user/entity/User.kt @@ -405,10 +405,10 @@ interface CaseloadRepository : JpaRepository { left join fetch d.type dt where c.staff.id = :id and (:nameOrCrn is null - or upper(p.crn) like '%' || upper(:nameOrCrn) || '%' - or upper(p.forename || ' ' || p.surname) like '%' || upper(:nameOrCrn) || '%' - or upper(p.surname || ' ' || p.forename) like '%' || upper(:nameOrCrn) || '%' - or upper(p.surname || ', ' || p.forename) like '%' || upper(:nameOrCrn) || '%') + or upper(p.crn) like '%' || upper(:nameOrCrn) || '%' ESCAPE '\' + or upper(p.forename || ' ' || p.surname) like '%' || upper(:nameOrCrn) || '%' ESCAPE '\' + or upper(p.surname || ' ' || p.forename) like '%' || upper(:nameOrCrn) || '%' ESCAPE '\' + or upper(p.surname || ', ' || p.forename) like '%' || upper(:nameOrCrn) || '%' ESCAPE '\') and (:nextContactCode is null or (upper(trim(naType.code)) = upper(trim(:nextContactCode)))) and (:sentenceCode is null or (upper(trim(dt.code)) = upper(trim(:sentenceCode)))) """ From cf5d89df1c60753d5bb1b0f4e4e85857f71c5348 Mon Sep 17 00:00:00 2001 From: "probation-integration-bot[bot]" <177347787+probation-integration-bot[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:15:12 +0000 Subject: [PATCH 32/42] Formatting changes --- .../gov/justice/digital/hmpps/MessagingIntegrationTest.kt | 2 +- .../digital/hmpps/ReferralControllerIntegrationTest.kt | 2 -- .../kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt | 6 +++++- .../delius/custody/date/CustodyDateUpdateService.kt | 2 +- .../uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt | 6 +++++- .../delius/sentence/entity/SentenceRepository.kt | 6 ++++-- .../kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt | 1 + 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt index e9bf510892..b655735861 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt @@ -150,7 +150,7 @@ internal class MessagingIntegrationTest { @Order(1) fun `booking made creates referral and contact`() { setUpTestSpecificData() - + // Given a booking-made event val event = prepEvent("booking-made", wireMockServer.port()) diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt index 6436839e72..8b26b65574 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt @@ -38,7 +38,6 @@ class ReferralControllerIntegrationTest { @Autowired lateinit var residenceRepository: ResidenceRepository - @Test fun `existing referrals for a crn are returned successfully`() { referralRepository.save(ReferralGenerator.EXISTING_REFERRAL) @@ -82,7 +81,6 @@ class ReferralControllerIntegrationTest { .andReturn().response.contentAsJson() assertThat(res, equalTo(detail)) - } companion object { diff --git a/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 268427a6ca..0727afcea0 100644 --- a/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/custody-key-dates-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -101,7 +101,11 @@ class DataLoader( createPersonWithKeyDates(PersonGenerator.PERSON_WITH_KEYDATES_BY_CRN, "48340A", keyDateTypes) } - private fun createPersonWithKeyDates(personRef: Person, bookingRef: String, keyDateTypes: List): Custody { + private fun createPersonWithKeyDates( + personRef: Person, + bookingRef: String, + keyDateTypes: List + ): Custody { val person = personRepository.save(personRef) val event = eventRepository.save(generateEvent(person, "1")) orderManagerRepository.save(generateOrderManager(event)) diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/CustodyDateUpdateService.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/CustodyDateUpdateService.kt index e800428b98..10ae004560 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/CustodyDateUpdateService.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/custody/date/CustodyDateUpdateService.kt @@ -94,7 +94,7 @@ class CustodyDateUpdateService( existing.changeDate(date) } else { val kdt = referenceDataRepository.findKeyDateType(code) - KeyDate( this, kdt, date) + KeyDate(this, kdt, date) } } diff --git a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt index 4758b153be..39393660a4 100644 --- a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt +++ b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt @@ -66,7 +66,11 @@ internal class ApiIntegrationTest { @ParameterizedTest @MethodSource("caseIdentifiers") - fun `successful retrieval of a case record by crn or noms id`(identifier: String, person: Person, loadData: Boolean) { + fun `successful retrieval of a case record by crn or noms id`( + identifier: String, + person: Person, + loadData: Boolean + ) { if (loadData) { loadTestData() } diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt index be13c91991..d15991e303 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/sentence/entity/SentenceRepository.kt @@ -47,12 +47,14 @@ interface OffenderManagerRepository : JpaRepository { fun countOffenderManagersByPerson(person: Person): Long - @Query(""" + @Query( + """ SELECT om FROM OffenderManager om WHERE om.person.id = :id ORDER BY om.endDate - """) + """ + ) fun findOffenderManagersByPersonOrderByEndDateDesc(id: Long): List } diff --git a/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 899331c33f..368b2d72f1 100644 --- a/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/resettlement-passport-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -100,6 +100,7 @@ class DataLoader( ) ) } + fun EntityManager.saveAll(vararg any: Any) = any.forEach { merge(it) } private fun createAppointments(person: Person) { From 97e02eeb60b2e4a6e6196ece376f48e731086395 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Fri, 3 Jan 2025 17:34:37 +0000 Subject: [PATCH 33/42] PI-2673 - move test data creation back to data loader. Use entityManager.merge to resolve issue with detached entities. --- .../justice/digital/hmpps/data/DataLoader.kt | 6 ++- .../hmpps/data/EntityManagerDataLoader.kt | 26 ++++++++++++ .../hmpps/data/ReferralBookingDataLoader.kt | 34 ++++++++++++++++ .../hmpps/data/generator/AddressGenerator.kt | 4 ++ .../hmpps/data/generator/ReferralGenerator.kt | 5 +++ .../hmpps/MessagingIntegrationInactiveTest.kt | 12 +----- .../digital/hmpps/MessagingIntegrationTest.kt | 8 +--- .../ReferralControllerIntegrationTest.kt | 40 +++---------------- 8 files changed, 81 insertions(+), 54 deletions(-) create mode 100644 projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt create mode 100644 projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 08220a56b2..94c04d8ab1 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -65,7 +65,9 @@ class DataLoader( private val lduRepository: LduRepository, private val staffUserRepository: StaffUserRepository, private val boroughRepository: BoroughRepository, + private val referralBookingDataLoader: ReferralBookingDataLoader, private val documentDataLoader: DocumentDataLoader, + private val entityManagerDataLoader: EntityManagerDataLoader ) : ApplicationListener { @@ -166,6 +168,7 @@ class DataLoader( ) ) + entityManagerDataLoader.loadData() eventRepository.save(PersonGenerator.EVENT) eventRepository.save(PersonGenerator.INACTIVE_EVENT) registrationRepository.save( @@ -211,8 +214,9 @@ class DataLoader( ) eventRepository.save(ANOTHER_EVENT) - personRepository.save(PersonGenerator.PERSON_WITH_BOOKING) + probationCaseDataLoader.loadData() + referralBookingDataLoader.loadData() documentDataLoader.loadData() } } diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt new file mode 100644 index 0000000000..9cc368c354 --- /dev/null +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt @@ -0,0 +1,26 @@ +package uk.gov.justice.digital.hmpps.data + +import jakarta.persistence.EntityManager +import jakarta.persistence.PersistenceContext +import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Transactional +import uk.gov.justice.digital.hmpps.data.generator.AddressGenerator +import uk.gov.justice.digital.hmpps.data.generator.ReferralGenerator + +@Component +class EntityManagerDataLoader { + + @PersistenceContext + private lateinit var entityManager: EntityManager + + @Transactional + fun loadData() { + AddressGenerator.PERSON_ADDRESS_ID = entityManager.merge(AddressGenerator.PERSON_ADDRESS).id + AddressGenerator.INACTIVE_PERSON_ADDRESS_ID = entityManager.merge(AddressGenerator.INACTIVE_PERSON_ADDRESS).id + entityManager.merge(ReferralGenerator.EXISTING_REFERRAL) + entityManager.merge(ReferralGenerator.BOOKING_WITHOUT_ARRIVAL) + ReferralGenerator.BOOKING_ARRIVED_DB_RECORD = entityManager.merge(ReferralGenerator.BOOKING_ARRIVED) + ReferralGenerator.BOOKING_DEPARTED_DB_RECORD = entityManager.merge(ReferralGenerator.BOOKING_DEPARTED) + } + +} \ No newline at end of file diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt new file mode 100644 index 0000000000..7882602810 --- /dev/null +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt @@ -0,0 +1,34 @@ +package uk.gov.justice.digital.hmpps.data + +import org.springframework.stereotype.Component +import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator +import uk.gov.justice.digital.hmpps.data.generator.ReferralGenerator +import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ResidenceRepository +import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonRepository + +@Component +class ReferralBookingDataLoader( + private val personRepository: PersonRepository, + private val residenceRepository: ResidenceRepository +) { + fun loadData() { + personRepository.save(PersonGenerator.PERSON_WITH_BOOKING) + ReferralGenerator.ARRIVAL = residenceRepository.save( + ReferralGenerator.generateResidence( + PersonGenerator.PERSON_WITH_BOOKING, + ReferralGenerator.BOOKING_ARRIVED_DB_RECORD!!, + arrivalDateTime = ReferralGenerator.ARRIVAL.arrivalDate, + ) + ) + ReferralGenerator.DEPARTURE = residenceRepository.save( + ReferralGenerator.generateResidence( + PersonGenerator.PERSON_WITH_BOOKING, + ReferralGenerator.BOOKING_DEPARTED_DB_RECORD!!, + arrivalDateTime = ReferralGenerator.DEPARTURE.arrivalDate, + departureDateTime = ReferralGenerator.DEPARTURE.departureDate + ) + ) + } + + +} \ No newline at end of file diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt index 402a5a1959..dfdf0ba857 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt @@ -13,6 +13,8 @@ object AddressGenerator { postcode = "MB01 3TD" ) + var PERSON_ADDRESS_ID: Long? = null + var INACTIVE_PERSON_ADDRESS = generatePersonAddress( personId = PersonGenerator.PERSON_INACTIVE_EVENT.id, addressNumber = "12", @@ -21,6 +23,8 @@ object AddressGenerator { postcode = "MB01 3TD" ) + var INACTIVE_PERSON_ADDRESS_ID: Long? = null + val Q001 = generateAddress( addressNumber = "1", streetName = "Promise Street", diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt index 78e9102ad5..720b411e08 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt @@ -31,6 +31,8 @@ object ReferralGenerator { expectedArrivalDate = LocalDate.now(), expectedDepartureDate = LocalDate.now().plusDays(7), ) + var BOOKING_ARRIVED_DB_RECORD:Referral? = null + var ARRIVAL = generateResidence(PersonGenerator.PERSON_WITH_BOOKING, BOOKING_ARRIVED) val DEPARTED_ID = UUID.randomUUID().toString() @@ -41,6 +43,9 @@ object ReferralGenerator { expectedArrivalDate = LocalDate.now().minusDays(8), expectedDepartureDate = LocalDate.now().minusDays(1) ) + + var BOOKING_DEPARTED_DB_RECORD:Referral? = null + var DEPARTURE = generateResidence( PersonGenerator.PERSON_WITH_BOOKING, BOOKING_DEPARTED, departureDateTime = ZonedDateTime.of( diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt index e6c0cbc668..49e65555d3 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt @@ -22,7 +22,6 @@ import uk.gov.justice.digital.hmpps.datetime.EuropeLondon import uk.gov.justice.digital.hmpps.integrations.approvedpremises.EventDetails import uk.gov.justice.digital.hmpps.integrations.approvedpremises.PersonArrived import uk.gov.justice.digital.hmpps.integrations.approvedpremises.PersonDeparted -import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.PreferredResidenceRepository import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ReferralRepository import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ResidenceRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.ContactRepository @@ -73,16 +72,9 @@ internal class MessagingIntegrationInactiveTest { @Autowired private lateinit var residenceRepository: ResidenceRepository - @Autowired - private lateinit var preferredResidenceRepository: PreferredResidenceRepository - @Autowired private lateinit var staffRepository: StaffRepository - fun setUpTestSpecificData() { - personAddressRepository.save(AddressGenerator.INACTIVE_PERSON_ADDRESS) - } - @Test fun `application submission with an inactive event creates an alert contact`() { // Given an application-submitted event @@ -133,8 +125,6 @@ internal class MessagingIntegrationInactiveTest { @Test @Order(1) fun `booking made with inactive event creates referral and contact`() { - setUpTestSpecificData() - // Given a booking-made event val event = prepEvent("booking-made-inactive", wireMockServer.port()) @@ -245,7 +235,7 @@ internal class MessagingIntegrationInactiveTest { // And the main address is updated to be that of the approved premises - consequently any existing main address is made previous val addresses = personAddressRepository.findAll().filter { it.personId == PersonGenerator.PERSON_INACTIVE_EVENT.id } - .associateBy { it.id == AddressGenerator.INACTIVE_PERSON_ADDRESS.id } + .associateBy { it.id == AddressGenerator.INACTIVE_PERSON_ADDRESS_ID } assertThat(addresses.size, equalTo(2)) val previous = addresses[true]!! assertThat(previous.endDate, equalTo(details.arrivedAt.toLocalDate())) diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt index b655735861..08f3263b73 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt @@ -94,10 +94,6 @@ internal class MessagingIntegrationTest { } while (message != null) } - fun setUpTestSpecificData() { - personAddressRepository.save(AddressGenerator.PERSON_ADDRESS) - } - @Test fun `application submission creates an alert contact`() { // Given an application-submitted event @@ -149,8 +145,6 @@ internal class MessagingIntegrationTest { @Test @Order(1) fun `booking made creates referral and contact`() { - setUpTestSpecificData() - // Given a booking-made event val event = prepEvent("booking-made", wireMockServer.port()) @@ -301,7 +295,7 @@ internal class MessagingIntegrationTest { // And the main address is updated to be that of the approved premises - consequently any existing main address is made previous val addresses = personAddressRepository.findAll().filter { it.personId == PersonGenerator.DEFAULT.id } - .associateBy { it.id == AddressGenerator.PERSON_ADDRESS.id } + .associateBy { it.id == AddressGenerator.PERSON_ADDRESS_ID } assertThat(addresses.size, equalTo(2)) val previous = addresses[true]!! assertThat(previous.endDate, equalTo(details.arrivedAt.toLocalDate())) diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt index 8b26b65574..f0f599273e 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ReferralControllerIntegrationTest.kt @@ -16,8 +16,6 @@ import uk.gov.justice.digital.hmpps.data.generator.ApprovedPremisesGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.ReferralGenerator import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.Referral -import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ReferralRepository -import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.ResidenceRepository import uk.gov.justice.digital.hmpps.model.ApReferral import uk.gov.justice.digital.hmpps.model.ApprovedPremises import uk.gov.justice.digital.hmpps.model.ExistingReferrals @@ -32,15 +30,8 @@ class ReferralControllerIntegrationTest { @Autowired lateinit var mockMvc: MockMvc - @Autowired - lateinit var referralRepository: ReferralRepository - - @Autowired - lateinit var residenceRepository: ResidenceRepository - @Test fun `existing referrals for a crn are returned successfully`() { - referralRepository.save(ReferralGenerator.EXISTING_REFERRAL) val person = PersonGenerator.DEFAULT val res = mockMvc .perform(get("/probation-case/${person.crn}/referrals").withToken()) @@ -50,30 +41,9 @@ class ReferralControllerIntegrationTest { assertThat(res.referrals.size, equalTo(1)) } - @ParameterizedTest() + @ParameterizedTest @MethodSource("bookingDetails") - fun `referral detail is returned correctly`(bookingId: String, detail: ReferralDetail, loadData: Boolean) { - if (loadData) { - referralRepository.save(ReferralGenerator.BOOKING_WITHOUT_ARRIVAL) - ReferralGenerator.BOOKING_ARRIVED = referralRepository.save(ReferralGenerator.BOOKING_ARRIVED) - ReferralGenerator.BOOKING_DEPARTED = referralRepository.save(ReferralGenerator.BOOKING_DEPARTED) - ReferralGenerator.ARRIVAL = residenceRepository.save( - ReferralGenerator.generateResidence( - PersonGenerator.PERSON_WITH_BOOKING, - ReferralGenerator.BOOKING_ARRIVED, - arrivalDateTime = ReferralGenerator.ARRIVAL.arrivalDate, - ) - ) - ReferralGenerator.DEPARTURE = residenceRepository.save( - ReferralGenerator.generateResidence( - PersonGenerator.PERSON_WITH_BOOKING, - ReferralGenerator.BOOKING_DEPARTED, - arrivalDateTime = ReferralGenerator.DEPARTURE.arrivalDate, - departureDateTime = ReferralGenerator.DEPARTURE.departureDate - ) - ) - } - + fun `referral detail is returned correctly`(bookingId: String, detail: ReferralDetail) { val person = PersonGenerator.PERSON_WITH_BOOKING val res = mockMvc .perform(get("/probation-case/${person.crn}/referrals/$bookingId").withToken()) @@ -99,19 +69,19 @@ class ReferralControllerIntegrationTest { @JvmStatic fun bookingDetails() = listOf( - Arguments.of(ReferralGenerator.BOOKING_ID, ReferralGenerator.BOOKING_WITHOUT_ARRIVAL.detail(), true), + Arguments.of(ReferralGenerator.BOOKING_ID, ReferralGenerator.BOOKING_WITHOUT_ARRIVAL.detail()), Arguments.of( ReferralGenerator.ARRIVED_ID, ReferralGenerator.BOOKING_ARRIVED.detail( ReferralGenerator.ARRIVAL.arrivalDate - ), false + ) ), Arguments.of( ReferralGenerator.DEPARTED_ID, ReferralGenerator.BOOKING_DEPARTED.detail( ReferralGenerator.DEPARTURE.arrivalDate, ReferralGenerator.DEPARTURE.departureDate - ), false + ) ) ) } From c71147d6f1a95a74bddd73c096d470ce72bc6642 Mon Sep 17 00:00:00 2001 From: "probation-integration-bot[bot]" <177347787+probation-integration-bot[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 18:17:13 +0000 Subject: [PATCH 34/42] Formatting changes --- .../kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt | 2 +- .../gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt | 1 - .../justice/digital/hmpps/data/ReferralBookingDataLoader.kt | 2 -- .../justice/digital/hmpps/data/generator/ReferralGenerator.kt | 4 ++-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 94c04d8ab1..3cd704aedb 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -69,7 +69,7 @@ class DataLoader( private val documentDataLoader: DocumentDataLoader, private val entityManagerDataLoader: EntityManagerDataLoader - ) : ApplicationListener { +) : ApplicationListener { @PostConstruct fun saveAuditUser() { diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt index 9cc368c354..2bf16b2760 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt @@ -22,5 +22,4 @@ class EntityManagerDataLoader { ReferralGenerator.BOOKING_ARRIVED_DB_RECORD = entityManager.merge(ReferralGenerator.BOOKING_ARRIVED) ReferralGenerator.BOOKING_DEPARTED_DB_RECORD = entityManager.merge(ReferralGenerator.BOOKING_DEPARTED) } - } \ No newline at end of file diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt index 7882602810..08b866804f 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt @@ -29,6 +29,4 @@ class ReferralBookingDataLoader( ) ) } - - } \ No newline at end of file diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt index 720b411e08..7bfabb2cd6 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt @@ -31,7 +31,7 @@ object ReferralGenerator { expectedArrivalDate = LocalDate.now(), expectedDepartureDate = LocalDate.now().plusDays(7), ) - var BOOKING_ARRIVED_DB_RECORD:Referral? = null + var BOOKING_ARRIVED_DB_RECORD: Referral? = null var ARRIVAL = generateResidence(PersonGenerator.PERSON_WITH_BOOKING, BOOKING_ARRIVED) @@ -44,7 +44,7 @@ object ReferralGenerator { expectedDepartureDate = LocalDate.now().minusDays(1) ) - var BOOKING_DEPARTED_DB_RECORD:Referral? = null + var BOOKING_DEPARTED_DB_RECORD: Referral? = null var DEPARTURE = generateResidence( PersonGenerator.PERSON_WITH_BOOKING, BOOKING_DEPARTED, From 40d58af4e0cec86d91f9c4593e0191e48f884f54 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 6 Jan 2025 16:29:25 +0000 Subject: [PATCH 35/42] PI-2673 - move test data creation back to data loader --- .../justice/digital/hmpps/data/DataLoader.kt | 25 +++++++- .../hmpps/data/EntityManagerDataLoader.kt | 30 ++++++++++ .../AllocationMessagingIntegrationTest.kt | 6 -- .../digital/hmpps/ApiIntegrationTest.kt | 57 ++----------------- 4 files changed, 60 insertions(+), 58 deletions(-) create mode 100644 projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt diff --git a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 65371f21c4..ca2b37e1e9 100644 --- a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -28,6 +28,7 @@ import java.time.LocalDate @ConditionalOnProperty("seed.database") class DataLoader( private val auditUserRepository: AuditUserRepository, + private val staffUserRepository: StaffUserRepository, private val referenceDataSetRepository: ReferenceDataSetRepository, private val referenceDataRepository: ReferenceDataRepository, private val registerTypeRepository: RegisterTypeRepository, @@ -37,13 +38,15 @@ class DataLoader( private val teamRepository: TeamRepository, private val staffRepository: StaffRepository, private val personRepository: PersonRepository, + private val personManagerRepository: PersonManagerRepository, private val eventRepository: EventRepository, private val disposalRepository: DisposalRepository, private val custodyRepository: CustodyRepository, private val caseAllocationRepository: CaseAllocationRepository, private val registrationRepository: RegistrationRepository, private val keyDateRepository: KeyDateRepository, - private val contactTypeRepository: ContactTypeRepository + private val contactTypeRepository: ContactTypeRepository, + private val entityManagerDataLoader: EntityManagerDataLoader ) : ApplicationListener { @PostConstruct @@ -75,9 +78,18 @@ class DataLoader( districtRepository.save(ProviderGenerator.DEFAULT_DISTRICT) teamRepository.saveAll(PersonManagerGenerator.ALL.map { it.team } + ProviderGenerator.POM_TEAM + ProviderGenerator.UNALLOCATED_TEAM) + val staffMap = entityManagerDataLoader.loadData() staffRepository.save(ProviderGenerator.generateStaff("Test", "Test", "Test")) + UserGenerator.DEFAULT_STAFF_USER = staffUserRepository.save( + StaffUser( + UserGenerator.DEFAULT_STAFF_USER.username, + staffMap[ProviderGenerator.DEFAULT_STAFF.code], + UserGenerator.DEFAULT_STAFF_USER.id + ) + ) + personRepository.saveAll( listOf( PersonGenerator.DEFAULT, @@ -90,6 +102,17 @@ class DataLoader( PersonGenerator.PERSON_MULTIPLE_CUSTODIAL ) ) + personManagerRepository.saveAll( + PersonManagerGenerator.ALL.map { + PersonManagerGenerator.generate( + team = it.team, + staff = staffMap[it.staff.code]!!, + person = it.person, + active = it.active, + softDeleted = it.softDeleted + ) + } + ) eventRepository.saveAll(CaseAllocationGenerator.ALL.map { it.event }) disposalRepository.saveAll(CaseAllocationGenerator.ALL.map { it.event.disposal }) diff --git a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt new file mode 100644 index 0000000000..e65de4ceac --- /dev/null +++ b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.data + +import jakarta.persistence.EntityManager +import jakarta.persistence.PersistenceContext +import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Transactional +import uk.gov.justice.digital.hmpps.data.generator.PersonManagerGenerator +import uk.gov.justice.digital.hmpps.data.generator.ProviderGenerator +import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.Staff + +@Component +class EntityManagerDataLoader{ + + @PersistenceContext + private lateinit var entityManager: EntityManager + + @Transactional + fun loadData():Map { + + val staffMap = (PersonManagerGenerator.ALL.map { it.staff } + ProviderGenerator.UNALLOCATED_STAFF).associateBy { it.code } + + val savedStaffMap = staffMap.map { + entityManager.merge(it.value) + }.associateBy { it.code } + + return savedStaffMap + + } + +} \ No newline at end of file diff --git a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt index 8af1c3613a..0af8f57432 100644 --- a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt +++ b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocationMessagingIntegrationTest.kt @@ -26,7 +26,6 @@ import uk.gov.justice.digital.hmpps.entity.PrisonStaff import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactRepository import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactType import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.PrisonManagerRepository -import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.StaffRepository import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.repository.PrisonStaffRepository import uk.gov.justice.digital.hmpps.resourceloader.ResourceLoader.notification @@ -58,9 +57,6 @@ internal class AllocationMessagingIntegrationTest { @Autowired lateinit var contactRepository: ContactRepository - @Autowired - lateinit var staffRepo: StaffRepository - @Order(1) @Test fun `no change if not yet ready to allocate`() { @@ -173,8 +169,6 @@ internal class AllocationMessagingIntegrationTest { @Order(4) @Test fun `deallocate POM successfully`() { - staffRepo.save(ProviderGenerator.UNALLOCATED_STAFF) - val existingPom = prisonManagerRepository.findActiveManagerAtDate(PersonGenerator.DEFAULT.id, ZonedDateTime.now())!! diff --git a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt index 39393660a4..9c069b2c2a 100644 --- a/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt +++ b/projects/manage-pom-cases-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ApiIntegrationTest.kt @@ -13,12 +13,10 @@ import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import uk.gov.justice.digital.hmpps.api.model.* -import uk.gov.justice.digital.hmpps.data.PersonManagerRepository -import uk.gov.justice.digital.hmpps.data.StaffUserRepository -import uk.gov.justice.digital.hmpps.data.generator.* +import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator +import uk.gov.justice.digital.hmpps.data.generator.ProviderGenerator +import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.Person -import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.StaffRepository -import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.StaffUser import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.contentAsJson import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken @@ -29,52 +27,9 @@ internal class ApiIntegrationTest { @Autowired lateinit var mockMvc: MockMvc - @Autowired - lateinit var staffRepository: StaffRepository - - @Autowired - lateinit var staffUserRepository: StaffUserRepository - - @Autowired - lateinit var personManagerRepository: PersonManagerRepository - - fun loadTestData() { - val staffMap = staffRepository.saveAll( - PersonManagerGenerator.ALL.map { it.staff } + - ProviderGenerator.UNALLOCATED_STAFF).associateBy { it.code } - - UserGenerator.DEFAULT_STAFF_USER = staffUserRepository.save( - StaffUser( - UserGenerator.DEFAULT_STAFF_USER.username, - staffMap[ProviderGenerator.DEFAULT_STAFF.code], - UserGenerator.DEFAULT_STAFF_USER.id - ) - ) - - personManagerRepository.saveAll( - PersonManagerGenerator.ALL.map { - PersonManagerGenerator.generate( - team = it.team, - staff = staffMap[it.staff.code]!!, - person = it.person, - active = it.active, - softDeleted = it.softDeleted - ) - } - ) - } - @ParameterizedTest @MethodSource("caseIdentifiers") - fun `successful retrieval of a case record by crn or noms id`( - identifier: String, - person: Person, - loadData: Boolean - ) { - if (loadData) { - loadTestData() - } - + fun `successful retrieval of a case record by crn or noms id`(identifier: String, person: Person) { val record = mockMvc .perform(get("/case-records/$identifier").withToken()) .andExpect(status().is2xxSuccessful) @@ -111,8 +66,8 @@ internal class ApiIntegrationTest { companion object { @JvmStatic fun caseIdentifiers() = listOf( - Arguments.of(PersonGenerator.DEFAULT.crn, PersonGenerator.DEFAULT, true), - Arguments.of(PersonGenerator.DEFAULT.nomsId, PersonGenerator.DEFAULT, false) + Arguments.of(PersonGenerator.DEFAULT.crn, PersonGenerator.DEFAULT), + Arguments.of(PersonGenerator.DEFAULT.nomsId, PersonGenerator.DEFAULT) ) } } From 315f102b7f159697983accbab40d0c875f1ca063 Mon Sep 17 00:00:00 2001 From: "probation-integration-bot[bot]" <177347787+probation-integration-bot[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:32:03 +0000 Subject: [PATCH 36/42] Formatting changes --- .../digital/hmpps/data/EntityManagerDataLoader.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt index e65de4ceac..6c2b4563e6 100644 --- a/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt +++ b/projects/manage-pom-cases-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt @@ -9,22 +9,21 @@ import uk.gov.justice.digital.hmpps.data.generator.ProviderGenerator import uk.gov.justice.digital.hmpps.integrations.delius.provider.entity.Staff @Component -class EntityManagerDataLoader{ +class EntityManagerDataLoader { @PersistenceContext private lateinit var entityManager: EntityManager @Transactional - fun loadData():Map { + fun loadData(): Map { - val staffMap = (PersonManagerGenerator.ALL.map { it.staff } + ProviderGenerator.UNALLOCATED_STAFF).associateBy { it.code } + val staffMap = + (PersonManagerGenerator.ALL.map { it.staff } + ProviderGenerator.UNALLOCATED_STAFF).associateBy { it.code } val savedStaffMap = staffMap.map { entityManager.merge(it.value) }.associateBy { it.code } return savedStaffMap - } - } \ No newline at end of file From cacb78fcd9ad25b7f17096edf7311b89d5c285e4 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 6 Jan 2025 17:36:20 +0000 Subject: [PATCH 37/42] PI-2673 - move test data creation back to data loader --- .../justice/digital/hmpps/data/DataLoader.kt | 5 +++- .../hmpps/data/EntityManagerDataLoader.kt | 23 +++++++++++++++++++ .../hmpps/ReferAndMonitorIntegrationTest.kt | 9 -------- 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt diff --git a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index ec8648575d..9dd8a71666 100644 --- a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -73,7 +73,8 @@ class DataLoader( private val disabilityRepository: DisabilityRepository, private val offenceRepository: OffenceRepository, private val mainOffenceRepository: MainOffenceRepository, - private val teamOfficeLinkRepository: TeamOfficeLinkRepository + private val teamOfficeLinkRepository: TeamOfficeLinkRepository, + private val entityManagerDataLoader: EntityManagerDataLoader ) : ApplicationListener { @PostConstruct @@ -279,6 +280,8 @@ class DataLoader( ) personRepository.save(PersonGenerator.FUZZY_SEARCH) + entityManagerDataLoader.loadData() + nsiManagerRepository.save(NsiGenerator.generateManager(entityManagerDataLoader.NSI_FUZZY_SEARCH!!)) auditUserRepository.save(UserGenerator.LIMITED_ACCESS_USER) personRepository.saveAll( diff --git a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt new file mode 100644 index 0000000000..150a61816c --- /dev/null +++ b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt @@ -0,0 +1,23 @@ +package uk.gov.justice.digital.hmpps.data + +import jakarta.persistence.EntityManager +import jakarta.persistence.PersistenceContext +import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Transactional +import uk.gov.justice.digital.hmpps.data.generator.NsiGenerator +import uk.gov.justice.digital.hmpps.integrations.delius.referral.entity.Nsi + +@Component +class EntityManagerDataLoader { + + @PersistenceContext + private lateinit var entityManager: EntityManager + + var NSI_FUZZY_SEARCH : Nsi? = null + + @Transactional + fun loadData() { + NSI_FUZZY_SEARCH = entityManager.merge(NsiGenerator.FUZZY_SEARCH) + entityManager.merge(NsiGenerator.TERMINATED) + } +} \ No newline at end of file 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 ba7b253254..ff425b5400 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 @@ -24,7 +24,6 @@ import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.Contact import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactOutcome import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactType import uk.gov.justice.digital.hmpps.integrations.delius.event.entity.EventRepository -import uk.gov.justice.digital.hmpps.integrations.delius.referral.NsiManagerRepository import uk.gov.justice.digital.hmpps.integrations.delius.referral.NsiRepository import uk.gov.justice.digital.hmpps.integrations.delius.referral.NsiStatusHistoryRepository import uk.gov.justice.digital.hmpps.integrations.delius.referral.entity.NsiStatus @@ -66,9 +65,6 @@ internal class ReferAndMonitorIntegrationTest { @Autowired lateinit var eventRepository: EventRepository - @Autowired - lateinit var nsiManagerRepository: NsiManagerRepository - @Test @Order(1) fun `session appointment feedback submitted failed to comply`() { @@ -368,11 +364,6 @@ internal class ReferAndMonitorIntegrationTest { @Test fun `failure to find appointment is rejected with reason`() { - NsiGenerator.FUZZY_SEARCH = nsiRepository.save(NsiGenerator.FUZZY_SEARCH) - nsiManagerRepository.save(NsiGenerator.generateManager(NsiGenerator.FUZZY_SEARCH)) - - NsiGenerator.TERMINATED = nsiRepository.save(NsiGenerator.TERMINATED) - val notification = prepNotification( notification("session-appointment-feedback-submitted-not-found"), wireMockServer.port() From 5f0f4b7c32a3604ce04988b9ee07d9fb253b4d3c Mon Sep 17 00:00:00 2001 From: "probation-integration-bot[bot]" <177347787+probation-integration-bot[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:38:05 +0000 Subject: [PATCH 38/42] Formatting changes --- .../gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt index 150a61816c..1363a9c8db 100644 --- a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt +++ b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt @@ -13,10 +13,10 @@ class EntityManagerDataLoader { @PersistenceContext private lateinit var entityManager: EntityManager - var NSI_FUZZY_SEARCH : Nsi? = null + var NSI_FUZZY_SEARCH: Nsi? = null @Transactional - fun loadData() { + fun loadData() { NSI_FUZZY_SEARCH = entityManager.merge(NsiGenerator.FUZZY_SEARCH) entityManager.merge(NsiGenerator.TERMINATED) } From 3e157a2438a5927a4bb46816b4b4703509d11fb7 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 6 Jan 2025 18:21:18 +0000 Subject: [PATCH 39/42] PI-2673 - order response correctly --- .../uk/gov/justice/digital/hmpps/SentencesIntegrationTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentencesIntegrationTest.kt b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentencesIntegrationTest.kt index 890a8997f4..4545762051 100644 --- a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentencesIntegrationTest.kt +++ b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentencesIntegrationTest.kt @@ -69,8 +69,8 @@ class SentencesIntegrationTest { EVENT_1.id, order = MinimalOrder(ACTIVE_ORDER.type.description, ACTIVE_ORDER.date), licenceConditions = listOf( - MinimalLicenceCondition(LC_WITH_NOTES.id, LIC_COND_MAIN_CAT.description), MinimalLicenceCondition(LC_WITHOUT_NOTES.id, LIC_COND_MAIN_CAT.description), + MinimalLicenceCondition(LC_WITH_NOTES.id, LIC_COND_MAIN_CAT.description), MinimalLicenceCondition(LC_WITH_NOTES_WITHOUT_ADDED_BY.id, LIC_COND_MAIN_CAT.description), MinimalLicenceCondition(LC_WITH_1500_CHAR_NOTE.id, LIC_COND_MAIN_CAT.description) ), From 0888f9be2faf798c39dbc582cd28f74121b692e6 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 6 Jan 2025 18:36:14 +0000 Subject: [PATCH 40/42] PI-2673 - move test variables to entityManagerDataLoader --- .../hmpps/data/EntityManagerDataLoader.kt | 17 +++++++++++++---- .../hmpps/data/ReferralBookingDataLoader.kt | 7 ++++--- .../hmpps/data/generator/AddressGenerator.kt | 4 ---- .../hmpps/data/generator/ReferralGenerator.kt | 3 --- .../hmpps/MessagingIntegrationInactiveTest.kt | 6 +++++- .../digital/hmpps/MessagingIntegrationTest.kt | 6 +++++- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt index 2bf16b2760..8b6dcb6a53 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt @@ -6,6 +6,7 @@ import org.springframework.stereotype.Component import org.springframework.transaction.annotation.Transactional import uk.gov.justice.digital.hmpps.data.generator.AddressGenerator import uk.gov.justice.digital.hmpps.data.generator.ReferralGenerator +import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.Referral @Component class EntityManagerDataLoader { @@ -13,13 +14,21 @@ class EntityManagerDataLoader { @PersistenceContext private lateinit var entityManager: EntityManager + var personAddressId: Long? = null + + var inactivePersonAddressId: Long? = null + + var bookingArrivedDbRecord: Referral? = null + + var bookingDepartedDbRecord: Referral? = null + @Transactional fun loadData() { - AddressGenerator.PERSON_ADDRESS_ID = entityManager.merge(AddressGenerator.PERSON_ADDRESS).id - AddressGenerator.INACTIVE_PERSON_ADDRESS_ID = entityManager.merge(AddressGenerator.INACTIVE_PERSON_ADDRESS).id + personAddressId = entityManager.merge(AddressGenerator.PERSON_ADDRESS).id + inactivePersonAddressId = entityManager.merge(AddressGenerator.INACTIVE_PERSON_ADDRESS).id entityManager.merge(ReferralGenerator.EXISTING_REFERRAL) entityManager.merge(ReferralGenerator.BOOKING_WITHOUT_ARRIVAL) - ReferralGenerator.BOOKING_ARRIVED_DB_RECORD = entityManager.merge(ReferralGenerator.BOOKING_ARRIVED) - ReferralGenerator.BOOKING_DEPARTED_DB_RECORD = entityManager.merge(ReferralGenerator.BOOKING_DEPARTED) + bookingArrivedDbRecord = entityManager.merge(ReferralGenerator.BOOKING_ARRIVED) + bookingDepartedDbRecord = entityManager.merge(ReferralGenerator.BOOKING_DEPARTED) } } \ No newline at end of file diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt index 08b866804f..97f3c212d1 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ReferralBookingDataLoader.kt @@ -9,21 +9,22 @@ import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonRepository @Component class ReferralBookingDataLoader( private val personRepository: PersonRepository, - private val residenceRepository: ResidenceRepository + private val residenceRepository: ResidenceRepository, + private val entityManagerDataLoader: EntityManagerDataLoader ) { fun loadData() { personRepository.save(PersonGenerator.PERSON_WITH_BOOKING) ReferralGenerator.ARRIVAL = residenceRepository.save( ReferralGenerator.generateResidence( PersonGenerator.PERSON_WITH_BOOKING, - ReferralGenerator.BOOKING_ARRIVED_DB_RECORD!!, + entityManagerDataLoader.bookingArrivedDbRecord!!, arrivalDateTime = ReferralGenerator.ARRIVAL.arrivalDate, ) ) ReferralGenerator.DEPARTURE = residenceRepository.save( ReferralGenerator.generateResidence( PersonGenerator.PERSON_WITH_BOOKING, - ReferralGenerator.BOOKING_DEPARTED_DB_RECORD!!, + entityManagerDataLoader.bookingDepartedDbRecord!!, arrivalDateTime = ReferralGenerator.DEPARTURE.arrivalDate, departureDateTime = ReferralGenerator.DEPARTURE.departureDate ) diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt index dfdf0ba857..402a5a1959 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/AddressGenerator.kt @@ -13,8 +13,6 @@ object AddressGenerator { postcode = "MB01 3TD" ) - var PERSON_ADDRESS_ID: Long? = null - var INACTIVE_PERSON_ADDRESS = generatePersonAddress( personId = PersonGenerator.PERSON_INACTIVE_EVENT.id, addressNumber = "12", @@ -23,8 +21,6 @@ object AddressGenerator { postcode = "MB01 3TD" ) - var INACTIVE_PERSON_ADDRESS_ID: Long? = null - val Q001 = generateAddress( addressNumber = "1", streetName = "Promise Street", diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt index 7bfabb2cd6..7b603db0ee 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ReferralGenerator.kt @@ -31,7 +31,6 @@ object ReferralGenerator { expectedArrivalDate = LocalDate.now(), expectedDepartureDate = LocalDate.now().plusDays(7), ) - var BOOKING_ARRIVED_DB_RECORD: Referral? = null var ARRIVAL = generateResidence(PersonGenerator.PERSON_WITH_BOOKING, BOOKING_ARRIVED) @@ -44,8 +43,6 @@ object ReferralGenerator { expectedDepartureDate = LocalDate.now().minusDays(1) ) - var BOOKING_DEPARTED_DB_RECORD: Referral? = null - var DEPARTURE = generateResidence( PersonGenerator.PERSON_WITH_BOOKING, BOOKING_DEPARTED, departureDateTime = ZonedDateTime.of( diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt index 49e65555d3..04ee09597f 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationInactiveTest.kt @@ -17,6 +17,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT import org.springframework.test.context.bean.override.mockito.MockitoBean +import uk.gov.justice.digital.hmpps.data.EntityManagerDataLoader import uk.gov.justice.digital.hmpps.data.generator.* import uk.gov.justice.digital.hmpps.datetime.EuropeLondon import uk.gov.justice.digital.hmpps.integrations.approvedpremises.EventDetails @@ -75,6 +76,9 @@ internal class MessagingIntegrationInactiveTest { @Autowired private lateinit var staffRepository: StaffRepository + @Autowired + private lateinit var entityManagerDataLoader: EntityManagerDataLoader + @Test fun `application submission with an inactive event creates an alert contact`() { // Given an application-submitted event @@ -235,7 +239,7 @@ internal class MessagingIntegrationInactiveTest { // And the main address is updated to be that of the approved premises - consequently any existing main address is made previous val addresses = personAddressRepository.findAll().filter { it.personId == PersonGenerator.PERSON_INACTIVE_EVENT.id } - .associateBy { it.id == AddressGenerator.INACTIVE_PERSON_ADDRESS_ID } + .associateBy { it.id == entityManagerDataLoader.inactivePersonAddressId } assertThat(addresses.size, equalTo(2)) val previous = addresses[true]!! assertThat(previous.endDate, equalTo(details.arrivedAt.toLocalDate())) diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt index 08f3263b73..511b18b6eb 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt @@ -18,6 +18,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT import org.springframework.test.context.bean.override.mockito.MockitoBean +import uk.gov.justice.digital.hmpps.data.EntityManagerDataLoader import uk.gov.justice.digital.hmpps.data.generator.* import uk.gov.justice.digital.hmpps.datetime.EuropeLondon import uk.gov.justice.digital.hmpps.integrations.approvedpremises.EventDetails @@ -86,6 +87,9 @@ internal class MessagingIntegrationTest { @Autowired private lateinit var staffRepository: StaffRepository + @Autowired + private lateinit var entityManagerDataLoader: EntityManagerDataLoader + @BeforeEach fun clearTopic() { val topic = channelManager.getChannel(topicName) @@ -295,7 +299,7 @@ internal class MessagingIntegrationTest { // And the main address is updated to be that of the approved premises - consequently any existing main address is made previous val addresses = personAddressRepository.findAll().filter { it.personId == PersonGenerator.DEFAULT.id } - .associateBy { it.id == AddressGenerator.PERSON_ADDRESS_ID } + .associateBy { it.id == entityManagerDataLoader.personAddressId } assertThat(addresses.size, equalTo(2)) val previous = addresses[true]!! assertThat(previous.endDate, equalTo(details.arrivedAt.toLocalDate())) From f202507d2c7ff21e75059276b85da22b673786b8 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Mon, 6 Jan 2025 19:13:46 +0000 Subject: [PATCH 41/42] PI-2673 - rename variable --- .../kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt | 2 +- .../gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 9dd8a71666..bc2b5e39f2 100644 --- a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -281,7 +281,7 @@ class DataLoader( personRepository.save(PersonGenerator.FUZZY_SEARCH) entityManagerDataLoader.loadData() - nsiManagerRepository.save(NsiGenerator.generateManager(entityManagerDataLoader.NSI_FUZZY_SEARCH!!)) + nsiManagerRepository.save(NsiGenerator.generateManager(entityManagerDataLoader.nsiFuzzySearch!!)) auditUserRepository.save(UserGenerator.LIMITED_ACCESS_USER) personRepository.saveAll( diff --git a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt index 1363a9c8db..392b0de86a 100644 --- a/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt +++ b/projects/refer-and-monitor-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/EntityManagerDataLoader.kt @@ -13,11 +13,11 @@ class EntityManagerDataLoader { @PersistenceContext private lateinit var entityManager: EntityManager - var NSI_FUZZY_SEARCH: Nsi? = null + var nsiFuzzySearch: Nsi? = null @Transactional fun loadData() { - NSI_FUZZY_SEARCH = entityManager.merge(NsiGenerator.FUZZY_SEARCH) + nsiFuzzySearch = entityManager.merge(NsiGenerator.FUZZY_SEARCH) entityManager.merge(NsiGenerator.TERMINATED) } } \ No newline at end of file From 1cac6a2a17edcfa7f092a2398af63350ab389027 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Wed, 8 Jan 2025 11:36:25 +0000 Subject: [PATCH 42/42] PI-2673 - apply review comment --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b6993f3239..de26dc9756 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ plugins { kotlin("plugin.spring") version "2.1.0" apply false kotlin("plugin.jpa") version "2.1.0" apply false id("org.springframework.boot") version "3.4.0" apply false - id("io.spring.dependency-management") version "1.1.6" apply false + id("io.spring.dependency-management") version "1.1.7" apply false id("com.gorylenko.gradle-git-properties") version "2.4.2" apply false id("com.google.cloud.tools.jib") apply false id("base")