From 2ee72e0c51b69731370cfe193a67206333fd8bf1 Mon Sep 17 00:00:00 2001 From: allanmckenzie Date: Thu, 23 Apr 2026 09:12:05 +0100 Subject: [PATCH 1/4] Upgrade to Java 21 and Jakarta EE 10.0 --- CHANGELOG.md | 12 + .../annotation-validator-core/pom.xml | 2 +- .../annotation-validator-maven-plugin/pom.xml | 16 +- .../AnnotationValidatorFactoryTest.java | 2 +- annotation-validator/pom.xml | 2 +- domain-test-dsl/pom.xml | 4 +- .../test/AggregateMethodInvocationTest.java | 4 +- .../test/matchers/HasEventsMatcherTest.java | 2 +- embedded-artemis/README.md | 7 - embedded-artemis/pom.xml | 108 ----- .../artemis/EmbeddedArtemisInitializer.java | 79 ---- .../artemis/EmbeddedArtemisServer.java | 166 -------- .../justice/artemis/EmbeddedJMSServer.java | 91 ---- .../uk/gov/justice/artemis/ServerPermit.java | 72 ---- .../EmbeddedArtemisInitializerTest.java | 30 -- .../artemis/EmbeddedArtemisServerIT.java | 97 ----- .../artemis/EmbeddedArtemisServerTest.java | 185 -------- .../artemis/EmbeddedJMSServerTest.java | 91 ---- .../gov/justice/artemis/ServerPermitTest.java | 79 ---- .../framework-api-aggregate-service/pom.xml | 2 +- framework-api/framework-api-all/pom.xml | 2 +- framework-api/framework-api-common/pom.xml | 8 +- .../services/core/annotation/Adapter.java | 2 +- .../services/core/annotation/AnyLiteral.java | 4 +- .../core/annotation/CustomAdapter.java | 2 +- .../annotation/CustomServiceComponent.java | 2 +- .../services/core/annotation/Direct.java | 2 +- .../core/annotation/DirectAdapter.java | 2 +- .../core/annotation/FrameworkComponent.java | 2 +- .../core/annotation/ServiceComponent.java | 2 +- .../annotation/ServiceComponentLocation.java | 2 +- .../core/annotation/MemberInjectionPoint.java | 6 +- .../ServiceComponentLocationTest.java | 2 +- framework-api/framework-api-core/pom.xml | 6 +- .../extension/ServiceComponentFoundEvent.java | 2 +- .../core/json/JsonValidationLoggerHelper.java | 2 +- .../justice/services/messaging/Envelope.java | 2 +- .../services/messaging/JsonEnvelope.java | 12 +- .../JsonObjectEnvelopeConverter.java | 4 +- .../justice/services/messaging/Metadata.java | 2 +- .../logging/HttpTraceLoggerHelper.java | 4 +- .../logging/JmsMessageLoggerHelper.java | 8 +- .../messaging/spi/EnvelopeProvider.java | 4 +- .../messaging/spi/JsonEnvelopeProvider.java | 6 +- .../ServiceComponentFoundEventTest.java | 2 +- .../messaging/spi/DummyEnvelopeProvider.java | 2 +- .../spi/DummyJsonEnvelopeProvider.java | 6 +- .../spi/HighPriorityEnvelopeProvider.java | 2 +- .../spi/HighPriorityJsonEnvelopeProvider.java | 6 +- .../framework-api-direct-adapter/pom.xml | 2 +- framework-api/framework-api-domain/pom.xml | 2 +- .../framework-api-event-buffer/pom.xml | 6 +- .../event/buffer/api/AllowAllEventFilter.java | 6 +- .../framework-api-event-source/pom.xml | 6 +- .../core/annotation/EventSourceName.java | 4 +- .../framework-api-event-stream/pom.xml | 2 +- .../framework-api-healthcheck/pom.xml | 2 +- .../src/main/resources/META-INF/beans.xml | 6 +- .../pom.xml | 6 +- .../interceptors/EventBufferInterceptor.java | 2 +- .../EventBufferServiceCaller.java | 2 +- .../interceptors/EventFilterInterceptor.java | 2 +- .../src/main/resources/META-INF/beans.xml | 6 +- .../framework-api-interceptors/pom.xml | 2 +- .../framework-api-messaging-adapter/pom.xml | 6 +- .../messaging/JmsParameterChecker.java | 2 +- .../adapter/messaging/JmsProcessor.java | 2 +- .../messaging/SubscriptionJmsProcessor.java | 2 +- .../src/main/resources/META-INF/beans.xml | 6 +- .../framework-api-messaging-client/pom.xml | 2 +- .../framework-api-messaging-jms/pom.xml | 6 +- .../messaging/jms/EnvelopeConverter.java | 2 +- .../messaging/jms/MessageConverter.java | 4 +- .../jms/annotation/ConnectionFactoryName.java | 4 +- .../exception/JmsEnvelopeSenderException.java | 4 +- .../framework-api-rest-adapter/pom.xml | 6 +- .../adapter/rest/mapping/ActionMapper.java | 2 +- .../rest/mapping/ActionMapperHelper.java | 2 +- .../adapter/rest/processor/RestProcessor.java | 6 +- .../response/ResponseStrategies.java | 2 +- .../processor/response/ResponseStrategy.java | 2 +- .../framework-api-rest-client/pom.xml | 2 +- framework-api/framework-api-rest-core/pom.xml | 6 +- .../adapter/rest/annotation/PATCH.java | 2 +- .../framework-api-subscription/pom.xml | 6 +- .../annotation/SubscriptionName.java | 4 +- .../framework-api-system-errors/pom.xml | 2 +- framework-api/framework-api-system/pom.xml | 2 +- .../framework-api-unifiedsearch/pom.xml | 6 +- .../unifiedsearch/TransformerApi.java | 2 +- .../unifiedsearch/UnifiedSearchIndexer.java | 2 +- .../unifiedsearch/UnifiedSearchName.java | 4 +- framework-api/framework-api-validator/pom.xml | 2 +- framework-api/pom.xml | 2 +- .../framework-datasource-providers/pom.xml | 6 +- .../JndiJobStoreDataSourceProvider.java | 4 +- .../src/main/resources/META-INF/beans.xml | 4 +- .../framework-datasource-test-utils/pom.xml | 6 +- framework-datasources/pom.xml | 2 +- framework-libraries-bom/pom.xml | 12 +- framework-libraries-version/pom.xml | 2 +- framework-utilities/maven-test-utils/pom.xml | 2 +- framework-utilities/pom.xml | 6 +- framework-utilities/test-utils/pom.xml | 3 +- .../test-utils/test-utils-core/pom.xml | 20 +- .../ExpectedJsonValuesResultCondition.java | 4 +- .../utils/core/http/HttpResponsePoller.java | 12 +- .../utils/core/http/PollingRequestParams.java | 4 +- .../http/PollingRequestParamsBuilder.java | 6 +- .../utils/core/http/PollingRestClient.java | 2 +- .../test/utils/core/http/RequestParams.java | 2 +- .../utils/core/http/RequestParamsBuilder.java | 4 +- .../test/utils/core/http/ResponseData.java | 4 +- .../test/utils/core/http/ResponseDetails.java | 2 +- .../utils/core/http/ResponseValidator.java | 2 +- .../test/utils/core/http/RestPoller.java | 4 +- .../utils/core/http/ValidatingRestClient.java | 6 +- .../core/matchers/ResponseHeadersMatcher.java | 2 +- .../core/matchers/ResponseStatusMatcher.java | 2 +- .../utils/core/messaging/ConsumerClient.java | 12 +- .../messaging/DeadLetterQueueBrowser.java | 16 +- .../core/messaging/JmsSessionFactory.java | 8 +- .../messaging/JsonObjectBuilderWrapper.java | 8 +- .../utils/core/messaging/JsonObjects.java | 22 +- .../core/messaging/MessageConsumerClient.java | 4 +- .../messaging/MessageConsumerFactory.java | 6 +- .../utils/core/messaging/TopicSender.java | 10 +- .../test/utils/core/rest/FilePart.java | 2 +- .../utils/core/rest/MultipartRestClient.java | 2 +- .../test/utils/core/rest/RestClient.java | 13 +- .../core/schema/SchemaDuplicateHelper.java | 4 +- .../core/http/HttpResponsePollerTest.java | 12 +- .../http/PollingRequestParamsBuilderTest.java | 4 +- .../core/http/PollingRestClientTest.java | 8 +- .../core/http/RequestParamsBuilderTest.java | 6 +- .../core/http/ResponseValidatorTest.java | 6 +- .../test/utils/core/http/RestPollerTest.java | 16 +- .../core/http/ValidatingRestClientTest.java | 8 +- .../matchers/ResponseHeadersMatcherTest.java | 8 +- .../matchers/ResponsePayloadMatcherTest.java | 2 +- .../matchers/ResponseStatusMatcherTest.java | 4 +- .../core/messaging/ConsumerClientTest.java | 6 +- .../messaging/DeadLetterQueueBrowserTest.java | 14 +- .../core/messaging/JmsSessionFactoryTest.java | 8 +- .../JsonObjectBuilderWrapperTest.java | 10 +- .../messaging/MessageConsumerClientTest.java | 6 +- .../messaging/MessageConsumerFactoryTest.java | 4 +- .../test/utils/core/rest/RestClientTest.java | 14 +- .../test-utils-framework-api/pom.xml | 2 +- .../api/JsonObjectConvertersFactoryTest.java | 6 +- .../test-utils/test-utils-hibernate/pom.xml | 63 +++ .../HibernateTestEntityManagerProvider.java | 156 +++++++ .../NoEntityManagerFieldFoundException.java | 8 + ...ibernateTestEntityManagerProviderTest.java | 294 +++++++++++++ .../test-utils/test-utils-logging-jdk/pom.xml | 2 +- .../test-utils-logging-log4j/pom.xml | 2 +- .../test-utils-logging-simple/pom.xml | 7 +- framework-utilities/utilities/pom.xml | 2 +- .../utilities/utilities-core/pom.xml | 14 +- .../services/cdi/InitialContextProducer.java | 12 +- .../justice/services/cdi/LoggerProducer.java | 6 +- .../cdi/QualifierAnnotationExtractor.java | 6 +- .../CommonValueAnnotationDef.java | 2 +- .../configuration/ContextNameProvider.java | 2 +- .../common/configuration/GlobalValue.java | 4 +- .../configuration/GlobalValueProducer.java | 6 +- .../JndiBasedServiceContextNameProvider.java | 4 +- .../services/common/configuration/Value.java | 4 +- .../common/configuration/ValueProducer.java | 8 +- .../converter/JSONObjectValueObfuscator.java | 16 +- .../JsonObjectConvertersProducer.java | 4 +- .../JsonObjectToObjectConverter.java | 4 +- .../common/converter/JsonValueFactory.java | 10 +- .../converter/ListToJsonArrayConverter.java | 6 +- .../ObjectToJsonObjectConverter.java | 4 +- .../converter/ObjectToJsonValueConverter.java | 6 +- .../StringToJsonObjectConverter.java | 4 +- .../common/converter/ZonedDateTimes.java | 2 +- .../jackson/ObjectMapperProducer.java | 24 +- .../AdditionalPropertiesDeserializer.java | 8 +- .../IntegerEnumBeanDeserializerModifier.java | 10 +- .../integerenum/IntegerEnumDeserializer.java | 3 +- .../jsr353/InclusionAwareJSR353Module.java | 6 +- .../InclusionAwareJsonValueSerializer.java | 6 +- .../jackson/jsr353/JsonIncludes.java | 8 +- .../LocalDatePersistenceConverter.java | 4 +- .../LocalDateTimePersistenceConverter.java | 4 +- .../polling/MultiIteratingPollerFactory.java | 2 +- .../common/polling/PollerFactory.java | 2 +- .../services/common/util/UtcClock.java | 2 +- .../services/ejb/timer/TimerCanceler.java | 4 +- .../ejb/timer/TimerConfigFactory.java | 2 +- .../ejb/timer/TimerServiceManager.java | 8 +- .../services/messaging/JsonObjects.java | 396 +++++++++++------- .../src/main/resources/META-INF/beans.xml | 6 +- .../cdi/InitialContextProducerTest.java | 4 +- .../services/cdi/LoggerProducerTest.java | 2 +- .../cdi/QualifierAnnotationExtractorTest.java | 10 +- .../GlobalValueProducerTest.java | 4 +- .../configuration/ValueProducerTest.java | 4 +- .../JSONObjectValueObfuscatorTest.java | 6 +- .../JsonObjectToObjectConverterTest.java | 21 +- .../converter/JsonValueFactoryTest.java | 8 +- .../ListToJsonArrayConverterTest.java | 2 +- .../converter/ObjectMapperProducerTest.java | 4 +- .../ObjectToJsonObjectConverterTest.java | 4 +- .../ObjectToJsonValueConverterTest.java | 6 +- .../StringToJsonObjectConverterTest.java | 2 +- .../common/converter/ZonedDateTimesTest.java | 2 +- .../IntegerEnumDeserializerTest.java | 5 +- .../jackson/jsr353/JsonIncludesTest.java | 4 +- .../services/common/polling/PollerTest.java | 2 +- .../services/ejb/timer/TimerCancelerTest.java | 4 +- .../ejb/timer/TimerConfigFactoryTest.java | 2 +- .../ejb/timer/TimerServiceManagerTest.java | 6 +- .../services/messaging/JsonObjectsTest.java | 121 ++++-- .../files-for-testing-io/pom.xml | 2 +- generator-maven-plugin/generator-core/pom.xml | 6 +- .../generator-io-utils/pom.xml | 2 +- .../generator-maven-test-utils/pom.xml | 2 +- .../generator-plugin-it/pom.xml | 23 +- .../generator-plugin/pom.xml | 17 +- .../includes-excludes-external/pom.xml | 2 + .../generator-raml-parser/pom.xml | 14 +- .../json-generator-for-testing-plugin/pom.xml | 8 +- .../test/JsonTitleAppendingGenerator.java | 2 +- .../JsonTitleAppendingGeneratorFactory.java | 2 +- generator-maven-plugin/parser-common/pom.xml | 2 +- generator-maven-plugin/pom.xml | 2 +- .../raml-generator-for-testing-plugin/pom.xml | 2 +- generator-maven-plugin/schema-parser/pom.xml | 12 +- .../io/files/parser/JsonSchemaFileParser.java | 8 +- .../parser/JsonSchemaFileParserFactory.java | 2 +- .../JsonSchemaFileParserFactoryTest.java | 2 +- .../parser/JsonSchemaFileParserTest.java | 4 +- job-manager/example/pom.xml | 8 +- .../cpp/jobmanager/example/BakeryService.java | 8 +- .../jobmanager/example/task/BakeCakeTask.java | 4 +- .../example/task/FillCakeTinTask.java | 4 +- .../example/task/GetIngredientsTask.java | 4 +- .../example/task/GetUtensilsTask.java | 4 +- .../cpp/jobmanager/example/task/JobUtil.java | 2 +- .../example/task/MixIngredientsTask.java | 4 +- .../example/task/SliceAndEatCakeTask.java | 4 +- .../example/task/SwitchOvenOnTask.java | 4 +- .../jobmanager/example/BakeryServiceIT.java | 4 +- .../util/PropertiesFileValueProducer.java | 4 +- job-manager/job-executor/pom.xml | 6 +- .../execution/DefaultExecutionService.java | 4 +- ...aultJobStoreSchedulerPrioritySelector.java | 4 +- .../moj/cpp/task/execution/JobExecutor.java | 12 +- .../moj/cpp/task/execution/JobScheduler.java | 38 +- .../moj/cpp/task/extension/TaskRegistry.java | 8 +- .../moj/cpp/task/extension/TaskScanner.java | 14 +- .../src/main/resources/META-INF/beans.xml | 4 +- ...> jakarta.enterprise.inject.spi.Extension} | 0 .../DefaultExecutionServiceTest.java | 2 +- .../cpp/task/execution/JobExecutorTest.java | 8 +- .../cpp/task/execution/JobSchedulerTest.java | 12 +- .../cpp/task/extension/TaskRegistryTest.java | 2 +- .../cpp/task/extension/TaskScannerTest.java | 16 +- job-manager/job-manager-it/pom.xml | 8 +- .../it/util/OpenEjbJobJdbcRepository.java | 4 +- .../moj/cpp/jobmanager/it/JobSchedulerIT.java | 16 +- .../moj/cpp/jobmanager/it/JobServiceIT.java | 16 +- job-manager/jobstore-api/pom.xml | 8 +- .../cpp/jobstore/api/task/ExecutionInfo.java | 2 +- .../src/main/resources/META-INF/beans.xml | 4 +- .../jobstore/api/task/ExecutionInfoTest.java | 2 +- job-manager/jobstore-liquibase/pom.xml | 2 +- job-manager/jobstore-persistence/pom.xml | 6 +- .../gov/moj/cpp/jobstore/persistence/Job.java | 2 +- .../persistence/JobJdbcRepository.java | 8 +- .../jobstore/persistence/JobRepository.java | 2 +- .../persistence/JobStoreConfiguration.java | 4 +- .../moj/cpp/jobstore/service/JobService.java | 6 +- .../src/main/resources/META-INF/beans.xml | 4 +- .../persistence/JobJdbcRepositoryTest.java | 2 +- .../moj/cpp/jobstore/persistence/JobTest.java | 2 +- .../cpp/jobstore/service/JobServiceTest.java | 2 +- job-manager/pom.xml | 4 +- json-schema-catalog/catalog-core/pom.xml | 8 +- .../schema/catalog/CatalogUpdater.java | 6 +- .../catalog/util/CatalogUpdaterTest.java | 2 +- json-schema-catalog/catalog-domain/pom.xml | 2 +- .../catalog-generation-plugin-it/pom.xml | 7 +- .../catalog-generation-plugin/pom.xml | 12 +- .../catalog-generation/pom.xml | 2 +- .../catalog/generation/SchemaIdParser.java | 6 +- .../generation/SchemaIdParserTest.java | 2 +- .../catalog-integration-test/pom.xml | 2 +- .../catalog-test-utils/pom.xml | 2 +- json-schema-catalog/pom.xml | 6 +- .../example-integration-test/pom.xml | 2 +- .../schema-example-context/pom.xml | 2 +- .../schema-example-command-api/pom.xml | 2 +- .../schema-example-standards/pom.xml | 2 +- json-schema-catalog/schema-service/pom.xml | 8 +- .../schema/service/CatalogProducer.java | 4 +- .../SchemaCatalogResolverProducer.java | 4 +- .../schema/service/SchemaCatalogService.java | 4 +- .../src/main/resources/META-INF/beans.xml | 4 +- .../schema/service/LoggerProducer.java | 6 +- .../service/SchemaCatalogResolverIT.java | 2 +- .../schema/service/SchemaServiceIT.java | 2 +- .../json-transformer-jolt/pom.xml | 12 +- .../justice/json/jolt/JoltTransformer.java | 6 +- .../src/main/resources/META-INF/beans.xml | 6 +- .../json/jolt/JoltTransformerTest.java | 2 +- .../uk/gov/justice/json/jolt/JsonHelper.java | 4 +- json-transformer/pom.xml | 4 +- .../example-pojo-schema/pom.xml | 2 +- .../example-schema-to-pojo-gen-test/pom.xml | 6 +- .../pojo-event-annotation-plugin/pom.xml | 2 +- .../pojo-generation-core/pom.xml | 2 +- .../AddHashcodeAndEqualsPluginTest.java | 4 +- .../builder/BuilderMethodFactoryTest.java | 5 +- .../builder/WithMethodGeneratorTest.java | 11 +- .../pojo-generation-plugin/pom.xml | 12 +- .../pojo-integration-test/pom.xml | 4 +- .../pojo-plugin-it/pom.xml | 4 +- jsonschema-pojo-generator/pom.xml | 4 +- .../standard-test-catalog/pom.xml | 2 +- pom.xml | 28 +- raml-maven/lint-checker-core/pom.xml | 2 +- raml-maven/pom.xml | 2 +- raml-maven/raml-for-testing-io/pom.xml | 2 +- raml-maven/raml-generator-core/pom.xml | 6 +- raml-maven/raml-generator-for-testing/pom.xml | 2 +- raml-maven/raml-maven-io-utils/pom.xml | 2 +- raml-maven/raml-maven-plugin-it/pom.xml | 6 +- raml-maven/raml-maven-plugin/pom.xml | 12 +- raml-maven/raml-parser/pom.xml | 6 +- security-updates.md | 52 +++ 334 files changed, 1800 insertions(+), 1980 deletions(-) delete mode 100644 embedded-artemis/README.md delete mode 100644 embedded-artemis/pom.xml delete mode 100644 embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedArtemisInitializer.java delete mode 100644 embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedArtemisServer.java delete mode 100644 embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedJMSServer.java delete mode 100644 embedded-artemis/src/main/java/uk/gov/justice/artemis/ServerPermit.java delete mode 100644 embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisInitializerTest.java delete mode 100644 embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisServerIT.java delete mode 100644 embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisServerTest.java delete mode 100644 embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedJMSServerTest.java delete mode 100644 embedded-artemis/src/test/java/uk/gov/justice/artemis/ServerPermitTest.java create mode 100644 framework-utilities/test-utils/test-utils-hibernate/pom.xml create mode 100644 framework-utilities/test-utils/test-utils-hibernate/src/main/java/uk/gov/justice/services/test/utils/persistence/HibernateTestEntityManagerProvider.java create mode 100644 framework-utilities/test-utils/test-utils-hibernate/src/main/java/uk/gov/justice/services/test/utils/persistence/NoEntityManagerFieldFoundException.java create mode 100644 framework-utilities/test-utils/test-utils-hibernate/src/test/java/uk/gov/justice/services/test/utils/persistence/HibernateTestEntityManagerProviderTest.java rename job-manager/job-executor/src/main/resources/META-INF/services/{javax.enterprise.inject.spi.Extension => jakarta.enterprise.inject.spi.Extension} (100%) create mode 100644 security-updates.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 05e328410..407acdb03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [21.0.0-SNAPSHOT] - 2026-03-31 +### Changed +- Upgraded to Java 21 and Jakarta EE 10 +- Migrated `javax.jms.*` to `jakarta.jms.*` in embedded Artemis and JMS test utility classes (`EmbeddedArtemisServerIT`, `MessageConsumerClient`, `MessageConsumerFactory`, `JmsSessionFactory`, `DeadLetterQueueBrowser`, `TopicSender`) +- Replaced `javax.xml.bind:jaxb-api` with `jakarta.xml.bind:jakarta.xml.bind-api` in plugin dependencies +- Removed test module 'embedded-artemis' and all associated code, in order to break the dependency on artemis +- Upgraded OpenEJB from `8.0.13` to `10.0.0` (Jakarta EE 10 compatible) — fixes `@Resource` injection in Application Composer integration tests and removes the need for xbean-asm9 overrides as OpenEJB 10 natively supports Java 21 class files +- Fixed `job-manager-it` integration tests (`JobSchedulerIT`, `JobServiceIT`): `@Resource(name = "openejb/Resource/jobStore")` injection now works correctly with OpenEJB 10 + `jakarta.annotation.Resource` +- Fixed `HasEventsMatcherTest` `UnnecessaryStubbingException`: in `shouldReturnTrueIfAllExpectedEventsAreInTheActualEventList`, `event_3` only appears in `actualEvents` so `fieldNames()` is never called on it via `WildcardTextNodeSupport`; replaced `create("event_3")` with a plain `mock(JsonNode.class, "event_3")` for that node, and replaced `lenient()` stubbing in the `create()` helper with strict `when()` stubbing +- Fixed Maven plugin scope warnings: added `provided` to `maven-plugin-api`, `maven-compat`, `maven-core`, and `maven-model` in `annotation-validator-maven-plugin`, `generator-plugin`, and `raml-maven-plugin`; added explicit `provided` declarations for `maven-plugin-api` and `maven-core` in `catalog-generation-plugin` and `pojo-generation-plugin` +- Added `commons-lang3` as an explicit compile dependency to `generator-plugin` (previously pulled in transitively via `maven-core`) +- Fixed `IntegerEnumDeserializer`: changed `super(enumResolver)` to `super(enumResolver, Boolean.FALSE)` — in Jackson 2.15.x the single-arg `EnumDeserializer(EnumResolver)` constructor internally passes `null` for `caseInsensitive` causing `NullPointerException` on unboxing # [17.105.0-M2] - 2026-02-26 ### Added diff --git a/annotation-validator/annotation-validator-core/pom.xml b/annotation-validator/annotation-validator-core/pom.xml index 7b65f01d5..43ba99339 100644 --- a/annotation-validator/annotation-validator-core/pom.xml +++ b/annotation-validator/annotation-validator-core/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.maven annotation-validator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/annotation-validator/annotation-validator-maven-plugin/pom.xml b/annotation-validator/annotation-validator-maven-plugin/pom.xml index 3771984e9..2f4725b70 100644 --- a/annotation-validator/annotation-validator-maven-plugin/pom.xml +++ b/annotation-validator/annotation-validator-maven-plugin/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.maven annotation-validator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -28,21 +28,25 @@ org.apache.maven maven-plugin-api + provided org.apache.maven maven-compat + provided org.apache.maven maven-core + provided org.apache.maven maven-model + provided @@ -82,8 +86,18 @@ annotation-validator-core ${project.version} + + com.google.guava + guava + + + jakarta.inject + jakarta.inject-api + ${jakarta.inject-api.version} + test + org.slf4j slf4j-simple diff --git a/annotation-validator/annotation-validator-maven-plugin/src/test/java/uk/gov/justice/plugin/validator/AnnotationValidatorFactoryTest.java b/annotation-validator/annotation-validator-maven-plugin/src/test/java/uk/gov/justice/plugin/validator/AnnotationValidatorFactoryTest.java index d8062ccea..93c8d075d 100644 --- a/annotation-validator/annotation-validator-maven-plugin/src/test/java/uk/gov/justice/plugin/validator/AnnotationValidatorFactoryTest.java +++ b/annotation-validator/annotation-validator-maven-plugin/src/test/java/uk/gov/justice/plugin/validator/AnnotationValidatorFactoryTest.java @@ -9,7 +9,7 @@ import uk.gov.justice.plugin.domain.TestAnnotation; import uk.gov.justice.plugin.exception.ValidatorNotFoundException; -import javax.inject.Inject; +import jakarta.inject.Inject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/annotation-validator/pom.xml b/annotation-validator/pom.xml index 2eb69e949..8217cf1a6 100644 --- a/annotation-validator/pom.xml +++ b/annotation-validator/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.maven diff --git a/domain-test-dsl/pom.xml b/domain-test-dsl/pom.xml index c2d88e707..9b30f987b 100644 --- a/domain-test-dsl/pom.xml +++ b/domain-test-dsl/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.services @@ -30,7 +30,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.22.2 + ${plugins.maven.failsafe.version} diff --git a/domain-test-dsl/src/test/java/uk/gov/justice/services/test/AggregateMethodInvocationTest.java b/domain-test-dsl/src/test/java/uk/gov/justice/services/test/AggregateMethodInvocationTest.java index 10d26566b..7b464f68c 100644 --- a/domain-test-dsl/src/test/java/uk/gov/justice/services/test/AggregateMethodInvocationTest.java +++ b/domain-test-dsl/src/test/java/uk/gov/justice/services/test/AggregateMethodInvocationTest.java @@ -10,7 +10,7 @@ import uk.gov.justice.services.test.domain.aggregate.GenericAggregate; import uk.gov.justice.services.test.domain.arg.ComplexArgument; -import java.time.ZoneId; +import java.time.ZoneOffset; import java.util.UUID; import org.junit.jupiter.api.BeforeEach; @@ -85,7 +85,7 @@ public void shouldCallMethodWithDateTimeArgFromFile() throws Exception { assertMethodInvocations(aggregateWrapper, "doSthWithDateTimeArg", 1, arrayContaining(ZonedDateTimes.fromString("2017-01-21T16:42:03.522Z") - .withZoneSameInstant(ZoneId.of("UTC")))); + .withZoneSameInstant(ZoneOffset.UTC))); } @Test diff --git a/domain-test-dsl/src/test/java/uk/gov/justice/services/test/matchers/HasEventsMatcherTest.java b/domain-test-dsl/src/test/java/uk/gov/justice/services/test/matchers/HasEventsMatcherTest.java index 3f20469d0..95954a639 100644 --- a/domain-test-dsl/src/test/java/uk/gov/justice/services/test/matchers/HasEventsMatcherTest.java +++ b/domain-test-dsl/src/test/java/uk/gov/justice/services/test/matchers/HasEventsMatcherTest.java @@ -43,7 +43,7 @@ public void shouldReturnTrueIfAllExpectedEventsAreInTheActualEventList() throws final JsonNode event_1 = create("event_1"); final JsonNode event_2 = create("event_2"); - final JsonNode event_3 = create("event_3"); + final JsonNode event_3 = mock(JsonNode.class, "event_3"); final Description description = mock(Description.class); diff --git a/embedded-artemis/README.md b/embedded-artemis/README.md deleted file mode 100644 index 3cc0a4f62..000000000 --- a/embedded-artemis/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Embedded Artemis - -## Usage - -An embedded version of Artemis that can be included in a project for testing. - -Supply the broker.xml in the main/resources or the test/resources folder. diff --git a/embedded-artemis/pom.xml b/embedded-artemis/pom.xml deleted file mode 100644 index e2bc85dc1..000000000 --- a/embedded-artemis/pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - - 4.0.0 - - uk.gov.justice.framework.libraries - framework-libraries - 17.105.0-M3-SNAPSHOT - - uk.gov.justice.artemis - embedded-artemis - - - - - org.apache.activemq - artemis-server - - - org.apache.activemq - artemis-jms-server - - - org.apache.johnzon - johnzon-core - - - - - org.apache.activemq - artemis-core-client - - - org.jboss.logging - jboss-logging - - - - - org.apache.activemq - artemis-jms-client - - - org.apache.activemq - artemis-journal - - - org.jboss.logging - jboss-logging - - - - - org.apache.activemq - artemis-selector - - - org.apache.geronimo.specs - geronimo-jms_2.0_spec - - - org.apache.activemq - artemis-commons - - - com.google.guava - guava - - - commons-logging - commons-logging - - - org.jboss.logging - jboss-logging - - - - - org.jboss.logging - jboss-logging - - - org.slf4j - slf4j-api - - - commons-beanutils - commons-beanutils - - - commons-logging - commons-logging - - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.mockito - mockito-core - test - - - diff --git a/embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedArtemisInitializer.java b/embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedArtemisInitializer.java deleted file mode 100644 index 2a331f152..000000000 --- a/embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedArtemisInitializer.java +++ /dev/null @@ -1,79 +0,0 @@ -package uk.gov.justice.artemis; - -import java.util.Set; - -import org.apache.activemq.artemis.core.security.CheckType; -import org.apache.activemq.artemis.core.security.Role; -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; -import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; - -/** - * - * An utility class for initialising an EmbeddedJMS instance
- * with certain checks and configuration objects. - * - * @see org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS - * - */ -public final class EmbeddedArtemisInitializer { - - /** - * Private constructor to avoid instantiating the utility class. - */ - private EmbeddedArtemisInitializer() {} - - /** - * Initialise an EmbeddedJMS with a configuration XML and security manager. - * - * @param jmsServer to be initialised - * @return EmbeddedJMS - * @see org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS - */ - public static EmbeddedJMS initialize(final EmbeddedJMS jmsServer) { - jmsServer.setConfigResourcePath("broker.xml"); - jmsServer.setSecurityManager(getSecurityManager()); - return jmsServer; - } - - /** - * Ensure that the ActiveMQServerLogger loggers are in the class path and loaded correctly.
- *
- * The ActiveMQServerLogger_$logger classes are generated dynamically and bundled in the
- * executable jars.
- * Having ActiveMQ jars without the bundled _$logger in the class path lead to
- * spurious errors that we want to avoid by having an initialisation check. - */ - public static void checkLoggers() { - org.apache.activemq.artemis.core.server.ActiveMQServerLogger.class.getCanonicalName(); - org.apache.activemq.artemis.core.server.ActiveMQServerLogger_$logger.class - .getCanonicalName(); - } - - /** - * An overridden security manager to cater for multiple test configuration
- * users and passwords.
- *
- * The returned security manager does not check for user passwords or user roles.
- *
- * Different project setups use different user/passwords in connections
- * which can quite conveniently be handled by this SecurityManager. - *
- * The EmbeddedArtemisServer should only be used for testing. - * - * @return ActiveMQSecurityManager - * @see ActiveMQSecurityManager - */ - public static ActiveMQSecurityManager getSecurityManager() { - return new ActiveMQSecurityManager() { - @Override - public boolean validateUser(final String user, final String password) { - return true; - } - @Override - public boolean validateUserAndRole(final String user, final String password, - final Set roles, final CheckType checkType) { - return true; - } - }; - } -} \ No newline at end of file diff --git a/embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedArtemisServer.java b/embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedArtemisServer.java deleted file mode 100644 index fba66b912..000000000 --- a/embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedArtemisServer.java +++ /dev/null @@ -1,166 +0,0 @@ -package uk.gov.justice.artemis; - -import static uk.gov.justice.artemis.EmbeddedArtemisInitializer.initialize; - -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * An embedded Artemis server that should be used only for testing . - * - * Example usage given below
- * - * @BeforeClass - * public static void beforeClass() { - * try{ - * EmbeddedArtemisServer.startServer(); - * }catch(Throwable e){ - * LOG.error("EmbeddedArtemisServer start: ", e); - * fail(e.getMessage()); - * } - * } - * - * @AfterClass - * public static void afterClass() { - * try{ - * EmbeddedArtemisServer.stopServer(); - * }catch(Exception e){ - * LOG.error("EmbeddedArtemisServer stop: ", e); - * } - * } - * - * - * - */ -public final class EmbeddedArtemisServer { - - private static final Logger LOG = LoggerFactory.getLogger(EmbeddedArtemisServer.class); - - /** - * Shutdown hook to ensure that all resources are tidy before exit - */ - static { - Runtime.getRuntime().addShutdownHook(getShutDownHook()); - } - - /** - * Create an instance of the EmbeddedJMSServer - */ - private static EmbeddedJMSServer jmsServer = - new EmbeddedJMSServer().setJmsServer(initialize(new EmbeddedJMS())); - - /** - * Create an explicit permit for invoking methods on the server. - */ - private static ServerPermit serverPermit = new ServerPermit(); - - /** - * Private constructor to avoid instantiating the utility class - */ - private EmbeddedArtemisServer() {} - - /** - * Start an embedded Artemis server using a broker.xml from a projects
- * class path - * - * @param args not expected - * @throws Exception while starting the server. - */ - public static void main(String args[]) throws Exception { - startServer(); - } - - /** - * Start the server after acquiring a permit - * - * @throws Exception if unsuccessful - */ - public static final void startServer() throws Exception { - try (final ServerPermit sp = serverPermit.acquire()) { - jmsServer.start(); - } - } - - /** - * Stop the server after acquiring a permit - * - * @throws Exception if unsuccessful - */ - public static final boolean stopServer() { - try (final ServerPermit sp = serverPermit.acquire()) { - return jmsServer.stop(); - } catch (Exception e) { - LOG.error("EmbeddedArtemisServer", e); - } - return false; - } - - /** - * Get the shutdown hook for stopping the server - * - * @return Thread - */ - public static Thread getShutDownHook() { - return new Thread(() -> { - stopServer(); - }, "EmbeddedArtemisServerRuntimeHook"); - } - - /** - * Get a reference to EmbeddedJMSServer - * - * @return EmbeddedJMSServer - */ - public static EmbeddedJMSServer getJmsServer() { - return jmsServer; - } - - /** - * Set a reference to EmbeddedJMSServer - * - * @param EmbeddedJMSServer - * @see EmbeddedJMSServer - */ - public static void setJmsServer(final EmbeddedJMSServer jmsServer) { - EmbeddedArtemisServer.jmsServer = jmsServer; - } - - /** - * Set a reference to EmbeddedJMS - * - * @return EmbeddedJMS - * @see EmbeddedJMS - */ - public static void setEmbeddedJms(final EmbeddedJMS embeddedJms) { - jmsServer.setJmsServer(embeddedJms); - } - - /** - * Get a reference to EmbeddedJMS - * - * @return EmbeddedJMS - */ - public static EmbeddedJMS getEmbeddedJms() { - return jmsServer.getJmsServer(); - } - - /** - * Get a reference to ServerPermit - * - * @return ServerPermit - */ - public static ServerPermit getServerPermit() { - return serverPermit; - } - - /** - * Set a reference to ServerPermit - * - * @param ServerPermit - */ - public static void setServerPermit(final ServerPermit serverPermit) { - EmbeddedArtemisServer.serverPermit = serverPermit; - } -} diff --git a/embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedJMSServer.java b/embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedJMSServer.java deleted file mode 100644 index 922666c3c..000000000 --- a/embedded-artemis/src/main/java/uk/gov/justice/artemis/EmbeddedJMSServer.java +++ /dev/null @@ -1,91 +0,0 @@ -package uk.gov.justice.artemis; - -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; - -/** - * An embedded JMS server with state checks for operations. - * - * @see org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS - */ -public class EmbeddedJMSServer { - - /** - * @see org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS - */ - private EmbeddedJMS jmsServer; - - /** - * Capture the state of the server - */ - private volatile boolean initialised; - - /** - * Start the server if its not running - * - * @throws Exception if unsuccessful - */ - public void start() throws Exception { - - if (initialised) { - return; - } - - jmsServer.start(); - - initialised = true; - } - - /** - * Stop the server if its running - * - * @throws Exception if unsuccessful - */ - public boolean stop() throws Exception { - - if (initialised) { - jmsServer.stop(); - - initialised = false; - } - - return initialised; - } - - /** - * Get a reference to EmbeddedJMS - * - * @return EmbeddedJMS - */ - public EmbeddedJMS getJmsServer() { - return jmsServer; - } - - /** - * Set a reference to EmbeddedJMS - * - * @return EmbeddedJMS - */ - public EmbeddedJMSServer setJmsServer(final EmbeddedJMS jmsServer) { - this.jmsServer = jmsServer; - return this; - } - - /** - * Get the initialisation flag - * - * @return boolean - */ - public boolean isInitialised() { - return initialised; - } - - /** - * Set the initialisation flag - * - * @param boolean flag - */ - public void setInitialised(final boolean initialised) { - this.initialised = initialised; - } - -} \ No newline at end of file diff --git a/embedded-artemis/src/main/java/uk/gov/justice/artemis/ServerPermit.java b/embedded-artemis/src/main/java/uk/gov/justice/artemis/ServerPermit.java deleted file mode 100644 index a126c4e24..000000000 --- a/embedded-artemis/src/main/java/uk/gov/justice/artemis/ServerPermit.java +++ /dev/null @@ -1,72 +0,0 @@ -package uk.gov.justice.artemis; - -import java.util.concurrent.Semaphore; - -/** - * - * Explicit Permit for restricting access on EmbeddedArtemisServer
- *
- * Current restricted operations include starting and stopping
- * an instance of the EmbeddedJMSServer in a mutually exclusive manner.
- * - * Example usage
- * - * - * try (final ServerPermit sp = serverPermit.acquire()) { - * jmsServer.start(); - * } - * - * - * @see EmbeddedArtemisServer - * @see EmbeddedJMSServer - * - */ -public class ServerPermit implements AutoCloseable { - - private Semaphore semaphore; - - /** - * Create a semaphore with a single permit for exclusion - */ - public ServerPermit() { - semaphore = new Semaphore(1, true); - } - - /** - * Acquire a permit - * - * @return ServerPermit - * @throws InterruptedException - */ - public ServerPermit acquire() throws InterruptedException { - semaphore.acquire(); - return this; - } - - /** - * Release a permit - */ - @Override - public void close() throws Exception { - semaphore.release(); - } - - /** - * Get a reference to Semaphore - * - * @return Semaphore - */ - public Semaphore getSemaphore() { - return semaphore; - } - - /** - * Set a reference to Semaphore - * - * @param Semaphore - */ - public ServerPermit setSemaphore(final Semaphore semaphore) { - this.semaphore = semaphore; - return this; - } -} diff --git a/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisInitializerTest.java b/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisInitializerTest.java deleted file mode 100644 index 5d84eb2ff..000000000 --- a/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisInitializerTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package uk.gov.justice.artemis; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.Collections; - -import org.apache.activemq.artemis.core.security.CheckType; -import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; -import org.junit.jupiter.api.Test; - -public class EmbeddedArtemisInitializerTest { - - - @Test - public void shouldTestActiveMQSecurityManagerAlwaysTrue() { - ActiveMQSecurityManager activeMQSecurityManager = - EmbeddedArtemisInitializer.getSecurityManager(); - assertNotNull(activeMQSecurityManager); - assertTrue(activeMQSecurityManager.validateUser("user", "password")); - assertTrue(activeMQSecurityManager.validateUserAndRole("user", "password", - Collections.emptySet(), CheckType.SEND)); - } - - @Test - public void shouldTestLoggersClassesAreAvailable(){ - EmbeddedArtemisInitializer.checkLoggers(); - } - -} diff --git a/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisServerIT.java b/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisServerIT.java deleted file mode 100644 index 3a7641225..000000000 --- a/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisServerIT.java +++ /dev/null @@ -1,97 +0,0 @@ -package uk.gov.justice.artemis; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; - -import java.util.Arrays; -import java.util.Date; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; - -import org.apache.activemq.artemis.api.core.TransportConfiguration; -import org.apache.activemq.artemis.core.config.Configuration; -import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory; -import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory; -import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration; -import org.apache.activemq.artemis.jms.server.config.JMSConfiguration; -import org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration; -import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl; -import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl; -import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl; -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; -import org.junit.jupiter.api.Test; - -public class EmbeddedArtemisServerIT { - - - @Test - public void shouldTestServerFlow() { - - try { - String queueName = "testQueue"; - - EmbeddedJMS jmsServer = new EmbeddedJMS().setConfiguration(getConfiguration()) - .setJmsConfiguration(getJMSConfiguration(queueName)); - - EmbeddedArtemisServer.setEmbeddedJms(jmsServer); - - EmbeddedArtemisServer.startServer(); - - ConnectionFactory cf = (ConnectionFactory) jmsServer.lookup("cf"); - - Queue queue = (Queue) jmsServer.lookup(String.join("/", "queue", queueName)); - - try (Connection connection = cf.createConnection()) { - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageProducer producer = session.createProducer(queue); - TextMessage message = session.createTextMessage("Hello sent at " + new Date()); - String expected = message.getText(); - producer.send(message); - MessageConsumer messageConsumer = session.createConsumer(queue); - connection.start(); - TextMessage messageReceived = (TextMessage) messageConsumer.receive(1000); - - assertEquals(expected, messageReceived.getText()); - } - } catch (Exception e) { - - fail(); - } finally { - EmbeddedArtemisServer.stopServer(); - } - } - - private Configuration getConfiguration() { - - return new ConfigurationImpl().setPersistenceEnabled(false) - .setJournalDirectory("target/data/journal").setSecurityEnabled(false) - .addAcceptorConfiguration(new TransportConfiguration( - NettyAcceptorFactory.class.getName())) - .addConnectorConfiguration("connector", new TransportConfiguration( - NettyConnectorFactory.class.getName())); - - } - - private JMSConfiguration getJMSConfiguration(String queueName) { - - JMSConfiguration jmsConfig = new JMSConfigurationImpl(); - - ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl() - .setName("cf").setConnectorNames(Arrays.asList("connector")) - .setBindings("cf"); - jmsConfig.getConnectionFactoryConfigurations().add(cfConfig); - - JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl().setName(queueName) - .setDurable(false).setBindings(String.join("/", "queue", queueName)); - jmsConfig.getQueueConfigurations().add(queueConfig); - - return jmsConfig; - } -} diff --git a/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisServerTest.java b/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisServerTest.java deleted file mode 100644 index 74ddd13f4..000000000 --- a/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedArtemisServerTest.java +++ /dev/null @@ -1,185 +0,0 @@ -package uk.gov.justice.artemis; - - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.util.concurrent.Semaphore; - -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; -import org.junit.jupiter.api.Test; - -public class EmbeddedArtemisServerTest { - - @Test - public void shouldStartServerUsingMainMethod() throws Exception { - - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - EmbeddedArtemisServer.setJmsServer(es); - EmbeddedArtemisServer.main(null); - - verify(es, times(1)).start(); - } - - @Test - public void shouldStartServer() throws Exception { - - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - EmbeddedArtemisServer.setJmsServer(es); - EmbeddedArtemisServer.startServer(); - - verify(es, times(1)).start(); - } - - @Test - public void shouldNotStartServerIfServerPermitFails() throws Exception { - - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - ServerPermit sp = mock(ServerPermit.class); - - EmbeddedArtemisServer.setJmsServer(es); - EmbeddedArtemisServer.setServerPermit(sp); - - doThrow(new InterruptedException()).when(sp).acquire(); - - try { - EmbeddedArtemisServer.startServer(); - } catch (InterruptedException ie) { - } - verify(es, never()).start(); - } - - - @Test - public void shouldReleaseServerPermitIfStartServerFails() throws Exception { - - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - Semaphore sem = mock(Semaphore.class); - ServerPermit sp = new ServerPermit(); - sp.setSemaphore(sem); - - EmbeddedArtemisServer.setJmsServer(es); - EmbeddedArtemisServer.setServerPermit(sp); - - doThrow(new Exception()).when(es).start(); - - try { - EmbeddedArtemisServer.startServer(); - } catch (Exception e) { - } - verify(sem, times(1)).release(); - } - - - @Test - public void shouldStopServer() throws Exception { - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - EmbeddedArtemisServer.setJmsServer(es); - EmbeddedArtemisServer.stopServer(); - - verify(es, times(1)).stop(); - } - - @Test - public void shouldNotStopServerIfServerPermitFails() throws Exception { - - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - ServerPermit sp = mock(ServerPermit.class); - - EmbeddedArtemisServer.setJmsServer(es); - EmbeddedArtemisServer.setServerPermit(sp); - - doThrow(new InterruptedException()).when(sp).acquire(); - - EmbeddedArtemisServer.stopServer(); - verify(es, never()).stop(); - } - - - @Test - public void shouldReleaseServerPermitIfStopServerFails() throws Exception { - - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - Semaphore sem = mock(Semaphore.class); - ServerPermit sp = new ServerPermit(); - sp.setSemaphore(sem); - - EmbeddedArtemisServer.setJmsServer(es); - EmbeddedArtemisServer.setServerPermit(sp); - - doThrow(new Exception()).when(es).stop(); - - try { - EmbeddedArtemisServer.stopServer(); - } catch (Exception e) { - } - - verify(sem, times(1)).release(); - } - - @Test - public void shouldSetAndGetJmsServer() { - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - EmbeddedArtemisServer.setJmsServer(es); - - assertEquals(es, EmbeddedArtemisServer.getJmsServer()); - } - - @Test - public void shouldSetAndGetServerPermit() { - ServerPermit sp = mock(ServerPermit.class); - EmbeddedArtemisServer.setServerPermit(sp); - - assertEquals(sp, EmbeddedArtemisServer.getServerPermit()); - } - - - @Test - public void shouldTestShutdownHookHandlesException() throws Exception { - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - EmbeddedArtemisServer.setJmsServer(es); - - doThrow(new Exception("Shutdown Exception")).when(es).stop(); - Thread t = EmbeddedArtemisServer.getShutDownHook(); - t.run(); - } - - @Test - public void shouldHandleThrownExceptionWhenInvokingStop() throws Exception { - - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - EmbeddedArtemisServer.setJmsServer(es); - - doThrow(new Exception()).when(es).stop(); - - assertEquals(false, EmbeddedArtemisServer.stopServer()); - } - - @Test - public void shouldSetEmbeddedJMS() { - EmbeddedJMS jms = mock(EmbeddedJMS.class); - EmbeddedJMSServer es = mock(EmbeddedJMSServer.class); - - EmbeddedArtemisServer.setJmsServer(es); - EmbeddedArtemisServer.setEmbeddedJms(jms); - - verify(es).setJmsServer(jms); - } - - @Test - public void shouldGetEmbeddedJMS() { - EmbeddedJMS jms = mock(EmbeddedJMS.class); - EmbeddedJMSServer es = new EmbeddedJMSServer(); - - EmbeddedArtemisServer.setJmsServer(es); - EmbeddedArtemisServer.setEmbeddedJms(jms); - - assertEquals(jms, EmbeddedArtemisServer.getEmbeddedJms()); - } - -} - diff --git a/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedJMSServerTest.java b/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedJMSServerTest.java deleted file mode 100644 index 5d2463cfa..000000000 --- a/embedded-artemis/src/test/java/uk/gov/justice/artemis/EmbeddedJMSServerTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package uk.gov.justice.artemis; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -public class EmbeddedJMSServerTest { - - EmbeddedJMSServer embeddedJMSServer; - - @BeforeEach - public void before() { - embeddedJMSServer = new EmbeddedJMSServer(); - } - - @Test - public void shouldStartJMSServerIfInitialisedIsFalse() throws Exception { - - EmbeddedJMS jms = mock(EmbeddedJMS.class); - embeddedJMSServer.setInitialised(false); - embeddedJMSServer.setJmsServer(jms); - - embeddedJMSServer.start(); - - assertTrue(embeddedJMSServer.isInitialised()); - - verify(jms, times(1)).start(); - } - - @Test - public void shouldNotStartJMSServerIfInitialisedIsTrue() throws Exception { - - EmbeddedJMS jms = mock(EmbeddedJMS.class); - embeddedJMSServer.setInitialised(true); - embeddedJMSServer.setJmsServer(jms); - - embeddedJMSServer.start(); - - assertTrue(embeddedJMSServer.isInitialised()); - - verify(jms, never()).start(); - } - - @Test - public void shouldNotStopJMSServerIfInitialisedIsFalse() throws Exception { - EmbeddedJMS jms = mock(EmbeddedJMS.class); - embeddedJMSServer.setInitialised(false); - embeddedJMSServer.setJmsServer(jms); - - embeddedJMSServer.stop(); - - assertFalse(embeddedJMSServer.isInitialised()); - - verify(jms, never()).stop(); - } - - @Test - public void shouldStopJMSServerIfInitialisedIsTrue() throws Exception { - EmbeddedJMS jms = mock(EmbeddedJMS.class); - embeddedJMSServer.setInitialised(true); - embeddedJMSServer.setJmsServer(jms); - - embeddedJMSServer.stop(); - - assertFalse(embeddedJMSServer.isInitialised()); - - verify(jms, times(1)).stop(); - } - - @Test - public void shouldGetJmsServer() { - EmbeddedJMS jms = mock(EmbeddedJMS.class); - embeddedJMSServer.setJmsServer(jms); - assertEquals(jms, embeddedJMSServer.getJmsServer()); - } - - @Test - public void shouldSetInitialised() { - embeddedJMSServer.setInitialised(true); - assertTrue(embeddedJMSServer.isInitialised()); - } - -} diff --git a/embedded-artemis/src/test/java/uk/gov/justice/artemis/ServerPermitTest.java b/embedded-artemis/src/test/java/uk/gov/justice/artemis/ServerPermitTest.java deleted file mode 100644 index fddd2b294..000000000 --- a/embedded-artemis/src/test/java/uk/gov/justice/artemis/ServerPermitTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package uk.gov.justice.artemis; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import java.util.concurrent.Semaphore; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -public class ServerPermitTest { - - ServerPermit serverPermit; - - @BeforeEach - public void before() { - serverPermit = new ServerPermit(); - } - - @Test - public void shouldCreateFairServerPermit() { - assertNotNull(serverPermit.getSemaphore()); - assertEquals(1, serverPermit.getSemaphore().availablePermits()); - assertTrue(serverPermit.getSemaphore().isFair()); - } - - @Test - public void shouldAcquireSemaphorePermit() throws InterruptedException { - Semaphore semaphore = mock(Semaphore.class); - serverPermit.setSemaphore(semaphore); - serverPermit.acquire(); - verify(semaphore).acquire(); - } - - @Test - public void shouldReleaseSemaphorePermit() throws Exception { - Semaphore semaphore = mock(Semaphore.class); - serverPermit.setSemaphore(semaphore); - serverPermit.close(); - verify(semaphore).release(); - } - - @Test - public void shouldGetDefaultSemaphore() { - assertNotNull(serverPermit.getSemaphore()); - } - - @Test - public void shouldSetSuppliedSemaphore() { - Semaphore semaphore = mock(Semaphore.class); - serverPermit.setSemaphore(semaphore); - assertEquals(semaphore, serverPermit.getSemaphore()); - } - - @Test - public void shouldReleaseSemaphorePermitWhenUsingTryWith() throws Exception { - Semaphore semaphore = mock(Semaphore.class); - try(final ServerPermit sp = new ServerPermit()){ - sp.setSemaphore(semaphore); - } - verify(semaphore).release(); - } - - @Test - public void shouldReleaseSemaphorePermitWhenUsingTryWithAndExceptionIsThrown() throws Exception { - Semaphore semaphore = mock(Semaphore.class); - try(final ServerPermit sp = new ServerPermit()){ - sp.setSemaphore(semaphore); - throw new RuntimeException("Testing Permit closing"); - } - catch(RuntimeException e){ - verify(semaphore).release(); - } - } - -} diff --git a/framework-api/framework-api-aggregate-service/pom.xml b/framework-api/framework-api-aggregate-service/pom.xml index 0acfa7916..65684ca2a 100644 --- a/framework-api/framework-api-aggregate-service/pom.xml +++ b/framework-api/framework-api-aggregate-service/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-all/pom.xml b/framework-api/framework-api-all/pom.xml index ba35ca59d..595df8b9d 100644 --- a/framework-api/framework-api-all/pom.xml +++ b/framework-api/framework-api-all/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-common/pom.xml b/framework-api/framework-api-common/pom.xml index a8e9052db..2ec7d158e 100644 --- a/framework-api/framework-api-common/pom.xml +++ b/framework-api/framework-api-common/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,8 +13,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided @@ -31,7 +31,7 @@
org.glassfish - javax.json + jakarta.json test diff --git a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/Adapter.java b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/Adapter.java index 449648e38..8e7965f35 100644 --- a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/Adapter.java +++ b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/Adapter.java @@ -7,7 +7,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; /** * Identifies adapters that receive messages from other service components.

Usage: diff --git a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/AnyLiteral.java b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/AnyLiteral.java index 8f43dcb68..db4b9e06d 100644 --- a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/AnyLiteral.java +++ b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/AnyLiteral.java @@ -1,7 +1,7 @@ package uk.gov.justice.services.core.annotation; -import javax.enterprise.inject.Any; -import javax.enterprise.util.AnnotationLiteral; +import jakarta.enterprise.inject.Any; +import jakarta.enterprise.util.AnnotationLiteral; public class AnyLiteral extends AnnotationLiteral { diff --git a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/CustomAdapter.java b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/CustomAdapter.java index c56cbe4e6..1edfb22c4 100644 --- a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/CustomAdapter.java +++ b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/CustomAdapter.java @@ -6,7 +6,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; /** * Identifies custom adapters that receive messages from other service components.

Usage: diff --git a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/CustomServiceComponent.java b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/CustomServiceComponent.java index b92c5c4ed..503fe8bbf 100644 --- a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/CustomServiceComponent.java +++ b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/CustomServiceComponent.java @@ -7,7 +7,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; /** * Identifies custom service components.

Usage: @CustomServiceComponent("CUSTOM_API") diff --git a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/Direct.java b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/Direct.java index 277bba073..619fad7a0 100644 --- a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/Direct.java +++ b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/Direct.java @@ -6,7 +6,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; @Retention(RUNTIME) @Target(TYPE) diff --git a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/DirectAdapter.java b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/DirectAdapter.java index 73234df61..07b90aa9d 100644 --- a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/DirectAdapter.java +++ b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/DirectAdapter.java @@ -7,7 +7,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; /** * Identifies direct adapters that receive messages directly from other service components.

Usage: diff --git a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/FrameworkComponent.java b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/FrameworkComponent.java index 58800e9e1..3873ba625 100644 --- a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/FrameworkComponent.java +++ b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/FrameworkComponent.java @@ -7,7 +7,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; /** * Identifies framework components.

Usage: @FrameworkComponent("COMPONENT_NAME") diff --git a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/ServiceComponent.java b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/ServiceComponent.java index a2f49a7ae..d154b321f 100644 --- a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/ServiceComponent.java +++ b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/ServiceComponent.java @@ -7,7 +7,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; /** * Identifies service components.

Usage: @ServiceComponent({@link Component#COMMAND_API}) diff --git a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/ServiceComponentLocation.java b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/ServiceComponentLocation.java index 26439931d..a1f541808 100644 --- a/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/ServiceComponentLocation.java +++ b/framework-api/framework-api-common/src/main/java/uk/gov/justice/services/core/annotation/ServiceComponentLocation.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.core.annotation; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.inject.spi.InjectionPoint; public enum ServiceComponentLocation { diff --git a/framework-api/framework-api-common/src/test/java/uk/gov/justice/services/core/annotation/MemberInjectionPoint.java b/framework-api/framework-api-common/src/test/java/uk/gov/justice/services/core/annotation/MemberInjectionPoint.java index 918942189..911e73728 100644 --- a/framework-api/framework-api-common/src/test/java/uk/gov/justice/services/core/annotation/MemberInjectionPoint.java +++ b/framework-api/framework-api-common/src/test/java/uk/gov/justice/services/core/annotation/MemberInjectionPoint.java @@ -6,9 +6,9 @@ import java.lang.reflect.Type; import java.util.Set; -import javax.enterprise.inject.spi.Annotated; -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.inject.spi.Annotated; +import jakarta.enterprise.inject.spi.Bean; +import jakarta.enterprise.inject.spi.InjectionPoint; public class MemberInjectionPoint implements InjectionPoint { diff --git a/framework-api/framework-api-common/src/test/java/uk/gov/justice/services/core/annotation/ServiceComponentLocationTest.java b/framework-api/framework-api-common/src/test/java/uk/gov/justice/services/core/annotation/ServiceComponentLocationTest.java index 89a1a6bf9..704063f18 100644 --- a/framework-api/framework-api-common/src/test/java/uk/gov/justice/services/core/annotation/ServiceComponentLocationTest.java +++ b/framework-api/framework-api-common/src/test/java/uk/gov/justice/services/core/annotation/ServiceComponentLocationTest.java @@ -8,7 +8,7 @@ import static uk.gov.justice.services.core.annotation.ServiceComponentLocation.REMOTE; import static uk.gov.justice.services.core.annotation.ServiceComponentLocation.componentLocationFrom; -import javax.inject.Inject; +import jakarta.inject.Inject; import org.junit.jupiter.api.Test; diff --git a/framework-api/framework-api-core/pom.xml b/framework-api/framework-api-core/pom.xml index a6ed7cfc6..c9ead6702 100644 --- a/framework-api/framework-api-core/pom.xml +++ b/framework-api/framework-api-core/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,8 +13,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/core/extension/ServiceComponentFoundEvent.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/core/extension/ServiceComponentFoundEvent.java index 838c20def..f0b0c34d0 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/core/extension/ServiceComponentFoundEvent.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/core/extension/ServiceComponentFoundEvent.java @@ -2,7 +2,7 @@ import uk.gov.justice.services.core.annotation.ServiceComponentLocation; -import javax.enterprise.inject.spi.Bean; +import jakarta.enterprise.inject.spi.Bean; public class ServiceComponentFoundEvent { diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/core/json/JsonValidationLoggerHelper.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/core/json/JsonValidationLoggerHelper.java index f36674b63..f703565f2 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/core/json/JsonValidationLoggerHelper.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/core/json/JsonValidationLoggerHelper.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.core.json; -import javax.json.JsonObject; +import jakarta.json.JsonObject; /** * Handles message logging for Json schema validation. diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/Envelope.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/Envelope.java index dcbe8829e..3bd957e8d 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/Envelope.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/Envelope.java @@ -2,7 +2,7 @@ import uk.gov.justice.services.messaging.spi.EnvelopeProvider; -import javax.json.JsonObject; +import jakarta.json.JsonObject; /** * Interface for a messaging envelope containing metadata and a payload. diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/JsonEnvelope.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/JsonEnvelope.java index 30951ad5f..9f7e06e49 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/JsonEnvelope.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/JsonEnvelope.java @@ -2,12 +2,12 @@ import uk.gov.justice.services.messaging.spi.JsonEnvelopeProvider; -import javax.json.JsonArray; -import javax.json.JsonNumber; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; -import javax.json.JsonString; -import javax.json.JsonValue; +import jakarta.json.JsonArray; +import jakarta.json.JsonNumber; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import jakarta.json.JsonString; +import jakarta.json.JsonValue; /** * Interface for a messaging envelope containing metadata and a JsonValue payload. diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/JsonObjectEnvelopeConverter.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/JsonObjectEnvelopeConverter.java index 1197b0533..e745c8885 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/JsonObjectEnvelopeConverter.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/JsonObjectEnvelopeConverter.java @@ -1,7 +1,7 @@ package uk.gov.justice.services.messaging; -import javax.json.JsonObject; -import javax.json.JsonValue; +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; /** * A converter class to convert between {@link JsonEnvelope} and {@link JsonObject}. diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/Metadata.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/Metadata.java index 5efbf46ee..124b7314e 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/Metadata.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/Metadata.java @@ -5,7 +5,7 @@ import java.util.Optional; import java.util.UUID; -import javax.json.JsonObject; +import jakarta.json.JsonObject; /** * Interface for an envelope's metadata. diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/logging/HttpTraceLoggerHelper.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/logging/HttpTraceLoggerHelper.java index 3afa1e5c2..b60bdebfd 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/logging/HttpTraceLoggerHelper.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/logging/HttpTraceLoggerHelper.java @@ -1,7 +1,7 @@ package uk.gov.justice.services.messaging.logging; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.MultivaluedMap; /** * Handles message logging for ReaderInterceptorContext headers. diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/logging/JmsMessageLoggerHelper.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/logging/JmsMessageLoggerHelper.java index a67c9eebc..7c310da95 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/logging/JmsMessageLoggerHelper.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/logging/JmsMessageLoggerHelper.java @@ -1,9 +1,9 @@ package uk.gov.justice.services.messaging.logging; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.TextMessage; -import javax.json.JsonObject; +import jakarta.jms.JMSException; +import jakarta.jms.Message; +import jakarta.jms.TextMessage; +import jakarta.json.JsonObject; public interface JmsMessageLoggerHelper { diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/spi/EnvelopeProvider.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/spi/EnvelopeProvider.java index e20cdbd2a..c403cfdb7 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/spi/EnvelopeProvider.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/spi/EnvelopeProvider.java @@ -8,8 +8,8 @@ import java.util.ServiceLoader; -import javax.json.JsonObject; -import javax.json.JsonValue; +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; /** * Interface for EnvelopeProvider implementations to provide methods for constructing diff --git a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/spi/JsonEnvelopeProvider.java b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/spi/JsonEnvelopeProvider.java index 2f280b8ce..939af95b4 100644 --- a/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/spi/JsonEnvelopeProvider.java +++ b/framework-api/framework-api-core/src/main/java/uk/gov/justice/services/messaging/spi/JsonEnvelopeProvider.java @@ -8,9 +8,9 @@ import java.util.ServiceLoader; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; -import javax.json.JsonValue; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import jakarta.json.JsonValue; /** * Abstract class for JsonEnvelopeProvider implementations to provide methods for constructing diff --git a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/core/extension/ServiceComponentFoundEventTest.java b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/core/extension/ServiceComponentFoundEventTest.java index 19e3b028b..d20c41d55 100644 --- a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/core/extension/ServiceComponentFoundEventTest.java +++ b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/core/extension/ServiceComponentFoundEventTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static uk.gov.justice.services.core.annotation.ServiceComponentLocation.LOCAL; -import javax.enterprise.inject.spi.Bean; +import jakarta.enterprise.inject.spi.Bean; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/DummyEnvelopeProvider.java b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/DummyEnvelopeProvider.java index 46f11beb5..ee2486ab9 100644 --- a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/DummyEnvelopeProvider.java +++ b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/DummyEnvelopeProvider.java @@ -4,7 +4,7 @@ import uk.gov.justice.services.messaging.Metadata; import uk.gov.justice.services.messaging.MetadataBuilder; -import javax.json.JsonObject; +import jakarta.json.JsonObject; public class DummyEnvelopeProvider implements EnvelopeProvider { diff --git a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/DummyJsonEnvelopeProvider.java b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/DummyJsonEnvelopeProvider.java index 8a3871e0e..e523f0e42 100644 --- a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/DummyJsonEnvelopeProvider.java +++ b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/DummyJsonEnvelopeProvider.java @@ -4,9 +4,9 @@ import uk.gov.justice.services.messaging.Metadata; import uk.gov.justice.services.messaging.MetadataBuilder; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; -import javax.json.JsonValue; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import jakarta.json.JsonValue; public class DummyJsonEnvelopeProvider implements JsonEnvelopeProvider { diff --git a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/HighPriorityEnvelopeProvider.java b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/HighPriorityEnvelopeProvider.java index 0418a4904..942d30a5e 100644 --- a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/HighPriorityEnvelopeProvider.java +++ b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/HighPriorityEnvelopeProvider.java @@ -6,7 +6,7 @@ import uk.gov.justice.services.messaging.Metadata; import uk.gov.justice.services.messaging.MetadataBuilder; -import javax.json.JsonObject; +import jakarta.json.JsonObject; public class HighPriorityEnvelopeProvider implements EnvelopeProvider { @Override diff --git a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/HighPriorityJsonEnvelopeProvider.java b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/HighPriorityJsonEnvelopeProvider.java index d53a225b8..3fd7429ea 100644 --- a/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/HighPriorityJsonEnvelopeProvider.java +++ b/framework-api/framework-api-core/src/test/java/uk/gov/justice/services/messaging/spi/HighPriorityJsonEnvelopeProvider.java @@ -6,9 +6,9 @@ import uk.gov.justice.services.messaging.Metadata; import uk.gov.justice.services.messaging.MetadataBuilder; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; -import javax.json.JsonValue; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import jakarta.json.JsonValue; public class HighPriorityJsonEnvelopeProvider implements JsonEnvelopeProvider { diff --git a/framework-api/framework-api-direct-adapter/pom.xml b/framework-api/framework-api-direct-adapter/pom.xml index a49163958..21bd05cc9 100644 --- a/framework-api/framework-api-direct-adapter/pom.xml +++ b/framework-api/framework-api-direct-adapter/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-domain/pom.xml b/framework-api/framework-api-domain/pom.xml index 5c0cbbb91..ea15a4e3e 100644 --- a/framework-api/framework-api-domain/pom.xml +++ b/framework-api/framework-api-domain/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-event-buffer/pom.xml b/framework-api/framework-api-event-buffer/pom.xml index 9564861f1..e5c703bc6 100644 --- a/framework-api/framework-api-event-buffer/pom.xml +++ b/framework-api/framework-api-event-buffer/pom.xml @@ -5,15 +5,15 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 framework-api-event-buffer - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-event-buffer/src/main/java/uk/gov/justice/services/event/buffer/api/AllowAllEventFilter.java b/framework-api/framework-api-event-buffer/src/main/java/uk/gov/justice/services/event/buffer/api/AllowAllEventFilter.java index 15e1fb223..e8a8e8a34 100644 --- a/framework-api/framework-api-event-buffer/src/main/java/uk/gov/justice/services/event/buffer/api/AllowAllEventFilter.java +++ b/framework-api/framework-api-event-buffer/src/main/java/uk/gov/justice/services/event/buffer/api/AllowAllEventFilter.java @@ -1,8 +1,8 @@ package uk.gov.justice.services.event.buffer.api; -import javax.annotation.Priority; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Alternative; +import jakarta.annotation.Priority; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; @ApplicationScoped @Alternative diff --git a/framework-api/framework-api-event-source/pom.xml b/framework-api/framework-api-event-source/pom.xml index 1ae3a8d78..1892d4119 100644 --- a/framework-api/framework-api-event-source/pom.xml +++ b/framework-api/framework-api-event-source/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,8 +13,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-event-source/src/main/java/uk/gov/justice/services/eventsourcing/source/core/annotation/EventSourceName.java b/framework-api/framework-api-event-source/src/main/java/uk/gov/justice/services/eventsourcing/source/core/annotation/EventSourceName.java index 617331a72..17adaf205 100644 --- a/framework-api/framework-api-event-source/src/main/java/uk/gov/justice/services/eventsourcing/source/core/annotation/EventSourceName.java +++ b/framework-api/framework-api-event-source/src/main/java/uk/gov/justice/services/eventsourcing/source/core/annotation/EventSourceName.java @@ -9,8 +9,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.util.Nonbinding; -import javax.inject.Qualifier; +import jakarta.enterprise.util.Nonbinding; +import jakarta.inject.Qualifier; @Qualifier diff --git a/framework-api/framework-api-event-stream/pom.xml b/framework-api/framework-api-event-stream/pom.xml index 886ca4c41..6434a574e 100644 --- a/framework-api/framework-api-event-stream/pom.xml +++ b/framework-api/framework-api-event-stream/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-healthcheck/pom.xml b/framework-api/framework-api-healthcheck/pom.xml index 6e9f8e58e..329c16092 100644 --- a/framework-api/framework-api-healthcheck/pom.xml +++ b/framework-api/framework-api-healthcheck/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-healthcheck/src/main/resources/META-INF/beans.xml b/framework-api/framework-api-healthcheck/src/main/resources/META-INF/beans.xml index c543550fc..e35ee868a 100644 --- a/framework-api/framework-api-healthcheck/src/main/resources/META-INF/beans.xml +++ b/framework-api/framework-api-healthcheck/src/main/resources/META-INF/beans.xml @@ -1,9 +1,9 @@ diff --git a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/pom.xml b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/pom.xml index ce221cdfe..1ef9e8759 100644 --- a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/pom.xml +++ b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/pom.xml @@ -5,7 +5,7 @@ framework-api-interceptors uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,8 +13,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventBufferInterceptor.java b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventBufferInterceptor.java index 635f971c9..382a2441d 100644 --- a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventBufferInterceptor.java +++ b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventBufferInterceptor.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.stream.Stream; -import javax.inject.Inject; +import jakarta.inject.Inject; /** * @deprecated This class should no longer be used, the SubscriptionManager now handles event diff --git a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventBufferServiceCaller.java b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventBufferServiceCaller.java index 648677feb..bbc4ae8e5 100644 --- a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventBufferServiceCaller.java +++ b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventBufferServiceCaller.java @@ -6,7 +6,7 @@ import java.util.stream.Stream; -import javax.inject.Inject; +import jakarta.inject.Inject; /** * @deprecated This class should no longer be used, the SubscriptionManager now handles event diff --git a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventFilterInterceptor.java b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventFilterInterceptor.java index ed9413514..2a88a8997 100644 --- a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventFilterInterceptor.java +++ b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/java/uk/gov/justice/services/components/event/listener/interceptors/EventFilterInterceptor.java @@ -6,7 +6,7 @@ import uk.gov.justice.services.core.interceptor.InterceptorContext; import uk.gov.justice.services.event.buffer.api.EventFilter; -import javax.inject.Inject; +import jakarta.inject.Inject; /** * @deprecated This class should no longer be used, EventFilterInterceptor is specifically generated diff --git a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/resources/META-INF/beans.xml b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/resources/META-INF/beans.xml index a0aaf4421..ce634ddf2 100644 --- a/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/resources/META-INF/beans.xml +++ b/framework-api/framework-api-interceptors/framework-api-event-listener-interceptors/src/main/resources/META-INF/beans.xml @@ -1,8 +1,8 @@ + https://jakarta.ee/xml/ns/jakartaee + https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd" bean-discovery-mode="all"> diff --git a/framework-api/framework-api-interceptors/pom.xml b/framework-api/framework-api-interceptors/pom.xml index f2798d8e0..4240b53b6 100644 --- a/framework-api/framework-api-interceptors/pom.xml +++ b/framework-api/framework-api-interceptors/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-messaging-adapter/pom.xml b/framework-api/framework-api-messaging-adapter/pom.xml index 03c0ef46f..891d5db7f 100644 --- a/framework-api/framework-api-messaging-adapter/pom.xml +++ b/framework-api/framework-api-messaging-adapter/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,8 +13,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/JmsParameterChecker.java b/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/JmsParameterChecker.java index 15ea585d6..15c7f776b 100644 --- a/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/JmsParameterChecker.java +++ b/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/JmsParameterChecker.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.adapter.messaging; -import javax.jms.TextMessage; +import jakarta.jms.TextMessage; public interface JmsParameterChecker { diff --git a/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/JmsProcessor.java b/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/JmsProcessor.java index 89c2bc862..e0a3bdbd1 100644 --- a/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/JmsProcessor.java +++ b/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/JmsProcessor.java @@ -4,7 +4,7 @@ import java.util.function.Consumer; -import javax.jms.Message; +import jakarta.jms.Message; public interface JmsProcessor { diff --git a/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/SubscriptionJmsProcessor.java b/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/SubscriptionJmsProcessor.java index 2b8d53926..921121d02 100644 --- a/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/SubscriptionJmsProcessor.java +++ b/framework-api/framework-api-messaging-adapter/src/main/java/uk/gov/justice/services/adapter/messaging/SubscriptionJmsProcessor.java @@ -2,7 +2,7 @@ import uk.gov.justice.services.subscription.SubscriptionManager; -import javax.jms.Message; +import jakarta.jms.Message; public interface SubscriptionJmsProcessor { diff --git a/framework-api/framework-api-messaging-adapter/src/main/resources/META-INF/beans.xml b/framework-api/framework-api-messaging-adapter/src/main/resources/META-INF/beans.xml index b36762a85..c3ac94ab5 100644 --- a/framework-api/framework-api-messaging-adapter/src/main/resources/META-INF/beans.xml +++ b/framework-api/framework-api-messaging-adapter/src/main/resources/META-INF/beans.xml @@ -1,8 +1,8 @@ + https://jakarta.ee/xml/ns/jakartaee + https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd" bean-discovery-mode="all"> \ No newline at end of file diff --git a/framework-api/framework-api-messaging-client/pom.xml b/framework-api/framework-api-messaging-client/pom.xml index 75221f27f..da103939d 100644 --- a/framework-api/framework-api-messaging-client/pom.xml +++ b/framework-api/framework-api-messaging-client/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-messaging-jms/pom.xml b/framework-api/framework-api-messaging-jms/pom.xml index 9459da4da..3a6b34683 100644 --- a/framework-api/framework-api-messaging-jms/pom.xml +++ b/framework-api/framework-api-messaging-jms/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,8 +13,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/EnvelopeConverter.java b/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/EnvelopeConverter.java index e654c0c38..6205fbc67 100644 --- a/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/EnvelopeConverter.java +++ b/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/EnvelopeConverter.java @@ -2,7 +2,7 @@ import uk.gov.justice.services.messaging.JsonEnvelope; -import javax.jms.TextMessage; +import jakarta.jms.TextMessage; public interface EnvelopeConverter extends MessageConverter { } \ No newline at end of file diff --git a/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/MessageConverter.java b/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/MessageConverter.java index 226167e6f..678c7b30e 100644 --- a/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/MessageConverter.java +++ b/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/MessageConverter.java @@ -1,7 +1,7 @@ package uk.gov.justice.services.messaging.jms; -import javax.jms.Message; -import javax.jms.Session; +import jakarta.jms.Message; +import jakarta.jms.Session; /** * Interface that specifies a converter between Java objects and JMS messages. diff --git a/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/annotation/ConnectionFactoryName.java b/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/annotation/ConnectionFactoryName.java index 0518dba20..cf9176dfe 100644 --- a/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/annotation/ConnectionFactoryName.java +++ b/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/annotation/ConnectionFactoryName.java @@ -9,8 +9,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.util.Nonbinding; -import javax.inject.Qualifier; +import jakarta.enterprise.util.Nonbinding; +import jakarta.inject.Qualifier; @Qualifier diff --git a/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/exception/JmsEnvelopeSenderException.java b/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/exception/JmsEnvelopeSenderException.java index ea51261b2..b0f12fdf8 100644 --- a/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/exception/JmsEnvelopeSenderException.java +++ b/framework-api/framework-api-messaging-jms/src/main/java/uk/gov/justice/services/messaging/jms/exception/JmsEnvelopeSenderException.java @@ -1,8 +1,8 @@ package uk.gov.justice.services.messaging.jms.exception; /** - * Exception representing a failure to send an envelope via Jms to a {@link javax.jms.Queue} or - * {@link javax.jms.Topic}. + * Exception representing a failure to send an envelope via Jms to a {@link jakarta.jms.Queue} or + * {@link jakarta.jms.Topic}. */ public class JmsEnvelopeSenderException extends RuntimeException { diff --git a/framework-api/framework-api-rest-adapter/pom.xml b/framework-api/framework-api-rest-adapter/pom.xml index 162226875..d19dcc34f 100644 --- a/framework-api/framework-api-rest-adapter/pom.xml +++ b/framework-api/framework-api-rest-adapter/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,8 +13,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/mapping/ActionMapper.java b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/mapping/ActionMapper.java index 3ed311466..49b40ee49 100644 --- a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/mapping/ActionMapper.java +++ b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/mapping/ActionMapper.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.adapter.rest.mapping; -import javax.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.HttpHeaders; public interface ActionMapper { diff --git a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/mapping/ActionMapperHelper.java b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/mapping/ActionMapperHelper.java index 825677006..10f2475c8 100644 --- a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/mapping/ActionMapperHelper.java +++ b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/mapping/ActionMapperHelper.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.adapter.rest.mapping; -import javax.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.HttpHeaders; public interface ActionMapperHelper { diff --git a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/RestProcessor.java b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/RestProcessor.java index 5a6d57b83..2b2a6f99d 100644 --- a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/RestProcessor.java +++ b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/RestProcessor.java @@ -11,9 +11,9 @@ import java.util.Optional; import java.util.function.Function; -import javax.json.JsonObject; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.Response; +import jakarta.json.JsonObject; +import jakarta.ws.rs.core.HttpHeaders; +import jakarta.ws.rs.core.Response; public interface RestProcessor { diff --git a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/response/ResponseStrategies.java b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/response/ResponseStrategies.java index dbf262580..e68f7cbc2 100644 --- a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/response/ResponseStrategies.java +++ b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/response/ResponseStrategies.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.adapter.rest.processor.response; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; /** * Named response strategies for REST generator diff --git a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/response/ResponseStrategy.java b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/response/ResponseStrategy.java index 0e08538e1..05271c756 100644 --- a/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/response/ResponseStrategy.java +++ b/framework-api/framework-api-rest-adapter/src/main/java/uk/gov/justice/services/adapter/rest/processor/response/ResponseStrategy.java @@ -4,7 +4,7 @@ import java.util.Optional; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; @FunctionalInterface public interface ResponseStrategy { diff --git a/framework-api/framework-api-rest-client/pom.xml b/framework-api/framework-api-rest-client/pom.xml index 8cb8647f6..95a8f3ead 100644 --- a/framework-api/framework-api-rest-client/pom.xml +++ b/framework-api/framework-api-rest-client/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-rest-core/pom.xml b/framework-api/framework-api-rest-core/pom.xml index 99ef12008..3f5ae393c 100644 --- a/framework-api/framework-api-rest-core/pom.xml +++ b/framework-api/framework-api-rest-core/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,8 +13,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-rest-core/src/main/java/uk/gov/justice/services/adapter/rest/annotation/PATCH.java b/framework-api/framework-api-rest-core/src/main/java/uk/gov/justice/services/adapter/rest/annotation/PATCH.java index 1dd7fc726..7fcabad9d 100644 --- a/framework-api/framework-api-rest-core/src/main/java/uk/gov/justice/services/adapter/rest/annotation/PATCH.java +++ b/framework-api/framework-api-rest-core/src/main/java/uk/gov/justice/services/adapter/rest/annotation/PATCH.java @@ -5,7 +5,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.ws.rs.HttpMethod; +import jakarta.ws.rs.HttpMethod; @Target({ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) diff --git a/framework-api/framework-api-subscription/pom.xml b/framework-api/framework-api-subscription/pom.xml index 542bc9e71..2cd499003 100644 --- a/framework-api/framework-api-subscription/pom.xml +++ b/framework-api/framework-api-subscription/pom.xml @@ -5,15 +5,15 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 framework-api-subscription - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-subscription/src/main/java/uk/gov/justice/services/subscription/annotation/SubscriptionName.java b/framework-api/framework-api-subscription/src/main/java/uk/gov/justice/services/subscription/annotation/SubscriptionName.java index 20bf248c8..c08ba2487 100644 --- a/framework-api/framework-api-subscription/src/main/java/uk/gov/justice/services/subscription/annotation/SubscriptionName.java +++ b/framework-api/framework-api-subscription/src/main/java/uk/gov/justice/services/subscription/annotation/SubscriptionName.java @@ -8,8 +8,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.enterprise.util.Nonbinding; -import javax.inject.Qualifier; +import jakarta.enterprise.util.Nonbinding; +import jakarta.inject.Qualifier; @Qualifier @Retention(RetentionPolicy.RUNTIME) diff --git a/framework-api/framework-api-system/framework-api-system-errors/pom.xml b/framework-api/framework-api-system/framework-api-system-errors/pom.xml index c1d022e24..7ae0ad018 100644 --- a/framework-api/framework-api-system/framework-api-system-errors/pom.xml +++ b/framework-api/framework-api-system/framework-api-system-errors/pom.xml @@ -5,7 +5,7 @@ framework-api-system uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-system/pom.xml b/framework-api/framework-api-system/pom.xml index 5207e5e84..aee8430a1 100644 --- a/framework-api/framework-api-system/pom.xml +++ b/framework-api/framework-api-system/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/framework-api-unifiedsearch/pom.xml b/framework-api/framework-api-unifiedsearch/pom.xml index e46a9a730..9c12b8773 100644 --- a/framework-api/framework-api-unifiedsearch/pom.xml +++ b/framework-api/framework-api-unifiedsearch/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,8 +13,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/TransformerApi.java b/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/TransformerApi.java index 96443b9db..8576718dc 100644 --- a/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/TransformerApi.java +++ b/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/TransformerApi.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.unifiedsearch; -import javax.json.JsonObject; +import jakarta.json.JsonObject; public interface TransformerApi { diff --git a/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/UnifiedSearchIndexer.java b/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/UnifiedSearchIndexer.java index 0b0d0ecab..df07b89f3 100644 --- a/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/UnifiedSearchIndexer.java +++ b/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/UnifiedSearchIndexer.java @@ -2,7 +2,7 @@ import uk.gov.justice.services.messaging.Envelope; -import javax.json.JsonObject; +import jakarta.json.JsonObject; public interface UnifiedSearchIndexer { void indexData(final Envelope eventWithJoltTransformedPayload); diff --git a/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/UnifiedSearchName.java b/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/UnifiedSearchName.java index d71003445..2d1c6e28b 100644 --- a/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/UnifiedSearchName.java +++ b/framework-api/framework-api-unifiedsearch/src/main/java/uk/gov/justice/services/unifiedsearch/UnifiedSearchName.java @@ -9,8 +9,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.enterprise.util.Nonbinding; -import javax.inject.Qualifier; +import jakarta.enterprise.util.Nonbinding; +import jakarta.inject.Qualifier; @Qualifier @Retention(RUNTIME) diff --git a/framework-api/framework-api-validator/pom.xml b/framework-api/framework-api-validator/pom.xml index b52bca1b7..c91bcca62 100644 --- a/framework-api/framework-api-validator/pom.xml +++ b/framework-api/framework-api-validator/pom.xml @@ -5,7 +5,7 @@ framework-api uk.gov.justice.framework-api - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-api/pom.xml b/framework-api/pom.xml index 5b3b3adcb..4418ba941 100644 --- a/framework-api/pom.xml +++ b/framework-api/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.framework-api diff --git a/framework-datasources/framework-datasource-providers/pom.xml b/framework-datasources/framework-datasource-providers/pom.xml index 120068819..77af53331 100644 --- a/framework-datasources/framework-datasource-providers/pom.xml +++ b/framework-datasources/framework-datasource-providers/pom.xml @@ -6,15 +6,15 @@ uk.gov.justice.framework.libraries framework-datasources - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT framework-datasource-providers - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-datasources/framework-datasource-providers/src/main/java/uk/gov/justice/framework/libraries/datasource/providers/jobstore/JndiJobStoreDataSourceProvider.java b/framework-datasources/framework-datasource-providers/src/main/java/uk/gov/justice/framework/libraries/datasource/providers/jobstore/JndiJobStoreDataSourceProvider.java index f5139d992..dbdcecec2 100644 --- a/framework-datasources/framework-datasource-providers/src/main/java/uk/gov/justice/framework/libraries/datasource/providers/jobstore/JndiJobStoreDataSourceProvider.java +++ b/framework-datasources/framework-datasource-providers/src/main/java/uk/gov/justice/framework/libraries/datasource/providers/jobstore/JndiJobStoreDataSourceProvider.java @@ -6,8 +6,8 @@ import uk.gov.justice.services.common.configuration.JndiBasedServiceContextNameProvider; import uk.gov.justice.services.jdbc.persistence.InitialContextFactory; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import javax.naming.NamingException; import javax.sql.DataSource; diff --git a/framework-datasources/framework-datasource-providers/src/main/resources/META-INF/beans.xml b/framework-datasources/framework-datasource-providers/src/main/resources/META-INF/beans.xml index cc3f8d286..fdf4a957b 100644 --- a/framework-datasources/framework-datasource-providers/src/main/resources/META-INF/beans.xml +++ b/framework-datasources/framework-datasource-providers/src/main/resources/META-INF/beans.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/framework-datasources/framework-datasource-test-utils/pom.xml b/framework-datasources/framework-datasource-test-utils/pom.xml index 358654926..7a343420f 100644 --- a/framework-datasources/framework-datasource-test-utils/pom.xml +++ b/framework-datasources/framework-datasource-test-utils/pom.xml @@ -6,15 +6,15 @@ uk.gov.justice.framework.libraries framework-datasources - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT framework-datasource-test-utils - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-datasources/pom.xml b/framework-datasources/pom.xml index 0139b5d9d..8f596772b 100644 --- a/framework-datasources/pom.xml +++ b/framework-datasources/pom.xml @@ -6,7 +6,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT framework-datasources diff --git a/framework-libraries-bom/pom.xml b/framework-libraries-bom/pom.xml index 06d2c4a69..d82995d90 100644 --- a/framework-libraries-bom/pom.xml +++ b/framework-libraries-bom/pom.xml @@ -5,7 +5,7 @@ framework-libraries uk.gov.justice.framework.libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -152,6 +152,11 @@ test-utils-core ${framework-libraries.version} + + uk.gov.justice.utils + test-utils-hibernate + ${framework-libraries.version} + uk.gov.justice.utils test-utils-framework-api @@ -271,11 +276,6 @@ pojo-generation-core ${framework-libraries.version} - - uk.gov.justice.artemis - embedded-artemis - ${framework-libraries.version} - uk.gov.justice.services domain-test-dsl diff --git a/framework-libraries-version/pom.xml b/framework-libraries-version/pom.xml index e31baf8c3..d8532e735 100644 --- a/framework-libraries-version/pom.xml +++ b/framework-libraries-version/pom.xml @@ -6,7 +6,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT framework-libraries-version diff --git a/framework-utilities/maven-test-utils/pom.xml b/framework-utilities/maven-test-utils/pom.xml index 5dd80bdfc..81ff55754 100644 --- a/framework-utilities/maven-test-utils/pom.xml +++ b/framework-utilities/maven-test-utils/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.framework.utilities framework-utilities - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-utilities/pom.xml b/framework-utilities/pom.xml index cc03608e0..3f94917ed 100644 --- a/framework-utilities/pom.xml +++ b/framework-utilities/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.framework.utilities @@ -22,8 +22,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/framework-utilities/test-utils/pom.xml b/framework-utilities/test-utils/pom.xml index 00fbb323a..28759c76f 100644 --- a/framework-utilities/test-utils/pom.xml +++ b/framework-utilities/test-utils/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.framework.utilities framework-utilities - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.utils @@ -17,6 +17,7 @@ test-utils-core test-utils-framework-api + test-utils-hibernate test-utils-logging-jdk test-utils-logging-log4j test-utils-logging-simple diff --git a/framework-utilities/test-utils/test-utils-core/pom.xml b/framework-utilities/test-utils/test-utils-core/pom.xml index 772587e3c..fa53cf332 100644 --- a/framework-utilities/test-utils/test-utils-core/pom.xml +++ b/framework-utilities/test-utils/test-utils-core/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.utils test-utils - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT test-utils-core @@ -15,11 +15,7 @@ org.glassfish - javax.json - - - com.sun.mail - javax.mail + jakarta.json org.jboss.resteasy @@ -27,7 +23,11 @@ org.apache.activemq - artemis-jms-client + artemis-jakarta-client + + + commons-io + commons-io org.apache.commons @@ -106,12 +106,12 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api provided - com.github.tomakehurst + org.wiremock wiremock test diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ExpectedJsonValuesResultCondition.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ExpectedJsonValuesResultCondition.java index 2c65e0f7f..e203143b7 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ExpectedJsonValuesResultCondition.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ExpectedJsonValuesResultCondition.java @@ -8,8 +8,8 @@ import java.util.Optional; import java.util.function.Predicate; -import javax.json.JsonObject; -import javax.json.JsonReader; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; import static uk.gov.justice.services.test.utils.core.messaging.JsonObjects.jsonReaderFactory; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/HttpResponsePoller.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/HttpResponsePoller.java index 62092cadb..fc2b5a5d2 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/HttpResponsePoller.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/HttpResponsePoller.java @@ -4,8 +4,8 @@ import static java.lang.String.format; import static java.lang.Thread.currentThread; import static java.lang.Thread.sleep; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; -import static javax.ws.rs.core.Response.Status.OK; +import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; +import static jakarta.ws.rs.core.Response.Status.OK; import static uk.gov.justice.services.test.utils.core.messaging.JsonObjects.jsonReaderFactory; import uk.gov.justice.services.test.utils.core.messaging.JsonObjects; @@ -16,10 +16,10 @@ import java.util.Optional; import java.util.function.Predicate; -import javax.json.JsonObject; -import javax.json.JsonReader; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response; /** * @deprecated Use {@link RestPoller} instead. diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParams.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParams.java index 185b451cb..bf6a4a01c 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParams.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParams.java @@ -4,8 +4,8 @@ import java.util.Optional; import java.util.function.Predicate; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response.Status; public class PollingRequestParams { diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParamsBuilder.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParamsBuilder.java index 54a08316b..1784501c4 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParamsBuilder.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParamsBuilder.java @@ -10,9 +10,9 @@ import java.util.Optional; import java.util.function.Predicate; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response.Status; /** * Builder for creating PollingRequestParameters. Expects a url and a media type. All other diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRestClient.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRestClient.java index 1fe9f2ee7..b1579fe74 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRestClient.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/PollingRestClient.java @@ -6,7 +6,7 @@ import java.util.Optional; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response.Status; import com.google.common.annotations.VisibleForTesting; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RequestParams.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RequestParams.java index bf816fef9..e10726ffc 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RequestParams.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RequestParams.java @@ -2,7 +2,7 @@ import java.util.Objects; -import javax.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.MultivaluedMap; public class RequestParams { diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RequestParamsBuilder.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RequestParamsBuilder.java index e1422db46..722387b76 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RequestParamsBuilder.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RequestParamsBuilder.java @@ -4,8 +4,8 @@ import java.util.Map; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.MultivaluedMap; /** * Builder for creating RequestParams. Expects a url and a media type. All other diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseData.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseData.java index 3917af4ad..4e925b084 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseData.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseData.java @@ -2,8 +2,8 @@ import java.util.Objects; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response.Status; /** * The response body and status of an HTTP call diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseDetails.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseDetails.java index bbad751d4..ddf66c2b2 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseDetails.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseDetails.java @@ -2,7 +2,7 @@ import java.util.Objects; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response.Status; /** * The response body and status of an HTTP call diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseValidator.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseValidator.java index 1130627bd..1255d67ad 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseValidator.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ResponseValidator.java @@ -2,7 +2,7 @@ import java.util.Optional; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response.Status; /** * Validates a responseBody and status against expected status and a response body condition diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RestPoller.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RestPoller.java index e9a99739e..8fa6da5b7 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RestPoller.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/RestPoller.java @@ -2,7 +2,7 @@ import static java.util.Optional.empty; import static java.util.concurrent.TimeUnit.SECONDS; -import static javax.ws.rs.core.Response.Status.fromStatusCode; +import static jakarta.ws.rs.core.Response.Status.fromStatusCode; import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.anyOf; @@ -19,7 +19,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import com.google.common.annotations.VisibleForTesting; import org.awaitility.core.ConditionEvaluationLogger; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ValidatingRestClient.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ValidatingRestClient.java index 4c94664f0..7dd06c960 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ValidatingRestClient.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/http/ValidatingRestClient.java @@ -2,14 +2,14 @@ import static java.util.Optional.empty; import static java.util.Optional.of; -import static javax.ws.rs.core.Response.Status.fromStatusCode; +import static jakarta.ws.rs.core.Response.Status.fromStatusCode; import uk.gov.justice.services.test.utils.core.rest.RestClient; import java.util.Optional; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import com.google.common.annotations.VisibleForTesting; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/matchers/ResponseHeadersMatcher.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/matchers/ResponseHeadersMatcher.java index a3921fb4e..bffb592ed 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/matchers/ResponseHeadersMatcher.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/matchers/ResponseHeadersMatcher.java @@ -6,7 +6,7 @@ import java.util.Optional; -import javax.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.MultivaluedMap; import org.hamcrest.Description; import org.hamcrest.Matcher; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/matchers/ResponseStatusMatcher.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/matchers/ResponseStatusMatcher.java index 0604d4f44..5f2f895c6 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/matchers/ResponseStatusMatcher.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/matchers/ResponseStatusMatcher.java @@ -3,7 +3,7 @@ import uk.gov.justice.services.test.utils.core.http.ResponseData; import uk.gov.justice.services.test.utils.core.http.RestPoller; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response.Status; import org.hamcrest.Description; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/ConsumerClient.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/ConsumerClient.java index 613cdbfe0..820a758e7 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/ConsumerClient.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/ConsumerClient.java @@ -5,12 +5,12 @@ import java.util.Optional; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.Queue; -import javax.jms.TextMessage; -import javax.jms.Topic; +import jakarta.jms.JMSException; +import jakarta.jms.Message; +import jakarta.jms.MessageConsumer; +import jakarta.jms.Queue; +import jakarta.jms.TextMessage; +import jakarta.jms.Topic; /** diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/DeadLetterQueueBrowser.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/DeadLetterQueueBrowser.java index b7046d095..daeaeaa29 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/DeadLetterQueueBrowser.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/DeadLetterQueueBrowser.java @@ -9,14 +9,14 @@ import java.util.Enumeration; import java.util.List; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.Queue; -import javax.jms.QueueBrowser; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.json.JsonObject; -import javax.json.JsonReader; +import jakarta.jms.JMSException; +import jakarta.jms.MessageConsumer; +import jakarta.jms.Queue; +import jakarta.jms.QueueBrowser; +import jakarta.jms.Session; +import jakarta.jms.TextMessage; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JmsSessionFactory.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JmsSessionFactory.java index ffeeee9cc..a31055691 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JmsSessionFactory.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JmsSessionFactory.java @@ -1,11 +1,11 @@ package uk.gov.justice.services.test.utils.core.messaging; import static java.lang.String.format; -import static javax.jms.Session.AUTO_ACKNOWLEDGE; +import static jakarta.jms.Session.AUTO_ACKNOWLEDGE; -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.Session; +import jakarta.jms.Connection; +import jakarta.jms.JMSException; +import jakarta.jms.Session; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjectBuilderWrapper.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjectBuilderWrapper.java index 014ac641a..75d5e1a50 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjectBuilderWrapper.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjectBuilderWrapper.java @@ -6,10 +6,10 @@ import java.util.HashMap; import java.util.Map; -import javax.json.JsonArray; -import javax.json.JsonArrayBuilder; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; +import jakarta.json.JsonArray; +import jakarta.json.JsonArrayBuilder; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; import static uk.gov.justice.services.test.utils.core.messaging.JsonObjects.jsonBuilderFactory; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjects.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjects.java index 0bf87e598..a8bf96ac7 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjects.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjects.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.test.utils.core.messaging; -import static javax.json.JsonValue.ValueType; +import static jakarta.json.JsonValue.ValueType; import java.util.Arrays; import java.util.Collection; @@ -12,16 +12,16 @@ import java.util.function.Function; import java.util.stream.Collectors; -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonArrayBuilder; -import javax.json.JsonBuilderFactory; -import javax.json.JsonNumber; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; -import javax.json.JsonReaderFactory; -import javax.json.JsonString; -import javax.json.JsonValue; +import jakarta.json.Json; +import jakarta.json.JsonArray; +import jakarta.json.JsonArrayBuilder; +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonNumber; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import jakarta.json.JsonReaderFactory; +import jakarta.json.JsonString; +import jakarta.json.JsonValue; import com.google.common.collect.ImmutableList; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerClient.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerClient.java index e058fbd1c..3556fd6bd 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerClient.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerClient.java @@ -5,8 +5,8 @@ import java.util.Optional; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; +import jakarta.jms.JMSException; +import jakarta.jms.MessageConsumer; import com.google.common.annotations.VisibleForTesting; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerFactory.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerFactory.java index b7698e838..1bbf48f2e 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerFactory.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerFactory.java @@ -3,9 +3,9 @@ import java.util.HashSet; import java.util.Set; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.Session; +import jakarta.jms.JMSException; +import jakarta.jms.MessageConsumer; +import jakarta.jms.Session; import com.google.common.annotations.VisibleForTesting; import org.apache.activemq.artemis.jms.client.ActiveMQTopic; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/TopicSender.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/TopicSender.java index d8ede9b0a..0982856f2 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/TopicSender.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/messaging/TopicSender.java @@ -6,11 +6,11 @@ import java.util.List; import java.util.function.BiConsumer; -import javax.jms.Connection; -import javax.jms.DeliveryMode; -import javax.jms.JMSException; -import javax.jms.MessageProducer; -import javax.jms.Session; +import jakarta.jms.Connection; +import jakarta.jms.DeliveryMode; +import jakarta.jms.JMSException; +import jakarta.jms.MessageProducer; +import jakarta.jms.Session; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/FilePart.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/FilePart.java index 1fbef75ea..b0a26a3af 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/FilePart.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/FilePart.java @@ -5,7 +5,7 @@ import java.io.InputStream; import java.util.Optional; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; /** * Used in conjunction with {@link MultipartRestClient}. Contains the parameters relating to the diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/MultipartRestClient.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/MultipartRestClient.java index 2d6a63803..49cce4fbc 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/MultipartRestClient.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/MultipartRestClient.java @@ -8,7 +8,7 @@ import java.util.Map; import java.util.Optional; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/RestClient.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/RestClient.java index 56249193c..19b18dfdc 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/RestClient.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/RestClient.java @@ -1,17 +1,18 @@ package uk.gov.justice.services.test.utils.core.rest; -import org.jboss.resteasy.client.jaxrs.ResteasyClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response; public class RestClient { private static final Logger LOGGER = LoggerFactory.getLogger(RestClient.class); - public static final ResteasyClient RESTEASY_CLIENT = ResteasyClientBuilderFactory.clientBuilder().connectionPoolSize(5).build(); + public static final Client RESTEASY_CLIENT = ClientBuilder.newClient(); public Response postCommand(final String url, final String contentType, final String requestPayload) { Entity entity = Entity.entity(requestPayload, MediaType.valueOf(contentType)); diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/schema/SchemaDuplicateHelper.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/schema/SchemaDuplicateHelper.java index 509c85086..bd7469da4 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/schema/SchemaDuplicateHelper.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/schema/SchemaDuplicateHelper.java @@ -9,8 +9,8 @@ import java.util.Arrays; import java.util.List; -import javax.json.JsonObject; -import javax.json.JsonReader; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; import org.apache.commons.codec.digest.DigestUtils; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/HttpResponsePollerTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/HttpResponsePollerTest.java index 8bd682829..f91906de2 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/HttpResponsePollerTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/HttpResponsePollerTest.java @@ -1,8 +1,8 @@ package uk.gov.justice.services.test.utils.core.http; import static java.util.Collections.singletonMap; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; -import static javax.ws.rs.core.Response.Status.OK; +import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; +import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; @@ -14,10 +14,10 @@ import java.util.HashMap; import java.util.Map; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response; -import org.jboss.resteasy.specimpl.MultivaluedMapImpl; +import jakarta.ws.rs.core.MultivaluedHashMap; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -236,7 +236,7 @@ public void shouldPassHeadersToRestClientIfItsProvided() { final String responseText = "Condition Met"; - MultivaluedMap arbitraryHerader = new MultivaluedMapImpl<>(); + MultivaluedMap arbitraryHerader = new MultivaluedHashMap<>(); when(restClient.query(URL, MEDIA_TYPE, arbitraryHerader)).thenReturn(response); when(response.getStatus()).thenReturn(OK.getStatusCode()); when(response.readEntity(String.class)).thenReturn(responseText); diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParamsBuilderTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParamsBuilderTest.java index 39e2bd39c..f33a906ed 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParamsBuilderTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/PollingRequestParamsBuilderTest.java @@ -11,8 +11,8 @@ import java.util.Map; import java.util.function.Predicate; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/PollingRestClientTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/PollingRestClientTest.java index 08e5716b9..f73d45a76 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/PollingRestClientTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/PollingRestClientTest.java @@ -2,8 +2,8 @@ import static java.util.Optional.empty; import static java.util.Optional.of; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; -import static javax.ws.rs.core.Response.Status.OK; +import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; +import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; @@ -16,8 +16,8 @@ import java.util.function.Predicate; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/RequestParamsBuilderTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/RequestParamsBuilderTest.java index 7e5e258dd..ca012370d 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/RequestParamsBuilderTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/RequestParamsBuilderTest.java @@ -5,9 +5,9 @@ import static uk.gov.justice.services.test.utils.core.http.RequestParamsBuilder.requestParams; import static uk.gov.justice.services.test.utils.core.http.RequestParamsBuilder.requestParamswithHeaders; -import javax.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.MultivaluedMap; -import org.jboss.resteasy.specimpl.MultivaluedMapImpl; +import jakarta.ws.rs.core.MultivaluedHashMap; import org.junit.jupiter.api.Test; public class RequestParamsBuilderTest { @@ -32,7 +32,7 @@ public void shouldCreateRequestParametersBuilderWithHeader() throws Exception { final String url = "a url"; final String mediaType = "the media type"; - MultivaluedMap headers = new MultivaluedMapImpl(); + MultivaluedMap headers = new MultivaluedHashMap(); headers.add("key", "value"); final RequestParamsBuilder requestParamsBuilder = requestParamswithHeaders(url, mediaType, headers); diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/ResponseValidatorTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/ResponseValidatorTest.java index 6808b6624..65dcf28ab 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/ResponseValidatorTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/ResponseValidatorTest.java @@ -1,14 +1,14 @@ package uk.gov.justice.services.test.utils.core.http; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; -import static javax.ws.rs.core.Response.Status.OK; +import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; +import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static uk.gov.justice.services.test.utils.core.http.PollingRequestParamsBuilder.pollingRequestParams; import java.util.function.Predicate; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response.Status; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/RestPollerTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/RestPollerTest.java index 1a2f550f8..fd0fd0574 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/RestPollerTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/RestPollerTest.java @@ -4,10 +4,10 @@ import static com.jayway.jsonpath.matchers.JsonPathMatchers.withJsonPath; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; -import static javax.ws.rs.core.Response.Status.ACCEPTED; -import static javax.ws.rs.core.Response.Status.FORBIDDEN; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; -import static javax.ws.rs.core.Response.Status.OK; +import static jakarta.ws.rs.core.Response.Status.ACCEPTED; +import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; +import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; +import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; @@ -30,10 +30,10 @@ import org.junit.jupiter.api.Assertions; import uk.gov.justice.services.test.utils.core.rest.RestClient; -import javax.json.JsonArray; -import javax.json.JsonArrayBuilder; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.Response; +import jakarta.json.JsonArray; +import jakarta.json.JsonArrayBuilder; +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.Response; import com.google.common.collect.ImmutableMap; import org.junit.jupiter.api.BeforeEach; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/ValidatingRestClientTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/ValidatingRestClientTest.java index 16358ac25..76e42e0e8 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/ValidatingRestClientTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/http/ValidatingRestClientTest.java @@ -1,7 +1,7 @@ package uk.gov.justice.services.test.utils.core.http; import static java.util.Collections.singletonList; -import static javax.ws.rs.core.Response.Status.OK; +import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; @@ -11,9 +11,9 @@ import java.util.Optional; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponseHeadersMatcherTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponseHeadersMatcherTest.java index 267f3ec72..1eb480ac7 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponseHeadersMatcherTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponseHeadersMatcherTest.java @@ -9,16 +9,16 @@ import java.util.List; -import javax.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.MultivaluedMap; -import org.jboss.resteasy.specimpl.MultivaluedMapImpl; +import jakarta.ws.rs.core.MultivaluedHashMap; import org.junit.jupiter.api.Test; public class ResponseHeadersMatcherTest { @Test public void shouldMatchHeadersFromResponse() throws Exception { - MultivaluedMap headers = new MultivaluedMapImpl(); + MultivaluedMap headers = new MultivaluedHashMap(); headers.add("Content-Disposition", "attachment"); headers.add("filename", "MaterialFullStackTestFile.docx"); headers.add("Content-Type", "application/pdf"); @@ -30,7 +30,7 @@ public void shouldMatchHeadersFromResponse() throws Exception { @Test public void shouldFailWhenResponseHeadersDoesNotMatch() { - MultivaluedMap headers = new MultivaluedMapImpl(); + MultivaluedMap headers = new MultivaluedHashMap(); headers.add("Content-Disposition", "attachment"); headers.add("filename", "MaterialFullStackTestFile.docx"); headers.add("Content-Type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponsePayloadMatcherTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponsePayloadMatcherTest.java index d35492849..a528e8c61 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponsePayloadMatcherTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponsePayloadMatcherTest.java @@ -13,7 +13,7 @@ import uk.gov.justice.services.test.utils.core.http.ResponseData; -import javax.json.JsonArrayBuilder; +import jakarta.json.JsonArrayBuilder; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponseStatusMatcherTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponseStatusMatcherTest.java index 4bfb0c940..66e588aa5 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponseStatusMatcherTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/matchers/ResponseStatusMatcherTest.java @@ -1,7 +1,7 @@ package uk.gov.justice.services.test.utils.core.matchers; -import static javax.ws.rs.core.Response.Status.ACCEPTED; -import static javax.ws.rs.core.Response.Status.NOT_FOUND; +import static jakarta.ws.rs.core.Response.Status.ACCEPTED; +import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/ConsumerClientTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/ConsumerClientTest.java index 4011e881c..0bcff499e 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/ConsumerClientTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/ConsumerClientTest.java @@ -10,9 +10,9 @@ import java.util.Optional; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.TextMessage; +import jakarta.jms.JMSException; +import jakarta.jms.MessageConsumer; +import jakarta.jms.TextMessage; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/DeadLetterQueueBrowserTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/DeadLetterQueueBrowserTest.java index 6d993a47a..26aea0070 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/DeadLetterQueueBrowserTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/DeadLetterQueueBrowserTest.java @@ -14,13 +14,13 @@ import java.util.List; import java.util.Vector; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.Queue; -import javax.jms.QueueBrowser; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.json.JsonObject; +import jakarta.jms.JMSException; +import jakarta.jms.MessageConsumer; +import jakarta.jms.Queue; +import jakarta.jms.QueueBrowser; +import jakarta.jms.Session; +import jakarta.jms.TextMessage; +import jakarta.json.JsonObject; import org.hamcrest.collection.IsMapContaining; import org.junit.jupiter.api.BeforeEach; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/JmsSessionFactoryTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/JmsSessionFactoryTest.java index 760e3b9a0..f64e00af9 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/JmsSessionFactoryTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/JmsSessionFactoryTest.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.test.utils.core.messaging; -import static javax.jms.Session.AUTO_ACKNOWLEDGE; +import static jakarta.jms.Session.AUTO_ACKNOWLEDGE; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -9,9 +9,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.Session; +import jakarta.jms.Connection; +import jakarta.jms.JMSException; +import jakarta.jms.Session; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjectBuilderWrapperTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjectBuilderWrapperTest.java index adc94af24..4a083fdb7 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjectBuilderWrapperTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/JsonObjectBuilderWrapperTest.java @@ -10,11 +10,11 @@ import java.math.BigDecimal; -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonArrayBuilder; -import javax.json.JsonBuilderFactory; -import javax.json.JsonObject; +import jakarta.json.Json; +import jakarta.json.JsonArray; +import jakarta.json.JsonArrayBuilder; +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonObject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerClientTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerClientTest.java index 2cad50744..b07891542 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerClientTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerClientTest.java @@ -12,9 +12,9 @@ import java.util.Optional; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.TextMessage; +import jakarta.jms.JMSException; +import jakarta.jms.MessageConsumer; +import jakarta.jms.TextMessage; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerFactoryTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerFactoryTest.java index 6e3b3a6b5..61eb20459 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerFactoryTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/messaging/MessageConsumerFactoryTest.java @@ -12,8 +12,8 @@ import java.util.Set; -import javax.jms.MessageConsumer; -import javax.jms.Session; +import jakarta.jms.MessageConsumer; +import jakarta.jms.Session; import org.apache.activemq.artemis.jms.client.ActiveMQTopic; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/rest/RestClientTest.java b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/rest/RestClientTest.java index b944a617b..01abeb567 100644 --- a/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/rest/RestClientTest.java +++ b/framework-utilities/test-utils/test-utils-core/src/test/java/uk/gov/justice/services/test/utils/core/rest/RestClientTest.java @@ -8,15 +8,15 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static javax.ws.rs.core.HttpHeaders.ACCEPT; -import static javax.ws.rs.core.HttpHeaders.CONTENT_TYPE; -import static javax.ws.rs.core.Response.Status.NO_CONTENT; -import static javax.ws.rs.core.Response.Status.OK; +import static jakarta.ws.rs.core.HttpHeaders.ACCEPT; +import static jakarta.ws.rs.core.HttpHeaders.CONTENT_TYPE; +import static jakarta.ws.rs.core.Response.Status.NO_CONTENT; +import static jakarta.ws.rs.core.Response.Status.OK; import static org.hamcrest.MatcherAssert.assertThat; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.MultivaluedMap; +import jakarta.ws.rs.core.Response; import com.github.tomakehurst.wiremock.junit5.WireMockTest; import org.hamcrest.CoreMatchers; diff --git a/framework-utilities/test-utils/test-utils-framework-api/pom.xml b/framework-utilities/test-utils/test-utils-framework-api/pom.xml index 24cf06fb6..21350e9a9 100644 --- a/framework-utilities/test-utils/test-utils-framework-api/pom.xml +++ b/framework-utilities/test-utils/test-utils-framework-api/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.utils test-utils - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-utilities/test-utils/test-utils-framework-api/src/test/java/uk/gov/justice/services/test/utils/framework/api/JsonObjectConvertersFactoryTest.java b/framework-utilities/test-utils/test-utils-framework-api/src/test/java/uk/gov/justice/services/test/utils/framework/api/JsonObjectConvertersFactoryTest.java index a6a737894..0cdad9ca1 100644 --- a/framework-utilities/test-utils/test-utils-framework-api/src/test/java/uk/gov/justice/services/test/utils/framework/api/JsonObjectConvertersFactoryTest.java +++ b/framework-utilities/test-utils/test-utils-framework-api/src/test/java/uk/gov/justice/services/test/utils/framework/api/JsonObjectConvertersFactoryTest.java @@ -66,10 +66,10 @@ public void shouldCreateStringToJsonObjectConverter() throws Exception { private void checkSetUpCorrectly(final ObjectMapper objectMapper) { final Set registeredModuleTypes = getValueOfField(objectMapper, "_registeredModuleTypes", Set.class); - assertThat(registeredModuleTypes, hasItem("com.fasterxml.jackson.datatype.jsr310.JavaTimeModule")); + assertThat(registeredModuleTypes, hasItem("jackson-datatype-jsr310")); assertThat(registeredModuleTypes, hasItem("com.fasterxml.jackson.datatype.jdk8.Jdk8Module")); - assertThat(registeredModuleTypes, hasItem("com.fasterxml.jackson.module.paramnames.ParameterNamesModule")); - assertThat(registeredModuleTypes, hasItem("uk.gov.justice.services.common.converter.jackson.jsr353.InclusionAwareJSR353Module")); + assertThat(registeredModuleTypes, hasItem("jackson-module-parameter-names")); + assertThat(registeredModuleTypes, hasItem("jackson-datatype-jakarta-jsonp")); assertThat(registeredModuleTypes, hasItem("uk.gov.justice.services.common.converter.jackson.additionalproperties.AdditionalPropertiesModule")); assertThat(registeredModuleTypes, hasItem("uk.gov.justice.services.common.converter.jackson.integerenum.IntegerEnumModule")); } diff --git a/framework-utilities/test-utils/test-utils-hibernate/pom.xml b/framework-utilities/test-utils/test-utils-hibernate/pom.xml new file mode 100644 index 000000000..8b3b6eda1 --- /dev/null +++ b/framework-utilities/test-utils/test-utils-hibernate/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + + uk.gov.justice.utils + test-utils + 21.0.0-SNAPSHOT + + + test-utils-hibernate + + + + uk.gov.justice.utils + test-utils-core + ${project.version} + + + + jakarta.persistence + jakarta.persistence-api + + + org.hibernate.orm + hibernate-core + + + + + org.junit.jupiter + junit-jupiter-api + + + org.mockito + mockito-junit-jupiter + test + + + org.hamcrest + hamcrest + test + + + com.h2database + h2 + test + + + com.fasterxml.jackson.core + jackson-databind + test + + + org.slf4j + slf4j-simple + test + + + + diff --git a/framework-utilities/test-utils/test-utils-hibernate/src/main/java/uk/gov/justice/services/test/utils/persistence/HibernateTestEntityManagerProvider.java b/framework-utilities/test-utils/test-utils-hibernate/src/main/java/uk/gov/justice/services/test/utils/persistence/HibernateTestEntityManagerProvider.java new file mode 100644 index 000000000..1c0092c6e --- /dev/null +++ b/framework-utilities/test-utils/test-utils-hibernate/src/main/java/uk/gov/justice/services/test/utils/persistence/HibernateTestEntityManagerProvider.java @@ -0,0 +1,156 @@ +package uk.gov.justice.services.test.utils.persistence; + +import static java.lang.String.format; +import static uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField; + +import uk.gov.justice.services.test.utils.core.reflection.ReflectionException; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; + +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; + +/** + * Test utility that bootstraps a standalone Hibernate {@link EntityManager} from a named + * persistence unit. Intended to be used in unit/integration tests for repository classes + * that inject an {@link EntityManager} via {@code @PersistenceContext}. + * + *

Typical usage pattern in a JUnit 5 test: + *

+ *     private final HibernateTestEntityManagerProvider provider =
+ *             new HibernateTestEntityManagerProvider("my-persistence-unit");
+ *
+ *     {@literal @}BeforeEach
+ *     void setUp() {
+ *         provider.openEntityManager();
+ *         provider.injectEntityManagerInto(myRepository);
+ *     }
+ *
+ *     {@literal @}AfterEach
+ *     void tearDown() {
+ *         provider.closeEntityManager();
+ *     }
+ *
+ *     {@literal @}AfterAll
+ *     static void tearDownFactory() {
+ *         provider.closeEntityManagerFactory();
+ *     }
+ * 
+ * + *

Each call to {@link #openEntityManager()} begins a new transaction. {@link + * #closeEntityManager()} rolls back any active transaction and closes the manager, leaving + * the database clean for the next test. + */ +public class HibernateTestEntityManagerProvider implements BeforeEachCallback, AfterEachCallback, AfterAllCallback { + + private final EntityManagerFactory entityManagerFactory; + private EntityManager entityManager; + + /** + * Creates the provider and immediately builds the {@link EntityManagerFactory} for the + * named persistence unit. The factory is expensive to create, so a single instance + * should be shared across all tests in a class (e.g. stored in a {@code static} field + * and initialised once with {@code @BeforeAll}). + * + * @param persistenceUnitName the name of the persistence unit as declared in + * {@code META-INF/persistence.xml} + */ + public HibernateTestEntityManagerProvider(final String persistenceUnitName) { + entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnitName); + } + + @Override + public void beforeEach(final ExtensionContext context) { + openEntityManager(); + } + + @Override + public void afterEach(final ExtensionContext context) { + closeEntityManager(); + } + + @Override + public void afterAll(final ExtensionContext context) { + closeEntityManagerFactory(); + } + + + /** + * Opens a new {@link EntityManager} and begins a transaction. Must be called before + * any repository interaction in a test. + */ + public void openEntityManager() { + entityManager = entityManagerFactory.createEntityManager(); + entityManager.getTransaction().begin(); + } + + /** + * Rolls back the active transaction (if any) and closes the {@link EntityManager}. + * Call this in {@code @AfterEach} so every test starts with a clean database state. + */ + public void closeEntityManager() { + if (entityManager != null) { + if (entityManager.getTransaction().isActive()) { + entityManager.getTransaction().rollback(); + } + if (entityManager.isOpen()) { + entityManager.close(); + } + } + } + + /** + * Closes the underlying {@link EntityManagerFactory}. Call this in {@code @AfterAll} + * once all tests in the class have finished. + */ + public void closeEntityManagerFactory() { + if (entityManagerFactory != null && entityManagerFactory.isOpen()) { + entityManagerFactory.close(); + } + } + + /** + * Returns the current {@link EntityManager}. Valid only between calls to + * {@link #openEntityManager()} and {@link #closeEntityManager()}. + * + * @return the active {@link EntityManager} + */ + public EntityManager getEntityManager() { + return entityManager; + } + + /** + * Injects the current {@link EntityManager} into the field named {@code entityManager} + * on the supplied repository object. Equivalent to calling + * {@link #injectEntityManagerInto(Object, String)} with {@code "entityManager"}. + * + * @param repository the repository instance to inject into + * @throws NoEntityManagerFieldFoundException if the field cannot be found + */ + public void injectEntityManagerInto(final Object repository) { + injectEntityManagerInto(repository, "entityManager"); + } + + /** + * Injects the current {@link EntityManager} into the named field of the supplied + * repository object. Uses reflection so that no special interface or constructor is + * required on the repository. + * + * @param repository the repository instance to inject into + * @param entityManagerFieldName the name of the field that holds the {@link EntityManager} + * @throws NoEntityManagerFieldFoundException if the field cannot be found + */ + public void injectEntityManagerInto(final Object repository, final String entityManagerFieldName) { + try { + setField(repository, entityManagerFieldName, entityManager); + } catch (final ReflectionException e) { + throw new NoEntityManagerFieldFoundException( + format("Failed to inject Hibernate EntityManager into %s. No EntityManager field found with the name '%s'", + repository.getClass().getName(), entityManagerFieldName)); + } + } +} diff --git a/framework-utilities/test-utils/test-utils-hibernate/src/main/java/uk/gov/justice/services/test/utils/persistence/NoEntityManagerFieldFoundException.java b/framework-utilities/test-utils/test-utils-hibernate/src/main/java/uk/gov/justice/services/test/utils/persistence/NoEntityManagerFieldFoundException.java new file mode 100644 index 000000000..4d7d9ba0e --- /dev/null +++ b/framework-utilities/test-utils/test-utils-hibernate/src/main/java/uk/gov/justice/services/test/utils/persistence/NoEntityManagerFieldFoundException.java @@ -0,0 +1,8 @@ +package uk.gov.justice.services.test.utils.persistence; + +public class NoEntityManagerFieldFoundException extends RuntimeException { + + public NoEntityManagerFieldFoundException(final String message) { + super(message); + } +} diff --git a/framework-utilities/test-utils/test-utils-hibernate/src/test/java/uk/gov/justice/services/test/utils/persistence/HibernateTestEntityManagerProviderTest.java b/framework-utilities/test-utils/test-utils-hibernate/src/test/java/uk/gov/justice/services/test/utils/persistence/HibernateTestEntityManagerProviderTest.java new file mode 100644 index 000000000..a15ad44bc --- /dev/null +++ b/framework-utilities/test-utils/test-utils-hibernate/src/test/java/uk/gov/justice/services/test/utils/persistence/HibernateTestEntityManagerProviderTest.java @@ -0,0 +1,294 @@ +package uk.gov.justice.services.test.utils.persistence; + +import static java.lang.String.format; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.UUID; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.MockedStatic; +import org.mockito.junit.jupiter.MockitoExtension; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.Id; +import jakarta.persistence.Persistence; +import jakarta.persistence.Table; + +@ExtendWith(MockitoExtension.class) +public class HibernateTestEntityManagerProviderTest { + + private static final String PERSISTENCE_UNIT = "test-utils-hibernate-test-unit"; + + @Mock + private EntityManagerFactory entityManagerFactory; + + @Mock + private EntityManager entityManager; + + @Mock + private EntityTransaction transaction; + + private HibernateTestEntityManagerProvider hibernateTestEntityManagerProvider; + + @BeforeEach + void setUp() { + try (final MockedStatic mockedPersistence = mockStatic(Persistence.class)) { + mockedPersistence.when(() -> Persistence.createEntityManagerFactory(PERSISTENCE_UNIT)).thenReturn(entityManagerFactory); + hibernateTestEntityManagerProvider = new HibernateTestEntityManagerProvider(PERSISTENCE_UNIT); + } + } + + @Test + void shouldCreateEntityManagerFactoryFromPersistenceUnitName() { + try (final MockedStatic mockedPersistence = mockStatic(Persistence.class)) { + mockedPersistence.when(() -> Persistence.createEntityManagerFactory(PERSISTENCE_UNIT)) + .thenReturn(entityManagerFactory); + + new HibernateTestEntityManagerProvider(PERSISTENCE_UNIT); + + mockedPersistence.verify(() -> Persistence.createEntityManagerFactory(PERSISTENCE_UNIT)); + } + } + + @Test + public void shouldOpenEntityManagerViaBeforeEachCallback() throws Exception { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + + hibernateTestEntityManagerProvider.beforeEach(null); + + verify(entityManagerFactory).createEntityManager(); + verify(transaction).begin(); + } + + @Test + public void shouldCloseEntityManagerViaAfterEachCallback() throws Exception { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + when(transaction.isActive()).thenReturn(true); + when(entityManager.isOpen()).thenReturn(true); + + hibernateTestEntityManagerProvider.beforeEach(null); + hibernateTestEntityManagerProvider.afterEach(null); + + verify(transaction).rollback(); + verify(entityManager).close(); + } + + @Test + public void shouldCloseEntityManagerFactoryViaAfterAllCallback() throws Exception { + when(entityManagerFactory.isOpen()).thenReturn(true); + + hibernateTestEntityManagerProvider.afterAll(null); + + verify(entityManagerFactory).close(); + } + + @Test + void shouldOpenEntityManagerAndBeginTransaction() { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + + hibernateTestEntityManagerProvider.openEntityManager(); + + verify(entityManagerFactory).createEntityManager(); + verify(transaction).begin(); + } + + @Test + void shouldReturnEntityManagerAfterOpen() { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + + hibernateTestEntityManagerProvider.openEntityManager(); + + assertThat(hibernateTestEntityManagerProvider.getEntityManager(), is(entityManager)); + } + + @Test + void shouldRollbackAndCloseEntityManagerOnClose() { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + when(transaction.isActive()).thenReturn(true); + when(entityManager.isOpen()).thenReturn(true); + + hibernateTestEntityManagerProvider.openEntityManager(); + hibernateTestEntityManagerProvider.closeEntityManager(); + + verify(transaction).rollback(); + verify(entityManager).close(); + } + + @Test + void shouldNotRollbackWhenTransactionIsNotActive() { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + when(transaction.isActive()).thenReturn(false); + when(entityManager.isOpen()).thenReturn(true); + + hibernateTestEntityManagerProvider.openEntityManager(); + hibernateTestEntityManagerProvider.closeEntityManager(); + + verify(transaction, never()).rollback(); + verify(entityManager).close(); + } + + @Test + void shouldNotCloseEntityManagerWhenAlreadyClosed() { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + when(transaction.isActive()).thenReturn(false); + when(entityManager.isOpen()).thenReturn(false); + + hibernateTestEntityManagerProvider.openEntityManager(); + hibernateTestEntityManagerProvider.closeEntityManager(); + + verify(entityManager, never()).close(); + } + + @Test + void shouldHandleCloseEntityManagerWhenNeverOpened() { + hibernateTestEntityManagerProvider.closeEntityManager(); + + verify(entityManagerFactory, never()).createEntityManager(); + } + + @Test + void shouldCloseEntityManagerFactoryWhenOpen() { + when(entityManagerFactory.isOpen()).thenReturn(true); + + hibernateTestEntityManagerProvider.closeEntityManagerFactory(); + + verify(entityManagerFactory).close(); + } + + @Test + void shouldNotCloseEntityManagerFactoryWhenAlreadyClosed() { + when(entityManagerFactory.isOpen()).thenReturn(false); + + hibernateTestEntityManagerProvider.closeEntityManagerFactory(); + + verify(entityManagerFactory, never()).close(); + } + + @Test + void shouldInjectEntityManagerIntoDefaultField() { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + + hibernateTestEntityManagerProvider.openEntityManager(); + + final DummyRepository repository = new DummyRepository(); + hibernateTestEntityManagerProvider.injectEntityManagerInto(repository); + + assertThat(repository.entityManager, is(entityManager)); + } + + @Test + void shouldInjectEntityManagerIntoNamedField() { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + + hibernateTestEntityManagerProvider.openEntityManager(); + + final DummyRepository repository = new DummyRepository(); + hibernateTestEntityManagerProvider.injectEntityManagerInto(repository, "customNamedEntityManager"); + + assertThat(repository.customNamedEntityManager, is(entityManager)); + } + + @Test + void shouldOnlySetTheNamedFieldWhenFieldNameIsSupplied() { + when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); + when(entityManager.getTransaction()).thenReturn(transaction); + + hibernateTestEntityManagerProvider.openEntityManager(); + + final DummyRepository repository = new DummyRepository(); + hibernateTestEntityManagerProvider.injectEntityManagerInto(repository, "customNamedEntityManager"); + + assertThat(repository.entityManager, is(nullValue())); + } + + @Test + void shouldThrowNoEntityManagerFieldFoundExceptionWhenDefaultFieldDoesNotExist() { + final Object noEntityManagerField = new Object(); + + final NoEntityManagerFieldFoundException exception = assertThrows( + NoEntityManagerFieldFoundException.class, + () -> hibernateTestEntityManagerProvider.injectEntityManagerInto(noEntityManagerField)); + + assertThat(exception.getMessage(), is("Failed to inject Hibernate EntityManager into java.lang.Object. No EntityManager field found with the name 'entityManager'")); + } + + @Test + void shouldIncludeCustomFieldNameInExceptionMessageWhenNamedFieldDoesNotExist() { + final Object noEntityManagerField = new Object(); + + final NoEntityManagerFieldFoundException exception = assertThrows( + NoEntityManagerFieldFoundException.class, + () -> hibernateTestEntityManagerProvider.injectEntityManagerInto(noEntityManagerField, "myEntityManager")); + + assertThat(exception.getMessage(), is("Failed to inject Hibernate EntityManager into java.lang.Object. No EntityManager field found with the name 'myEntityManager'")); + } + + static class DummyRepository { + + EntityManager entityManager; + EntityManager customNamedEntityManager; + + public DummyEntity findBy(final UUID id) { + return entityManager.find(DummyEntity.class, id); + } + + public void save(final DummyEntity entity) { + entityManager.persist(entity); + } + + public DummyEntity findByUsingCustomField(final UUID id) { + return customNamedEntityManager.find(DummyEntity.class, id); + } + } + + @Entity + @Table(name = "test_entity") + static class DummyEntity { + + @Id + @Column(name = "id") + private UUID id; + + @Column(name = "name") + private String name; + + public DummyEntity() { + } + + public DummyEntity(final UUID id, final String name) { + this.id = id; + this.name = name; + } + + public UUID getId() { + return id; + } + + public String getName() { + return name; + } + } +} diff --git a/framework-utilities/test-utils/test-utils-logging-jdk/pom.xml b/framework-utilities/test-utils/test-utils-logging-jdk/pom.xml index 6475e6549..92d1e0a0c 100644 --- a/framework-utilities/test-utils/test-utils-logging-jdk/pom.xml +++ b/framework-utilities/test-utils/test-utils-logging-jdk/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.utils test-utils - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-utilities/test-utils/test-utils-logging-log4j/pom.xml b/framework-utilities/test-utils/test-utils-logging-log4j/pom.xml index a7f5fc57f..56cdb50b5 100644 --- a/framework-utilities/test-utils/test-utils-logging-log4j/pom.xml +++ b/framework-utilities/test-utils/test-utils-logging-log4j/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.utils test-utils - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/framework-utilities/test-utils/test-utils-logging-simple/pom.xml b/framework-utilities/test-utils/test-utils-logging-simple/pom.xml index 457877ec7..5eaed8c3c 100644 --- a/framework-utilities/test-utils/test-utils-logging-simple/pom.xml +++ b/framework-utilities/test-utils/test-utils-logging-simple/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.utils test-utils - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -23,11 +23,6 @@ org.slf4j jul-to-slf4j - - org.slf4j - slf4j-reload4j - - org.slf4j diff --git a/framework-utilities/utilities/pom.xml b/framework-utilities/utilities/pom.xml index 47b7426a7..053c56c97 100644 --- a/framework-utilities/utilities/pom.xml +++ b/framework-utilities/utilities/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.framework.utilities framework-utilities - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.utils diff --git a/framework-utilities/utilities/utilities-core/pom.xml b/framework-utilities/utilities/utilities-core/pom.xml index 40dca4b33..1dca454f7 100644 --- a/framework-utilities/utilities/utilities-core/pom.xml +++ b/framework-utilities/utilities/utilities-core/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.utils utilities - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT utilities-core @@ -31,7 +31,7 @@ com.fasterxml.jackson.datatype - jackson-datatype-jsr353 + jackson-datatype-jakarta-jsonp com.fasterxml.jackson.core @@ -46,8 +46,8 @@ guava - javax.json - javax.json-api + jakarta.json + jakarta.json-api org.apache.commons @@ -65,12 +65,12 @@ org.glassfish - javax.json + jakarta.json test - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api test diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/InitialContextProducer.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/InitialContextProducer.java index 8ae937f67..fbfb24b54 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/InitialContextProducer.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/InitialContextProducer.java @@ -1,11 +1,11 @@ package uk.gov.justice.services.cdi; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.CreationException; -import javax.enterprise.inject.Disposes; -import javax.enterprise.inject.InjectionException; -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.CreationException; +import jakarta.enterprise.inject.Disposes; +import jakarta.enterprise.inject.InjectionException; +import jakarta.enterprise.inject.Produces; +import jakarta.enterprise.inject.spi.InjectionPoint; import javax.naming.InitialContext; import javax.naming.NamingException; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/LoggerProducer.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/LoggerProducer.java index c2f36cd3f..b61900956 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/LoggerProducer.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/LoggerProducer.java @@ -1,8 +1,8 @@ package uk.gov.justice.services.cdi; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; +import jakarta.enterprise.inject.spi.InjectionPoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/QualifierAnnotationExtractor.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/QualifierAnnotationExtractor.java index 5bd6e185a..2efd16701 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/QualifierAnnotationExtractor.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/cdi/QualifierAnnotationExtractor.java @@ -5,9 +5,9 @@ import java.lang.annotation.Annotation; import java.util.Set; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.InjectionException; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.InjectionException; +import jakarta.enterprise.inject.spi.InjectionPoint; /** * Extracts a qualifier from an {@link InjectionPoint} diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/CommonValueAnnotationDef.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/CommonValueAnnotationDef.java index ba38cbd7b..abe4865c2 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/CommonValueAnnotationDef.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/CommonValueAnnotationDef.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.common.configuration; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.inject.spi.InjectionPoint; class CommonValueAnnotationDef { diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/ContextNameProvider.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/ContextNameProvider.java index 7eb31dc2b..ef03de067 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/ContextNameProvider.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/ContextNameProvider.java @@ -2,7 +2,7 @@ import uk.gov.justice.services.common.util.LazyValue; -import javax.inject.Inject; +import jakarta.inject.Inject; public class ContextNameProvider { diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/GlobalValue.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/GlobalValue.java index c22741698..09592d95f 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/GlobalValue.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/GlobalValue.java @@ -5,8 +5,8 @@ import java.lang.annotation.Retention; -import javax.enterprise.util.Nonbinding; -import javax.inject.Qualifier; +import jakarta.enterprise.util.Nonbinding; +import jakarta.inject.Qualifier; @Qualifier @Retention(RUNTIME) diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/GlobalValueProducer.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/GlobalValueProducer.java index da935acac..5ba4c6012 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/GlobalValueProducer.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/GlobalValueProducer.java @@ -2,9 +2,9 @@ import static uk.gov.justice.services.common.configuration.CommonValueAnnotationDef.globalValueAnnotationOf; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; +import jakarta.enterprise.inject.spi.InjectionPoint; import javax.naming.NamingException; /** diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/JndiBasedServiceContextNameProvider.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/JndiBasedServiceContextNameProvider.java index d76893447..7adf47737 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/JndiBasedServiceContextNameProvider.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/JndiBasedServiceContextNameProvider.java @@ -2,8 +2,8 @@ import static java.lang.String.format; -import javax.annotation.Resource; -import javax.enterprise.context.ApplicationScoped; +import jakarta.annotation.Resource; +import jakarta.enterprise.context.ApplicationScoped; import com.google.common.annotations.VisibleForTesting; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/Value.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/Value.java index 07e60ad23..0ed7aa3b7 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/Value.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/Value.java @@ -5,8 +5,8 @@ import java.lang.annotation.Retention; -import javax.enterprise.util.Nonbinding; -import javax.inject.Qualifier; +import jakarta.enterprise.util.Nonbinding; +import jakarta.inject.Qualifier; @Qualifier @Retention(RUNTIME) diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/ValueProducer.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/ValueProducer.java index be9730208..43b8c6db7 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/ValueProducer.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/configuration/ValueProducer.java @@ -3,10 +3,10 @@ import static java.lang.String.format; import static uk.gov.justice.services.common.configuration.CommonValueAnnotationDef.localValueAnnotationOf; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.InjectionPoint; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; +import jakarta.enterprise.inject.spi.InjectionPoint; +import jakarta.inject.Inject; import javax.naming.NamingException; /** diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JSONObjectValueObfuscator.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JSONObjectValueObfuscator.java index 376271005..ffc3b9c25 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JSONObjectValueObfuscator.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JSONObjectValueObfuscator.java @@ -1,17 +1,17 @@ package uk.gov.justice.services.common.converter; -import static javax.json.JsonValue.NULL; +import static jakarta.json.JsonValue.NULL; import static uk.gov.justice.services.messaging.JsonObjects.getJsonBuilderFactory; import java.util.UUID; -import javax.json.JsonArray; -import javax.json.JsonArrayBuilder; -import javax.json.JsonNumber; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; -import javax.json.JsonString; -import javax.json.JsonValue; +import jakarta.json.JsonArray; +import jakarta.json.JsonArrayBuilder; +import jakarta.json.JsonNumber; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import jakarta.json.JsonString; +import jakarta.json.JsonValue; /** diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonObjectConvertersProducer.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonObjectConvertersProducer.java index 07ae17113..01a9e8516 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonObjectConvertersProducer.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonObjectConvertersProducer.java @@ -1,7 +1,7 @@ package uk.gov.justice.services.common.converter; -import javax.enterprise.inject.Produces; -import javax.inject.Inject; +import jakarta.enterprise.inject.Produces; +import jakarta.inject.Inject; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonObjectToObjectConverter.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonObjectToObjectConverter.java index 52569994f..209e1f49c 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonObjectToObjectConverter.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonObjectToObjectConverter.java @@ -7,8 +7,8 @@ import java.io.IOException; -import javax.enterprise.inject.Vetoed; -import javax.json.JsonObject; +import jakarta.enterprise.inject.Vetoed; +import jakarta.json.JsonObject; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonValueFactory.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonValueFactory.java index 1883be077..58cd0f124 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonValueFactory.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/JsonValueFactory.java @@ -1,14 +1,14 @@ package uk.gov.justice.services.common.converter; -import static javax.json.JsonValue.FALSE; -import static javax.json.JsonValue.TRUE; +import static jakarta.json.JsonValue.FALSE; +import static jakarta.json.JsonValue.TRUE; import static uk.gov.justice.services.messaging.JsonObjects.getJsonBuilderFactory; import java.math.BigDecimal; -import javax.json.JsonNumber; -import javax.json.JsonString; -import javax.json.JsonValue; +import jakarta.json.JsonNumber; +import jakarta.json.JsonString; +import jakarta.json.JsonValue; /** * Factory for producing JsonValue based values for literals. diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ListToJsonArrayConverter.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ListToJsonArrayConverter.java index 4742c2564..cf85cfa73 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ListToJsonArrayConverter.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ListToJsonArrayConverter.java @@ -8,9 +8,9 @@ import java.io.IOException; import java.util.List; -import javax.inject.Inject; -import javax.json.JsonArray; -import javax.json.JsonArrayBuilder; +import jakarta.inject.Inject; +import jakarta.json.JsonArray; +import jakarta.json.JsonArrayBuilder; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ObjectToJsonObjectConverter.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ObjectToJsonObjectConverter.java index fb0913c1f..36339ff91 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ObjectToJsonObjectConverter.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ObjectToJsonObjectConverter.java @@ -6,8 +6,8 @@ import java.io.IOException; -import javax.enterprise.inject.Vetoed; -import javax.json.JsonObject; +import jakarta.enterprise.inject.Vetoed; +import jakarta.json.JsonObject; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ObjectToJsonValueConverter.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ObjectToJsonValueConverter.java index cc198d0ff..5dfbc1abe 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ObjectToJsonValueConverter.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ObjectToJsonValueConverter.java @@ -1,13 +1,13 @@ package uk.gov.justice.services.common.converter; -import static javax.json.JsonValue.NULL; +import static jakarta.json.JsonValue.NULL; import uk.gov.justice.services.common.converter.exception.ConverterException; import java.io.IOException; -import javax.enterprise.inject.Vetoed; -import javax.json.JsonValue; +import jakarta.enterprise.inject.Vetoed; +import jakarta.json.JsonValue; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/StringToJsonObjectConverter.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/StringToJsonObjectConverter.java index fdd9bfc02..9cf99f8d0 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/StringToJsonObjectConverter.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/StringToJsonObjectConverter.java @@ -2,8 +2,8 @@ import java.io.StringReader; -import javax.json.JsonObject; -import javax.json.JsonReader; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; import static uk.gov.justice.services.messaging.JsonObjects.getJsonReaderFactory; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ZonedDateTimes.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ZonedDateTimes.java index f2831ab6a..2d4b61ee9 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ZonedDateTimes.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/ZonedDateTimes.java @@ -7,7 +7,7 @@ import java.sql.Timestamp; import java.time.ZonedDateTime; -import javax.json.JsonString; +import jakarta.json.JsonString; /** * Utility functions for converting to and from date time objects. diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/ObjectMapperProducer.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/ObjectMapperProducer.java index 28ea20b28..a587a4d3a 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/ObjectMapperProducer.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/ObjectMapperProducer.java @@ -2,6 +2,7 @@ import static com.fasterxml.jackson.annotation.JsonCreator.Mode.PROPERTIES; import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_ABSENT; +import static com.fasterxml.jackson.databind.DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE; import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; import static com.fasterxml.jackson.databind.DeserializationFeature.READ_ENUMS_USING_TO_STRING; import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS; @@ -9,7 +10,6 @@ import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_ENUMS_USING_TO_STRING; import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_NULL_MAP_VALUES; import static com.fasterxml.jackson.databind.cfg.ConstructorDetector.USE_PROPERTIES_BASED; -import static java.time.ZoneOffset.UTC; import static java.time.format.DateTimeFormatter.ofPattern; import static java.util.TimeZone.getTimeZone; import static uk.gov.justice.services.common.converter.ZonedDateTimes.ISO_8601; @@ -19,13 +19,14 @@ import uk.gov.justice.services.common.converter.jackson.jsr353.InclusionAwareJSR353Module; import java.time.ZonedDateTime; +import java.util.ServiceConfigurationError; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; @@ -49,28 +50,37 @@ public ObjectMapper objectMapperWith(final JsonFactory jsonFactory) { public ObjectMapper yamlObjectMapper() { return configureObjectMapper(new ObjectMapper(new YAMLFactory())) - .setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); + .setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); } private ObjectMapper configureObjectMapper(final ObjectMapper objectMapper) { + tryRegisterJsr353Module(objectMapper); return objectMapper .registerModule(javaTimeModuleWithFormattedDateTime()) .registerModule(new Jdk8Module()) .registerModule(new ParameterNamesModule(PROPERTIES)) - .registerModule(new InclusionAwareJSR353Module()) .registerModule(new AdditionalPropertiesModule()) .registerModule(new IntegerEnumModule()) .configure(WRITE_DATES_AS_TIMESTAMPS, false) .configure(WRITE_DATES_WITH_ZONE_ID, false) .configure(WRITE_NULL_MAP_VALUES, false) - .setTimeZone(getTimeZone(UTC)) + .setTimeZone(getTimeZone("UTC")) .setSerializationInclusion(NON_ABSENT) .enable(WRITE_ENUMS_USING_TO_STRING) .configure(FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(ADJUST_DATES_TO_CONTEXT_TIME_ZONE, true) .enable(READ_ENUMS_USING_TO_STRING) .setConstructorDetector(USE_PROPERTIES_BASED); } + private void tryRegisterJsr353Module(final ObjectMapper objectMapper) { + try { + objectMapper.registerModule(new InclusionAwareJSR353Module()); + } catch (final ServiceConfigurationError | ExceptionInInitializerError | NoClassDefFoundError e) { + // JSON-P provider not available in this classloader context (e.g. Maven plugin execution) + } + } + private JavaTimeModule javaTimeModuleWithFormattedDateTime() { final JavaTimeModule javaTimeModule = new JavaTimeModule(); javaTimeModule.addSerializer(ZonedDateTime.class, new ZonedDateTimeSerializer(ofPattern(ISO_8601))); diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/additionalproperties/AdditionalPropertiesDeserializer.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/additionalproperties/AdditionalPropertiesDeserializer.java index 27aba11d2..fdf8d6bdb 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/additionalproperties/AdditionalPropertiesDeserializer.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/additionalproperties/AdditionalPropertiesDeserializer.java @@ -44,10 +44,12 @@ public void handleUnknownProperty(final JsonParser jsonParser, } additionalPropertiesMap.put(propName, value); } else { - throw context.mappingException("Expected target object to have additionalProperties attribute! [" + bean.getClass() + "]"); + throw new IOException("Expected target object to have additionalProperties attribute! [" + bean.getClass() + "]"); } + } catch (final IOException ex) { + throw ex; } catch (final Exception ex) { - throw context.mappingException("Couldn't add [" + propName + "] to additionalProperties attribute!", ex); + throw new IOException("Couldn't add [" + propName + "] to additionalProperties attribute!", ex); } } @@ -83,7 +85,7 @@ private Object deserializeFromType(final JsonParser jsonParser, final Deserializ obj = null; break; default: - throw context.mappingException(this.handledType()); + throw new IOException("Cannot deserialize value of type " + this.handledType() + " from token " + jsonToken); } return obj; } diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumBeanDeserializerModifier.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumBeanDeserializerModifier.java index c9380c79f..e2448631e 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumBeanDeserializerModifier.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumBeanDeserializerModifier.java @@ -1,7 +1,7 @@ package uk.gov.justice.services.common.converter.jackson.integerenum; -import static com.fasterxml.jackson.databind.AnnotationIntrospector.nopInstance; import static com.fasterxml.jackson.databind.util.EnumResolver.constructFor; +import static com.fasterxml.jackson.databind.util.EnumResolver.constructUsingToString; import com.fasterxml.jackson.databind.BeanDescription; import com.fasterxml.jackson.databind.DeserializationConfig; @@ -10,9 +10,9 @@ import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier; import com.fasterxml.jackson.databind.util.EnumResolver; + public class IntegerEnumBeanDeserializerModifier extends BeanDeserializerModifier { - @SuppressWarnings("unchecked") @Override public JsonDeserializer modifyEnumDeserializer( final DeserializationConfig config, @@ -20,12 +20,12 @@ public JsonDeserializer modifyEnumDeserializer( final BeanDescription beanDesc, final JsonDeserializer deserializer) { - final Class> enumClass = (Class>) type.getRawClass(); - - final EnumResolver enumResolver = constructFor(enumClass, nopInstance()); + final EnumResolver enumResolver = constructFor(config, beanDesc.getClassInfo()); + final EnumResolver toStringResolver = constructUsingToString(config, beanDesc.getClassInfo()); return new IntegerEnumDeserializer( enumResolver, + toStringResolver, new EnumObjectUtil()); } } diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumDeserializer.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumDeserializer.java index 1b00b33d6..ec3a0b8e8 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumDeserializer.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumDeserializer.java @@ -20,8 +20,9 @@ public class IntegerEnumDeserializer extends EnumDeserializer { private final EnumObjectUtil enumObjectUtil; public IntegerEnumDeserializer(final EnumResolver enumResolver, + final EnumResolver toStringResolver, final EnumObjectUtil enumObjectUtil) { - super(enumResolver); + super(enumResolver, false, toStringResolver); this.enumerations = asList(enumResolver.getRawEnums()); this.enumObjectUtil = enumObjectUtil; } diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/InclusionAwareJSR353Module.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/InclusionAwareJSR353Module.java index 68fcc2f44..b083b3ffb 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/InclusionAwareJSR353Module.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/InclusionAwareJSR353Module.java @@ -1,13 +1,13 @@ package uk.gov.justice.services.common.converter.jackson.jsr353; -import javax.json.JsonValue; +import jakarta.json.JsonValue; -import com.fasterxml.jackson.datatype.jsr353.JSR353Module; +import com.fasterxml.jackson.datatype.jsonp.JSONPModule; /** * Customised version of the JSR353Module that excludes null values. */ -public class InclusionAwareJSR353Module extends JSR353Module { +public class InclusionAwareJSR353Module extends JSONPModule { private static final long serialVersionUID = -1112006287109681036L; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/InclusionAwareJsonValueSerializer.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/InclusionAwareJsonValueSerializer.java index 467ece0b1..c473fa630 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/InclusionAwareJsonValueSerializer.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/InclusionAwareJsonValueSerializer.java @@ -5,12 +5,12 @@ import java.io.IOException; import java.util.Map.Entry; -import javax.json.JsonObject; -import javax.json.JsonValue; +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.datatype.jsr353.JsonValueSerializer; +import com.fasterxml.jackson.datatype.jsonp.JsonValueSerializer; /** * Customised version of the JSR353 JsonValueSerializer that excludes null values. diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/JsonIncludes.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/JsonIncludes.java index b3d3cbf8d..99514cdbc 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/JsonIncludes.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/jsr353/JsonIncludes.java @@ -1,10 +1,10 @@ package uk.gov.justice.services.common.converter.jackson.jsr353; -import static javax.json.JsonValue.NULL; +import static jakarta.json.JsonValue.NULL; -import javax.json.JsonArray; -import javax.json.JsonString; -import javax.json.JsonValue; +import jakarta.json.JsonArray; +import jakarta.json.JsonString; +import jakarta.json.JsonValue; import com.fasterxml.jackson.annotation.JsonInclude.Include; diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/jpa/converter/LocalDatePersistenceConverter.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/jpa/converter/LocalDatePersistenceConverter.java index df5d07e24..9d0911cf9 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/jpa/converter/LocalDatePersistenceConverter.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/jpa/converter/LocalDatePersistenceConverter.java @@ -5,8 +5,8 @@ import java.sql.Date; import java.time.LocalDate; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; /** * JPA {@link AttributeConverter} to manage date field conversion between entities and database. diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/jpa/converter/LocalDateTimePersistenceConverter.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/jpa/converter/LocalDateTimePersistenceConverter.java index 6bc21acfd..90a70dc50 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/jpa/converter/LocalDateTimePersistenceConverter.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/jpa/converter/LocalDateTimePersistenceConverter.java @@ -5,8 +5,8 @@ import java.sql.Timestamp; import java.time.LocalDateTime; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; /** * JPA {@link AttributeConverter} to manage date time field conversion between entities and diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/polling/MultiIteratingPollerFactory.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/polling/MultiIteratingPollerFactory.java index 06b087da4..6210a668a 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/polling/MultiIteratingPollerFactory.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/polling/MultiIteratingPollerFactory.java @@ -2,7 +2,7 @@ import uk.gov.justice.services.common.util.Sleeper; -import javax.inject.Inject; +import jakarta.inject.Inject; public class MultiIteratingPollerFactory { diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/polling/PollerFactory.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/polling/PollerFactory.java index ba1f003df..02f6f5564 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/polling/PollerFactory.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/polling/PollerFactory.java @@ -2,7 +2,7 @@ import uk.gov.justice.services.common.util.Sleeper; -import javax.inject.Inject; +import jakarta.inject.Inject; public class PollerFactory { diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/util/UtcClock.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/util/UtcClock.java index 91610b5f2..bef064a6f 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/util/UtcClock.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/util/UtcClock.java @@ -5,7 +5,7 @@ import java.time.ZonedDateTime; -import javax.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.ApplicationScoped; /** * Implementation of a clock that always generates a {@link java.time.ZonedDateTime} in UTC. diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerCanceler.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerCanceler.java index 539d36973..86d6dccab 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerCanceler.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerCanceler.java @@ -1,7 +1,7 @@ package uk.gov.justice.services.ejb.timer; -import javax.ejb.Timer; -import javax.ejb.TimerService; +import jakarta.ejb.Timer; +import jakarta.ejb.TimerService; public class TimerCanceler { diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerConfigFactory.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerConfigFactory.java index 1d9527a30..01878cc7c 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerConfigFactory.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerConfigFactory.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.ejb.timer; -import javax.ejb.TimerConfig; +import jakarta.ejb.TimerConfig; public class TimerConfigFactory { diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerServiceManager.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerServiceManager.java index e9ef8c379..078a1e77b 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerServiceManager.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/ejb/timer/TimerServiceManager.java @@ -1,9 +1,9 @@ package uk.gov.justice.services.ejb.timer; -import javax.ejb.Timer; -import javax.ejb.TimerConfig; -import javax.ejb.TimerService; -import javax.inject.Inject; +import jakarta.ejb.Timer; +import jakarta.ejb.TimerConfig; +import jakarta.ejb.TimerService; +import jakarta.inject.Inject; public class TimerServiceManager { diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/messaging/JsonObjects.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/messaging/JsonObjects.java index 6bb043922..85df2446c 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/messaging/JsonObjects.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/messaging/JsonObjects.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.messaging; -import static javax.json.JsonValue.ValueType; +import static jakarta.json.JsonValue.ValueType; import java.io.InputStream; import java.io.OutputStream; @@ -11,35 +11,43 @@ import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.ServiceLoader; import java.util.UUID; import java.util.function.BiFunction; import java.util.function.Function; import java.util.stream.Collectors; -import javax.json.JsonArray; -import javax.json.JsonArrayBuilder; -import javax.json.JsonBuilderFactory; -import javax.json.JsonException; -import javax.json.JsonNumber; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; -import javax.json.JsonReader; -import javax.json.JsonReaderFactory; -import javax.json.JsonString; -import javax.json.JsonValue; -import javax.json.JsonWriter; -import javax.json.JsonWriterFactory; -import javax.json.spi.JsonProvider; -import javax.json.stream.JsonGenerator; -import javax.json.stream.JsonParser; +import jakarta.json.JsonArray; +import jakarta.json.JsonArrayBuilder; +import jakarta.json.JsonBuilderFactory; +import jakarta.json.JsonException; +import jakarta.json.JsonNumber; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import jakarta.json.JsonReader; +import jakarta.json.JsonReaderFactory; +import jakarta.json.JsonString; +import jakarta.json.JsonValue; +import jakarta.json.JsonWriter; +import jakarta.json.JsonWriterFactory; +import jakarta.json.spi.JsonProvider; +import jakarta.json.stream.JsonGenerator; +import jakarta.json.stream.JsonParser; import com.google.common.collect.ImmutableList; /** - * Collection of static utility methods for getting deep values from a {@link JsonObject}. + * Static utility methods for reading deeply-nested values from a {@link JsonObject}, and for + * creating JSON parsers, generators, readers, writers, and builders. + * + *

All Jakarta JSON-P factory objects ({@link JsonProvider}, {@link JsonBuilderFactory}, + * {@link JsonReaderFactory}, {@link JsonWriterFactory}) are resolved once at class-load time and + * cached as static fields. Callers should use the methods on this class rather than calling + * {@code Json.create*()} directly, both to avoid repeated factory-creation overhead and to + * ensure the correct {@link JsonProvider} is used in Maven plugin classloader contexts. */ public final class JsonObjects { - private static final JsonProvider provider = JsonProvider.provider(); + private static final JsonProvider provider = findProvider(); private static final JsonBuilderFactory jsonBuilderFactory = provider.createBuilderFactory(null); private static final JsonReaderFactory jsonReaderFactory = provider.createReaderFactory(null); private static final JsonWriterFactory jsonWriterFactory = provider.createWriterFactory(null); @@ -47,6 +55,17 @@ public final class JsonObjects { private static final String FIELD_IS_NOT_A_TYPE = "Field %s is not a %s"; + private static JsonProvider findProvider() { + // Use the classloader that loaded JsonProvider itself (the plugin realm classloader in + // Maven plugin contexts) rather than the Thread Context ClassLoader used by + // JsonProvider.provider(). This avoids isAssignableFrom mismatches caused by Classworlds + // realm isolation, where the TCCL resolves the implementation through a different realm + // than the one that loaded the JsonProvider interface. + return ServiceLoader.load(JsonProvider.class, JsonProvider.class.getClassLoader()) + .findFirst() + .orElseGet(JsonProvider::provider); + } + /** * Private constructor to prevent misuse of utility class. */ @@ -54,204 +73,242 @@ private JsonObjects() { } /** - * This is usage instead of Json.getProvider() to avoid re creation of Provider each time + * Returns the cached {@link JsonProvider}. * - * @return cached provider instance. + *

The provider is resolved once at class-load time using a classloader-aware + * {@link ServiceLoader} call and reused for all subsequent operations. + * + * @return the cached {@link JsonProvider} instance */ public static JsonProvider getProvider() { return provider; } /** - * This is usage instead of Json.createBuilderFactory(null) to avoid re creation of BuilderFactory each time + * Returns the cached {@link JsonBuilderFactory}. + * + *

Equivalent to {@code Json.createBuilderFactory(null)} but resolved once at + * class-load time and reused, avoiding repeated factory-creation overhead. * - * @return cached builder factory instance. + * @return the cached {@link JsonBuilderFactory} instance */ public static JsonBuilderFactory getJsonBuilderFactory() { return jsonBuilderFactory; } /** - * This is usage instead of Json.createReaderFactory(null) to avoid re creation of ReaderFactory each time + * Returns the cached {@link JsonReaderFactory}. * - * @return cached reader factory instance. + *

Equivalent to {@code Json.createReaderFactory(null)} but resolved once at + * class-load time and reused, avoiding repeated factory-creation overhead. + * + * @return the cached {@link JsonReaderFactory} instance */ public static JsonReaderFactory getJsonReaderFactory() { return jsonReaderFactory; } /** - * This is usage instead of Json.createWriterFactory(null) to avoid re creation of WriterFactory each time + * Returns the cached {@link JsonWriterFactory}. + * + *

Equivalent to {@code Json.createWriterFactory(null)} but resolved once at + * class-load time and reused, avoiding repeated factory-creation overhead. * - * @return cached writer factory instance. + * @return the cached {@link JsonWriterFactory} instance */ public static JsonWriterFactory getJsonWriterFactory() { return jsonWriterFactory; } /** - * This is usage instead of Json.createGeneratorFactory(null) to avoid re creation of Provider each time + * Creates a {@link JsonParser} that reads from the given {@link Reader}, using the + * cached {@link JsonProvider}. * - * @param reader i/o reader from which JSON is to be read - * @return a JSON parser + * @param reader the character stream from which JSON is to be read + * @return a {@link JsonParser} positioned at the start of the JSON text */ public static JsonParser createParser(Reader reader) { return getProvider().createParser(reader); } /** - * This is usage instead of Json.createParserFactory(null) to avoid re creation of Provider each time + * Creates a {@link JsonParser} that reads from the given {@link InputStream}, using the + * cached {@link JsonProvider}. The character encoding is auto-detected per the JSON + * specification. * - * @param in i/o stream from which JSON is to be read - * @throws JsonException if encoding cannot be determined - * or i/o error (IOException would be cause of JsonException) - * @return a JSON parser + * @param in the byte stream from which JSON is to be read + * @return a {@link JsonParser} positioned at the start of the JSON text + * @throws JsonException if the character encoding cannot be determined, or if an I/O error + * occurs (the causing {@link java.io.IOException} will be the cause) */ public static JsonParser createParser(InputStream in) { return getProvider().createParser(in); } /** - * This is usage instead of Json.createGeneratorFactory(null) to avoid re creation of Provider each time + * Creates a {@link JsonGenerator} that writes to the given {@link Writer}, using the + * cached {@link JsonProvider}. * - * @param writer a i/o writer to which JSON is written - * @return a JSON generator + * @param writer the character stream to which JSON is written + * @return a new {@link JsonGenerator} */ public static JsonGenerator createGenerator(Writer writer) { return getProvider().createGenerator(writer); } /** - * This is usage instead of Json.createGeneratorFactory(null) to avoid re creation of Provider each time + * Creates a {@link JsonGenerator} that writes to the given {@link OutputStream}, using the + * cached {@link JsonProvider}. * - * @param out i/o stream to which JSON is written - * @return a JSON generator + * @param out the byte stream to which JSON is written + * @return a new {@link JsonGenerator} */ public static JsonGenerator createGenerator(OutputStream out) { return getProvider().createGenerator(out); } + /** - * This is usage instead of Json.createWriterFactory(null) to avoid re creation of WriterFactory each time + * Creates a {@link JsonWriter} that writes to the given {@link Writer}, using the + * cached {@link JsonWriterFactory}. * - * @param writer to which JSON object or array is written - * @return a JSON writer + * @param writer the character stream to which a JSON object or array is written + * @return a new {@link JsonWriter} */ public static JsonWriter createWriter(Writer writer) { return getJsonWriterFactory().createWriter(writer); } /** - * This is usage instead of Json.createWriterFactory(null) to avoid re creation of WriterFactory each time + * Creates a {@link JsonWriter} that writes to the given {@link OutputStream}, using the + * cached {@link JsonWriterFactory}. * - * @param out to which JSON object or array is written - * @return a JSON writer + * @param out the byte stream to which a JSON object or array is written + * @return a new {@link JsonWriter} */ public static JsonWriter createWriter(OutputStream out) { return getJsonWriterFactory().createWriter(out); } /** - * This is usage instead of Json.createReaderFactory(null) to avoid re creation of ReaderFactory each time + * Creates a {@link JsonReader} that reads from the given {@link Reader}, using the + * cached {@link JsonReaderFactory}. * - * @param reader a reader from which JSON is to be read - * @return a JSON reader + * @param reader the character stream from which JSON is to be read + * @return a new {@link JsonReader} */ public static JsonReader createReader(Reader reader) { return getJsonReaderFactory().createReader(reader); } /** - * This is usage instead of Json.createReaderFactory(null) to avoid re creation of ReaderFactory each time + * Creates a {@link JsonReader} that reads from the given {@link InputStream}, using the + * cached {@link JsonReaderFactory}. * - * @param in a byte stream from which JSON is to be read - * @return a JSON reader + * @param in the byte stream from which JSON is to be read + * @return a new {@link JsonReader} */ public static JsonReader createReader(InputStream in) { return getJsonReaderFactory().createReader(in); } - /** - * This is usage instead of Json.createArrayBuilder() to avoid re creation of JsonBuilderFactory each time + * Creates a new {@link JsonArrayBuilder} using the cached {@link JsonBuilderFactory}. * - * @return a JSON array builder + * @return a new {@link JsonArrayBuilder} */ public static JsonArrayBuilder createArrayBuilder() { return getJsonBuilderFactory().createArrayBuilder(); } /** - * This is usage instead of Json.createObjectBuilder() to avoid re creation of JsonBuilderFactory each time + * Creates a new empty {@link JsonObjectBuilder} using the cached {@link JsonBuilderFactory}. * - * @return a JSON object builder + * @return a new {@link JsonObjectBuilder} */ public static JsonObjectBuilder createObjectBuilder() { return getJsonBuilderFactory().createObjectBuilder(); } /** - * Returns the (possibly nested) array value to which the specified name is mapped, if it - * exists. + * Returns the (possibly nested) array value at the given field name path, if it exists and + * is not JSON null. * - * @param object the JsonObject from which to retrieve the value - * @param names the field name path whose associated value is to be returned - * @return the array value to which the specified name is mapped - * @throws IllegalStateException if the value is not assignable to JsonArray type + * @param object the {@link JsonObject} from which to retrieve the value + * @param names one or more field names forming a path into nested objects + * @return an {@link Optional} containing the {@link JsonArray}, or {@link Optional#empty()} + * if the field is absent or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but its value is not a JSON array */ public static Optional getJsonArray(final JsonObject object, final String... names) { return getJsonValue(object, ValueType.ARRAY, JsonObject::getJsonArray, names); } /** - * Returns the (possibly nested) object value to which the specified name is mapped, if it - * exists. - * - * @param object the JsonObject from which to retrieve the value - * @param names the field name path whose associated value is to be returned - * @return the object value to which the specified name is mapped, or {@code null} if this - * object contains no mapping for the name - * @throws IllegalStateException if the value is not assignable to JsonObject type + * Returns the (possibly nested) object value at the given field name path, if it exists and + * is not JSON null. + * + * @param object the {@link JsonObject} from which to retrieve the value + * @param names one or more field names forming a path into nested objects + * @return an {@link Optional} containing the {@link JsonObject}, or {@link Optional#empty()} + * if the field is absent or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but its value is not a JSON object */ public static Optional getJsonObject(final JsonObject object, final String... names) { return getJsonValue(object, ValueType.OBJECT, JsonObject::getJsonObject, names); } /** - * Returns the (possibly nested) number value to which the specified name is mapped, if it - * exists. + * Returns the (possibly nested) number value at the given field name path, if it exists and + * is not JSON null. * - * @param object the JsonObject from which to retrieve the value - * @param names the field name path whose associated value is to be returned - * @return the number value to which the specified name is mapped - * @throws IllegalStateException if the value is not assignable to JsonNumber type + * @param object the {@link JsonObject} from which to retrieve the value + * @param names one or more field names forming a path into nested objects + * @return an {@link Optional} containing the {@link JsonNumber}, or {@link Optional#empty()} + * if the field is absent or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but its value is not a JSON number */ public static Optional getJsonNumber(final JsonObject object, final String... names) { return getJsonValue(object, ValueType.NUMBER, JsonObject::getJsonNumber, names); } /** - * Returns the (possibly nested) string value to which the specified name is mapped, if it - * exists. + * Returns the (possibly nested) string value at the given field name path, if it exists and + * is not JSON null. * - * @param object the JsonObject from which to retrieve the value - * @param names the field name path whose associated value is to be returned - * @return the string value to which the specified name is mapped - * @throws IllegalStateException if the value is not assignable to JsonString type + * @param object the {@link JsonObject} from which to retrieve the value + * @param names one or more field names forming a path into nested objects + * @return an {@link Optional} containing the {@link JsonString}, or {@link Optional#empty()} + * if the field is absent or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but its value is not a JSON string */ public static Optional getJsonString(final JsonObject object, final String... names) { return getJsonValue(object, ValueType.STRING, JsonObject::getJsonString, names); } /** - * Returns a (possibly nested) value converted into a specified JsonValue type. - * - * @param object the JsonObject from which to retrieve the value - * @param valueType the type of JsonValue we need to return - * @param function the function to use to get the correct type of JsonValue from the - * JsonObject - * @param names the field name path whose associated value is to be returned - * @param the type of JsonValue that will be returned - * @return an optional value found at the specified location in the JsonObject + * Retrieves a typed JSON value at a (possibly nested) field path, applying type checking. + * + *

If {@code names} contains a single element the value is looked up directly in + * {@code object}. If it contains more than one element, the first name is resolved as an + * intermediate {@link JsonObject} and the lookup recurses into it with the remaining names. + * + * @param object the {@link JsonObject} from which to retrieve the value + * @param valueType the expected {@link ValueType} of the target field + * @param function extracts the correctly-typed value from a {@link JsonObject} by field name + * @param names one or more field names forming a path into nested objects + * @param the {@link JsonValue} subtype to return + * @return an {@link Optional} containing the value, or {@link Optional#empty()} if the field + * is absent at any level of the path, or its value is JSON null + * @throws IllegalStateException if the field exists but its {@link ValueType} does not match + * {@code valueType} */ private static Optional getJsonValue(final JsonObject object, final ValueType valueType, @@ -280,12 +337,16 @@ private static Optional getJsonValue(final JsonObject o } /** - * A convenience method for {@code getJsonString(name).get().getString()}. + * Returns the (possibly nested) string value at the given field name path as a plain + * {@link String}, if it exists and is not JSON null. * - * @param object the JsonObject from which to retrieve the value - * @param names whose associated value is to be returned as String - * @return the String value to which the specified name is mapped - * @throws IllegalStateException if the value is not assignable to JsonString type + * @param object the {@link JsonObject} from which to retrieve the value + * @param names one or more field names forming a path into nested objects + * @return an {@link Optional} containing the string value, or {@link Optional#empty()} if + * the field is absent or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but its value is not a JSON string */ public static Optional getString(final JsonObject object, final String... names) { return getJsonValue(object, ValueType.STRING, JsonObject::getJsonString, names) @@ -293,13 +354,17 @@ public static Optional getString(final JsonObject object, final String.. } /** - * A convenience method for {@code UUID.fromString(getJsonString(name).get().getString())}. + * Returns the (possibly nested) string value at the given field name path parsed as a + * {@link UUID}, if it exists and is not JSON null. * - * @param object the JsonObject from which to retrieve the value - * @param names whose associated value is to be returned as String - * @return the String value to which the specified name is mapped - * @throws IllegalStateException if the value is not assignable to JsonString type - * @throws IllegalArgumentException if the value is not assignable to a UUID + * @param object the {@link JsonObject} from which to retrieve the value + * @param names one or more field names forming a path into nested objects + * @return an {@link Optional} containing the {@link UUID}, or {@link Optional#empty()} if + * the field is absent or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but is not a JSON string, or if the + * string value cannot be parsed as a UUID */ public static Optional getUUID(final JsonObject object, final String... names) { return getString(object, names) @@ -313,13 +378,16 @@ public static Optional getUUID(final JsonObject object, final String... na } /** - * A convenience method for {@code JsonNumber.longValue}. + * Returns the (possibly nested) number value at the given field name path as a {@link Long}, + * if it exists and is not JSON null. * - * @param object the JsonObject from which to retrieve the value - * @param names whose associated value is to be returned as Long - * @return the Long value to which the specified name is mapped - * @throws IllegalStateException if the value is not assignable to JsonNumber type - * @throws IllegalArgumentException if the value is not assignable to a Long + * @param object the {@link JsonObject} from which to retrieve the value + * @param names one or more field names forming a path into nested objects + * @return an {@link Optional} containing the long value, or {@link Optional#empty()} if the + * field is absent or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but its value is not a JSON number */ public static Optional getLong(final JsonObject object, final String... names) { return getJsonValue(object, ValueType.NUMBER, JsonObject::getJsonNumber, names) @@ -327,12 +395,16 @@ public static Optional getLong(final JsonObject object, final String... na } /** - * A convenience method to retrieve a Boolean value + * Returns the boolean value mapped to the given field name, if it exists. + * + *

Unlike the other getter methods this one does not support nested paths; it operates + * only on a single field name. * - * @param object the JsonObject from which to retrieve the value - * @param name whose associated value is to be returned as Long - * @return the Boolean value to which the specified name is mapped - * @throws IllegalStateException if the value is not assignable to a Boolean + * @param object the {@link JsonObject} from which to retrieve the value + * @param name the field name whose associated value is to be returned + * @return an {@link Optional} containing the boolean value, or {@link Optional#empty()} if + * the field is absent + * @throws IllegalStateException if the field exists but its value is not a JSON boolean */ public static Optional getBoolean(final JsonObject object, final String name) { try { @@ -342,16 +414,19 @@ public static Optional getBoolean(final JsonObject object, final String } } - /** - * A convenience method for getting a JsonArray as a List of a specific JsonValue type. - * - * @param object the JsonObject from which to retrieve the value - * @param names whose associated value is to be returned - * @param clazz the type of JsonValue that the returned list will contain - * @return the Long value to which the specified name is mapped - * @throws IllegalStateException if the value is not assignable to the specified type - * @throws IllegalArgumentException if the value is not assignable to a Long + * Returns the (possibly nested) JSON array at the given field name path as a typed + * {@link List}, if it exists and is not JSON null. + * + * @param object the {@link JsonObject} from which to retrieve the value + * @param clazz the {@link JsonValue} subtype that each array element must be cast to + * @param names one or more field names forming a path into nested objects + * @param the {@link JsonValue} subtype of the list elements + * @return an {@link Optional} containing an immutable list of values, or + * {@link Optional#empty()} if the field is absent or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but its value is not a JSON array */ public static Optional> getList(final JsonObject object, final Class clazz, final String... names) { return getJsonValue(object, ValueType.ARRAY, JsonObject::getJsonArray, names) @@ -360,15 +435,23 @@ public static Optional> getList(final JsonObject o } /** - * A convenience method for getting a list of a specific type. - * - * @param object the JsonObject from which to retrieve the value - * @param jsonClazz the JsonValue type that the value is stored as - * @param converter a function that can convert from the JsonValue class to the required type - * @param names whose associated value is to be returned - * @param the type of items in the return list - * @param the JsonValue type that the value is stored as - * @return an optional list of values found + * Returns the (possibly nested) JSON array at the given field name path as a {@link List} of + * converted values, if it exists and is not JSON null. + * + *

Each element in the JSON array is first cast to {@code jsonClazz} and then passed + * through {@code converter} to produce the final list element type. + * + * @param object the {@link JsonObject} from which to retrieve the value + * @param jsonClazz the {@link JsonValue} subtype that each array element is stored as + * @param converter a function that converts each {@link JsonValue} element to type {@code R} + * @param names one or more field names forming a path into nested objects + * @param the type of items in the returned list + * @param the {@link JsonValue} subtype of the array elements + * @return an {@link Optional} containing an immutable list of converted values, or + * {@link Optional#empty()} if the field is absent or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but its value is not a JSON array */ public static Optional> getList(final JsonObject object, final Class jsonClazz, @@ -382,11 +465,16 @@ public static Optional> getList(final JsonObjec } /** - * Get a list of UUIDs from a JsonObject. + * Returns the (possibly nested) JSON array at the given field name path as a {@link List} of + * {@link UUID} values. Each array element must be a JSON string containing a valid UUID. * - * @param object object the JsonObject from which to retrieve the list - * @param names the field name path whose associated value is to be returned - * @return the list of UUIDs or an empty list if none were found + * @param object the {@link JsonObject} from which to retrieve the list + * @param names one or more field names forming a path into nested objects + * @return an immutable list of {@link UUID} values, or an empty list if the field is absent + * or its value is JSON null + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * the first name is null or empty + * @throws IllegalStateException if the field exists but its value is not a JSON array */ public static List getUUIDs(final JsonObject object, final String... names) { return getList(object, JsonString.class, jsonString -> UUID.fromString(jsonString.getString()), names) @@ -394,11 +482,13 @@ public static List getUUIDs(final JsonObject object, final String... names } /** - * Create a {@link JsonObjectBuilder} from an existing {@link JsonObject} applying the filter. - * Only copy the field names for which the filter returns true. + * Creates a {@link JsonObjectBuilder} initialised with all fields from {@code source} for + * which {@code filter} returns {@code true}. * - * @param source {@link JsonObject} to copy fields from - * @return a {@link JsonObjectBuilder} initialised with the fields contained in the source + * @param source the {@link JsonObject} whose fields are to be selectively copied + * @param filter a predicate applied to each field name; only fields for which it returns + * {@code true} are included in the builder + * @return a {@link JsonObjectBuilder} containing the filtered fields */ public static JsonObjectBuilder createObjectBuilderWithFilter(final JsonObject source, Function filter) { JsonObjectBuilder builder = getJsonBuilderFactory().createObjectBuilder(); @@ -407,21 +497,22 @@ public static JsonObjectBuilder createObjectBuilderWithFilter(final JsonObject s } /** - * Create a {@link JsonObjectBuilder} from an existing {@link JsonObject}. + * Creates a {@link JsonObjectBuilder} initialised with all fields from {@code source}. * - * @param source {@link JsonObject} to copy fields from - * @return a {@link JsonObjectBuilder} initialised with the fields contained in the source + * @param source the {@link JsonObject} whose fields are to be copied + * @return a {@link JsonObjectBuilder} containing all fields from {@code source} */ public static JsonObjectBuilder createObjectBuilder(final JsonObject source) { return createObjectBuilderWithFilter(source, x -> true); } /** - * Assert that the provided arguments are valid. The object must not be null, and the next field - * name must be non-empty. + * Validates that the arguments passed to a getter method are well-formed. * - * @param object the JsonObject from which to retrieve the value - * @param names the field names + * @param object the {@link JsonObject} being queried; must not be null + * @param names the field name path; must contain at least one non-null, non-empty name + * @throws IllegalArgumentException if {@code object} is null, {@code names} is empty, or + * {@code names[0]} is null or empty */ private static void checkArguments(final JsonObject object, final String... names) { if (object == null) { @@ -436,12 +527,13 @@ private static void checkArguments(final JsonObject object, final String... name } /** - * Convert a collection of objects into a JsonArray + * Converts a collection of values into a {@link JsonArray} by applying {@code converter} to + * each element. * - * @param entries the collection to be converted - * @param converter to convert each entry in the collection + * @param entries the collection of values to convert + * @param converter a function that maps each entry to a {@link JsonValue} * @param the type of element in the collection - * @return a JsonArray with the converted entries + * @return a {@link JsonArray} containing the converted entries in iteration order */ public static JsonArray toJsonArray(final Collection entries, final Function converter) { final JsonArrayBuilder arrayBuilder = getJsonBuilderFactory().createArrayBuilder(); diff --git a/framework-utilities/utilities/utilities-core/src/main/resources/META-INF/beans.xml b/framework-utilities/utilities/utilities-core/src/main/resources/META-INF/beans.xml index c543550fc..e35ee868a 100644 --- a/framework-utilities/utilities/utilities-core/src/main/resources/META-INF/beans.xml +++ b/framework-utilities/utilities/utilities-core/src/main/resources/META-INF/beans.xml @@ -1,9 +1,9 @@ diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/InitialContextProducerTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/InitialContextProducerTest.java index 94c587fd7..105b138ae 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/InitialContextProducerTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/InitialContextProducerTest.java @@ -7,8 +7,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import javax.enterprise.inject.InjectionException; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.inject.InjectionException; +import jakarta.enterprise.inject.spi.InjectionPoint; import javax.naming.InitialContext; import javax.naming.NamingException; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/LoggerProducerTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/LoggerProducerTest.java index 346f3da53..33d408ab7 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/LoggerProducerTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/LoggerProducerTest.java @@ -8,7 +8,7 @@ import uk.gov.justice.services.common.util.Clock; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.inject.spi.InjectionPoint; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/QualifierAnnotationExtractorTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/QualifierAnnotationExtractorTest.java index e0e825a7d..fbe12f1e8 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/QualifierAnnotationExtractorTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/cdi/QualifierAnnotationExtractorTest.java @@ -11,10 +11,10 @@ import java.util.HashSet; import java.util.Set; -import javax.enterprise.inject.InjectionException; -import javax.enterprise.inject.spi.Bean; -import javax.enterprise.inject.spi.InjectionPoint; -import javax.inject.Named; +import jakarta.enterprise.inject.InjectionException; +import jakarta.enterprise.inject.spi.Bean; +import jakarta.enterprise.inject.spi.InjectionPoint; +import jakarta.inject.Named; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -56,7 +56,7 @@ public void shouldThrowARuntimeExceptionIfNoSubscriptionNameQualifierOnAnEventLi qualifierAnnotationExtractor.getFrom(injectionPoint, Named.class); fail(); } catch (final InjectionException expected) { - assertThat(expected.getMessage(), is("Failed to find 'javax.inject.Named' annotation on bean 'uk.gov.justice.services.cdi.QualifierAnnotationExtractorTest$MayAnnotatedClass'")); + assertThat(expected.getMessage(), is("Failed to find 'jakarta.inject.Named' annotation on bean 'uk.gov.justice.services.cdi.QualifierAnnotationExtractorTest$MayAnnotatedClass'")); } } diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/configuration/GlobalValueProducerTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/configuration/GlobalValueProducerTest.java index ff1c96bad..4ec42687c 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/configuration/GlobalValueProducerTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/configuration/GlobalValueProducerTest.java @@ -5,8 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; -import javax.enterprise.inject.spi.Annotated; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.inject.spi.Annotated; +import jakarta.enterprise.inject.spi.InjectionPoint; import javax.naming.InitialContext; import javax.naming.NameNotFoundException; import javax.naming.NamingException; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/configuration/ValueProducerTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/configuration/ValueProducerTest.java index 70a76ed61..297b4e5d2 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/configuration/ValueProducerTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/configuration/ValueProducerTest.java @@ -6,8 +6,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; -import javax.enterprise.inject.spi.Annotated; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.inject.spi.Annotated; +import jakarta.enterprise.inject.spi.InjectionPoint; import javax.naming.InitialContext; import javax.naming.NameNotFoundException; import javax.naming.NamingException; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JSONObjectValueObfuscatorTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JSONObjectValueObfuscatorTest.java index ac3bf3e64..e9636b84b 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JSONObjectValueObfuscatorTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JSONObjectValueObfuscatorTest.java @@ -2,7 +2,7 @@ import static com.jayway.jsonassert.JsonAssert.with; import static java.util.UUID.randomUUID; -import static javax.json.JsonValue.NULL; +import static jakarta.json.JsonValue.NULL; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; @@ -11,8 +11,8 @@ import java.math.BigDecimal; -import javax.json.JsonArray; -import javax.json.JsonObject; +import jakarta.json.JsonArray; +import jakarta.json.JsonObject; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JsonObjectToObjectConverterTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JsonObjectToObjectConverterTest.java index 2ecd8d831..70f2c4c05 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JsonObjectToObjectConverterTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JsonObjectToObjectConverterTest.java @@ -14,12 +14,13 @@ import java.io.IOException; import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.util.List; import java.util.UUID; -import javax.json.JsonArray; -import javax.json.JsonObject; +import jakarta.json.JsonArray; +import jakarta.json.JsonObject; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException; @@ -65,20 +66,20 @@ public void shouldConvertToPojoWithUTCDateTime() throws Exception { assertThat(jsonObjectToObjectConverter .convert(getJsonBuilderFactory().createObjectBuilder().add("dateTime", "2016-07-25T13:09:01.0+00:00").build(), - PojoWithDateTime.class).getDateTime(), - equalTo(ZonedDateTime.of(2016, 7, 25, 13, 9, 1, 0, ZoneId.of("UTC")))); + PojoWithDateTime.class).getDateTime().toInstant(), + equalTo(ZonedDateTime.of(2016, 7, 25, 13, 9, 1, 0, ZoneOffset.UTC).toInstant())); assertThat(jsonObjectToObjectConverter .convert(getJsonBuilderFactory().createObjectBuilder().add("dateTime", "2016-07-25T13:09:01.0Z").build(), - PojoWithDateTime.class).getDateTime(), - equalTo(ZonedDateTime.of(2016, 7, 25, 13, 9, 1, 0, ZoneId.of("UTC")))); + PojoWithDateTime.class).getDateTime().toInstant(), + equalTo(ZonedDateTime.of(2016, 7, 25, 13, 9, 1, 0, ZoneOffset.UTC).toInstant())); assertThat(jsonObjectToObjectConverter .convert(getJsonBuilderFactory().createObjectBuilder().add("dateTime", "2016-07-25T13:09:01Z").build(), - PojoWithDateTime.class).getDateTime(), - equalTo(ZonedDateTime.of(2016, 7, 25, 13, 9, 1, 0, ZoneId.of("UTC")))); + PojoWithDateTime.class).getDateTime().toInstant(), + equalTo(ZonedDateTime.of(2016, 7, 25, 13, 9, 1, 0, ZoneOffset.UTC).toInstant())); assertThat(jsonObjectToObjectConverter .convert(getJsonBuilderFactory().createObjectBuilder().add("dateTime", "2016-07-25T16:09:01.0+03:00").build(), - PojoWithDateTime.class).getDateTime(), - equalTo(ZonedDateTime.of(2016, 7, 25, 13, 9, 1, 0, ZoneId.of("UTC")))); + PojoWithDateTime.class).getDateTime().toInstant(), + equalTo(ZonedDateTime.of(2016, 7, 25, 13, 9, 1, 0, ZoneOffset.UTC).toInstant())); } diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JsonValueFactoryTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JsonValueFactoryTest.java index 73d59fbdc..fad14b435 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JsonValueFactoryTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/JsonValueFactoryTest.java @@ -1,15 +1,15 @@ package uk.gov.justice.services.common.converter; -import static javax.json.JsonValue.FALSE; +import static jakarta.json.JsonValue.FALSE; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; import static org.junit.jupiter.api.Assertions.assertTrue; import java.math.BigDecimal; -import javax.json.JsonNumber; -import javax.json.JsonString; -import javax.json.JsonValue; +import jakarta.json.JsonNumber; +import jakarta.json.JsonString; +import jakarta.json.JsonValue; import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ListToJsonArrayConverterTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ListToJsonArrayConverterTest.java index 5d0e749a1..1bbefc8e2 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ListToJsonArrayConverterTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ListToJsonArrayConverterTest.java @@ -15,7 +15,7 @@ import java.util.UUID; -import javax.json.JsonArray; +import jakarta.json.JsonArray; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectMapperProducerTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectMapperProducerTest.java index ab341d073..4b343d670 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectMapperProducerTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectMapperProducerTest.java @@ -23,8 +23,8 @@ import java.util.Map; import java.util.Objects; -import javax.json.JsonObject; -import javax.json.JsonValue; +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectToJsonObjectConverterTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectToJsonObjectConverterTest.java index c7038bd1b..e90dbf109 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectToJsonObjectConverterTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectToJsonObjectConverterTest.java @@ -16,8 +16,8 @@ import java.util.List; import java.util.UUID; -import javax.json.JsonArray; -import javax.json.JsonObject; +import jakarta.json.JsonArray; +import jakarta.json.JsonObject; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectToJsonValueConverterTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectToJsonValueConverterTest.java index 123f432ae..d869321ab 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectToJsonValueConverterTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ObjectToJsonValueConverterTest.java @@ -1,6 +1,6 @@ package uk.gov.justice.services.common.converter; -import static javax.json.JsonValue.NULL; +import static jakarta.json.JsonValue.NULL; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; @@ -18,8 +18,8 @@ import java.util.List; import java.util.UUID; -import javax.json.JsonArray; -import javax.json.JsonValue; +import jakarta.json.JsonArray; +import jakarta.json.JsonValue; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/StringToJsonObjectConverterTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/StringToJsonObjectConverterTest.java index c00beb208..2a752a214 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/StringToJsonObjectConverterTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/StringToJsonObjectConverterTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; -import javax.json.JsonObject; +import jakarta.json.JsonObject; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ZonedDateTimesTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ZonedDateTimesTest.java index 718f5313c..2ea0710f1 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ZonedDateTimesTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/ZonedDateTimesTest.java @@ -12,7 +12,7 @@ import java.time.ZoneId; import java.time.ZonedDateTime; -import javax.json.JsonString; +import jakarta.json.JsonString; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumDeserializerTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumDeserializerTest.java index 3495c6d7f..1bb05ae5c 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumDeserializerTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumDeserializerTest.java @@ -23,6 +23,9 @@ public class IntegerEnumDeserializerTest { @Mock private EnumResolver enumResolver; + @Mock + private EnumResolver toStringResolver; + @Mock private EnumObjectUtil enumObjectUtil; @@ -31,7 +34,7 @@ public class IntegerEnumDeserializerTest { @BeforeEach public void setup() { when(enumResolver.getRawEnums()).thenReturn(Age.values()); - integerEnumDeserializer = new IntegerEnumDeserializer(enumResolver, enumObjectUtil); + integerEnumDeserializer = new IntegerEnumDeserializer(enumResolver, toStringResolver, enumObjectUtil); } @Test diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/jackson/jsr353/JsonIncludesTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/jackson/jsr353/JsonIncludesTest.java index 6d27d0af6..c4ebc0ed6 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/jackson/jsr353/JsonIncludesTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/converter/jackson/jsr353/JsonIncludesTest.java @@ -6,8 +6,8 @@ import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY; import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; import static com.fasterxml.jackson.annotation.JsonInclude.Include.USE_DEFAULTS; -import static javax.json.JsonValue.NULL; -import static javax.json.JsonValue.TRUE; +import static jakarta.json.JsonValue.NULL; +import static jakarta.json.JsonValue.TRUE; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static uk.gov.justice.services.common.converter.jackson.jsr353.JsonIncludes.includeField; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/polling/PollerTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/polling/PollerTest.java index 5710a6411..fd9762b70 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/polling/PollerTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/common/polling/PollerTest.java @@ -11,7 +11,7 @@ import java.util.function.BooleanSupplier; -import javax.inject.Inject; +import jakarta.inject.Inject; import org.junit.jupiter.api.Test; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerCancelerTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerCancelerTest.java index 904e4cb92..ab815ab0d 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerCancelerTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerCancelerTest.java @@ -6,8 +6,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import javax.ejb.Timer; -import javax.ejb.TimerService; +import jakarta.ejb.Timer; +import jakarta.ejb.TimerService; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerConfigFactoryTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerConfigFactoryTest.java index 49fec8466..296608fdf 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerConfigFactoryTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerConfigFactoryTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import javax.ejb.TimerConfig; +import jakarta.ejb.TimerConfig; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerServiceManagerTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerServiceManagerTest.java index 01e62670f..68678bb8e 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerServiceManagerTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/ejb/timer/TimerServiceManagerTest.java @@ -6,9 +6,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import javax.ejb.Timer; -import javax.ejb.TimerConfig; -import javax.ejb.TimerService; +import jakarta.ejb.Timer; +import jakarta.ejb.TimerConfig; +import jakarta.ejb.TimerService; import org.apache.activemq.artemis.api.core.ICoreMessage; import org.hamcrest.CoreMatchers; diff --git a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/messaging/JsonObjectsTest.java b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/messaging/JsonObjectsTest.java index 4abb273a1..3fc4f2fd1 100644 --- a/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/messaging/JsonObjectsTest.java +++ b/framework-utilities/utilities/utilities-core/src/test/java/uk/gov/justice/services/messaging/JsonObjectsTest.java @@ -2,7 +2,7 @@ import static java.util.Arrays.asList; import static java.util.Collections.emptyList; -import static javax.json.JsonValue.NULL; +import static jakarta.json.JsonValue.NULL; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -18,12 +18,12 @@ import java.util.UUID; import java.util.function.Function; -import javax.json.JsonArray; -import javax.json.JsonNumber; -import javax.json.JsonObject; -import javax.json.JsonObjectBuilder; -import javax.json.JsonString; -import javax.json.JsonValue; +import jakarta.json.JsonArray; +import jakarta.json.JsonNumber; +import jakarta.json.JsonObject; +import jakarta.json.JsonObjectBuilder; +import jakarta.json.JsonString; +import jakarta.json.JsonValue; import com.google.common.collect.ImmutableList; import org.junit.jupiter.api.Test; @@ -36,8 +36,8 @@ public class JsonObjectsTest { private static final String UUID_A = "da45e8f6-d945-4f09-a115-1139a9dbb754"; private static final String UUID_B = "d04885b4-9652-4c2a-87c6-299bda0a87d4"; - private static final javax.json.JsonBuilderFactory jsonBuilderFactory = JsonObjects.getJsonBuilderFactory(); - private static final javax.json.JsonReaderFactory jsonReaderFactory = JsonObjects.getJsonReaderFactory(); + private static final jakarta.json.JsonBuilderFactory jsonBuilderFactory = JsonObjects.getJsonBuilderFactory(); + private static final jakarta.json.JsonReaderFactory jsonReaderFactory = JsonObjects.getJsonReaderFactory(); @Test public void shouldReturnJsonArray() { @@ -370,8 +370,8 @@ public void shouldJsonObjectsCacheProviders() { @Test public void shouldGetJsonReaderFactoryAndCacheIt() { // when - final javax.json.JsonReaderFactory first = JsonObjects.getJsonReaderFactory(); - final javax.json.JsonReaderFactory second = JsonObjects.getJsonReaderFactory(); + final jakarta.json.JsonReaderFactory first = JsonObjects.getJsonReaderFactory(); + final jakarta.json.JsonReaderFactory second = JsonObjects.getJsonReaderFactory(); // then assertNotNull(first); @@ -382,8 +382,8 @@ public void shouldGetJsonReaderFactoryAndCacheIt() { @Test public void shouldGetJsonWriterFactoryAndCacheIt() { // when - final javax.json.JsonWriterFactory first = JsonObjects.getJsonWriterFactory(); - final javax.json.JsonWriterFactory second = JsonObjects.getJsonWriterFactory(); + final jakarta.json.JsonWriterFactory first = JsonObjects.getJsonWriterFactory(); + final jakarta.json.JsonWriterFactory second = JsonObjects.getJsonWriterFactory(); // then assertNotNull(first); @@ -394,8 +394,8 @@ public void shouldGetJsonWriterFactoryAndCacheIt() { @Test public void shouldGetJsonBuilderFactoryAndCacheIt() { // when - final javax.json.JsonBuilderFactory first = JsonObjects.getJsonBuilderFactory(); - final javax.json.JsonBuilderFactory second = JsonObjects.getJsonBuilderFactory(); + final jakarta.json.JsonBuilderFactory first = JsonObjects.getJsonBuilderFactory(); + final jakarta.json.JsonBuilderFactory second = JsonObjects.getJsonBuilderFactory(); // then assertNotNull(first); @@ -406,8 +406,8 @@ public void shouldGetJsonBuilderFactoryAndCacheIt() { @Test public void shouldGetProviderAndCacheIt() { // when - final javax.json.spi.JsonProvider first = JsonObjects.getProvider(); - final javax.json.spi.JsonProvider second = JsonObjects.getProvider(); + final jakarta.json.spi.JsonProvider first = JsonObjects.getProvider(); + final jakarta.json.spi.JsonProvider second = JsonObjects.getProvider(); // then assertNotNull(first); @@ -420,15 +420,15 @@ public void shouldCreateParserFromReader() { final String json = "{\"a\":1}"; // when - final javax.json.stream.JsonParser parser = JsonObjects.createParser(new java.io.StringReader(json)); + final jakarta.json.stream.JsonParser parser = JsonObjects.createParser(new java.io.StringReader(json)); boolean sawKey = false; boolean sawValue = false; while (parser.hasNext()) { - final javax.json.stream.JsonParser.Event event = parser.next(); - if (event == javax.json.stream.JsonParser.Event.KEY_NAME) { + final jakarta.json.stream.JsonParser.Event event = parser.next(); + if (event == jakarta.json.stream.JsonParser.Event.KEY_NAME) { sawKey = true; } - if (event == javax.json.stream.JsonParser.Event.VALUE_NUMBER) { + if (event == jakarta.json.stream.JsonParser.Event.VALUE_NUMBER) { sawValue = true; } } @@ -445,15 +445,15 @@ public void shouldCreateParserFromInputStream() { final java.io.InputStream in = new java.io.ByteArrayInputStream(json.getBytes(java.nio.charset.StandardCharsets.UTF_8)); // when - final javax.json.stream.JsonParser parser = JsonObjects.createParser(in); + final jakarta.json.stream.JsonParser parser = JsonObjects.createParser(in); boolean sawKey = false; boolean sawValue = false; while (parser.hasNext()) { - final javax.json.stream.JsonParser.Event event = parser.next(); - if (event == javax.json.stream.JsonParser.Event.KEY_NAME) { + final jakarta.json.stream.JsonParser.Event event = parser.next(); + if (event == jakarta.json.stream.JsonParser.Event.KEY_NAME) { sawKey = true; } - if (event == javax.json.stream.JsonParser.Event.VALUE_NUMBER) { + if (event == jakarta.json.stream.JsonParser.Event.VALUE_NUMBER) { sawValue = true; } } @@ -469,13 +469,13 @@ public void shouldCreateGeneratorToWriter() { final java.io.StringWriter writer = new java.io.StringWriter(); // when - final javax.json.stream.JsonGenerator generator = JsonObjects.createGenerator(writer); + final jakarta.json.stream.JsonGenerator generator = JsonObjects.createGenerator(writer); generator.writeStartObject().write("a", 1).writeEnd(); generator.close(); // then final String json = writer.toString(); - final javax.json.JsonObject obj = JsonObjects.createReader(new java.io.StringReader(json)).readObject(); + final jakarta.json.JsonObject obj = JsonObjects.createReader(new java.io.StringReader(json)).readObject(); assertThat(obj.getInt("a"), equalTo(1)); } @@ -485,58 +485,107 @@ public void shouldCreateGeneratorToOutputStream() { final java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream(); // when - final javax.json.stream.JsonGenerator generator = JsonObjects.createGenerator(out); + final jakarta.json.stream.JsonGenerator generator = JsonObjects.createGenerator(out); generator.writeStartObject().write("b", 2).writeEnd(); generator.close(); // then final String json = new String(out.toByteArray(), java.nio.charset.StandardCharsets.UTF_8); - final javax.json.JsonObject obj = JsonObjects.createReader(new java.io.StringReader(json)).readObject(); + final jakarta.json.JsonObject obj = JsonObjects.createReader(new java.io.StringReader(json)).readObject(); assertThat(obj.getInt("b"), equalTo(2)); } @Test public void shouldCreateWriterAndReaderUsingWriter() { // given - final javax.json.JsonObject source = JsonObjects.createObjectBuilder().add("x", "y").build(); + final jakarta.json.JsonObject source = JsonObjects.createObjectBuilder().add("x", "y").build(); // when final java.io.StringWriter stringWriter = new java.io.StringWriter(); - try (final javax.json.JsonWriter jsonWriter = JsonObjects.createWriter(stringWriter)) { + try (final jakarta.json.JsonWriter jsonWriter = JsonObjects.createWriter(stringWriter)) { jsonWriter.write(source); } // then final String json = stringWriter.toString(); - final javax.json.JsonObject readBack = JsonObjects.createReader(new java.io.StringReader(json)).readObject(); + final jakarta.json.JsonObject readBack = JsonObjects.createReader(new java.io.StringReader(json)).readObject(); assertThat(readBack.getString("x"), equalTo("y")); } @Test public void shouldCreateWriterAndReaderUsingOutputStream() { // given - final javax.json.JsonObject source = JsonObjects.createObjectBuilder().add("p", true).build(); + final jakarta.json.JsonObject source = JsonObjects.createObjectBuilder().add("p", true).build(); // when final java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream(); - try (final javax.json.JsonWriter jsonWriter = JsonObjects.createWriter(out)) { + try (final jakarta.json.JsonWriter jsonWriter = JsonObjects.createWriter(out)) { jsonWriter.write(source); } // then final byte[] bytes = out.toByteArray(); - final javax.json.JsonObject readBack = JsonObjects.createReader(new java.io.ByteArrayInputStream(bytes)).readObject(); + final jakarta.json.JsonObject readBack = JsonObjects.createReader(new java.io.ByteArrayInputStream(bytes)).readObject(); assertThat(readBack.getBoolean("p"), is(true)); } @Test public void shouldCreateArrayBuilder() { // when - final javax.json.JsonArray array = JsonObjects.createArrayBuilder().add("v1").add("v2").build(); + final jakarta.json.JsonArray array = JsonObjects.createArrayBuilder().add("v1").add("v2").build(); // then assertThat(array.size(), equalTo(2)); assertThat(array.getString(0), equalTo("v1")); assertThat(array.getString(1), equalTo("v2")); } + + @Test + public void shouldThrowExceptionForEmptyFieldName() { + final JsonObject object = jsonBuilderFactory.createObjectBuilder() + .add("name", "test") + .build(); + assertThrows(IllegalArgumentException.class, () -> getString(object, "")); + } + + @Test + public void shouldReturnEmptyForNestedFieldWhenIntermediateObjectNotFound() { + final JsonObject object = jsonBuilderFactory.createObjectBuilder() + .add("other", "value") + .build(); + + final Optional result = getString(object, "missing", "child"); + + assertThat(result.isPresent(), is(false)); + } + + @Test + public void shouldReturnEmptyListForGetUUIDsWhenFieldNotFound() { + final JsonObject object = jsonBuilderFactory.createObjectBuilder() + .build(); + + final List result = getUUIDs(object, "missing"); + + assertThat(result, equalTo(java.util.Collections.emptyList())); + } + + @Test + public void shouldReturnEmptyOptionalForGetListWhenFieldNotFound() { + final JsonObject object = jsonBuilderFactory.createObjectBuilder() + .build(); + + final Optional> result = getList(object, JsonString.class, "missing"); + + assertThat(result.isPresent(), is(false)); + } + + @Test + public void shouldReturnEmptyOptionalForGetListWithConverterWhenFieldNotFound() { + final JsonObject object = jsonBuilderFactory.createObjectBuilder() + .build(); + + final Optional> result = getList(object, JsonString.class, JsonString::getString, "missing"); + + assertThat(result.isPresent(), is(false)); + } } diff --git a/generator-maven-plugin/files-for-testing-io/pom.xml b/generator-maven-plugin/files-for-testing-io/pom.xml index 369911ca8..e5f522321 100644 --- a/generator-maven-plugin/files-for-testing-io/pom.xml +++ b/generator-maven-plugin/files-for-testing-io/pom.xml @@ -5,7 +5,7 @@ generator-maven-plugin uk.gov.justice.maven.generator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/generator-maven-plugin/generator-core/pom.xml b/generator-maven-plugin/generator-core/pom.xml index f0aa6bf4a..af42efbd0 100644 --- a/generator-maven-plugin/generator-core/pom.xml +++ b/generator-maven-plugin/generator-core/pom.xml @@ -5,7 +5,7 @@ generator-maven-plugin uk.gov.justice.maven.generator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -27,5 +27,9 @@ + + javax.xml.bind + jaxb-api + diff --git a/generator-maven-plugin/generator-io-utils/pom.xml b/generator-maven-plugin/generator-io-utils/pom.xml index 3c02a3d7c..8b52757e6 100644 --- a/generator-maven-plugin/generator-io-utils/pom.xml +++ b/generator-maven-plugin/generator-io-utils/pom.xml @@ -5,7 +5,7 @@ generator-maven-plugin uk.gov.justice.maven.generator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/generator-maven-plugin/generator-maven-test-utils/pom.xml b/generator-maven-plugin/generator-maven-test-utils/pom.xml index 1707925c2..b342c49ef 100644 --- a/generator-maven-plugin/generator-maven-test-utils/pom.xml +++ b/generator-maven-plugin/generator-maven-test-utils/pom.xml @@ -5,7 +5,7 @@ generator-maven-plugin uk.gov.justice.maven.generator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/generator-maven-plugin/generator-plugin-it/pom.xml b/generator-maven-plugin/generator-plugin-it/pom.xml index 80cbf60bf..379109682 100644 --- a/generator-maven-plugin/generator-plugin-it/pom.xml +++ b/generator-maven-plugin/generator-plugin-it/pom.xml @@ -6,7 +6,7 @@ uk.gov.justice.maven.generator generator-maven-plugin - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -147,10 +147,9 @@ ${project.version} - javax.xml.bind - jaxb-api - - 2.3.1 + jakarta.xml.bind + jakarta.xml.bind-api + ${jakarta.xml.bind-api.version} @@ -189,14 +188,20 @@ test - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api test - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api test + + + jakarta.activation + jakarta.activation-api + + diff --git a/generator-maven-plugin/generator-plugin/pom.xml b/generator-maven-plugin/generator-plugin/pom.xml index 8ca2c0ff4..f971e0ddb 100644 --- a/generator-maven-plugin/generator-plugin/pom.xml +++ b/generator-maven-plugin/generator-plugin/pom.xml @@ -6,7 +6,7 @@ uk.gov.justice.maven.generator generator-maven-plugin - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT generator-plugin @@ -67,21 +67,25 @@ org.apache.maven maven-plugin-api + provided org.apache.maven maven-compat + provided org.apache.maven maven-core + provided org.apache.maven maven-model + provided @@ -89,6 +93,11 @@ org.eclipse.sisu.plexus + + org.apache.commons + commons-lang3 + + org.apache.maven maven-aether-provider @@ -140,7 +149,7 @@ org.glassfish - javax.json + jakarta.json test @@ -157,8 +166,8 @@ test - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api test diff --git a/generator-maven-plugin/generator-plugin/src/test/resources/includes-excludes-external/pom.xml b/generator-maven-plugin/generator-plugin/src/test/resources/includes-excludes-external/pom.xml index 9e2ab8dea..a7ed63dfe 100644 --- a/generator-maven-plugin/generator-plugin/src/test/resources/includes-excludes-external/pom.xml +++ b/generator-maven-plugin/generator-plugin/src/test/resources/includes-excludes-external/pom.xml @@ -22,6 +22,8 @@ **/*external-ignore.raml + **/*external-3.raml + **/*external-4.raml diff --git a/generator-maven-plugin/generator-raml-parser/pom.xml b/generator-maven-plugin/generator-raml-parser/pom.xml index 69556dce2..8e8e37bfe 100644 --- a/generator-maven-plugin/generator-raml-parser/pom.xml +++ b/generator-maven-plugin/generator-raml-parser/pom.xml @@ -7,15 +7,15 @@ generator-maven-plugin uk.gov.justice.maven.generator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT generator-raml-parser - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided @@ -72,13 +72,17 @@ org.glassfish - javax.json + jakarta.json + test + + + jakarta.xml.bind + jakarta.xml.bind-api test javax.xml.bind jaxb-api - test diff --git a/generator-maven-plugin/json-generator-for-testing-plugin/pom.xml b/generator-maven-plugin/json-generator-for-testing-plugin/pom.xml index 7519b4015..0e10a5cd8 100644 --- a/generator-maven-plugin/json-generator-for-testing-plugin/pom.xml +++ b/generator-maven-plugin/json-generator-for-testing-plugin/pom.xml @@ -5,7 +5,7 @@ generator-maven-plugin uk.gov.justice.maven.generator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 json-generator-for-testing-plugin @@ -17,13 +17,13 @@ ${project.version} - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided org.glassfish - javax.json + jakarta.json diff --git a/generator-maven-plugin/json-generator-for-testing-plugin/src/test/java/uk/gov/justice/maven/generator/io/files/parser/json/test/JsonTitleAppendingGenerator.java b/generator-maven-plugin/json-generator-for-testing-plugin/src/test/java/uk/gov/justice/maven/generator/io/files/parser/json/test/JsonTitleAppendingGenerator.java index c61d71d44..f8fe7a7be 100644 --- a/generator-maven-plugin/json-generator-for-testing-plugin/src/test/java/uk/gov/justice/maven/generator/io/files/parser/json/test/JsonTitleAppendingGenerator.java +++ b/generator-maven-plugin/json-generator-for-testing-plugin/src/test/java/uk/gov/justice/maven/generator/io/files/parser/json/test/JsonTitleAppendingGenerator.java @@ -12,7 +12,7 @@ import java.nio.file.Files; import java.nio.file.Path; -import javax.json.JsonObject; +import jakarta.json.JsonObject; /** * Generator for testing - JSON titles are appended to a text file. diff --git a/generator-maven-plugin/json-generator-for-testing-plugin/src/test/java/uk/gov/justice/maven/generator/io/files/parser/json/test/JsonTitleAppendingGeneratorFactory.java b/generator-maven-plugin/json-generator-for-testing-plugin/src/test/java/uk/gov/justice/maven/generator/io/files/parser/json/test/JsonTitleAppendingGeneratorFactory.java index 13c870d4c..cb4d93117 100644 --- a/generator-maven-plugin/json-generator-for-testing-plugin/src/test/java/uk/gov/justice/maven/generator/io/files/parser/json/test/JsonTitleAppendingGeneratorFactory.java +++ b/generator-maven-plugin/json-generator-for-testing-plugin/src/test/java/uk/gov/justice/maven/generator/io/files/parser/json/test/JsonTitleAppendingGeneratorFactory.java @@ -3,7 +3,7 @@ import uk.gov.justice.maven.generator.io.files.parser.core.Generator; import uk.gov.justice.maven.generator.io.files.parser.core.GeneratorFactory; -import javax.json.JsonObject; +import jakarta.json.JsonObject; public class JsonTitleAppendingGeneratorFactory implements GeneratorFactory { diff --git a/generator-maven-plugin/parser-common/pom.xml b/generator-maven-plugin/parser-common/pom.xml index 11a918ede..ed0d0e2da 100644 --- a/generator-maven-plugin/parser-common/pom.xml +++ b/generator-maven-plugin/parser-common/pom.xml @@ -5,7 +5,7 @@ generator-maven-plugin uk.gov.justice.maven.generator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/generator-maven-plugin/pom.xml b/generator-maven-plugin/pom.xml index 6e7537bdd..cff8245a6 100644 --- a/generator-maven-plugin/pom.xml +++ b/generator-maven-plugin/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.maven.generator diff --git a/generator-maven-plugin/raml-generator-for-testing-plugin/pom.xml b/generator-maven-plugin/raml-generator-for-testing-plugin/pom.xml index bbdfb616e..23388654c 100644 --- a/generator-maven-plugin/raml-generator-for-testing-plugin/pom.xml +++ b/generator-maven-plugin/raml-generator-for-testing-plugin/pom.xml @@ -5,7 +5,7 @@ generator-maven-plugin uk.gov.justice.maven.generator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/generator-maven-plugin/schema-parser/pom.xml b/generator-maven-plugin/schema-parser/pom.xml index e6612d9ad..f98412e85 100644 --- a/generator-maven-plugin/schema-parser/pom.xml +++ b/generator-maven-plugin/schema-parser/pom.xml @@ -7,7 +7,7 @@ generator-maven-plugin uk.gov.justice.maven.generator - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT schema-parser @@ -15,8 +15,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided @@ -41,12 +41,12 @@ org.glassfish - javax.json + jakarta.json test - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api test diff --git a/generator-maven-plugin/schema-parser/src/main/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParser.java b/generator-maven-plugin/schema-parser/src/main/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParser.java index a5b099b37..6d5a458a9 100644 --- a/generator-maven-plugin/schema-parser/src/main/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParser.java +++ b/generator-maven-plugin/schema-parser/src/main/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParser.java @@ -8,10 +8,10 @@ import java.util.Collection; import java.util.stream.Collectors; -import javax.json.Json; -import javax.json.JsonObject; -import javax.json.JsonReader; -import javax.json.JsonReaderFactory; +import jakarta.json.Json; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; +import jakarta.json.JsonReaderFactory; public class JsonSchemaFileParser implements FileParser { diff --git a/generator-maven-plugin/schema-parser/src/main/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserFactory.java b/generator-maven-plugin/schema-parser/src/main/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserFactory.java index a0c36e29e..7758e9585 100644 --- a/generator-maven-plugin/schema-parser/src/main/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserFactory.java +++ b/generator-maven-plugin/schema-parser/src/main/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserFactory.java @@ -1,6 +1,6 @@ package uk.gov.justice.maven.generator.io.files.parser; -import javax.json.JsonObject; +import jakarta.json.JsonObject; public class JsonSchemaFileParserFactory implements FileParserFactory { diff --git a/generator-maven-plugin/schema-parser/src/test/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserFactoryTest.java b/generator-maven-plugin/schema-parser/src/test/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserFactoryTest.java index 09dfae9fa..6fd2f9abc 100644 --- a/generator-maven-plugin/schema-parser/src/test/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserFactoryTest.java +++ b/generator-maven-plugin/schema-parser/src/test/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserFactoryTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import javax.json.JsonObject; +import jakarta.json.JsonObject; import org.junit.jupiter.api.Test; diff --git a/generator-maven-plugin/schema-parser/src/test/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserTest.java b/generator-maven-plugin/schema-parser/src/test/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserTest.java index d7ea1c7c1..72ac1393e 100644 --- a/generator-maven-plugin/schema-parser/src/test/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserTest.java +++ b/generator-maven-plugin/schema-parser/src/test/java/uk/gov/justice/maven/generator/io/files/parser/JsonSchemaFileParserTest.java @@ -17,8 +17,8 @@ import java.util.Collection; import java.util.List; -import javax.json.JsonObject; -import javax.json.JsonValue; +import jakarta.json.JsonObject; +import jakarta.json.JsonValue; import org.junit.jupiter.api.Test; diff --git a/job-manager/example/pom.xml b/job-manager/example/pom.xml index 05663beb2..c3c10354e 100644 --- a/job-manager/example/pom.xml +++ b/job-manager/example/pom.xml @@ -5,7 +5,7 @@ job-manager uk.gov.justice.services - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -23,8 +23,8 @@ ${project.version} - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided @@ -86,7 +86,7 @@ org.apache.xbean - xbean-asm7-shaded + xbean-asm9-shaded test diff --git a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/BakeryService.java b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/BakeryService.java index 253e68752..f0d153c87 100644 --- a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/BakeryService.java +++ b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/BakeryService.java @@ -8,10 +8,10 @@ import uk.gov.moj.cpp.jobstore.api.task.ExecutionStatus; import uk.gov.moj.cpp.task.execution.DefaultExecutionService; -import javax.inject.Inject; -import javax.transaction.Status; -import javax.transaction.SystemException; -import javax.transaction.UserTransaction; +import jakarta.inject.Inject; +import jakarta.transaction.Status; +import jakarta.transaction.SystemException; +import jakarta.transaction.UserTransaction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/BakeCakeTask.java b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/BakeCakeTask.java index 36ff49356..d4de15aa7 100644 --- a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/BakeCakeTask.java +++ b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/BakeCakeTask.java @@ -16,8 +16,8 @@ import java.util.List; import java.util.Optional; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.slf4j.Logger; diff --git a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/FillCakeTinTask.java b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/FillCakeTinTask.java index 6b019c32f..8234388f9 100644 --- a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/FillCakeTinTask.java +++ b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/FillCakeTinTask.java @@ -7,8 +7,8 @@ import uk.gov.moj.cpp.jobstore.api.task.ExecutableTask; import uk.gov.moj.cpp.jobstore.api.task.ExecutionInfo; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.slf4j.Logger; diff --git a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/GetIngredientsTask.java b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/GetIngredientsTask.java index 84111fae0..ef76a083c 100644 --- a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/GetIngredientsTask.java +++ b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/GetIngredientsTask.java @@ -6,8 +6,8 @@ import uk.gov.moj.cpp.jobstore.api.task.ExecutableTask; import uk.gov.moj.cpp.jobstore.api.task.ExecutionInfo; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.slf4j.Logger; diff --git a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/GetUtensilsTask.java b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/GetUtensilsTask.java index cc83a38d0..50804ee83 100644 --- a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/GetUtensilsTask.java +++ b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/GetUtensilsTask.java @@ -6,8 +6,8 @@ import uk.gov.moj.cpp.jobstore.api.task.ExecutableTask; import uk.gov.moj.cpp.jobstore.api.task.ExecutionInfo; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.slf4j.Logger; diff --git a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/JobUtil.java b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/JobUtil.java index 38eceaa2b..71d55e1f2 100644 --- a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/JobUtil.java +++ b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/JobUtil.java @@ -14,7 +14,7 @@ import java.time.ZonedDateTime; -import javax.inject.Inject; +import jakarta.inject.Inject; public class JobUtil { diff --git a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/MixIngredientsTask.java b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/MixIngredientsTask.java index e0969233b..5810ab7d1 100644 --- a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/MixIngredientsTask.java +++ b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/MixIngredientsTask.java @@ -6,8 +6,8 @@ import uk.gov.moj.cpp.jobstore.api.task.ExecutableTask; import uk.gov.moj.cpp.jobstore.api.task.ExecutionInfo; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.slf4j.Logger; diff --git a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/SliceAndEatCakeTask.java b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/SliceAndEatCakeTask.java index 99caf4d0f..219154be4 100644 --- a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/SliceAndEatCakeTask.java +++ b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/SliceAndEatCakeTask.java @@ -6,8 +6,8 @@ import uk.gov.moj.cpp.jobstore.api.task.ExecutableTask; import uk.gov.moj.cpp.jobstore.api.task.ExecutionInfo; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.slf4j.Logger; diff --git a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/SwitchOvenOnTask.java b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/SwitchOvenOnTask.java index 70707cf90..01e1fecf6 100644 --- a/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/SwitchOvenOnTask.java +++ b/job-manager/example/src/main/java/uk/gov/moj/cpp/jobmanager/example/task/SwitchOvenOnTask.java @@ -6,8 +6,8 @@ import uk.gov.moj.cpp.jobstore.api.task.ExecutableTask; import uk.gov.moj.cpp.jobstore.api.task.ExecutionInfo; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.slf4j.Logger; diff --git a/job-manager/example/src/test/java/uk/gov/moj/cpp/jobmanager/example/BakeryServiceIT.java b/job-manager/example/src/test/java/uk/gov/moj/cpp/jobmanager/example/BakeryServiceIT.java index 2611387ec..e59d7ce9c 100644 --- a/job-manager/example/src/test/java/uk/gov/moj/cpp/jobmanager/example/BakeryServiceIT.java +++ b/job-manager/example/src/test/java/uk/gov/moj/cpp/jobmanager/example/BakeryServiceIT.java @@ -35,8 +35,8 @@ import java.util.Properties; -import javax.annotation.Resource; -import javax.inject.Inject; +import jakarta.annotation.Resource; +import jakarta.inject.Inject; import javax.naming.InitialContext; import javax.sql.DataSource; diff --git a/job-manager/example/src/test/java/uk/gov/moj/cpp/jobmanager/example/util/PropertiesFileValueProducer.java b/job-manager/example/src/test/java/uk/gov/moj/cpp/jobmanager/example/util/PropertiesFileValueProducer.java index b2c0fa602..f9c7fddf4 100644 --- a/job-manager/example/src/test/java/uk/gov/moj/cpp/jobmanager/example/util/PropertiesFileValueProducer.java +++ b/job-manager/example/src/test/java/uk/gov/moj/cpp/jobmanager/example/util/PropertiesFileValueProducer.java @@ -6,8 +6,8 @@ import java.io.InputStream; import java.util.Properties; -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.inject.Produces; +import jakarta.enterprise.inject.spi.InjectionPoint; import javax.naming.NamingException; import org.slf4j.Logger; diff --git a/job-manager/job-executor/pom.xml b/job-manager/job-executor/pom.xml index b1cfda43c..a4e95b570 100644 --- a/job-manager/job-executor/pom.xml +++ b/job-manager/job-executor/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.services job-manager - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -17,8 +17,8 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/DefaultExecutionService.java b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/DefaultExecutionService.java index b898f7721..463d4c9a3 100644 --- a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/DefaultExecutionService.java +++ b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/DefaultExecutionService.java @@ -9,8 +9,8 @@ import uk.gov.moj.cpp.jobstore.service.JobService; import uk.gov.moj.cpp.task.extension.TaskRegistry; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; @ApplicationScoped public class DefaultExecutionService implements ExecutionService { diff --git a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/DefaultJobStoreSchedulerPrioritySelector.java b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/DefaultJobStoreSchedulerPrioritySelector.java index 165ec84d1..657061085 100644 --- a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/DefaultJobStoreSchedulerPrioritySelector.java +++ b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/DefaultJobStoreSchedulerPrioritySelector.java @@ -9,8 +9,8 @@ import java.util.List; -import javax.enterprise.inject.Default; -import javax.inject.Inject; +import jakarta.enterprise.inject.Default; +import jakarta.inject.Inject; @Default public class DefaultJobStoreSchedulerPrioritySelector implements JobStoreSchedulerPrioritySelector { diff --git a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/JobExecutor.java b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/JobExecutor.java index 3173b05b3..bb2be502c 100644 --- a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/JobExecutor.java +++ b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/JobExecutor.java @@ -15,12 +15,12 @@ import java.util.List; import java.util.Optional; -import javax.transaction.HeuristicMixedException; -import javax.transaction.HeuristicRollbackException; -import javax.transaction.NotSupportedException; -import javax.transaction.RollbackException; -import javax.transaction.SystemException; -import javax.transaction.UserTransaction; +import jakarta.transaction.HeuristicMixedException; +import jakarta.transaction.HeuristicRollbackException; +import jakarta.transaction.NotSupportedException; +import jakarta.transaction.RollbackException; +import jakarta.transaction.SystemException; +import jakarta.transaction.UserTransaction; import org.slf4j.Logger; diff --git a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/JobScheduler.java b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/JobScheduler.java index 7970a39cc..1f7cfde65 100644 --- a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/JobScheduler.java +++ b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/execution/JobScheduler.java @@ -15,25 +15,25 @@ import java.util.UUID; import java.util.stream.Stream; -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import javax.ejb.Singleton; -import javax.ejb.Startup; -import javax.ejb.Timeout; -import javax.ejb.Timer; -import javax.ejb.TimerConfig; -import javax.ejb.TimerService; -import javax.ejb.TransactionManagement; -import javax.ejb.TransactionManagementType; -import javax.enterprise.concurrent.ManagedExecutorService; -import javax.inject.Inject; -import javax.transaction.HeuristicMixedException; -import javax.transaction.HeuristicRollbackException; -import javax.transaction.NotSupportedException; -import javax.transaction.RollbackException; -import javax.transaction.Status; -import javax.transaction.SystemException; -import javax.transaction.UserTransaction; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.Resource; +import jakarta.ejb.Singleton; +import jakarta.ejb.Startup; +import jakarta.ejb.Timeout; +import jakarta.ejb.Timer; +import jakarta.ejb.TimerConfig; +import jakarta.ejb.TimerService; +import jakarta.ejb.TransactionManagement; +import jakarta.ejb.TransactionManagementType; +import jakarta.enterprise.concurrent.ManagedExecutorService; +import jakarta.inject.Inject; +import jakarta.transaction.HeuristicMixedException; +import jakarta.transaction.HeuristicRollbackException; +import jakarta.transaction.NotSupportedException; +import jakarta.transaction.RollbackException; +import jakarta.transaction.Status; +import jakarta.transaction.SystemException; +import jakarta.transaction.UserTransaction; import org.slf4j.Logger; diff --git a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/extension/TaskRegistry.java b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/extension/TaskRegistry.java index 207067427..c738d30b1 100644 --- a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/extension/TaskRegistry.java +++ b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/extension/TaskRegistry.java @@ -8,10 +8,10 @@ import java.util.Map; import java.util.Optional; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.event.Observes; -import javax.enterprise.inject.Instance; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.event.Observes; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; import org.slf4j.Logger; diff --git a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/extension/TaskScanner.java b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/extension/TaskScanner.java index bec8e2385..a2e3620ba 100644 --- a/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/extension/TaskScanner.java +++ b/job-manager/job-executor/src/main/java/uk/gov/moj/cpp/task/extension/TaskScanner.java @@ -7,12 +7,12 @@ import java.util.ArrayList; import java.util.List; -import javax.enterprise.event.Observes; -import javax.enterprise.inject.spi.AfterDeploymentValidation; -import javax.enterprise.inject.spi.AnnotatedType; -import javax.enterprise.inject.spi.BeanManager; -import javax.enterprise.inject.spi.Extension; -import javax.enterprise.inject.spi.ProcessAnnotatedType; +import jakarta.enterprise.event.Observes; +import jakarta.enterprise.inject.spi.AfterDeploymentValidation; +import jakarta.enterprise.inject.spi.AnnotatedType; +import jakarta.enterprise.inject.spi.BeanManager; +import jakarta.enterprise.inject.spi.Extension; +import jakarta.enterprise.inject.spi.ProcessAnnotatedType; public class TaskScanner implements Extension { @@ -29,6 +29,6 @@ void processAnnotatedType(@Observes final ProcessAnnotatedType pat) { @SuppressWarnings("unused") void afterDeploymentValidation(@Observes final AfterDeploymentValidation event, final BeanManager beanManager) { - events.forEach(beanManager::fireEvent); + events.forEach(e -> beanManager.getEvent().fire(e)); } } diff --git a/job-manager/job-executor/src/main/resources/META-INF/beans.xml b/job-manager/job-executor/src/main/resources/META-INF/beans.xml index ce2829b7f..750657d6f 100644 --- a/job-manager/job-executor/src/main/resources/META-INF/beans.xml +++ b/job-manager/job-executor/src/main/resources/META-INF/beans.xml @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/job-manager/job-executor/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/job-manager/job-executor/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension similarity index 100% rename from job-manager/job-executor/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension rename to job-manager/job-executor/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension diff --git a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/DefaultExecutionServiceTest.java b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/DefaultExecutionServiceTest.java index 8e807d718..7eb20164a 100644 --- a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/DefaultExecutionServiceTest.java +++ b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/DefaultExecutionServiceTest.java @@ -17,7 +17,7 @@ import java.time.ZonedDateTime; import java.util.UUID; -import javax.json.JsonObject; +import jakarta.json.JsonObject; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/JobExecutorTest.java b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/JobExecutorTest.java index 0b9b9895b..9e7755ff2 100644 --- a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/JobExecutorTest.java +++ b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/JobExecutorTest.java @@ -29,10 +29,10 @@ import java.util.Optional; import java.util.UUID; -import javax.json.JsonObject; -import javax.transaction.NotSupportedException; -import javax.transaction.SystemException; -import javax.transaction.UserTransaction; +import jakarta.json.JsonObject; +import jakarta.transaction.NotSupportedException; +import jakarta.transaction.SystemException; +import jakarta.transaction.UserTransaction; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/JobSchedulerTest.java b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/JobSchedulerTest.java index c418d6ca5..bac0bfbe5 100644 --- a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/JobSchedulerTest.java +++ b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/execution/JobSchedulerTest.java @@ -26,12 +26,12 @@ import java.util.UUID; import java.util.stream.Stream; -import javax.ejb.TimerConfig; -import javax.ejb.TimerService; -import javax.enterprise.concurrent.ManagedExecutorService; -import javax.transaction.NotSupportedException; -import javax.transaction.SystemException; -import javax.transaction.UserTransaction; +import jakarta.ejb.TimerConfig; +import jakarta.ejb.TimerService; +import jakarta.enterprise.concurrent.ManagedExecutorService; +import jakarta.transaction.NotSupportedException; +import jakarta.transaction.SystemException; +import jakarta.transaction.UserTransaction; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/extension/TaskRegistryTest.java b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/extension/TaskRegistryTest.java index b2996d0a7..944f183ba 100644 --- a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/extension/TaskRegistryTest.java +++ b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/extension/TaskRegistryTest.java @@ -11,7 +11,7 @@ import java.util.Iterator; import java.util.Optional; -import javax.enterprise.inject.Instance; +import jakarta.enterprise.inject.Instance; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/extension/TaskScannerTest.java b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/extension/TaskScannerTest.java index 0845d39db..959d4b3ed 100644 --- a/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/extension/TaskScannerTest.java +++ b/job-manager/job-executor/src/test/java/uk/gov/moj/cpp/task/extension/TaskScannerTest.java @@ -7,12 +7,14 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import uk.gov.moj.cpp.jobstore.api.annotation.Task; -import javax.enterprise.inject.spi.AnnotatedType; -import javax.enterprise.inject.spi.BeanManager; -import javax.enterprise.inject.spi.ProcessAnnotatedType; +import jakarta.enterprise.event.Event; +import jakarta.enterprise.inject.spi.AnnotatedType; +import jakarta.enterprise.inject.spi.BeanManager; +import jakarta.enterprise.inject.spi.ProcessAnnotatedType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -33,6 +35,9 @@ public class TaskScannerTest { @Mock private BeanManager beanManager; + @Mock + private Event event; + @InjectMocks private TaskScanner taskScanner; @@ -40,11 +45,12 @@ public class TaskScannerTest { public void shouldNotifyTaskFoundEvent() { doReturn(annotatedType).when(processAnnotatedType).getAnnotatedType(); doReturn(true).when(annotatedType).isAnnotationPresent(Task.class); + when(beanManager.getEvent()).thenReturn(event); taskScanner.processAnnotatedType(processAnnotatedType); taskScanner.afterDeploymentValidation(null, beanManager); final ArgumentCaptor captor = ArgumentCaptor.forClass(TaskFoundEvent.class); - verify(beanManager).fireEvent(captor.capture()); + verify(event).fire(captor.capture()); assertThat(captor.getValue(), instanceOf(TaskFoundEvent.class)); } @@ -56,6 +62,6 @@ public void shouldNotFireNotifyTaskFoundEventForNonNotifyTaskBeans() { taskScanner.processAnnotatedType(processAnnotatedType); taskScanner.afterDeploymentValidation(null, beanManager); - verify(beanManager, never()).fireEvent(any()); + verify(event, never()).fire(any()); } } \ No newline at end of file diff --git a/job-manager/job-manager-it/pom.xml b/job-manager/job-manager-it/pom.xml index 8a928a27c..36d88584f 100644 --- a/job-manager/job-manager-it/pom.xml +++ b/job-manager/job-manager-it/pom.xml @@ -5,7 +5,7 @@ job-manager uk.gov.justice.services - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -44,20 +44,18 @@ test - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api test org.apache.tomee openejb-core - ${openejb.version} test org.apache.tomee openejb-junit5 - ${openejb.version} test diff --git a/job-manager/job-manager-it/src/main/java/uk/gov/moj/cpp/jobmanager/it/util/OpenEjbJobJdbcRepository.java b/job-manager/job-manager-it/src/main/java/uk/gov/moj/cpp/jobmanager/it/util/OpenEjbJobJdbcRepository.java index fe7758b09..30955cd95 100644 --- a/job-manager/job-manager-it/src/main/java/uk/gov/moj/cpp/jobmanager/it/util/OpenEjbJobJdbcRepository.java +++ b/job-manager/job-manager-it/src/main/java/uk/gov/moj/cpp/jobmanager/it/util/OpenEjbJobJdbcRepository.java @@ -28,8 +28,8 @@ import java.util.UUID; import java.util.stream.Stream; -import javax.json.JsonObject; -import javax.json.JsonReader; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; import javax.sql.DataSource; public class OpenEjbJobJdbcRepository extends JobJdbcRepository { diff --git a/job-manager/job-manager-it/src/test/java/uk/gov/moj/cpp/jobmanager/it/JobSchedulerIT.java b/job-manager/job-manager-it/src/test/java/uk/gov/moj/cpp/jobmanager/it/JobSchedulerIT.java index d68b3e208..b2cc0ee54 100644 --- a/job-manager/job-manager-it/src/test/java/uk/gov/moj/cpp/jobmanager/it/JobSchedulerIT.java +++ b/job-manager/job-manager-it/src/test/java/uk/gov/moj/cpp/jobmanager/it/JobSchedulerIT.java @@ -45,16 +45,16 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Resource; -import javax.inject.Inject; +import jakarta.annotation.Resource; +import jakarta.inject.Inject; import javax.naming.InitialContext; import javax.sql.DataSource; -import javax.transaction.HeuristicMixedException; -import javax.transaction.HeuristicRollbackException; -import javax.transaction.NotSupportedException; -import javax.transaction.RollbackException; -import javax.transaction.SystemException; -import javax.transaction.UserTransaction; +import jakarta.transaction.HeuristicMixedException; +import jakarta.transaction.HeuristicRollbackException; +import jakarta.transaction.NotSupportedException; +import jakarta.transaction.RollbackException; +import jakarta.transaction.SystemException; +import jakarta.transaction.UserTransaction; import com.fasterxml.jackson.databind.ObjectMapper; import liquibase.Liquibase; diff --git a/job-manager/job-manager-it/src/test/java/uk/gov/moj/cpp/jobmanager/it/JobServiceIT.java b/job-manager/job-manager-it/src/test/java/uk/gov/moj/cpp/jobmanager/it/JobServiceIT.java index 3310d096a..74cc1d67b 100644 --- a/job-manager/job-manager-it/src/test/java/uk/gov/moj/cpp/jobmanager/it/JobServiceIT.java +++ b/job-manager/job-manager-it/src/test/java/uk/gov/moj/cpp/jobmanager/it/JobServiceIT.java @@ -43,16 +43,16 @@ import java.util.concurrent.CyclicBarrier; import java.util.stream.Stream; -import javax.annotation.Resource; -import javax.inject.Inject; +import jakarta.annotation.Resource; +import jakarta.inject.Inject; import javax.naming.InitialContext; import javax.sql.DataSource; -import javax.transaction.HeuristicMixedException; -import javax.transaction.HeuristicRollbackException; -import javax.transaction.NotSupportedException; -import javax.transaction.RollbackException; -import javax.transaction.SystemException; -import javax.transaction.UserTransaction; +import jakarta.transaction.HeuristicMixedException; +import jakarta.transaction.HeuristicRollbackException; +import jakarta.transaction.NotSupportedException; +import jakarta.transaction.RollbackException; +import jakarta.transaction.SystemException; +import jakarta.transaction.UserTransaction; import liquibase.Liquibase; import liquibase.database.jvm.JdbcConnection; diff --git a/job-manager/jobstore-api/pom.xml b/job-manager/jobstore-api/pom.xml index 554ce26ad..ec97440cc 100644 --- a/job-manager/jobstore-api/pom.xml +++ b/job-manager/jobstore-api/pom.xml @@ -5,15 +5,15 @@ uk.gov.justice.services job-manager - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 jobstore-api - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided @@ -43,7 +43,7 @@ org.glassfish - javax.json + jakarta.json test diff --git a/job-manager/jobstore-api/src/main/java/uk/gov/moj/cpp/jobstore/api/task/ExecutionInfo.java b/job-manager/jobstore-api/src/main/java/uk/gov/moj/cpp/jobstore/api/task/ExecutionInfo.java index fbc3ee9ec..a7ea3632d 100644 --- a/job-manager/jobstore-api/src/main/java/uk/gov/moj/cpp/jobstore/api/task/ExecutionInfo.java +++ b/job-manager/jobstore-api/src/main/java/uk/gov/moj/cpp/jobstore/api/task/ExecutionInfo.java @@ -5,7 +5,7 @@ import java.time.ZonedDateTime; -import javax.json.JsonObject; +import jakarta.json.JsonObject; public class ExecutionInfo { private final JsonObject jobData; diff --git a/job-manager/jobstore-api/src/main/resources/META-INF/beans.xml b/job-manager/jobstore-api/src/main/resources/META-INF/beans.xml index ce2829b7f..750657d6f 100644 --- a/job-manager/jobstore-api/src/main/resources/META-INF/beans.xml +++ b/job-manager/jobstore-api/src/main/resources/META-INF/beans.xml @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/job-manager/jobstore-api/src/test/java/uk/gov/moj/cpp/jobstore/api/task/ExecutionInfoTest.java b/job-manager/jobstore-api/src/test/java/uk/gov/moj/cpp/jobstore/api/task/ExecutionInfoTest.java index f0a5a558e..afa6c4b95 100644 --- a/job-manager/jobstore-api/src/test/java/uk/gov/moj/cpp/jobstore/api/task/ExecutionInfoTest.java +++ b/job-manager/jobstore-api/src/test/java/uk/gov/moj/cpp/jobstore/api/task/ExecutionInfoTest.java @@ -13,7 +13,7 @@ import java.time.ZonedDateTime; -import javax.json.JsonObject; +import jakarta.json.JsonObject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/job-manager/jobstore-liquibase/pom.xml b/job-manager/jobstore-liquibase/pom.xml index b3276a91f..b05fa4e86 100644 --- a/job-manager/jobstore-liquibase/pom.xml +++ b/job-manager/jobstore-liquibase/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.services job-manager - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT jobstore-liquibase diff --git a/job-manager/jobstore-persistence/pom.xml b/job-manager/jobstore-persistence/pom.xml index 88f447f19..4c6890acd 100644 --- a/job-manager/jobstore-persistence/pom.xml +++ b/job-manager/jobstore-persistence/pom.xml @@ -7,15 +7,15 @@ uk.gov.justice.services job-manager - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT jobstore-persistence - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided diff --git a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/Job.java b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/Job.java index b9dbfeb28..456c99d95 100644 --- a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/Job.java +++ b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/Job.java @@ -4,7 +4,7 @@ import java.util.Optional; import java.util.UUID; -import javax.json.JsonObject; +import jakarta.json.JsonObject; public class Job { diff --git a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobJdbcRepository.java b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobJdbcRepository.java index fdafceea2..f0afa17aa 100644 --- a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobJdbcRepository.java +++ b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobJdbcRepository.java @@ -22,10 +22,10 @@ import java.util.function.Function; import java.util.stream.Stream; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.json.JsonObject; -import javax.json.JsonReader; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; import javax.sql.DataSource; import org.slf4j.Logger; diff --git a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobRepository.java b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobRepository.java index 400c1bfe2..93567b557 100644 --- a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobRepository.java +++ b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobRepository.java @@ -4,7 +4,7 @@ import java.util.UUID; import java.util.stream.Stream; -import javax.json.JsonObject; +import jakarta.json.JsonObject; public interface JobRepository { void insertJob(final Job notificationJob); diff --git a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobStoreConfiguration.java b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobStoreConfiguration.java index 4ce20728d..dc929654f 100644 --- a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobStoreConfiguration.java +++ b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/persistence/JobStoreConfiguration.java @@ -5,8 +5,8 @@ import uk.gov.justice.services.common.configuration.Value; -import javax.annotation.Resource; -import javax.inject.Inject; +import jakarta.annotation.Resource; +import jakarta.inject.Inject; public class JobStoreConfiguration { diff --git a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/service/JobService.java b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/service/JobService.java index b410d388a..18cbf57bb 100644 --- a/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/service/JobService.java +++ b/job-manager/jobstore-persistence/src/main/java/uk/gov/moj/cpp/jobstore/service/JobService.java @@ -14,9 +14,9 @@ import java.util.UUID; import java.util.stream.Stream; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.json.JsonObject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.json.JsonObject; @ApplicationScoped public class JobService { diff --git a/job-manager/jobstore-persistence/src/main/resources/META-INF/beans.xml b/job-manager/jobstore-persistence/src/main/resources/META-INF/beans.xml index cc3f8d286..fdf4a957b 100644 --- a/job-manager/jobstore-persistence/src/main/resources/META-INF/beans.xml +++ b/job-manager/jobstore-persistence/src/main/resources/META-INF/beans.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/persistence/JobJdbcRepositoryTest.java b/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/persistence/JobJdbcRepositoryTest.java index 7da934b08..f3bbba401 100644 --- a/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/persistence/JobJdbcRepositoryTest.java +++ b/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/persistence/JobJdbcRepositoryTest.java @@ -36,7 +36,7 @@ import java.util.Optional; import java.util.UUID; -import javax.json.JsonObject; +import jakarta.json.JsonObject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/persistence/JobTest.java b/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/persistence/JobTest.java index ff00376d7..d48960234 100644 --- a/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/persistence/JobTest.java +++ b/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/persistence/JobTest.java @@ -11,7 +11,7 @@ import java.time.ZonedDateTime; -import javax.json.JsonObject; +import jakarta.json.JsonObject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/service/JobServiceTest.java b/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/service/JobServiceTest.java index 22199d081..18e9c346f 100644 --- a/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/service/JobServiceTest.java +++ b/job-manager/jobstore-persistence/src/test/java/uk/gov/moj/cpp/jobstore/service/JobServiceTest.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.UUID; -import javax.json.JsonObject; +import jakarta.json.JsonObject; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/job-manager/pom.xml b/job-manager/pom.xml index 3be9a91b1..2b0b9e899 100644 --- a/job-manager/pom.xml +++ b/job-manager/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.services @@ -33,7 +33,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${argLine} -Xmx64m + @{argLine} -Xmx64m -Dnet.bytebuddy.experimental=true diff --git a/json-schema-catalog/catalog-core/pom.xml b/json-schema-catalog/catalog-core/pom.xml index 9951e4570..56b5dece9 100644 --- a/json-schema-catalog/catalog-core/pom.xml +++ b/json-schema-catalog/catalog-core/pom.xml @@ -5,7 +5,7 @@ json-schema-catalog uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,13 +13,13 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided org.glassfish - javax.json + jakarta.json uk.gov.justice.schema diff --git a/json-schema-catalog/catalog-core/src/main/java/uk/gov/justice/schema/catalog/CatalogUpdater.java b/json-schema-catalog/catalog-core/src/main/java/uk/gov/justice/schema/catalog/CatalogUpdater.java index ecca14bfc..3c34cf9f9 100644 --- a/json-schema-catalog/catalog-core/src/main/java/uk/gov/justice/schema/catalog/CatalogUpdater.java +++ b/json-schema-catalog/catalog-core/src/main/java/uk/gov/justice/schema/catalog/CatalogUpdater.java @@ -13,9 +13,9 @@ import java.util.Collection; import java.util.Map; -import javax.json.JsonObject; -import javax.json.JsonReader; -import javax.json.stream.JsonParsingException; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; +import jakarta.json.stream.JsonParsingException; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; diff --git a/json-schema-catalog/catalog-core/src/test/java/uk/gov/justice/schema/catalog/util/CatalogUpdaterTest.java b/json-schema-catalog/catalog-core/src/test/java/uk/gov/justice/schema/catalog/util/CatalogUpdaterTest.java index a89a6fab6..70c8582d2 100644 --- a/json-schema-catalog/catalog-core/src/test/java/uk/gov/justice/schema/catalog/util/CatalogUpdaterTest.java +++ b/json-schema-catalog/catalog-core/src/test/java/uk/gov/justice/schema/catalog/util/CatalogUpdaterTest.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.Map; -import javax.json.stream.JsonParsingException; +import jakarta.json.stream.JsonParsingException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/json-schema-catalog/catalog-domain/pom.xml b/json-schema-catalog/catalog-domain/pom.xml index 73c306964..a26f8da46 100644 --- a/json-schema-catalog/catalog-domain/pom.xml +++ b/json-schema-catalog/catalog-domain/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.schema json-schema-catalog - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/json-schema-catalog/catalog-generation-plugin-it/pom.xml b/json-schema-catalog/catalog-generation-plugin-it/pom.xml index 3787e59c2..d5fcaa060 100644 --- a/json-schema-catalog/catalog-generation-plugin-it/pom.xml +++ b/json-schema-catalog/catalog-generation-plugin-it/pom.xml @@ -5,7 +5,7 @@ json-schema-catalog uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -53,6 +53,11 @@ catalog-generation ${project.version} + + com.fasterxml.jackson.datatype + jackson-datatype-jakarta-jsonp + ${jackson-datatype-jakarta-jsonp.version} + diff --git a/json-schema-catalog/catalog-generation-plugin/pom.xml b/json-schema-catalog/catalog-generation-plugin/pom.xml index 66d3217ca..97cfe19ce 100644 --- a/json-schema-catalog/catalog-generation-plugin/pom.xml +++ b/json-schema-catalog/catalog-generation-plugin/pom.xml @@ -5,7 +5,7 @@ json-schema-catalog uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -49,6 +49,16 @@ + + org.apache.maven + maven-plugin-api + provided + + + org.apache.maven + maven-core + provided + diff --git a/json-schema-catalog/catalog-generation/pom.xml b/json-schema-catalog/catalog-generation/pom.xml index 8e29f3182..ba6b73e2c 100644 --- a/json-schema-catalog/catalog-generation/pom.xml +++ b/json-schema-catalog/catalog-generation/pom.xml @@ -5,7 +5,7 @@ json-schema-catalog uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/json-schema-catalog/catalog-generation/src/main/java/uk/gov/justice/schema/catalog/generation/SchemaIdParser.java b/json-schema-catalog/catalog-generation/src/main/java/uk/gov/justice/schema/catalog/generation/SchemaIdParser.java index c5ad5b62c..997ed13c0 100644 --- a/json-schema-catalog/catalog-generation/src/main/java/uk/gov/justice/schema/catalog/generation/SchemaIdParser.java +++ b/json-schema-catalog/catalog-generation/src/main/java/uk/gov/justice/schema/catalog/generation/SchemaIdParser.java @@ -14,9 +14,9 @@ import java.net.URL; import java.util.Optional; -import javax.json.JsonObject; -import javax.json.JsonReader; -import javax.json.stream.JsonParsingException; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; +import jakarta.json.stream.JsonParsingException; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; diff --git a/json-schema-catalog/catalog-generation/src/test/java/uk/gov/justice/schema/catalog/generation/SchemaIdParserTest.java b/json-schema-catalog/catalog-generation/src/test/java/uk/gov/justice/schema/catalog/generation/SchemaIdParserTest.java index f628dfb48..88eb6d73a 100644 --- a/json-schema-catalog/catalog-generation/src/test/java/uk/gov/justice/schema/catalog/generation/SchemaIdParserTest.java +++ b/json-schema-catalog/catalog-generation/src/test/java/uk/gov/justice/schema/catalog/generation/SchemaIdParserTest.java @@ -17,7 +17,7 @@ import java.net.URL; import java.util.Optional; -import javax.json.stream.JsonParsingException; +import jakarta.json.stream.JsonParsingException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/json-schema-catalog/catalog-integration-test/pom.xml b/json-schema-catalog/catalog-integration-test/pom.xml index 5a5182625..80859fcfa 100644 --- a/json-schema-catalog/catalog-integration-test/pom.xml +++ b/json-schema-catalog/catalog-integration-test/pom.xml @@ -5,7 +5,7 @@ json-schema-catalog uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/json-schema-catalog/catalog-test-utils/pom.xml b/json-schema-catalog/catalog-test-utils/pom.xml index 711e4b7a2..ab12b74c5 100644 --- a/json-schema-catalog/catalog-test-utils/pom.xml +++ b/json-schema-catalog/catalog-test-utils/pom.xml @@ -5,7 +5,7 @@ json-schema-catalog uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/json-schema-catalog/pom.xml b/json-schema-catalog/pom.xml index 638062519..6c789e7a7 100644 --- a/json-schema-catalog/pom.xml +++ b/json-schema-catalog/pom.xml @@ -7,12 +7,12 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.schema json-schema-catalog - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT pom @@ -34,7 +34,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${argLine} -Xmx64m + @{argLine} -Xmx64m -Dnet.bytebuddy.experimental=true diff --git a/json-schema-catalog/schema-example-context/example-integration-test/pom.xml b/json-schema-catalog/schema-example-context/example-integration-test/pom.xml index 784313b05..655f13fb6 100644 --- a/json-schema-catalog/schema-example-context/example-integration-test/pom.xml +++ b/json-schema-catalog/schema-example-context/example-integration-test/pom.xml @@ -5,7 +5,7 @@ schema-example-context uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/json-schema-catalog/schema-example-context/pom.xml b/json-schema-catalog/schema-example-context/pom.xml index 63d9677e9..7f59c7c9e 100644 --- a/json-schema-catalog/schema-example-context/pom.xml +++ b/json-schema-catalog/schema-example-context/pom.xml @@ -5,7 +5,7 @@ json-schema-catalog uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/json-schema-catalog/schema-example-context/schema-example-command-api/pom.xml b/json-schema-catalog/schema-example-context/schema-example-command-api/pom.xml index 2dffdb576..9db60a432 100644 --- a/json-schema-catalog/schema-example-context/schema-example-command-api/pom.xml +++ b/json-schema-catalog/schema-example-context/schema-example-command-api/pom.xml @@ -5,7 +5,7 @@ schema-example-context uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/json-schema-catalog/schema-example-context/schema-example-standards/pom.xml b/json-schema-catalog/schema-example-context/schema-example-standards/pom.xml index ec485811a..d9373948e 100644 --- a/json-schema-catalog/schema-example-context/schema-example-standards/pom.xml +++ b/json-schema-catalog/schema-example-context/schema-example-standards/pom.xml @@ -5,7 +5,7 @@ schema-example-context uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/json-schema-catalog/schema-service/pom.xml b/json-schema-catalog/schema-service/pom.xml index 1f681c637..81569c3e6 100644 --- a/json-schema-catalog/schema-service/pom.xml +++ b/json-schema-catalog/schema-service/pom.xml @@ -5,7 +5,7 @@ json-schema-catalog uk.gov.justice.schema - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,13 +13,13 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided org.glassfish - javax.json + jakarta.json uk.gov.justice.schema diff --git a/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/CatalogProducer.java b/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/CatalogProducer.java index 7a2174672..a43401099 100644 --- a/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/CatalogProducer.java +++ b/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/CatalogProducer.java @@ -3,8 +3,8 @@ import uk.gov.justice.schema.catalog.Catalog; import uk.gov.justice.schema.catalog.CatalogObjectFactory; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; /** * A Producer for the {@link Catalog} should you be running in a CDI container diff --git a/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/SchemaCatalogResolverProducer.java b/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/SchemaCatalogResolverProducer.java index 8a40c2a14..309a607c3 100644 --- a/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/SchemaCatalogResolverProducer.java +++ b/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/SchemaCatalogResolverProducer.java @@ -3,8 +3,8 @@ import uk.gov.justice.schema.catalog.CatalogObjectFactory; import uk.gov.justice.schema.catalog.SchemaCatalogResolver; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; /** * A Producer for the {@link SchemaCatalogResolver} should you be running in a CDI container diff --git a/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/SchemaCatalogService.java b/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/SchemaCatalogService.java index bd9ae0b05..952c4638b 100644 --- a/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/SchemaCatalogService.java +++ b/json-schema-catalog/schema-service/src/main/java/uk/gov/justice/schema/service/SchemaCatalogService.java @@ -6,8 +6,8 @@ import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; import org.everit.json.schema.Schema; diff --git a/json-schema-catalog/schema-service/src/main/resources/META-INF/beans.xml b/json-schema-catalog/schema-service/src/main/resources/META-INF/beans.xml index 794b8b5fb..b88648ba0 100644 --- a/json-schema-catalog/schema-service/src/main/resources/META-INF/beans.xml +++ b/json-schema-catalog/schema-service/src/main/resources/META-INF/beans.xml @@ -1,6 +1,6 @@ - diff --git a/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/LoggerProducer.java b/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/LoggerProducer.java index ce866cfdb..b5c494385 100644 --- a/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/LoggerProducer.java +++ b/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/LoggerProducer.java @@ -1,8 +1,8 @@ package uk.gov.justice.schema.service; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.InjectionPoint; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Produces; +import jakarta.enterprise.inject.spi.InjectionPoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/SchemaCatalogResolverIT.java b/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/SchemaCatalogResolverIT.java index 3df1869a3..09676cab9 100644 --- a/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/SchemaCatalogResolverIT.java +++ b/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/SchemaCatalogResolverIT.java @@ -9,7 +9,7 @@ import java.io.InputStream; -import javax.inject.Inject; +import jakarta.inject.Inject; import org.apache.openejb.jee.Application; import org.apache.openejb.jee.WebApp; diff --git a/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/SchemaServiceIT.java b/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/SchemaServiceIT.java index 6c898213f..0a52fdd57 100644 --- a/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/SchemaServiceIT.java +++ b/json-schema-catalog/schema-service/src/test/java/uk/gov/justice/schema/service/SchemaServiceIT.java @@ -5,7 +5,7 @@ import java.util.Optional; -import javax.inject.Inject; +import jakarta.inject.Inject; import org.apache.openejb.jee.Application; import org.apache.openejb.jee.WebApp; diff --git a/json-transformer/json-transformer-jolt/pom.xml b/json-transformer/json-transformer-jolt/pom.xml index eece04cce..af69061e9 100644 --- a/json-transformer/json-transformer-jolt/pom.xml +++ b/json-transformer/json-transformer-jolt/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.json json-transformer - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -13,13 +13,13 @@ - javax - javaee-api + jakarta.platform + jakarta.jakartaee-api provided - javax.json - javax.json-api + jakarta.json + jakarta.json-api uk.gov.justice.utils @@ -73,7 +73,7 @@ org.glassfish - javax.json + jakarta.json test diff --git a/json-transformer/json-transformer-jolt/src/main/java/uk/gov/justice/json/jolt/JoltTransformer.java b/json-transformer/json-transformer-jolt/src/main/java/uk/gov/justice/json/jolt/JoltTransformer.java index 93af5ac91..5be1a1877 100644 --- a/json-transformer/json-transformer-jolt/src/main/java/uk/gov/justice/json/jolt/JoltTransformer.java +++ b/json-transformer/json-transformer-jolt/src/main/java/uk/gov/justice/json/jolt/JoltTransformer.java @@ -12,9 +12,9 @@ import java.util.List; import java.util.Map; -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.json.JsonObject; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.json.JsonObject; import com.bazaarvoice.jolt.Chainr; import com.bazaarvoice.jolt.JsonUtils; diff --git a/json-transformer/json-transformer-jolt/src/main/resources/META-INF/beans.xml b/json-transformer/json-transformer-jolt/src/main/resources/META-INF/beans.xml index a0aaf4421..ce634ddf2 100644 --- a/json-transformer/json-transformer-jolt/src/main/resources/META-INF/beans.xml +++ b/json-transformer/json-transformer-jolt/src/main/resources/META-INF/beans.xml @@ -1,8 +1,8 @@ + https://jakarta.ee/xml/ns/jakartaee + https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd" bean-discovery-mode="all"> diff --git a/json-transformer/json-transformer-jolt/src/test/java/uk/gov/justice/json/jolt/JoltTransformerTest.java b/json-transformer/json-transformer-jolt/src/test/java/uk/gov/justice/json/jolt/JoltTransformerTest.java index 8abf278c9..dff8186c2 100644 --- a/json-transformer/json-transformer-jolt/src/test/java/uk/gov/justice/json/jolt/JoltTransformerTest.java +++ b/json-transformer/json-transformer-jolt/src/test/java/uk/gov/justice/json/jolt/JoltTransformerTest.java @@ -11,7 +11,7 @@ import java.io.FileNotFoundException; -import javax.json.JsonObject; +import jakarta.json.JsonObject; import com.fasterxml.jackson.core.JsonProcessingException; import org.junit.jupiter.api.BeforeEach; diff --git a/json-transformer/json-transformer-jolt/src/test/java/uk/gov/justice/json/jolt/JsonHelper.java b/json-transformer/json-transformer-jolt/src/test/java/uk/gov/justice/json/jolt/JsonHelper.java index f2fd838be..68f178d78 100644 --- a/json-transformer/json-transformer-jolt/src/test/java/uk/gov/justice/json/jolt/JsonHelper.java +++ b/json-transformer/json-transformer-jolt/src/test/java/uk/gov/justice/json/jolt/JsonHelper.java @@ -6,8 +6,8 @@ import java.io.InputStream; import java.io.UncheckedIOException; -import javax.json.JsonObject; -import javax.json.JsonReader; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; import static uk.gov.justice.services.messaging.JsonObjects.getJsonReaderFactory; diff --git a/json-transformer/pom.xml b/json-transformer/pom.xml index e35c1380b..a4ed6f1a9 100644 --- a/json-transformer/pom.xml +++ b/json-transformer/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.json @@ -27,7 +27,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${argLine} -Xmx64m + @{argLine} -Xmx64m -Dnet.bytebuddy.experimental=true diff --git a/jsonschema-pojo-generator/example-pojo-schema/pom.xml b/jsonschema-pojo-generator/example-pojo-schema/pom.xml index 5f4aa4558..18068d723 100644 --- a/jsonschema-pojo-generator/example-pojo-schema/pom.xml +++ b/jsonschema-pojo-generator/example-pojo-schema/pom.xml @@ -5,7 +5,7 @@ jsonschema-pojo-generator uk.gov.justice.generators - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/jsonschema-pojo-generator/example-schema-to-pojo-gen-test/pom.xml b/jsonschema-pojo-generator/example-schema-to-pojo-gen-test/pom.xml index 6dc8c6f64..87dca9ca9 100644 --- a/jsonschema-pojo-generator/example-schema-to-pojo-gen-test/pom.xml +++ b/jsonschema-pojo-generator/example-schema-to-pojo-gen-test/pom.xml @@ -5,7 +5,7 @@ jsonschema-pojo-generator uk.gov.justice.generators - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT ../pom.xml 4.0.0 @@ -21,8 +21,8 @@ - javax.json - javax.json-api + jakarta.json + jakarta.json-api provided diff --git a/jsonschema-pojo-generator/pojo-event-annotation-plugin/pom.xml b/jsonschema-pojo-generator/pojo-event-annotation-plugin/pom.xml index f54a6038f..061cb66dc 100644 --- a/jsonschema-pojo-generator/pojo-event-annotation-plugin/pom.xml +++ b/jsonschema-pojo-generator/pojo-event-annotation-plugin/pom.xml @@ -5,7 +5,7 @@ jsonschema-pojo-generator uk.gov.justice.generators - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/jsonschema-pojo-generator/pojo-generation-core/pom.xml b/jsonschema-pojo-generator/pojo-generation-core/pom.xml index a064e03d6..9ae87ee9e 100644 --- a/jsonschema-pojo-generator/pojo-generation-core/pom.xml +++ b/jsonschema-pojo-generator/pojo-generation-core/pom.xml @@ -5,7 +5,7 @@ jsonschema-pojo-generator uk.gov.justice.generators - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/AddHashcodeAndEqualsPluginTest.java b/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/AddHashcodeAndEqualsPluginTest.java index 9e20ae7ee..bdd915a82 100644 --- a/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/AddHashcodeAndEqualsPluginTest.java +++ b/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/AddHashcodeAndEqualsPluginTest.java @@ -59,7 +59,7 @@ public void shouldGenerateEqualsAndHashCodeMethodsUsingTheClassesFields() throws final String expectedHashCodeMethod = "@java.lang.Override\n" + "public int hashCode() {\n " + - "return java.util.Objects.hash(firstName, lastName, age);" + + "return java.util.Objects.hash(firstName, lastName, age);\n" + "}\n"; final TypeSpec.Builder classBuilder = classBuilder("MyClass").addModifiers(PUBLIC); @@ -123,7 +123,7 @@ public void shouldAddAdditionalPropertiesToHashcodeAndEquals() throws Exception final String expectedHashCodeMethod = "@java.lang.Override\n" + "public int hashCode() {\n " + - "return java.util.Objects.hash(firstName, lastName, age, additionalProperties);" + + "return java.util.Objects.hash(firstName, lastName, age, additionalProperties);\n" + "}\n"; final TypeSpec.Builder classBuilder = classBuilder("MyClass").addModifiers(PUBLIC); diff --git a/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/builder/BuilderMethodFactoryTest.java b/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/builder/BuilderMethodFactoryTest.java index 4ed386ab4..5bbe536b9 100644 --- a/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/builder/BuilderMethodFactoryTest.java +++ b/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/builder/BuilderMethodFactoryTest.java @@ -203,9 +203,8 @@ public void shouldCreateMethodsWithAdditionalProperties() throws Exception { final String expectedAdditionalPropertiesWithMethod = - "public org.bloggs.fred.AlcubierreDrive.Builder withAdditionalProperty(" + - "final java.lang.String name, " + - "final java.lang.Object value) {\n " + + "public org.bloggs.fred.AlcubierreDrive.Builder withAdditionalProperty(final java.lang.String name,\n" + + " final java.lang.Object value) {\n " + "additionalProperties.put(name, value);\n " + "return this;\n" + "}\n"; diff --git a/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/builder/WithMethodGeneratorTest.java b/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/builder/WithMethodGeneratorTest.java index 019b7aca0..168681647 100644 --- a/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/builder/WithMethodGeneratorTest.java +++ b/jsonschema-pojo-generator/pojo-generation-core/src/test/java/uk/gov/justice/generation/pojo/plugin/classmodifying/builder/WithMethodGeneratorTest.java @@ -109,11 +109,13 @@ public void shouldOverloadTheWithMethodIfTheFieldIsOptional() throws Exception { "}\n"; final String overloadedBuildMethod = - "public org.bloggs.fred.AlcubierreDriveBuilder withFirstName(final java.util.Optional firstName) {" + - "\n if (firstName != null) {\n" + + "public org.bloggs.fred.AlcubierreDriveBuilder withFirstName(\n" + + " final java.util.Optional firstName) {\n" + + " if (firstName != null) {\n" + " this.firstName = firstName.orElse(null);\n" + " }\n" + - " return this;\n}\n"; + " return this;\n" + + "}\n"; assertThat(methodSpecs.get(0).toString(), is(expectedWithMethod)); assertThat(methodSpecs.get(1).toString(), is(overloadedBuildMethod)); @@ -162,7 +164,8 @@ public void shouldGenerateTheBuildersWithValuesFromMethod() throws Exception { pluginContext); final String expectedGeneratedMethod = - "public org.bloggs.fred.AlcubierreDriveBuilder withValuesFrom(final org.bloggs.fred.AlcubierreDrive alcubierreDrive) {\n" + + "public org.bloggs.fred.AlcubierreDriveBuilder withValuesFrom(\n" + + " final org.bloggs.fred.AlcubierreDrive alcubierreDrive) {\n" + " this.name = alcubierreDrive.getName();\n" + " this.age = alcubierreDrive.getAge();\n" + " this.haircut = alcubierreDrive.getHaircut();\n" + diff --git a/jsonschema-pojo-generator/pojo-generation-plugin/pom.xml b/jsonschema-pojo-generator/pojo-generation-plugin/pom.xml index ea4871c91..3606fe06c 100644 --- a/jsonschema-pojo-generator/pojo-generation-plugin/pom.xml +++ b/jsonschema-pojo-generator/pojo-generation-plugin/pom.xml @@ -5,7 +5,7 @@ jsonschema-pojo-generator uk.gov.justice.generators - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -49,6 +49,16 @@ + + org.apache.maven + maven-plugin-api + provided + + + org.apache.maven + maven-core + provided + diff --git a/jsonschema-pojo-generator/pojo-integration-test/pom.xml b/jsonschema-pojo-generator/pojo-integration-test/pom.xml index 2070914ca..a66bdde43 100644 --- a/jsonschema-pojo-generator/pojo-integration-test/pom.xml +++ b/jsonschema-pojo-generator/pojo-integration-test/pom.xml @@ -5,7 +5,7 @@ jsonschema-pojo-generator uk.gov.justice.generators - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -16,7 +16,7 @@ org.glassfish - javax.json + jakarta.json org.junit.jupiter diff --git a/jsonschema-pojo-generator/pojo-plugin-it/pom.xml b/jsonschema-pojo-generator/pojo-plugin-it/pom.xml index b88efcf0f..b8210eb0f 100644 --- a/jsonschema-pojo-generator/pojo-plugin-it/pom.xml +++ b/jsonschema-pojo-generator/pojo-plugin-it/pom.xml @@ -5,7 +5,7 @@ jsonschema-pojo-generator uk.gov.justice.generators - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -25,7 +25,7 @@ org.glassfish - javax.json + jakarta.json test diff --git a/jsonschema-pojo-generator/pom.xml b/jsonschema-pojo-generator/pom.xml index 7b92b45ce..d3bc3cc7e 100644 --- a/jsonschema-pojo-generator/pom.xml +++ b/jsonschema-pojo-generator/pom.xml @@ -7,7 +7,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.generators @@ -34,7 +34,7 @@ org.apache.maven.plugins maven-surefire-plugin - ${argLine} -Xmx64m + @{argLine} -Xmx64m -Dnet.bytebuddy.experimental=true diff --git a/jsonschema-pojo-generator/standard-test-catalog/pom.xml b/jsonschema-pojo-generator/standard-test-catalog/pom.xml index 798848a1c..e540f5b34 100644 --- a/jsonschema-pojo-generator/standard-test-catalog/pom.xml +++ b/jsonschema-pojo-generator/standard-test-catalog/pom.xml @@ -5,7 +5,7 @@ jsonschema-pojo-generator uk.gov.justice.generators - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index 648b58773..76fbb6366 100644 --- a/pom.xml +++ b/pom.xml @@ -6,13 +6,13 @@ uk.gov.justice maven-framework-parent-pom - 17.103.0 + 21.0.0-SNAPSHOT 4.0.0 uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT pom Framework Common Libraries @@ -21,7 +21,6 @@ annotation-validator domain-test-dsl - embedded-artemis framework-api framework-libraries-bom framework-utilities @@ -37,16 +36,13 @@ framework-libraries - 17.104.0 + 21.0.0-SNAPSHOT 2.0.0 - 17.0.1 - 17.104.0 - - - 8.0.13 + 21.0.0-SNAPSHOT + 21.0.0-SNAPSHOT - 3.7.1 + 3.9.0 @@ -92,6 +88,14 @@ + + + org.mockito + mockito-junit-jupiter + test + + + ${cpp.scm.connection} ${cpp.scm.developerConnection} @@ -109,8 +113,8 @@ - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api ${jaxb.version} diff --git a/raml-maven/lint-checker-core/pom.xml b/raml-maven/lint-checker-core/pom.xml index 3021ebb1f..207e31bb5 100644 --- a/raml-maven/lint-checker-core/pom.xml +++ b/raml-maven/lint-checker-core/pom.xml @@ -5,7 +5,7 @@ raml-maven uk.gov.justice.maven - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/raml-maven/pom.xml b/raml-maven/pom.xml index 00c0e0b3b..b20dd878d 100644 --- a/raml-maven/pom.xml +++ b/raml-maven/pom.xml @@ -5,7 +5,7 @@ uk.gov.justice.framework.libraries framework-libraries - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT uk.gov.justice.maven diff --git a/raml-maven/raml-for-testing-io/pom.xml b/raml-maven/raml-for-testing-io/pom.xml index a3300d5a1..f4bbe2c01 100644 --- a/raml-maven/raml-for-testing-io/pom.xml +++ b/raml-maven/raml-for-testing-io/pom.xml @@ -5,7 +5,7 @@ raml-maven uk.gov.justice.maven - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/raml-maven/raml-generator-core/pom.xml b/raml-maven/raml-generator-core/pom.xml index 587bdaf87..f72581c11 100644 --- a/raml-maven/raml-generator-core/pom.xml +++ b/raml-maven/raml-generator-core/pom.xml @@ -5,7 +5,7 @@ raml-maven uk.gov.justice.maven - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -27,5 +27,9 @@ + + javax.xml.bind + jaxb-api + diff --git a/raml-maven/raml-generator-for-testing/pom.xml b/raml-maven/raml-generator-for-testing/pom.xml index 2585d56a6..ba9cebabd 100644 --- a/raml-maven/raml-generator-for-testing/pom.xml +++ b/raml-maven/raml-generator-for-testing/pom.xml @@ -5,7 +5,7 @@ raml-maven uk.gov.justice.maven - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/raml-maven/raml-maven-io-utils/pom.xml b/raml-maven/raml-maven-io-utils/pom.xml index fb403597a..460fa40ac 100644 --- a/raml-maven/raml-maven-io-utils/pom.xml +++ b/raml-maven/raml-maven-io-utils/pom.xml @@ -5,7 +5,7 @@ raml-maven uk.gov.justice.maven - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 diff --git a/raml-maven/raml-maven-plugin-it/pom.xml b/raml-maven/raml-maven-plugin-it/pom.xml index f237ec620..961e9e325 100644 --- a/raml-maven/raml-maven-plugin-it/pom.xml +++ b/raml-maven/raml-maven-plugin-it/pom.xml @@ -6,7 +6,7 @@ uk.gov.justice.maven raml-maven - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT 4.0.0 @@ -109,8 +109,8 @@ ${project.version} - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api ${jaxb.version} diff --git a/raml-maven/raml-maven-plugin/pom.xml b/raml-maven/raml-maven-plugin/pom.xml index 2f5a450e3..61b193acb 100644 --- a/raml-maven/raml-maven-plugin/pom.xml +++ b/raml-maven/raml-maven-plugin/pom.xml @@ -6,7 +6,7 @@ uk.gov.justice.maven raml-maven - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT raml-maven-plugin @@ -67,21 +67,25 @@ org.apache.maven maven-plugin-api + provided org.apache.maven maven-compat + provided org.apache.maven maven-core + provided org.apache.maven maven-model + provided @@ -138,7 +142,7 @@ org.glassfish - javax.json + jakarta.json test @@ -159,8 +163,8 @@ test - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api test diff --git a/raml-maven/raml-parser/pom.xml b/raml-maven/raml-parser/pom.xml index b1e63812f..b75522932 100644 --- a/raml-maven/raml-parser/pom.xml +++ b/raml-maven/raml-parser/pom.xml @@ -7,7 +7,7 @@ raml-maven uk.gov.justice.maven - 17.105.0-M3-SNAPSHOT + 21.0.0-SNAPSHOT @@ -34,6 +34,10 @@ javax.xml.bind jaxb-api + + + jakarta.xml.bind + jakarta.xml.bind-api test diff --git a/security-updates.md b/security-updates.md new file mode 100644 index 000000000..6a0d4bd84 --- /dev/null +++ b/security-updates.md @@ -0,0 +1,52 @@ +# Framework Libraries — Security Updates (Java 21 / Jakarta EE 10 Baseline) + +The Java 21 / Jakarta EE 10 release (`21.0.0-SNAPSHOT`) does not itself introduce new CVE-tagged fixes, but it is built on the full `17.x` release history. The security vulnerabilities below were all resolved in the `17.x` series and are included in the Java 21 baseline. The `21.0.0-SNAPSHOT` upgrade also transitively eliminates the javax namespace surface area (replacing it with Jakarta EE 10 APIs), which removes entire categories of vulnerability exposure in the older `javax.*` ecosystem. + +--- + +## CVE-Referenced Security Fixes Included in the Java 21 Baseline + +### Fixed in [17.104.0] — 2025-12-16 + +| CVE | Component | Fixed Version | Detail | +|-----|-----------|---------------|--------| +| CVE-2025-48734 | `commons-beanutils` | 1.11.0 | https://cwe.mitre.org/data/definitions/284.html | +| CVE-2023-0482 | `resteasy` | 3.15.5.Final | https://cwe.mitre.org/data/definitions/378.html | +| CVE-2021-47621 | `classgraph` | 4.8.112 | https://cwe.mitre.org/data/definitions/611.html | +| CVE-2025-48924 | `commons-lang` | 3.18.0 | https://cwe.mitre.org/data/definitions/674.html | + +### Fixed in [17.101.2] — 2025-01-09 + +| CVE | Component | Fixed Version | Detail | +|-----|-----------|---------------|--------| +| CWE-787 | `com.jayway.json-path` | 2.9.0 | https://cwe.mitre.org/data/definitions/787.html | +| CVE-2024-47554 | `commons-io` | 2.18.0 | https://nvd.nist.gov/vuln/detail/CVE-2024-47554 | + +### Fixed in [17.0.2] — 2023-06-14 + +| CVE | Component | Fixed Version | Detail | +|-----|-----------|---------------|--------| +| CVE-2022-45688 | `org.json` | 20230227 | https://nvd.nist.gov/vuln/detail/CVE-2022-45688 | + +--- + +## Additional Security Updates (No CVE Assigned) + +These versions applied security-related dependency upgrades that were not associated with a specific CVE number in the changelog. + +| Version | Components Updated | +|---------|--------------------| +| [17.2.0] — 2023-11-03 | `org.json`, `plexus-codehaus`, `apache-tika`, `google-guava` (via `maven-common-bom 17.2.0`) | +| [7.1.3] — 2020-10-14 | `apache-tika`, `commons-beanutils`, `commons-guava`, `junit` (via `maven-common-bom 7.1.1`) | + +--- + +## Jakarta EE 10 Namespace Migration (21.0.0-SNAPSHOT) + +The `21.0.0-SNAPSHOT` upgrade replaces all `javax.*` APIs with their `jakarta.*` equivalents. While not assigned individual CVEs, this migration removes exposure to vulnerabilities in the unmaintained `javax` namespace and aligns the platform with actively maintained Jakarta EE 10 security patches. + +Key changes in `21.0.0-SNAPSHOT`: + +- Migrated `javax.jms.*` → `jakarta.jms.*` +- Replaced `javax.xml.bind:jaxb-api` → `jakarta.xml.bind:jakarta.xml.bind-api` +- Upgraded OpenEJB `8.0.13` → `10.0.0` (Jakarta EE 10 compatible) From 612a1340b2d310049a582e00604d7f36740dc06c Mon Sep 17 00:00:00 2001 From: allanmckenzie Date: Thu, 23 Apr 2026 09:12:05 +0100 Subject: [PATCH 2/4] Upgrade to Java 21 and Jakarta EE 10.0 --- .../services/test/utils/core/rest/RestClient.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/RestClient.java b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/RestClient.java index 19b18dfdc..9d8a63fdc 100644 --- a/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/RestClient.java +++ b/framework-utilities/test-utils/test-utils-core/src/main/java/uk/gov/justice/services/test/utils/core/rest/RestClient.java @@ -22,7 +22,6 @@ public Response postCommand(final String url, final String contentType, final St try (Response response = RESTEASY_CLIENT.target(url).request().post(entity)) { response.bufferEntity(); - logIfFailed(response); return response; } } @@ -35,7 +34,6 @@ public Response postCommand(final String url, final String contentType, final St try (Response response = RESTEASY_CLIENT.target(url).request().headers(headers).post(entity)) { response.bufferEntity(); - logIfFailed(response); return response; } } @@ -47,7 +45,6 @@ public Response query(final String url, final String contentTypes) { try (Response response = RESTEASY_CLIENT.target(url).request(new MediaType[]{MediaType.valueOf(contentTypes)}).get()) { response.bufferEntity(); - logIfFailed(response); return response; } } @@ -59,7 +56,6 @@ public Response query(final String url, final String contentTypes, final Multiva try (Response response = RESTEASY_CLIENT.target(url).request().headers(headers).header("Accept", contentTypes).get()) { response.bufferEntity(); - logIfFailed(response); return response; } } @@ -71,18 +67,8 @@ public Response deleteCommand(final String url, final String contentType, final try (Response response = RESTEASY_CLIENT.target(url).request().headers(headers).header("Content-Type", contentType).delete()) { response.bufferEntity(); - logIfFailed(response); return response; } } - - private static void logIfFailed(final Response response) { - if (LOGGER.isInfoEnabled()) { - Response.StatusType statusType = response.getStatusInfo(); - if (statusType.getFamily() != Response.Status.Family.SUCCESSFUL) { - LOGGER.info("Received response status '{}' '{}' {} ", statusType.getStatusCode(), statusType.getReasonPhrase(), response.readEntity(String.class)); - } - } - } } From a943c04e6bd6582bcb2fd01fdf89c84d00011cd0 Mon Sep 17 00:00:00 2001 From: allanmckenzie Date: Fri, 24 Apr 2026 12:54:53 +0100 Subject: [PATCH 3/4] Fix IntegerEnumBeanDeserializerModifier for Jackson 2.18 API change Co-Authored-By: Claude Sonnet 4.6 --- .../integerenum/IntegerEnumBeanDeserializerModifier.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumBeanDeserializerModifier.java b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumBeanDeserializerModifier.java index e2448631e..dd3d6e692 100644 --- a/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumBeanDeserializerModifier.java +++ b/framework-utilities/utilities/utilities-core/src/main/java/uk/gov/justice/services/common/converter/jackson/integerenum/IntegerEnumBeanDeserializerModifier.java @@ -20,8 +20,8 @@ public JsonDeserializer modifyEnumDeserializer( final BeanDescription beanDesc, final JsonDeserializer deserializer) { - final EnumResolver enumResolver = constructFor(config, beanDesc.getClassInfo()); - final EnumResolver toStringResolver = constructUsingToString(config, beanDesc.getClassInfo()); + final EnumResolver enumResolver = constructFor(config, beanDesc.getBeanClass()); + final EnumResolver toStringResolver = constructUsingToString(config, beanDesc.getBeanClass()); return new IntegerEnumDeserializer( enumResolver, From 58f8a8f9405d63c4abcb9a708ee1fa030a9e29d4 Mon Sep 17 00:00:00 2001 From: allanmckenzie Date: Fri, 24 Apr 2026 16:52:50 +0100 Subject: [PATCH 4/4] Add effective-json-schema-maven-plugin Generates self-contained effective JSON schema documents at build time by inlining all external \$ref references, in the same spirit as Maven's help:effective-pom. Output is written to target/effective-json-schemas/. New modules: - catalog-effective-json-schema-generation: core inlining library - effective-json-schema-maven-plugin: Maven Mojo wrapper - effective-json-schema-plugin-it: integration test Schema discovery resolves refs from dependency JAR catalogs, with a classpath fallback scan for JARs that carry schemas without a catalog. Circular references are detected and handled safely. Co-Authored-By: Claude Sonnet 4.6 --- .../pom.xml | 60 +++ .../effective/CatalogJsonSchemaLoader.java | 175 ++++++++ .../effective/DefinitionNameFactory.java | 19 + ...ffectiveJsonSchemaGenerationException.java | 12 + .../EffectiveJsonSchemaGenerator.java | 76 ++++ .../EffectiveJsonSchemaObjectFactory.java | 30 ++ .../effective/EffectiveJsonSchemaWriter.java | 21 + .../effective/JsonSchemaInliner.java | 114 +++++ .../CatalogJsonSchemaLoaderTest.java | 153 +++++++ .../effective/DefinitionNameFactoryTest.java | 48 ++ .../EffectiveJsonSchemaGeneratorTest.java | 137 ++++++ .../EffectiveJsonSchemaObjectFactoryTest.java | 42 ++ .../EffectiveJsonSchemaWriterTest.java | 64 +++ .../effective/JsonSchemaInlinerTest.java | 280 ++++++++++++ .../pom.xml | 85 ++++ .../maven/EffectiveJsonSchemaMojo.java | 119 +++++ .../maven/EffectiveJsonSchemaMojoTest.java | 154 +++++++ .../effective-json-schema-plugin-it/pom.xml | 153 +++++++ .../src/raml/json/schema/context/person.json | 25 ++ .../raml/json/schema/standards/address.json | 24 + .../schema/standards/complex_address.json | 35 ++ .../it/EffectiveJsonSchemaGenerationIT.java | 118 +++++ .../effective-json-schema-plugin.md | 417 ++++++++++++++++++ json-schema-catalog/pom.xml | 3 + 24 files changed, 2364 insertions(+) create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/pom.xml create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/CatalogJsonSchemaLoader.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/DefinitionNameFactory.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGenerationException.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGenerator.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaObjectFactory.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaWriter.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/JsonSchemaInliner.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/CatalogJsonSchemaLoaderTest.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/DefinitionNameFactoryTest.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGeneratorTest.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaObjectFactoryTest.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaWriterTest.java create mode 100644 json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/JsonSchemaInlinerTest.java create mode 100644 json-schema-catalog/effective-json-schema-maven-plugin/pom.xml create mode 100644 json-schema-catalog/effective-json-schema-maven-plugin/src/main/java/uk/gov/justice/schema/catalog/maven/EffectiveJsonSchemaMojo.java create mode 100644 json-schema-catalog/effective-json-schema-maven-plugin/src/test/java/uk/gov/justice/schema/catalog/maven/EffectiveJsonSchemaMojoTest.java create mode 100644 json-schema-catalog/effective-json-schema-plugin-it/pom.xml create mode 100644 json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/context/person.json create mode 100644 json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/standards/address.json create mode 100644 json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/standards/complex_address.json create mode 100644 json-schema-catalog/effective-json-schema-plugin-it/src/test/java/uk/gov/justice/schema/catalog/generation/effective/it/EffectiveJsonSchemaGenerationIT.java create mode 100644 json-schema-catalog/effective-json-schema-plugin.md diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/pom.xml b/json-schema-catalog/catalog-effective-json-schema-generation/pom.xml new file mode 100644 index 000000000..32c582081 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/pom.xml @@ -0,0 +1,60 @@ + + + + json-schema-catalog + uk.gov.justice.schema + 21.0.0-SNAPSHOT + + 4.0.0 + + catalog-effective-json-schema-generation + + + + uk.gov.justice.schema + catalog-core + ${project.version} + + + org.json + json + + + commons-io + commons-io + + + org.slf4j + slf4j-api + + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.mockito + mockito-core + test + + + org.mockito + mockito-junit-jupiter + test + + + org.hamcrest + hamcrest + test + + + org.slf4j + slf4j-reload4j + test + + + diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/CatalogJsonSchemaLoader.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/CatalogJsonSchemaLoader.java new file mode 100644 index 000000000..f821e302e --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/CatalogJsonSchemaLoader.java @@ -0,0 +1,175 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import static java.lang.String.format; +import static java.nio.charset.StandardCharsets.UTF_8; + +import uk.gov.justice.schema.catalog.domain.Catalog; +import uk.gov.justice.schema.catalog.domain.Group; +import uk.gov.justice.schema.catalog.domain.Schema; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.io.IOUtils; +import org.json.JSONException; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Loads raw JSON schema content (keyed by schema ID) from two sources: + *
    + *
  1. Dependency JAR files — each JAR is inspected for a + * {@code META-INF/schema_catalog.json} catalog, and the schemas listed there + * are read directly from the JAR.
  2. + *
  3. A local source directory — every {@code .json} file that contains an {@code "id"} + * field is included.
  4. + *
+ * + * The resulting map ({@code schemaId -> rawJsonString}) is used by {@link JsonSchemaInliner} + * to resolve external {@code $ref} values when building effective JSON schema documents. + */ +public class CatalogJsonSchemaLoader { + + private static final Logger LOGGER = LoggerFactory.getLogger(CatalogJsonSchemaLoader.class); + + private static final String SCHEMA_CATALOG_PATH = "META-INF/schema_catalog.json"; + + private final ObjectMapper objectMapper; + + public CatalogJsonSchemaLoader(final ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + + /** + * Loads all known schemas from the given dependency JARs and the local source directory. + * + * @param dependencyJars JAR files from the project's compile classpath + * @param sourceDirectory the directory containing the current module's JSON schema files + * @return a map of schema ID to raw JSON string + */ + public Map loadAllJsonSchemas(final List dependencyJars, + final Path sourceDirectory) { + final Map schemasById = new HashMap<>(); + loadJsonSchemasFromJars(dependencyJars, schemasById); + loadJsonSchemasFromSourceDirectory(sourceDirectory, schemasById); + return schemasById; + } + + private void loadJsonSchemasFromJars(final List jars, + final Map schemasById) { + for (final File jar : jars) { + if (jar != null && jar.exists()) { + loadJsonSchemasFromJar(jar, schemasById); + } + } + } + + private void loadJsonSchemasFromJar(final File jar, final Map schemasById) { + try (final ZipFile zipFile = new ZipFile(jar)) { + final ZipEntry catalogEntry = zipFile.getEntry(SCHEMA_CATALOG_PATH); + if (catalogEntry != null) { + loadSchemasViaCatalog(zipFile, catalogEntry, jar, schemasById); + } + fallbackScanJsonEntriesInJar(zipFile, jar, schemasById); + } catch (final IOException e) { + throw new EffectiveJsonSchemaGenerationException( + format("Failed to load JSON schemas from JAR '%s'", jar.getAbsolutePath()), e); + } + } + + private void loadSchemasViaCatalog(final ZipFile zipFile, + final ZipEntry catalogEntry, + final File jar, + final Map schemasById) throws IOException { + final String catalogJson; + try (final InputStream catalogStream = zipFile.getInputStream(catalogEntry)) { + catalogJson = IOUtils.toString(catalogStream, UTF_8); + } + + final Catalog catalog = objectMapper.readValue(catalogJson, Catalog.class); + + for (final Group group : catalog.getGroups()) { + final String baseLocation = group.getBaseLocation() != null ? group.getBaseLocation() : ""; + for (final Schema schema : group.getSchemas()) { + final String schemaPath = baseLocation + schema.getLocation(); + final ZipEntry schemaEntry = zipFile.getEntry(schemaPath); + if (schemaEntry != null) { + try (final InputStream schemaStream = zipFile.getInputStream(schemaEntry)) { + schemasById.put(schema.getId(), IOUtils.toString(schemaStream, UTF_8)); + } + } else { + LOGGER.warn("Schema entry '{}' not found in JAR '{}'", schemaPath, jar.getName()); + } + } + } + } + + private void fallbackScanJsonEntriesInJar(final ZipFile zipFile, + final File jar, + final Map schemasById) { + zipFile.stream() + .filter(entry -> !entry.isDirectory()) + .filter(entry -> entry.getName().endsWith(".json")) + .filter(entry -> !entry.getName().equals(SCHEMA_CATALOG_PATH)) + .forEach(entry -> { + try (final InputStream stream = zipFile.getInputStream(entry)) { + final String content = IOUtils.toString(stream, UTF_8); + final var jsonNode = objectMapper.readTree(content); + if (jsonNode.has("id") && jsonNode.get("id").isTextual()) { + // Validate with org.json before caching — JsonSchemaInliner uses + // org.json later and is strict about duplicate keys + try { + new JSONObject(content); + schemasById.putIfAbsent(jsonNode.get("id").asText(), content); + } catch (final JSONException e) { + LOGGER.warn("Skipping '{}' in JAR '{}': rejected by JSON parser ({})", + entry.getName(), jar.getName(), e.getMessage()); + } + } + } catch (final IOException e) { + LOGGER.warn("Skipping entry '{}' in JAR '{}': could not read as JSON ({})", + entry.getName(), jar.getName(), e.getMessage()); + } + }); + } + + private void loadJsonSchemasFromSourceDirectory(final Path sourceDirectory, + final Map schemasById) { + if (!Files.isDirectory(sourceDirectory)) { + LOGGER.warn("Source directory '{}' does not exist or is not a directory", sourceDirectory); + return; + } + + try { + Files.walk(sourceDirectory) + .filter(path -> path.toString().endsWith(".json")) + .forEach(path -> loadJsonSchemaFile(path, schemasById)); + } catch (final IOException e) { + throw new EffectiveJsonSchemaGenerationException( + format("Failed to scan source directory '%s'", sourceDirectory), e); + } + } + + private void loadJsonSchemaFile(final Path schemaFile, final Map schemasById) { + try { + final String content = Files.readString(schemaFile); + final var jsonNode = objectMapper.readTree(content); + if (jsonNode.has("id") && jsonNode.get("id").isTextual()) { + schemasById.put(jsonNode.get("id").asText(), content); + } + } catch (final IOException e) { + LOGGER.warn("Skipping '{}': could not parse as JSON ({})", schemaFile, e.getMessage()); + } + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/DefinitionNameFactory.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/DefinitionNameFactory.java new file mode 100644 index 000000000..20aa67526 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/DefinitionNameFactory.java @@ -0,0 +1,19 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +/** + * Creates safe JSON Schema definition names from schema ID URLs, for use when + * inlining referenced schemas into an effective JSON schema document. + * + * Example: {@code http://justice.gov.uk/standards/complex_address.json} + * becomes {@code justice_gov_uk_standards_complex_address} + */ +public class DefinitionNameFactory { + + public String createFor(final String schemaId) { + String name = schemaId.replaceFirst("^https?://", ""); + name = name.replaceAll("[^a-zA-Z0-9]+", "_"); + name = name.replaceAll("_json$", ""); + name = name.replaceAll("^_+|_+$", ""); + return name; + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGenerationException.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGenerationException.java new file mode 100644 index 000000000..7d9a1f1d0 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGenerationException.java @@ -0,0 +1,12 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +public class EffectiveJsonSchemaGenerationException extends RuntimeException { + + public EffectiveJsonSchemaGenerationException(final String message) { + super(message); + } + + public EffectiveJsonSchemaGenerationException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGenerator.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGenerator.java new file mode 100644 index 000000000..eb45500c6 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGenerator.java @@ -0,0 +1,76 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import static java.lang.String.format; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Map; + +import org.json.JSONException; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Generates effective JSON schema documents for a set of source schema files. + * For each schema file, all external {@code $ref} references are resolved and inlined + * into a single self-contained document, which is written to the output directory + * preserving the relative path structure of the source directory. + */ +public class EffectiveJsonSchemaGenerator { + + private static final Logger LOGGER = LoggerFactory.getLogger(EffectiveJsonSchemaGenerator.class); + + private final JsonSchemaInliner jsonSchemaInliner; + private final EffectiveJsonSchemaWriter effectiveJsonSchemaWriter; + + public EffectiveJsonSchemaGenerator(final JsonSchemaInliner jsonSchemaInliner, + final EffectiveJsonSchemaWriter effectiveJsonSchemaWriter) { + this.jsonSchemaInliner = jsonSchemaInliner; + this.effectiveJsonSchemaWriter = effectiveJsonSchemaWriter; + } + + /** + * Generates effective JSON schema documents for each of the given source schema files. + * + * @param schemaFiles the source schema files to process + * @param sourceBaseDirectory the root directory used to compute output relative paths + * @param allSchemasById a map of schema ID to raw JSON for all known schemas + * @param outputDirectory directory under which effective schemas are written + */ + public void generate(final List schemaFiles, + final Path sourceBaseDirectory, + final Map allSchemasById, + final Path outputDirectory) { + for (final Path schemaFile : schemaFiles) { + generateEffectiveJsonSchema(schemaFile, sourceBaseDirectory, allSchemasById, outputDirectory); + } + } + + private void generateEffectiveJsonSchema(final Path schemaFile, + final Path sourceBaseDirectory, + final Map allSchemasById, + final Path outputDirectory) { + try { + final String rawJson = Files.readString(schemaFile); + final JSONObject schema; + try { + schema = new JSONObject(rawJson); + } catch (final JSONException e) { + LOGGER.warn("Skipping '{}': could not parse as JSON schema ({})", schemaFile, e.getMessage()); + return; + } + final JSONObject effectiveJsonSchema = jsonSchemaInliner.inline(schema, allSchemasById); + + final Path relativePath = sourceBaseDirectory.relativize(schemaFile); + final Path outputPath = outputDirectory.resolve(relativePath); + + effectiveJsonSchemaWriter.write(effectiveJsonSchema, outputPath); + } catch (final IOException e) { + throw new EffectiveJsonSchemaGenerationException( + format("Failed to generate effective JSON schema for '%s'", schemaFile), e); + } + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaObjectFactory.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaObjectFactory.java new file mode 100644 index 000000000..47624c814 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaObjectFactory.java @@ -0,0 +1,30 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import uk.gov.justice.schema.catalog.CatalogObjectFactory; + +/** + * Factory for creating instances of the effective JSON schema generation components. + * Avoids the need for a dependency injection framework in library/plugin code. + */ +public class EffectiveJsonSchemaObjectFactory { + + public DefinitionNameFactory definitionNameFactory() { + return new DefinitionNameFactory(); + } + + public JsonSchemaInliner jsonSchemaInliner() { + return new JsonSchemaInliner(definitionNameFactory()); + } + + public EffectiveJsonSchemaWriter effectiveJsonSchemaWriter() { + return new EffectiveJsonSchemaWriter(); + } + + public EffectiveJsonSchemaGenerator effectiveJsonSchemaGenerator() { + return new EffectiveJsonSchemaGenerator(jsonSchemaInliner(), effectiveJsonSchemaWriter()); + } + + public CatalogJsonSchemaLoader catalogJsonSchemaLoader() { + return new CatalogJsonSchemaLoader(new CatalogObjectFactory().objectMapper()); + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaWriter.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaWriter.java new file mode 100644 index 000000000..7b1624929 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaWriter.java @@ -0,0 +1,21 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import static java.nio.charset.StandardCharsets.UTF_8; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.json.JSONObject; + +/** + * Writes a generated effective JSON schema document to a file, creating any + * intermediate parent directories as needed. + */ +public class EffectiveJsonSchemaWriter { + + public void write(final JSONObject effectiveJsonSchema, final Path outputPath) throws IOException { + Files.createDirectories(outputPath.getParent()); + Files.writeString(outputPath, effectiveJsonSchema.toString(2), UTF_8); + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/JsonSchemaInliner.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/JsonSchemaInliner.java new file mode 100644 index 000000000..8d9264bb1 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/main/java/uk/gov/justice/schema/catalog/generation/effective/JsonSchemaInliner.java @@ -0,0 +1,114 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import org.json.JSONArray; +import org.json.JSONObject; + +/** + * Inlines all external {@code $ref} references in a JSON schema into a single self-contained + * effective JSON schema document. Referenced schemas are collected in a top-level + * {@code definitions} block, and all external {@code $ref} values are rewritten to point to + * those local definitions. + * + *

Fragment references (e.g. {@code http://example.com/address.json#/definitions/postal}) + * are preserved as a JSON Pointer path beneath the inlined definition entry. + * + *

Circular references are handled safely: if a schema is encountered while it is already + * being processed, that particular {@code $ref} is left pointing to the external URL rather + * than causing infinite recursion. + */ +public class JsonSchemaInliner { + + private final DefinitionNameFactory definitionNameFactory; + + public JsonSchemaInliner(final DefinitionNameFactory definitionNameFactory) { + this.definitionNameFactory = definitionNameFactory; + } + + /** + * Produces an effective JSON schema by recursively inlining all externally referenced schemas. + * + * @param schema the root JSON schema to process + * @param allSchemasById a map of schema ID to raw JSON string for every known schema + * @return a new {@link JSONObject} with all reachable external {@code $ref} values inlined + */ + public JSONObject inline(final JSONObject schema, final Map allSchemasById) { + final Map collectedDefinitions = new LinkedHashMap<>(); + final Set currentlyProcessing = new HashSet<>(); + + final JSONObject workingSchema = deepCopy(schema); + resolveRefsInNode(workingSchema, allSchemasById, collectedDefinitions, currentlyProcessing); + + if (!collectedDefinitions.isEmpty()) { + final JSONObject mergedDefinitions = workingSchema.has("definitions") + ? deepCopy(workingSchema.getJSONObject("definitions")) + : new JSONObject(); + collectedDefinitions.forEach(mergedDefinitions::put); + workingSchema.put("definitions", mergedDefinitions); + } + + return workingSchema; + } + + private void resolveRefsInNode(final Object node, + final Map allSchemas, + final Map definitions, + final Set processing) { + if (node instanceof JSONObject obj) { + if (obj.has("$ref")) { + final String ref = obj.getString("$ref"); + if (!ref.startsWith("#")) { + processExternalRef(obj, ref, allSchemas, definitions, processing); + } + } else { + for (final String key : obj.keySet()) { + resolveRefsInNode(obj.get(key), allSchemas, definitions, processing); + } + } + } else if (node instanceof JSONArray arr) { + for (int i = 0; i < arr.length(); i++) { + resolveRefsInNode(arr.get(i), allSchemas, definitions, processing); + } + } + } + + private void processExternalRef(final JSONObject refNode, + final String ref, + final Map allSchemas, + final Map definitions, + final Set processing) { + final int hashIdx = ref.indexOf('#'); + final String baseId = hashIdx >= 0 ? ref.substring(0, hashIdx) : ref; + final String fragment = hashIdx >= 0 ? ref.substring(hashIdx + 1) : ""; + + final String defName = definitionNameFactory.createFor(baseId); + + if (!definitions.containsKey(defName) && !processing.contains(baseId)) { + final String rawSchema = allSchemas.get(baseId); + if (rawSchema == null) { + return; + } + processing.add(baseId); + final JSONObject referencedSchema = new JSONObject(rawSchema); + resolveRefsInNode(referencedSchema, allSchemas, definitions, processing); + definitions.put(defName, referencedSchema); + processing.remove(baseId); + } + + if (definitions.containsKey(defName)) { + final String localFragment = fragment.replaceFirst("^/", ""); + final String newRef = localFragment.isEmpty() + ? "#/definitions/" + defName + : "#/definitions/" + defName + "/" + localFragment; + refNode.put("$ref", newRef); + } + } + + private JSONObject deepCopy(final JSONObject original) { + return new JSONObject(original.toString()); + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/CatalogJsonSchemaLoaderTest.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/CatalogJsonSchemaLoaderTest.java new file mode 100644 index 000000000..d5e4f2637 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/CatalogJsonSchemaLoaderTest.java @@ -0,0 +1,153 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasKey; +import static org.hamcrest.Matchers.not; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class CatalogJsonSchemaLoaderTest { + + @TempDir + Path tempDir; + + @Mock + private ObjectMapper objectMapper; + + @InjectMocks + private CatalogJsonSchemaLoader catalogJsonSchemaLoader; + + @Test + public void shouldLoadJsonSchemasFromSourceDirectory() throws Exception { + final Path sourceDir = tempDir.resolve("schemas"); + Files.createDirectories(sourceDir); + Files.writeString(sourceDir.resolve("address.json"), + "{ \"id\": \"http://example.com/address.json\", \"type\": \"object\" }"); + + final var mockNode = new ObjectMapper().readTree( + "{ \"id\": \"http://example.com/address.json\", \"type\": \"object\" }"); + when(objectMapper.readTree(any(String.class))).thenReturn(mockNode); + + final Map result = catalogJsonSchemaLoader.loadAllJsonSchemas(List.of(), sourceDir); + + assertThat(result, hasKey("http://example.com/address.json")); + } + + @Test + public void shouldSkipJsonFilesWithNoIdField() throws Exception { + final Path sourceDir = tempDir.resolve("schemas"); + Files.createDirectories(sourceDir); + Files.writeString(sourceDir.resolve("config.json"), "{ \"someKey\": \"someValue\" }"); + + final var mockNode = new ObjectMapper().readTree("{ \"someKey\": \"someValue\" }"); + when(objectMapper.readTree(any(String.class))).thenReturn(mockNode); + + final Map result = catalogJsonSchemaLoader.loadAllJsonSchemas(List.of(), sourceDir); + + assertThat(result, not(hasKey("someKey"))); + assertThat(result.isEmpty(), is(true)); + } + + @Test + public void shouldSkipNonExistentJarFiles() throws Exception { + final Path sourceDir = tempDir.resolve("schemas"); + Files.createDirectories(sourceDir); + + final File nonExistentJar = new File("/does/not/exist.jar"); + + final Map result = catalogJsonSchemaLoader.loadAllJsonSchemas( + List.of(nonExistentJar), sourceDir); + + assertThat(result.isEmpty(), is(true)); + } + + @Test + public void shouldHandleNullJarEntryGracefully() throws Exception { + final Path sourceDir = tempDir.resolve("schemas"); + Files.createDirectories(sourceDir); + + final Map result = catalogJsonSchemaLoader.loadAllJsonSchemas( + Arrays.asList((File) null), sourceDir); + + assertThat(result.isEmpty(), is(true)); + } + + @Test + public void shouldHandleNonExistentSourceDirectory() throws Exception { + final Path nonExistentDir = tempDir.resolve("does-not-exist"); + + final Map result = catalogJsonSchemaLoader.loadAllJsonSchemas( + List.of(), nonExistentDir); + + assertThat(result.isEmpty(), is(true)); + } + + @Test + public void shouldFallbackToScanningAllJsonEntriesWhenNoCatalogFound() throws Exception { + final Path jarPath = tempDir.resolve("test-schemas.jar"); + final String schemaContent = "{ \"id\": \"http://example.com/fallback.json\", \"type\": \"object\" }"; + + try (final ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(jarPath))) { + zos.putNextEntry(new ZipEntry("schemas/fallback.json")); + zos.write(schemaContent.getBytes(UTF_8)); + zos.closeEntry(); + } + + final var mockNode = new ObjectMapper().readTree(schemaContent); + when(objectMapper.readTree(eq(schemaContent))).thenReturn(mockNode); + + final Path sourceDir = tempDir.resolve("src"); + Files.createDirectories(sourceDir); + + final Map result = catalogJsonSchemaLoader.loadAllJsonSchemas( + List.of(jarPath.toFile()), sourceDir); + + assertThat(result, hasKey("http://example.com/fallback.json")); + assertThat(result.get("http://example.com/fallback.json"), is(schemaContent)); + } + + @Test + public void shouldLoadMultipleSchemasFromSourceDirectory() throws Exception { + final Path sourceDir = tempDir.resolve("schemas"); + final Path contextDir = sourceDir.resolve("context"); + Files.createDirectories(contextDir); + + Files.writeString(sourceDir.resolve("address.json"), + "{ \"id\": \"http://example.com/address.json\", \"type\": \"object\" }"); + Files.writeString(contextDir.resolve("person.json"), + "{ \"id\": \"http://example.com/person.json\", \"type\": \"object\" }"); + + final ObjectMapper realMapper = new ObjectMapper(); + when(objectMapper.readTree(eq("{ \"id\": \"http://example.com/address.json\", \"type\": \"object\" }"))) + .thenReturn(realMapper.readTree("{ \"id\": \"http://example.com/address.json\", \"type\": \"object\" }")); + when(objectMapper.readTree(eq("{ \"id\": \"http://example.com/person.json\", \"type\": \"object\" }"))) + .thenReturn(realMapper.readTree("{ \"id\": \"http://example.com/person.json\", \"type\": \"object\" }")); + + final Map result = catalogJsonSchemaLoader.loadAllJsonSchemas(List.of(), sourceDir); + + assertThat(result, hasKey("http://example.com/address.json")); + assertThat(result, hasKey("http://example.com/person.json")); + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/DefinitionNameFactoryTest.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/DefinitionNameFactoryTest.java new file mode 100644 index 000000000..d27cb9089 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/DefinitionNameFactoryTest.java @@ -0,0 +1,48 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; + +public class DefinitionNameFactoryTest { + + private final DefinitionNameFactory definitionNameFactory = new DefinitionNameFactory(); + + @Test + public void shouldConvertHttpUrlToSafeDefinitionName() { + final String result = definitionNameFactory.createFor("http://justice.gov.uk/standards/address.json"); + assertThat(result, is("justice_gov_uk_standards_address")); + } + + @Test + public void shouldConvertHttpsUrlToSafeDefinitionName() { + final String result = definitionNameFactory.createFor("https://justice.gov.uk/standards/address.json"); + assertThat(result, is("justice_gov_uk_standards_address")); + } + + @Test + public void shouldHandleNestedPathSegments() { + final String result = definitionNameFactory.createFor("http://justice.gov.uk/standards/complex_address.json"); + assertThat(result, is("justice_gov_uk_standards_complex_address")); + } + + @Test + public void shouldCollapseConsecutiveNonAlphanumericCharacters() { + final String result = definitionNameFactory.createFor("http://justice.gov.uk/context/person.json"); + assertThat(result, is("justice_gov_uk_context_person")); + } + + @Test + public void shouldNotProduceLeadingOrTrailingUnderscores() { + final String result = definitionNameFactory.createFor("http://example.com/thing.json"); + assertThat(result.charAt(0) != '_', is(true)); + assertThat(result.charAt(result.length() - 1) != '_', is(true)); + } + + @Test + public void shouldStripTrailingJsonSuffix() { + final String result = definitionNameFactory.createFor("http://example.com/my-schema.json"); + assertThat(result.endsWith("json"), is(false)); + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGeneratorTest.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGeneratorTest.java new file mode 100644 index 000000000..a5a115dc7 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaGeneratorTest.java @@ -0,0 +1,137 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Map; + +import org.json.JSONObject; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class EffectiveJsonSchemaGeneratorTest { + + @TempDir + Path tempDir; + + @Mock + private JsonSchemaInliner jsonSchemaInliner; + + @Mock + private EffectiveJsonSchemaWriter effectiveJsonSchemaWriter; + + @InjectMocks + private EffectiveJsonSchemaGenerator effectiveJsonSchemaGenerator; + + @Test + public void shouldCallInlinerAndWriterForEachSchemaFile() throws Exception { + final Path sourceDir = tempDir.resolve("source"); + Files.createDirectories(sourceDir); + final Path schemaFile = sourceDir.resolve("person.json"); + Files.writeString(schemaFile, "{ \"id\": \"http://example.com/person.json\", \"type\": \"object\" }"); + + final Path outputDir = tempDir.resolve("output"); + final Map allSchemas = Map.of("http://example.com/person.json", "{}"); + final JSONObject inlinedSchema = new JSONObject("{ \"type\": \"object\" }"); + + when(jsonSchemaInliner.inline(any(JSONObject.class), eq(allSchemas))).thenReturn(inlinedSchema); + + effectiveJsonSchemaGenerator.generate(List.of(schemaFile), sourceDir, allSchemas, outputDir); + + final ArgumentCaptor schemaCaptor = ArgumentCaptor.forClass(JSONObject.class); + final ArgumentCaptor pathCaptor = ArgumentCaptor.forClass(Path.class); + verify(effectiveJsonSchemaWriter).write(schemaCaptor.capture(), pathCaptor.capture()); + + assertThat(schemaCaptor.getValue().getString("type"), is("object")); + assertThat(pathCaptor.getValue(), is(outputDir.resolve("person.json"))); + } + + @Test + public void shouldPreserveRelativeDirectoryStructureInOutput() throws Exception { + final Path sourceDir = tempDir.resolve("source"); + final Path contextDir = sourceDir.resolve("context"); + Files.createDirectories(contextDir); + final Path schemaFile = contextDir.resolve("person.json"); + Files.writeString(schemaFile, "{ \"id\": \"http://example.com/person.json\" }"); + + final Path outputDir = tempDir.resolve("output"); + final JSONObject inlinedSchema = new JSONObject("{}"); + + when(jsonSchemaInliner.inline(any(JSONObject.class), any())).thenReturn(inlinedSchema); + + effectiveJsonSchemaGenerator.generate(List.of(schemaFile), sourceDir, Map.of(), outputDir); + + final ArgumentCaptor pathCaptor = ArgumentCaptor.forClass(Path.class); + verify(effectiveJsonSchemaWriter).write(any(), pathCaptor.capture()); + + assertThat(pathCaptor.getValue(), is(outputDir.resolve("context/person.json"))); + } + + @Test + public void shouldProcessMultipleSchemaFiles() throws Exception { + final Path sourceDir = tempDir.resolve("source"); + Files.createDirectories(sourceDir); + + final Path schema1 = sourceDir.resolve("a.json"); + final Path schema2 = sourceDir.resolve("b.json"); + Files.writeString(schema1, "{ \"id\": \"http://example.com/a.json\" }"); + Files.writeString(schema2, "{ \"id\": \"http://example.com/b.json\" }"); + + final JSONObject inlinedSchema = new JSONObject("{}"); + when(jsonSchemaInliner.inline(any(JSONObject.class), any())).thenReturn(inlinedSchema); + + effectiveJsonSchemaGenerator.generate(List.of(schema1, schema2), sourceDir, Map.of(), + tempDir.resolve("output")); + + verify(effectiveJsonSchemaWriter, org.mockito.Mockito.times(2)).write(any(), any()); + } + + @Test + public void shouldSkipSchemaFileWithDuplicateKeys() throws Exception { + final Path sourceDir = tempDir.resolve("source"); + Files.createDirectories(sourceDir); + final Path schemaFile = sourceDir.resolve("bad.json"); + Files.writeString(schemaFile, "{ \"name\": \"first\", \"name\": \"second\" }"); + + effectiveJsonSchemaGenerator.generate( + List.of(schemaFile), sourceDir, Map.of(), tempDir.resolve("output")); + + verify(effectiveJsonSchemaWriter, never()).write(any(), any()); + } + + @Test + public void shouldThrowEffectiveJsonSchemaGenerationExceptionWhenWriterFails() throws Exception { + final Path sourceDir = tempDir.resolve("source"); + Files.createDirectories(sourceDir); + final Path schemaFile = sourceDir.resolve("person.json"); + Files.writeString(schemaFile, "{ \"id\": \"http://example.com/person.json\" }"); + + final JSONObject inlinedSchema = new JSONObject("{}"); + when(jsonSchemaInliner.inline(any(JSONObject.class), any())).thenReturn(inlinedSchema); + doThrow(new IOException("disk full")).when(effectiveJsonSchemaWriter).write(any(), any()); + + final EffectiveJsonSchemaGenerationException exception = assertThrows( + EffectiveJsonSchemaGenerationException.class, + () -> effectiveJsonSchemaGenerator.generate( + List.of(schemaFile), sourceDir, Map.of(), tempDir.resolve("output"))); + + assertThat(exception.getMessage().contains("person.json"), is(true)); + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaObjectFactoryTest.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaObjectFactoryTest.java new file mode 100644 index 000000000..2201ffa26 --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaObjectFactoryTest.java @@ -0,0 +1,42 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class EffectiveJsonSchemaObjectFactoryTest { + + @InjectMocks + private EffectiveJsonSchemaObjectFactory effectiveJsonSchemaObjectFactory; + + @Test + public void shouldCreateDefinitionNameFactory() { + assertThat(effectiveJsonSchemaObjectFactory.definitionNameFactory(), is(notNullValue())); + } + + @Test + public void shouldCreateJsonSchemaInliner() { + assertThat(effectiveJsonSchemaObjectFactory.jsonSchemaInliner(), is(notNullValue())); + } + + @Test + public void shouldCreateEffectiveJsonSchemaWriter() { + assertThat(effectiveJsonSchemaObjectFactory.effectiveJsonSchemaWriter(), is(notNullValue())); + } + + @Test + public void shouldCreateEffectiveJsonSchemaGenerator() { + assertThat(effectiveJsonSchemaObjectFactory.effectiveJsonSchemaGenerator(), is(notNullValue())); + } + + @Test + public void shouldCreateCatalogJsonSchemaLoader() { + assertThat(effectiveJsonSchemaObjectFactory.catalogJsonSchemaLoader(), is(notNullValue())); + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaWriterTest.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaWriterTest.java new file mode 100644 index 000000000..ffefeb71a --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/EffectiveJsonSchemaWriterTest.java @@ -0,0 +1,64 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.nio.file.Files; +import java.nio.file.Path; + +import org.json.JSONObject; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.InjectMocks; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class EffectiveJsonSchemaWriterTest { + + @TempDir + Path tempDir; + + @InjectMocks + private EffectiveJsonSchemaWriter effectiveJsonSchemaWriter; + + @Test + public void shouldWriteEffectiveJsonSchemaToFile() throws Exception { + final JSONObject schema = new JSONObject(""" + { "id": "http://example.com/person.json", "type": "object" } + """); + + final Path outputPath = tempDir.resolve("context/person.json"); + + effectiveJsonSchemaWriter.write(schema, outputPath); + + assertThat(Files.exists(outputPath), is(true)); + final JSONObject written = new JSONObject(Files.readString(outputPath)); + assertThat(written.getString("id"), is("http://example.com/person.json")); + assertThat(written.getString("type"), is("object")); + } + + @Test + public void shouldCreateIntermediateParentDirectories() throws Exception { + final JSONObject schema = new JSONObject("{ \"type\": \"object\" }"); + final Path outputPath = tempDir.resolve("deep/nested/path/schema.json"); + + effectiveJsonSchemaWriter.write(schema, outputPath); + + assertThat(Files.exists(outputPath), is(true)); + } + + @Test + public void shouldWritePrettyPrintedJson() throws Exception { + final JSONObject schema = new JSONObject(""" + { "id": "http://example.com/test.json", "type": "object" } + """); + + final Path outputPath = tempDir.resolve("test.json"); + + effectiveJsonSchemaWriter.write(schema, outputPath); + + final String content = Files.readString(outputPath); + assertThat(content.contains("\n"), is(true)); + } +} diff --git a/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/JsonSchemaInlinerTest.java b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/JsonSchemaInlinerTest.java new file mode 100644 index 000000000..ad9c0e26e --- /dev/null +++ b/json-schema-catalog/catalog-effective-json-schema-generation/src/test/java/uk/gov/justice/schema/catalog/generation/effective/JsonSchemaInlinerTest.java @@ -0,0 +1,280 @@ +package uk.gov.justice.schema.catalog.generation.effective; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.when; + +import java.util.Map; + +import org.json.JSONObject; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class JsonSchemaInlinerTest { + + @Mock + private DefinitionNameFactory definitionNameFactory; + + @InjectMocks + private JsonSchemaInliner jsonSchemaInliner; + + @Test + public void shouldReturnSchemaUnchangedIfNoExternalRefs() { + final JSONObject schema = new JSONObject(""" + { + "id": "http://example.com/person.json", + "type": "object", + "properties": { + "name": { "type": "string" } + } + } + """); + + final JSONObject result = jsonSchemaInliner.inline(schema, Map.of()); + + assertThat(result.getString("id"), is("http://example.com/person.json")); + assertThat(result.getString("type"), is("object")); + assertThat(result.has("definitions"), is(false)); + } + + @Test + public void shouldLeaveLocalRefUnchanged() { + final JSONObject schema = new JSONObject(""" + { + "id": "http://example.com/person.json", + "type": "object", + "properties": { + "address": { "$ref": "#/definitions/address" } + }, + "definitions": { + "address": { "type": "object" } + } + } + """); + + final JSONObject result = jsonSchemaInliner.inline(schema, Map.of()); + + assertThat(result.getJSONObject("properties").getJSONObject("address").getString("$ref"), + is("#/definitions/address")); + } + + @Test + public void shouldInlineExternalRefAndRewriteToLocalDefinition() { + final String addressSchemaJson = """ + { + "id": "http://example.com/address.json", + "type": "object", + "properties": { + "city": { "type": "string" } + } + } + """; + + final JSONObject schema = new JSONObject(""" + { + "id": "http://example.com/person.json", + "type": "object", + "properties": { + "homeAddress": { "$ref": "http://example.com/address.json" } + } + } + """); + + when(definitionNameFactory.createFor("http://example.com/address.json")) + .thenReturn("example_com_address"); + + final JSONObject result = jsonSchemaInliner.inline(schema, Map.of( + "http://example.com/address.json", addressSchemaJson)); + + assertThat(result.getJSONObject("properties").getJSONObject("homeAddress").getString("$ref"), + is("#/definitions/example_com_address")); + assertThat(result.getJSONObject("definitions").has("example_com_address"), is(true)); + assertThat(result.getJSONObject("definitions") + .getJSONObject("example_com_address").getString("type"), is("object")); + } + + @Test + public void shouldInlineExternalRefWithFragment() { + final String addressSchemaJson = """ + { + "id": "http://example.com/address.json", + "type": "object", + "definitions": { + "postal": { "type": "object", "properties": { "postcode": { "type": "string" } } } + } + } + """; + + final JSONObject schema = new JSONObject(""" + { + "id": "http://example.com/person.json", + "type": "object", + "properties": { + "address": { "$ref": "http://example.com/address.json#/definitions/postal" } + } + } + """); + + when(definitionNameFactory.createFor("http://example.com/address.json")) + .thenReturn("example_com_address"); + + final JSONObject result = jsonSchemaInliner.inline(schema, Map.of( + "http://example.com/address.json", addressSchemaJson)); + + assertThat(result.getJSONObject("properties").getJSONObject("address").getString("$ref"), + is("#/definitions/example_com_address/definitions/postal")); + assertThat(result.getJSONObject("definitions").has("example_com_address"), is(true)); + } + + @Test + public void shouldLeaveRefUnchangedWhenSchemaNotFoundInCatalog() { + final JSONObject schema = new JSONObject(""" + { + "id": "http://example.com/person.json", + "type": "object", + "properties": { + "address": { "$ref": "http://example.com/unknown.json" } + } + } + """); + + when(definitionNameFactory.createFor("http://example.com/unknown.json")) + .thenReturn("example_com_unknown"); + + final JSONObject result = jsonSchemaInliner.inline(schema, Map.of()); + + assertThat(result.getJSONObject("properties").getJSONObject("address").getString("$ref"), + is("http://example.com/unknown.json")); + assertThat(result.has("definitions"), is(false)); + } + + @Test + public void shouldMergeInlinedDefinitionsWithExistingDefinitions() { + final String addressSchemaJson = """ + { + "id": "http://example.com/address.json", + "type": "object" + } + """; + + final JSONObject schema = new JSONObject(""" + { + "id": "http://example.com/person.json", + "type": "object", + "properties": { + "address": { "$ref": "http://example.com/address.json" } + }, + "definitions": { + "existing": { "type": "string" } + } + } + """); + + when(definitionNameFactory.createFor("http://example.com/address.json")) + .thenReturn("example_com_address"); + + final JSONObject result = jsonSchemaInliner.inline(schema, Map.of( + "http://example.com/address.json", addressSchemaJson)); + + assertThat(result.getJSONObject("definitions").has("existing"), is(true)); + assertThat(result.getJSONObject("definitions").has("example_com_address"), is(true)); + } + + @Test + public void shouldHandleCircularReferencesWithoutInfiniteRecursion() { + final String schemaAJson = """ + { + "id": "http://example.com/a.json", + "type": "object", + "properties": { + "b": { "$ref": "http://example.com/b.json" } + } + } + """; + + final String schemaBJson = """ + { + "id": "http://example.com/b.json", + "type": "object", + "properties": { + "a": { "$ref": "http://example.com/a.json" } + } + } + """; + + final JSONObject schema = new JSONObject(""" + { + "id": "http://example.com/root.json", + "properties": { + "a": { "$ref": "http://example.com/a.json" } + } + } + """); + + when(definitionNameFactory.createFor("http://example.com/a.json")).thenReturn("example_com_a"); + when(definitionNameFactory.createFor("http://example.com/b.json")).thenReturn("example_com_b"); + + final Map allSchemas = Map.of( + "http://example.com/a.json", schemaAJson, + "http://example.com/b.json", schemaBJson); + + final JSONObject result = jsonSchemaInliner.inline(schema, allSchemas); + + assertThat(result.getJSONObject("definitions").has("example_com_a"), is(true)); + assertThat(result.getJSONObject("definitions").has("example_com_b"), is(true)); + } + + @Test + public void shouldInlineRefsNestedInsideArrays() { + final String addressSchemaJson = """ + { "id": "http://example.com/address.json", "type": "object" } + """; + + final JSONObject schema = new JSONObject(""" + { + "id": "http://example.com/person.json", + "allOf": [ + { "$ref": "http://example.com/address.json" } + ] + } + """); + + when(definitionNameFactory.createFor("http://example.com/address.json")) + .thenReturn("example_com_address"); + + final JSONObject result = jsonSchemaInliner.inline(schema, Map.of( + "http://example.com/address.json", addressSchemaJson)); + + assertThat(result.getJSONArray("allOf").getJSONObject(0).getString("$ref"), + is("#/definitions/example_com_address")); + } + + @Test + public void shouldNotAddDefinitionEntryTwiceForSameRef() { + final String addressSchemaJson = """ + { "id": "http://example.com/address.json", "type": "object" } + """; + + final JSONObject schema = new JSONObject(""" + { + "id": "http://example.com/person.json", + "properties": { + "home": { "$ref": "http://example.com/address.json" }, + "work": { "$ref": "http://example.com/address.json" } + } + } + """); + + when(definitionNameFactory.createFor("http://example.com/address.json")) + .thenReturn("example_com_address"); + + final JSONObject result = jsonSchemaInliner.inline(schema, Map.of( + "http://example.com/address.json", addressSchemaJson)); + + assertThat(result.getJSONObject("definitions").length(), is(1)); + } +} diff --git a/json-schema-catalog/effective-json-schema-maven-plugin/pom.xml b/json-schema-catalog/effective-json-schema-maven-plugin/pom.xml new file mode 100644 index 000000000..2760fc9ca --- /dev/null +++ b/json-schema-catalog/effective-json-schema-maven-plugin/pom.xml @@ -0,0 +1,85 @@ + + + + json-schema-catalog + uk.gov.justice.schema + 21.0.0-SNAPSHOT + + 4.0.0 + + effective-json-schema-maven-plugin + maven-plugin + + + + + org.apache.maven.plugins + maven-plugin-plugin + ${plugins.maven-plugin-plugin.version} + + false + effective-json-schema + + + + default-descriptor + process-classes + + + + + + + + + uk.gov.justice.schema + catalog-effective-json-schema-generation + ${project.version} + + + org.apache.maven.plugin-tools + maven-plugin-annotations + provided + + + org.apache.maven + maven-artifact + + + + + org.apache.maven + maven-plugin-api + provided + + + org.apache.maven + maven-core + provided + + + + + org.junit.jupiter + junit-jupiter-api + test + + + org.mockito + mockito-core + test + + + org.mockito + mockito-junit-jupiter + test + + + org.hamcrest + hamcrest + test + + + diff --git a/json-schema-catalog/effective-json-schema-maven-plugin/src/main/java/uk/gov/justice/schema/catalog/maven/EffectiveJsonSchemaMojo.java b/json-schema-catalog/effective-json-schema-maven-plugin/src/main/java/uk/gov/justice/schema/catalog/maven/EffectiveJsonSchemaMojo.java new file mode 100644 index 000000000..d8ba862f7 --- /dev/null +++ b/json-schema-catalog/effective-json-schema-maven-plugin/src/main/java/uk/gov/justice/schema/catalog/maven/EffectiveJsonSchemaMojo.java @@ -0,0 +1,119 @@ +package uk.gov.justice.schema.catalog.maven; + +import static java.util.stream.Collectors.toList; +import static org.apache.maven.plugins.annotations.LifecyclePhase.PROCESS_SOURCES; +import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE; + +import uk.gov.justice.schema.catalog.generation.effective.CatalogJsonSchemaLoader; +import uk.gov.justice.schema.catalog.generation.effective.EffectiveJsonSchemaGenerationException; +import uk.gov.justice.schema.catalog.generation.effective.EffectiveJsonSchemaGenerator; +import uk.gov.justice.schema.catalog.generation.effective.EffectiveJsonSchemaObjectFactory; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; + +/** + * Maven plugin goal that generates an effective JSON schema for each JSON schema file + * in the configured source directory. The effective schema is a single self-contained document + * with all external {@code $ref} references inlined, in the same spirit as Maven's + * {@code help:effective-pom}. + * + *

Effective JSON schema files are written to {@code target/effective-json-schemas/} (or the + * configured {@code outputDirectory}), preserving the relative directory structure of the + * source directory. + * + *

This goal must run after the {@code generate-schema-catalog} goal so that the current + * module's own schemas are available. It is therefore bound to the {@code process-sources} phase + * by default. + */ +@Mojo(name = "generate-effective-json-schemas", + requiresDependencyResolution = COMPILE, + defaultPhase = PROCESS_SOURCES) +public class EffectiveJsonSchemaMojo extends AbstractMojo { + + @Parameter(required = true) + private File sourceDirectory; + + @Parameter(defaultValue = "${project.build.directory}/effective-json-schemas") + private File outputDirectory; + + @Parameter(defaultValue = "${project}", readonly = true, required = true) + private MavenProject project; + + private final EffectiveJsonSchemaObjectFactory objectFactory; + + public EffectiveJsonSchemaMojo() { + this.objectFactory = new EffectiveJsonSchemaObjectFactory(); + } + + EffectiveJsonSchemaMojo(final EffectiveJsonSchemaObjectFactory objectFactory, + final MavenProject project, + final File sourceDirectory, + final File outputDirectory) { + this.objectFactory = objectFactory; + this.project = project; + this.sourceDirectory = sourceDirectory; + this.outputDirectory = outputDirectory; + } + + @Override + public void execute() throws MojoExecutionException { + if (!sourceDirectory.exists()) { + getLog().warn("Source directory '" + sourceDirectory + "' does not exist — skipping effective JSON schema generation"); + return; + } + + try { + final List dependencyJars = collectDependencyJars(); + final CatalogJsonSchemaLoader loader = objectFactory.catalogJsonSchemaLoader(); + final Map allSchemasById = loader.loadAllJsonSchemas( + dependencyJars, sourceDirectory.toPath()); + + final List schemaFiles = findJsonSchemaFiles(sourceDirectory.toPath()); + + if (schemaFiles.isEmpty()) { + getLog().info("No JSON schema files found in '" + sourceDirectory + "' — nothing to generate"); + return; + } + + final EffectiveJsonSchemaGenerator generator = objectFactory.effectiveJsonSchemaGenerator(); + generator.generate(schemaFiles, sourceDirectory.toPath(), allSchemasById, + outputDirectory.toPath()); + + getLog().info("Generated " + schemaFiles.size() + " effective JSON schema(s) in '" + + outputDirectory.getAbsolutePath() + "'"); + + } catch (final EffectiveJsonSchemaGenerationException e) { + throw new MojoExecutionException("Effective JSON schema generation failed", e); + } catch (final IOException e) { + throw new MojoExecutionException("Failed to scan source directory '" + sourceDirectory + "'", e); + } + } + + private List collectDependencyJars() { + return project.getArtifacts().stream() + .filter(artifact -> "jar".equals(artifact.getType())) + .map(Artifact::getFile) + .filter(Objects::nonNull) + .filter(File::exists) + .collect(toList()); + } + + private List findJsonSchemaFiles(final Path sourceDir) throws IOException { + return Files.walk(sourceDir) + .filter(path -> path.toString().endsWith(".json")) + .collect(toList()); + } +} diff --git a/json-schema-catalog/effective-json-schema-maven-plugin/src/test/java/uk/gov/justice/schema/catalog/maven/EffectiveJsonSchemaMojoTest.java b/json-schema-catalog/effective-json-schema-maven-plugin/src/test/java/uk/gov/justice/schema/catalog/maven/EffectiveJsonSchemaMojoTest.java new file mode 100644 index 000000000..87d64f539 --- /dev/null +++ b/json-schema-catalog/effective-json-schema-maven-plugin/src/test/java/uk/gov/justice/schema/catalog/maven/EffectiveJsonSchemaMojoTest.java @@ -0,0 +1,154 @@ +package uk.gov.justice.schema.catalog.maven; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import uk.gov.justice.schema.catalog.generation.effective.CatalogJsonSchemaLoader; +import uk.gov.justice.schema.catalog.generation.effective.EffectiveJsonSchemaGenerationException; +import uk.gov.justice.schema.catalog.generation.effective.EffectiveJsonSchemaGenerator; +import uk.gov.justice.schema.catalog.generation.effective.EffectiveJsonSchemaObjectFactory; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Map; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class EffectiveJsonSchemaMojoTest { + + @TempDir + Path tempDir; + + @Mock + private EffectiveJsonSchemaObjectFactory objectFactory; + + @Mock + private MavenProject project; + + @Mock + private CatalogJsonSchemaLoader catalogJsonSchemaLoader; + + @Mock + private EffectiveJsonSchemaGenerator effectiveJsonSchemaGenerator; + + @Test + public void shouldSkipExecutionWhenSourceDirectoryDoesNotExist() throws Exception { + final File nonExistentDir = new File(tempDir.toFile(), "does-not-exist"); + final File outputDir = tempDir.resolve("output").toFile(); + + final EffectiveJsonSchemaMojo mojo = new EffectiveJsonSchemaMojo( + objectFactory, project, nonExistentDir, outputDir); + + mojo.execute(); + + verify(objectFactory, never()).catalogJsonSchemaLoader(); + } + + @Test + public void shouldSkipExecutionWhenSourceDirectoryContainsNoJsonFiles() throws Exception { + final Path sourceDir = tempDir.resolve("source"); + Files.createDirectories(sourceDir); + Files.writeString(sourceDir.resolve("readme.txt"), "not a schema"); + + when(project.getArtifacts()).thenReturn(Set.of()); + when(objectFactory.catalogJsonSchemaLoader()).thenReturn(catalogJsonSchemaLoader); + when(catalogJsonSchemaLoader.loadAllJsonSchemas(anyList(), any())).thenReturn(Map.of()); + + final EffectiveJsonSchemaMojo mojo = new EffectiveJsonSchemaMojo( + objectFactory, project, sourceDir.toFile(), tempDir.resolve("output").toFile()); + + mojo.execute(); + + verify(objectFactory, never()).effectiveJsonSchemaGenerator(); + } + + @Test + public void shouldCallGeneratorWithCollectedSchemasAndSchemaFiles() throws Exception { + final Path sourceDir = tempDir.resolve("source"); + Files.createDirectories(sourceDir); + Files.writeString(sourceDir.resolve("person.json"), + "{ \"id\": \"http://example.com/person.json\" }"); + + final Map loadedSchemas = Map.of( + "http://example.com/person.json", "{ \"id\": \"http://example.com/person.json\" }"); + + when(project.getArtifacts()).thenReturn(Set.of()); + when(objectFactory.catalogJsonSchemaLoader()).thenReturn(catalogJsonSchemaLoader); + when(catalogJsonSchemaLoader.loadAllJsonSchemas(anyList(), any())).thenReturn(loadedSchemas); + when(objectFactory.effectiveJsonSchemaGenerator()).thenReturn(effectiveJsonSchemaGenerator); + + final File outputDir = tempDir.resolve("output").toFile(); + final EffectiveJsonSchemaMojo mojo = new EffectiveJsonSchemaMojo( + objectFactory, project, sourceDir.toFile(), outputDir); + + mojo.execute(); + + verify(effectiveJsonSchemaGenerator).generate(any(), any(), any(), any()); + } + + @Test + public void shouldCollectJarArtifactsFromProjectAndPassToLoader() throws Exception { + final Path sourceDir = tempDir.resolve("source"); + Files.createDirectories(sourceDir); + Files.writeString(sourceDir.resolve("schema.json"), "{ \"id\": \"http://example.com/schema.json\" }"); + + final File jarFile = tempDir.resolve("dep.jar").toFile(); + jarFile.createNewFile(); + + final Artifact artifact = org.mockito.Mockito.mock(Artifact.class); + when(artifact.getType()).thenReturn("jar"); + when(artifact.getFile()).thenReturn(jarFile); + + when(project.getArtifacts()).thenReturn(Set.of(artifact)); + when(objectFactory.catalogJsonSchemaLoader()).thenReturn(catalogJsonSchemaLoader); + when(catalogJsonSchemaLoader.loadAllJsonSchemas(anyList(), any())).thenReturn(Map.of()); + when(objectFactory.effectiveJsonSchemaGenerator()).thenReturn(effectiveJsonSchemaGenerator); + + final EffectiveJsonSchemaMojo mojo = new EffectiveJsonSchemaMojo( + objectFactory, project, sourceDir.toFile(), tempDir.resolve("output").toFile()); + + mojo.execute(); + + verify(catalogJsonSchemaLoader).loadAllJsonSchemas( + org.mockito.ArgumentMatchers.argThat(list -> list.contains(jarFile)), + any()); + } + + @Test + public void shouldWrapEffectiveJsonSchemaGenerationExceptionInMojoExecutionException() throws Exception { + final Path sourceDir = tempDir.resolve("source"); + Files.createDirectories(sourceDir); + Files.writeString(sourceDir.resolve("schema.json"), "{ \"id\": \"http://example.com/schema.json\" }"); + + when(project.getArtifacts()).thenReturn(Set.of()); + when(objectFactory.catalogJsonSchemaLoader()).thenReturn(catalogJsonSchemaLoader); + when(catalogJsonSchemaLoader.loadAllJsonSchemas(anyList(), any())).thenReturn(Map.of()); + when(objectFactory.effectiveJsonSchemaGenerator()).thenReturn(effectiveJsonSchemaGenerator); + org.mockito.Mockito.doThrow(new EffectiveJsonSchemaGenerationException("boom")) + .when(effectiveJsonSchemaGenerator).generate(any(), any(), any(), any()); + + final EffectiveJsonSchemaMojo mojo = new EffectiveJsonSchemaMojo( + objectFactory, project, sourceDir.toFile(), tempDir.resolve("output").toFile()); + + final MojoExecutionException exception = assertThrows(MojoExecutionException.class, mojo::execute); + + assertThat(exception.getMessage().contains("Effective JSON schema generation failed"), is(true)); + } +} diff --git a/json-schema-catalog/effective-json-schema-plugin-it/pom.xml b/json-schema-catalog/effective-json-schema-plugin-it/pom.xml new file mode 100644 index 000000000..5963eb56b --- /dev/null +++ b/json-schema-catalog/effective-json-schema-plugin-it/pom.xml @@ -0,0 +1,153 @@ + + + + json-schema-catalog + uk.gov.justice.schema + 21.0.0-SNAPSHOT + + 4.0.0 + + effective-json-schema-plugin-it + + + + + + uk.gov.justice.schema + catalog-generation-plugin + ${project.version} + + + generate-schema-catalog + generate-sources + + generate-schema-catalog + + + + uk.gov.justice.schema.catalog.generation.maven.MavenCatalogGeneratorFactory + + + uk.gov.justice.schema.catalog.generation.io.parser.ListOfUriParser + + ${basedir}/src/raml/json/schema + ${project.build.directory}/generated-resources + + **/*.json + + + + ${project.artifactId} + + + + + + + uk.gov.justice.schema + catalog-generation + ${project.version} + + + com.fasterxml.jackson.datatype + jackson-datatype-jakarta-jsonp + ${jackson-datatype-jakarta-jsonp.version} + + + + + + + uk.gov.justice.schema + effective-json-schema-maven-plugin + ${project.version} + + + generate-effective-json-schemas + process-sources + + generate-effective-json-schemas + + + ${basedir}/src/raml/json/schema + ${project.build.directory}/effective-json-schemas + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${plugins.maven.enforcer.version} + + + enforce-rules + + enforce + + + + + ${enforcer.java.version.range} + + + ${enforcer.maven.version.range} + + + Please define plugin versions + false + + + + + + + + + + + + + uk.gov.justice.schema + catalog-effective-json-schema-generation + ${project.version} + test + + + org.json + json + test + + + org.junit.jupiter + junit-jupiter-api + test + + + org.mockito + mockito-core + test + + + org.mockito + mockito-junit-jupiter + test + + + org.hamcrest + hamcrest + test + + + diff --git a/json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/context/person.json b/json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/context/person.json new file mode 100644 index 000000000..82e48199c --- /dev/null +++ b/json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/context/person.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://justice.gov.uk/context/person.json", + "type": "object", + "properties": { + "nino": { + "type": "string" + }, + "name": { + "type": "string" + }, + "home_address": { + "$ref": "http://justice.gov.uk/standards/address.json" + }, + "correspondence_address": { + "$ref": "http://justice.gov.uk/standards/complex_address.json#/definitions/complex_address" + } + }, + "required": [ + "nino", + "name", + "home_address", + "correspondence_address" + ] +} diff --git a/json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/standards/address.json b/json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/standards/address.json new file mode 100644 index 000000000..08abe3bfb --- /dev/null +++ b/json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/standards/address.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://justice.gov.uk/standards/address.json", + "type": "object", + "properties": { + "addressline1": { + "type": "string" + }, + "addressline2": { + "type": "string" + }, + "city": { + "type": "string" + }, + "postcode": { + "type": "string" + } + }, + "required": [ + "addressline1", + "city", + "postcode" + ] +} diff --git a/json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/standards/complex_address.json b/json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/standards/complex_address.json new file mode 100644 index 000000000..5d71a55b7 --- /dev/null +++ b/json-schema-catalog/effective-json-schema-plugin-it/src/raml/json/schema/standards/complex_address.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://justice.gov.uk/standards/complex_address.json", + "type": "object", + "definitions": { + "complex_address": { + "type": "object", + "properties": { + "addressline1": { + "type": "string" + }, + "city": { + "type": "string" + }, + "postcode": { + "type": "string" + }, + "country": { + "type": "string" + } + }, + "required": [ + "addressline1", + "city", + "postcode", + "country" + ] + } + }, + "allOf": [ + { + "$ref": "#/definitions/complex_address" + } + ] +} diff --git a/json-schema-catalog/effective-json-schema-plugin-it/src/test/java/uk/gov/justice/schema/catalog/generation/effective/it/EffectiveJsonSchemaGenerationIT.java b/json-schema-catalog/effective-json-schema-plugin-it/src/test/java/uk/gov/justice/schema/catalog/generation/effective/it/EffectiveJsonSchemaGenerationIT.java new file mode 100644 index 000000000..d21b3ebf0 --- /dev/null +++ b/json-schema-catalog/effective-json-schema-plugin-it/src/test/java/uk/gov/justice/schema/catalog/generation/effective/it/EffectiveJsonSchemaGenerationIT.java @@ -0,0 +1,118 @@ +package uk.gov.justice.schema.catalog.generation.effective.it; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.json.JSONObject; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + +/** + * Integration test that verifies the effective-json-schema-maven-plugin correctly generates + * effective JSON schema files with all external {@code $ref} values inlined. + * + * The plugin runs at {@code process-sources} phase and writes output to + * {@code target/effective-json-schemas/}. This test is deliberately placed in the + * test phase (after process-sources) so the generated files are already present. + */ +@ExtendWith(MockitoExtension.class) +public class EffectiveJsonSchemaGenerationIT { + + private static final Path EFFECTIVE_SCHEMAS_DIR = + Paths.get("target/effective-json-schemas"); + + @Test + public void shouldGenerateEffectiveJsonSchemaForSimpleSchemaWithNoExternalRefs() throws Exception { + final Path effectiveAddressSchema = EFFECTIVE_SCHEMAS_DIR.resolve("standards/address.json"); + + assertThat("Effective schema file should exist: " + effectiveAddressSchema, + Files.exists(effectiveAddressSchema), is(true)); + + final JSONObject schema = new JSONObject(Files.readString(effectiveAddressSchema)); + + assertThat(schema.getString("id"), is("http://justice.gov.uk/standards/address.json")); + assertThat(schema.getString("type"), is("object")); + assertThat(schema.getJSONObject("properties").has("city"), is(true)); + } + + @Test + public void shouldGenerateEffectiveJsonSchemaForPersonWithExternalRefsInlined() throws Exception { + final Path effectivePersonSchema = EFFECTIVE_SCHEMAS_DIR.resolve("context/person.json"); + + assertThat("Effective schema file should exist: " + effectivePersonSchema, + Files.exists(effectivePersonSchema), is(true)); + + final JSONObject schema = new JSONObject(Files.readString(effectivePersonSchema)); + + assertThat(schema.getString("id"), is("http://justice.gov.uk/context/person.json")); + assertThat(schema.getString("type"), is("object")); + } + + @Test + public void shouldInlineAddressSchemaDefinitionIntoPersonEffectiveSchema() throws Exception { + final Path effectivePersonSchema = EFFECTIVE_SCHEMAS_DIR.resolve("context/person.json"); + final JSONObject schema = new JSONObject(Files.readString(effectivePersonSchema)); + + final JSONObject definitions = schema.getJSONObject("definitions"); + + assertThat("Effective person schema should contain inlined address definition", + definitions.has("justice_gov_uk_standards_address"), is(true)); + + final JSONObject inlinedAddress = definitions.getJSONObject("justice_gov_uk_standards_address"); + assertThat(inlinedAddress.getString("type"), is("object")); + assertThat(inlinedAddress.getJSONObject("properties").has("city"), is(true)); + assertThat(inlinedAddress.getJSONObject("properties").has("postcode"), is(true)); + } + + @Test + public void shouldInlineComplexAddressSchemaDefinitionIntoPersonEffectiveSchema() throws Exception { + final Path effectivePersonSchema = EFFECTIVE_SCHEMAS_DIR.resolve("context/person.json"); + final JSONObject schema = new JSONObject(Files.readString(effectivePersonSchema)); + + final JSONObject definitions = schema.getJSONObject("definitions"); + + assertThat("Effective person schema should contain inlined complex_address definition", + definitions.has("justice_gov_uk_standards_complex_address"), is(true)); + } + + @Test + public void shouldRewriteExternalRefToLocalDefinitionInPersonEffectiveSchema() throws Exception { + final Path effectivePersonSchema = EFFECTIVE_SCHEMAS_DIR.resolve("context/person.json"); + final JSONObject schema = new JSONObject(Files.readString(effectivePersonSchema)); + + final String homeAddressRef = schema.getJSONObject("properties") + .getJSONObject("home_address") + .getString("$ref"); + + assertThat("home_address $ref should point to a local definition", + homeAddressRef.startsWith("#/definitions/"), is(true)); + assertThat(homeAddressRef, is("#/definitions/justice_gov_uk_standards_address")); + } + + @Test + public void shouldRewriteFragmentRefToLocalDefinitionInPersonEffectiveSchema() throws Exception { + final Path effectivePersonSchema = EFFECTIVE_SCHEMAS_DIR.resolve("context/person.json"); + final JSONObject schema = new JSONObject(Files.readString(effectivePersonSchema)); + + final String correspondenceRef = schema.getJSONObject("properties") + .getJSONObject("correspondence_address") + .getString("$ref"); + + assertThat("correspondence_address $ref should point to a local definition with fragment path", + correspondenceRef.startsWith("#/definitions/"), is(true)); + assertThat(correspondenceRef, + is("#/definitions/justice_gov_uk_standards_complex_address/definitions/complex_address")); + } + + @Test + public void shouldPreserveRelativeDirectoryStructureOfOutputFiles() { + assertThat(Files.exists(EFFECTIVE_SCHEMAS_DIR.resolve("standards/address.json")), is(true)); + assertThat(Files.exists(EFFECTIVE_SCHEMAS_DIR.resolve("standards/complex_address.json")), is(true)); + assertThat(Files.exists(EFFECTIVE_SCHEMAS_DIR.resolve("context/person.json")), is(true)); + } +} diff --git a/json-schema-catalog/effective-json-schema-plugin.md b/json-schema-catalog/effective-json-schema-plugin.md new file mode 100644 index 000000000..eed6474dc --- /dev/null +++ b/json-schema-catalog/effective-json-schema-plugin.md @@ -0,0 +1,417 @@ +# Effective JSON Schema Maven Plugin + +## Background + +JSON schemas in the CPP platform are designed to be composable. Shared definitions — +UUID patterns, post code formats, common domain types — live in central library schemas +(e.g. `http://justice.gov.uk/domain/core/common/definitions.json`) and are referenced +from context-specific schemas using `$ref`: + +```json +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "caseId": { + "$ref": "http://justice.gov.uk/domain/core/common/definitions.json#/definitions/uuid" + } + } +} +``` + +This composition model keeps schemas DRY but creates a practical problem: to understand +what a schema actually validates you must mentally (or programmatically) chase every `$ref` +across multiple JARs. Validators, code generators, and documentation tools all need the +complete schema in one place. + +The `effective-json-schema-maven-plugin` solves this in the same spirit as Maven's +`help:effective-pom` — it produces a **single, self-contained document** with every +external `$ref` resolved and inlined, written to `target/effective-json-schemas/` at +build time. + +--- + +## What "effective" means + +Given a source schema that references an external definition: + +**Source (`src/raml/json/schema/feature-permission.json`):** +```json +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "permissionId": { + "$ref": "http://justice.gov.uk/domain/core/common/definitions.json#/definitions/uuid" + } + } +} +``` + +The plugin produces an effective schema where the referenced definitions file is inlined +under a sanitised key in a top-level `definitions` block, and the `$ref` is rewritten to +point at that local copy: + +**Output (`target/effective-json-schemas/feature-permission.json`):** +```json +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "definitions": { + "justice_gov_uk_domain_core_common_definitions": { + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://justice.gov.uk/domain/core/common/definitions.json", + "definitions": { + "uuid": { + "pattern": "[a-fA-F0-9]{8}-...", + "type": "string" + } + } + } + }, + "properties": { + "permissionId": { + "$ref": "#/definitions/justice_gov_uk_domain_core_common_definitions/definitions/uuid" + } + } +} +``` + +The effective schema is valid JSON Schema draft-04. All `$ref` values point to `#/…` +(local document) rather than external URLs, making the schema fully self-contained. + +--- + +## Maven coordinates + +| Artifact | Group ID | Artifact ID | +|---|---|---| +| Maven plugin | `uk.gov.justice.schema` | `effective-json-schema-maven-plugin` | +| Generation library | `uk.gov.justice.schema` | `catalog-effective-json-schema-generation` | + +Both are versioned as part of `cp-framework-libraries` (`json-schema-catalog` sub-project). + +--- + +## How it activates automatically + +The plugin is configured in `cpp-platform-maven-service-parent-pom` so every context +module with a `src/raml` directory gets it with zero additional pom changes. + +### In `pluginManagement` + +Default configuration is declared in `pluginManagement` (applies to all modules): + +```xml + + uk.gov.justice.schema + effective-json-schema-maven-plugin + ${framework-libraries.version} + + + generate-effective-json-schemas + + ${schema.generation.source.directory} + ${project.build.directory}/effective-json-schemas + + generate-effective-json-schemas + process-sources + + + +``` + +`schema.generation.source.directory` defaults to `src/raml/json/schema`. + +### In the `raml-catalog-generation` profile + +The profile activates automatically when a module contains a `src/raml` directory: + +```xml + + raml-catalog-generation + + src/raml + + + + + + uk.gov.justice.schema + effective-json-schema-maven-plugin + ${framework-libraries.version} + + + generate-effective-json-schemas + generate-effective-json-schemas + process-sources + + + + + + +``` + +Any module with `src/raml` will have both the catalog generation plugin (phase: +`generate-sources`) and the effective schema plugin (phase: `process-sources`) active. + +--- + +## Build lifecycle + +``` +generate-sources → catalog-generation-plugin builds META-INF/schema_catalog.json + (indexes this module's own schemas) + +process-sources → effective-json-schema-maven-plugin + 1. Loads all schemas from dependency JARs (via their catalogs, then + via full classpath scan as fallback) + 2. Loads all schemas from the local source directory + 3. For each .json file in the source directory, resolves and inlines + every external $ref into a self-contained effective schema + 4. Writes results to target/effective-json-schemas/ +``` + +The ordering matters: the catalog-generation plugin runs first so the local module's +schemas are available before the inliner runs. + +--- + +## Plugin parameters + +| Parameter | Default | Required | Description | +|---|---|---|---| +| `sourceDirectory` | `${schema.generation.source.directory}` | yes | Directory containing source JSON schema files to process | +| `outputDirectory` | `${project.build.directory}/effective-json-schemas` | no | Directory where effective schemas are written | + +--- + +## Schema discovery — how `$ref` targets are resolved + +The plugin builds a map of `{ schemaId → rawJson }` before inlining. It populates this +map from three sources, in precedence order: + +### 1. Dependency JAR catalogs (highest precedence) + +Every dependency JAR that contains a `META-INF/schema_catalog.json` is opened. The +catalog lists each schema's `id` and its path within the JAR. Those schemas are read +and added to the map first. + +This is the primary mechanism for resolving refs to platform library schemas +(e.g. `cpp-platform-core-domain`) and shared domain schemas. + +### 2. Full classpath scan (fallback) + +After catalog-based loading, every `.json` entry in every dependency JAR is scanned. +If a file contains a top-level `"id"` field and can be parsed, it is added to the map +via `putIfAbsent` — catalog-loaded schemas always take precedence. + +This fallback handles JARs that carry JSON schema files but have no +`META-INF/schema_catalog.json` (e.g. schemas bundled by a context that does not +publish a catalog). + +### 3. Local source directory + +Finally, every `.json` file in the configured `sourceDirectory` that contains an `"id"` +field is added to the map (again using `put`, so local schemas override dependency +schemas with the same ID). + +--- + +## Fragment references + +A `$ref` that includes a JSON Pointer fragment: + +```json +{ "$ref": "http://justice.gov.uk/domain/core/common/definitions.json#/definitions/uuid" } +``` + +is inlined so the full referenced schema is placed in `definitions` and the fragment +path is preserved: + +```json +{ "$ref": "#/definitions/justice_gov_uk_domain_core_common_definitions/definitions/uuid" } +``` + +The definition name is derived from the schema's base URL by stripping the protocol, +replacing non-alphanumeric characters with underscores, and removing the `.json` suffix: + +| Schema URL | Definition name | +|---|---| +| `http://justice.gov.uk/domain/core/common/definitions.json` | `justice_gov_uk_domain_core_common_definitions` | +| `http://justice.gov.uk/standards/complex_address.json` | `justice_gov_uk_standards_complex_address` | + +--- + +## Edge cases + +### Circular references + +If schema A references schema B which references schema A, the plugin detects the cycle +and leaves the back-reference pointing at the external URL rather than causing infinite +recursion. + +### Unresolvable `$ref` + +If a `$ref` target cannot be found in any dependency JAR or the local source directory, +the `$ref` is left unchanged in the output. A warning is not emitted — this preserves +forward compatibility when a schema references a peer that is not yet on the classpath. + +### Schema file with invalid JSON or duplicate keys + +If a source schema file cannot be parsed (e.g. duplicate JSON keys), the file is +skipped with a `WARN` log entry and all other schemas are still processed: + +``` +[WARNING] Skipping 'src/raml/json/schema/bad.json': could not parse as JSON schema (Duplicate key "name" ...) +``` + +Similarly, any classpath-scanned schema that fails the JSON parser is silently skipped +and does not block other schemas from being resolved. + +--- + +## Running manually + +To regenerate effective schemas for a single module without running the full build: + +```bash +# In a context API module (e.g. usersgroups-query-api) +mvn process-sources -Denforcer.skip=true +``` + +The output lands in `target/effective-json-schemas/` mirroring the relative path +structure of the source directory: + +``` +target/effective-json-schemas/ +├── feature-permission.json +├── group-details-schema.json +├── user-details-schema.json +└── ... +``` + +--- + +## Example output walkthrough + +Source schema (`person.json`) references two external schemas: + +```json +{ + "id": "http://justice.gov.uk/context/person.json", + "type": "object", + "properties": { + "home_address": { "$ref": "http://justice.gov.uk/standards/address.json" }, + "correspondence_address":{ "$ref": "http://justice.gov.uk/standards/complex_address.json#/definitions/complex_address" }, + "name": { "type": "string" }, + "nino": { "type": "string" } + }, + "required": ["nino","name","home_address","correspondence_address"] +} +``` + +Effective schema output: + +```json +{ + "id": "http://justice.gov.uk/context/person.json", + "type": "object", + "definitions": { + "justice_gov_uk_standards_address": { + "type": "object", + "properties": { + "addressline1": { "type": "string" }, + "city": { "type": "string" }, + "postcode": { "type": "string" }, + "addressline2": { "type": "string" } + }, + "required": ["addressline1","city","postcode"] + }, + "justice_gov_uk_standards_complex_address": { + "type": "object", + "definitions": { + "complex_address": { + "type": "object", + "properties": { + "addressline1": { "type": "string" }, + "city": { "type": "string" }, + "postcode": { "type": "string" }, + "country": { "type": "string" } + }, + "required": ["addressline1","city","postcode","country"] + } + } + } + }, + "properties": { + "home_address": { "$ref": "#/definitions/justice_gov_uk_standards_address" }, + "correspondence_address": { "$ref": "#/definitions/justice_gov_uk_standards_complex_address/definitions/complex_address" }, + "name": { "type": "string" }, + "nino": { "type": "string" } + }, + "required": ["nino","name","home_address","correspondence_address"] +} +``` + +--- + +## Module structure + +``` +json-schema-catalog/ +├── catalog-effective-json-schema-generation/ # Core library (no Maven API dependency) +│ └── src/main/java/.../generation/effective/ +│ ├── CatalogJsonSchemaLoader.java # Loads schemas from JARs + source dir +│ ├── DefinitionNameFactory.java # Converts schema URLs to definition keys +│ ├── EffectiveJsonSchemaGenerator.java # Orchestrates inlining per schema file +│ ├── EffectiveJsonSchemaObjectFactory.java# Wires components together (no DI framework) +│ ├── EffectiveJsonSchemaWriter.java # Writes output files +│ ├── EffectiveJsonSchemaGenerationException.java +│ └── JsonSchemaInliner.java # Core $ref resolution and rewriting +│ +├── effective-json-schema-maven-plugin/ # Thin Maven Mojo wrapper +│ └── src/main/java/.../catalog/maven/ +│ └── EffectiveJsonSchemaMojo.java +│ +└── effective-json-schema-plugin-it/ # Integration test (runs the plugin for real) + └── src/test/java/.../it/ + └── EffectiveJsonSchemaGenerationIT.java +``` + +The core library (`catalog-effective-json-schema-generation`) has no dependency on the +Maven plugin API and can be used directly in tests or tooling without a Maven runtime. + +--- + +## Testing + +### Unit tests + +Every class has a dedicated JUnit 5 test using `@ExtendWith(MockitoExtension.class)`. +Run from the library module: + +```bash +cd catalog-effective-json-schema-generation +mvn test -Denforcer.skip=true +``` + +### Integration test + +`effective-json-schema-plugin-it` is a self-contained Maven module that carries real +JSON schema files (with cross-schema `$ref` relationships) and runs the plugin as part +of its own build. The IT test class reads the generated files from +`target/effective-json-schemas/` and asserts on their content. + +```bash +cd effective-json-schema-plugin-it +mvn clean verify -Denforcer.skip=true +``` + +The IT covers: + +- Schemas with no external refs are passed through unchanged +- External refs are inlined into `definitions` +- Fragment refs (`schema.json#/definitions/foo`) are rewritten correctly +- The schema `"id"` field is preserved in the output +- Nested definitions (schema referencing schema referencing schema) are all inlined diff --git a/json-schema-catalog/pom.xml b/json-schema-catalog/pom.xml index 6c789e7a7..d99c16c82 100644 --- a/json-schema-catalog/pom.xml +++ b/json-schema-catalog/pom.xml @@ -25,6 +25,9 @@ schema-example-context catalog-generation-plugin schema-service + catalog-effective-json-schema-generation + effective-json-schema-maven-plugin + effective-json-schema-plugin-it