diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-09-23 15:13:36 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2024-11-01 10:36:08 +0000 |
commit | ac4b5296ab01fc25d89cc4fc89b6407fb7254f1b (patch) | |
tree | 4fd2fe6f3b611dbdba48d6f4947bfb716eb08dc5 | |
parent | f8ff4184fe5cc5d5a84c266d50e63c289729ef2f (diff) |
Moving message bus configurations to its own module
Issue-ID: POLICY-5131
Change-Id: Ibbcdc487300767e7b10d69e9b388c50f09e1adbc
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
-rw-r--r-- | common-parameters/pom.xml | 33 | ||||
-rw-r--r-- | common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java | 9 | ||||
-rw-r--r-- | common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java | 36 | ||||
-rw-r--r-- | common-parameters/src/main/java/org/onap/policy/common/parameters/rest/RestClientParameters.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestClientParameters.java) | 6 | ||||
-rw-r--r-- | common-parameters/src/main/java/org/onap/policy/common/parameters/rest/RestServerParameters.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestServerParameters.java) | 4 | ||||
-rw-r--r-- | common-parameters/src/main/java/org/onap/policy/common/parameters/topic/BusTopicParams.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java) | 16 | ||||
-rw-r--r-- | common-parameters/src/main/java/org/onap/policy/common/parameters/topic/TopicParameterGroup.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java) | 2 | ||||
-rw-r--r-- | common-parameters/src/main/java/org/onap/policy/common/parameters/topic/TopicParameters.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameters.java) | 5 | ||||
-rw-r--r-- | common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java | 4 | ||||
-rw-r--r-- | common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java | 98 | ||||
-rw-r--r-- | common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java | 4 | ||||
-rw-r--r-- | common-parameters/src/test/java/org/onap/policy/common/parameters/rest/RestClientParametersTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestClientParametersTest.java) | 2 | ||||
-rw-r--r-- | common-parameters/src/test/java/org/onap/policy/common/parameters/topic/BusTopicParamsTest.java | 201 | ||||
-rw-r--r-- | gson/pom.xml | 16 | ||||
-rw-r--r-- | gson/src/test/java/org/onap/policy/common/gson/internal/ClassWalkerTest.java | 58 | ||||
-rw-r--r-- | message-bus/pom.xml | 142 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/Topic.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/Topic.java) | 4 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicEndpoint.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java) | 14 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicEndpointManager.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java) | 5 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicEndpointProxy.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java) | 18 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicListener.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicListener.java) | 17 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicRegisterable.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicRegisterable.java) | 17 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicSink.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSink.java) | 15 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicSource.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSource.java) | 15 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/ApiKeyEnabled.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/ApiKeyEnabled.java) | 17 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusConsumer.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java) | 24 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusPublisher.java | 43 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusTopicBase.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java) | 22 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusTopicSink.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java) | 6 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusTopicSource.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java) | 6 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/InlineBusTopicSink.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java) | 28 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/SingleThreadedBusTopicSource.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java) | 25 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/TopicBase.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBase.java) | 8 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/TopicBaseFactory.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/TopicBaseFactory.java) | 7 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/TopicBaseHashedFactory.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/TopicBaseHashedFactory.java) | 9 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/BidirectionalTopicClient.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClient.java) | 20 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/BidirectionalTopicClientException.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientException.java) | 4 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/TopicSinkClient.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java) | 8 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/TopicSinkClientException.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientException.java) | 6 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/IndexedKafkaTopicSinkFactory.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSinkFactory.java) | 24 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/IndexedKafkaTopicSourceFactory.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSourceFactory.java) | 43 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/InlineKafkaTopicSink.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSink.java) | 11 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaPublisherWrapper.java | 121 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicFactories.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicFactories.java) | 4 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSink.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSink.java) | 6 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSinkFactory.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkFactory.java) | 6 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSource.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSource.java) | 6 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSourceFactory.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceFactory.java) | 6 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/SingleThreadedKafkaTopicSource.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSource.java) | 15 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicEndpoint.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java) | 11 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicFactories.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java) | 3 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicFactory.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactory.java) | 15 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSink.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java) | 7 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSinkFactory.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactory.java) | 10 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSource.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java) | 7 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSourceFactory.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSourceFactory.java) | 10 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/features/NetLoggerFeatureApi.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java) | 9 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/features/NetLoggerFeatureProviders.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java) | 3 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/properties/MessageBusProperties.java | 78 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/utils/KafkaPropertyUtils.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/KafkaPropertyUtils.java) | 16 | ||||
-rw-r--r-- | message-bus/src/main/java/org/onap/policy/common/message/bus/utils/NetLoggerUtil.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java) | 9 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/CommonTestData.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java) | 47 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/TopicEndpointProxyTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java) | 28 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/TopicParameterGroupTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java) | 19 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/BusConsumerTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java) | 22 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/BusTopicBaseTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java) | 6 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/BusTopicFactoryTestBase.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java) | 39 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/InlineBusTopicSinkTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java) | 10 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/SingleThreadedBusTopicSourceTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java) | 10 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicBaseTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java) | 16 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicFactoryTestBase.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java) | 24 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicPropertyBuilder.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java) | 3 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicTestBase.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicTestBase.java) | 11 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/client/BidirectionalTopicClientTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientTest.java) | 32 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/client/TopicClientExceptionTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicClientExceptionTest.java) | 2 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/client/TopicSinkClientTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java) | 13 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/IndexedKafkaTopicSourceFactoryTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSourceFactoryTest.java) | 15 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/InlineKafkaTopicSinkTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSinkTest.java) | 8 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaPublisherWrapperTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/KafkaPublisherWrapperTest.java) | 9 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicFactoryTestBase.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicFactoryTestBase.java) | 9 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicPropertyBuilder.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicPropertyBuilder.java) | 19 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSinkFactoryTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkFactoryTest.java) | 21 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSinkTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkTest.java) | 2 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSourceFactoryTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceFactoryTest.java) | 15 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSourceTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceTest.java) | 2 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/SingleThreadedKafkaTopicSourceTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSourceTest.java) | 15 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicEndpointTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpointTest.java) | 7 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicFactoryTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactoryTest.java) | 28 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicPropertyBuilder.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicPropertyBuilder.java) | 27 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSinkFactoryTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactoryTest.java) | 2 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSinkTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkTest.java) | 2 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSourceFactoryTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSourceFactoryTest.java) | 2 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSourceTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSourceTest.java) | 4 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/features/NetLoggerFeatureApiTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApiTest.java) | 6 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/utils/KafkaPropertyUtilsTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/KafkaPropertyUtilsTest.java) | 7 | ||||
-rw-r--r-- | message-bus/src/test/java/org/onap/policy/common/message/bus/utils/NetLoggerUtilTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java) | 18 | ||||
-rw-r--r-- | message-bus/src/test/resources/META-INF/services/org.onap.policy.common.message.bus.features.NetLoggerFeatureApi | 1 | ||||
-rw-r--r-- | message-bus/src/test/resources/logback-test.xml | 42 | ||||
-rw-r--r-- | message-bus/src/test/resources/org/onap/policy/common/message/bus/event/TopicEndpointProxyTest.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json) | 0 | ||||
-rw-r--r-- | message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/BusTopicBaseTest.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json) | 0 | ||||
-rw-r--r-- | message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/InlineBusTopicSinkTest.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json) | 0 | ||||
-rw-r--r-- | message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/SingleThreadedBusTopicSourceTest.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json) | 0 | ||||
-rw-r--r-- | message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/TopicBaseTest.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json) | 0 | ||||
-rw-r--r-- | message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_all_params.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json) | 0 | ||||
-rw-r--r-- | message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_invalid.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_invalid.json) | 0 | ||||
-rw-r--r-- | message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_missing_mandatory.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json) | 0 | ||||
-rw-r--r-- | message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_valid.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json) | 0 | ||||
-rw-r--r-- | policy-endpoints/pom.xml | 119 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java | 144 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java | 3 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java | 6 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java | 4 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/IndexedHttpServletServerFactory.java | 2 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java | 2 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java | 5 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java | 3 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java | 3 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java | 3 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/TypedMessageListener.java | 3 | ||||
-rw-r--r-- | policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java | 54 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParamsTest.java | 161 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java | 15 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java | 4 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java | 2 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/JsonListenerTest.java | 2 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcherTest.java | 2 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java | 2 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java | 24 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/rest/CommonTestData.java | 99 | ||||
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/rest/RestServerParametersTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java) | 9 | ||||
-rw-r--r-- | policy-endpoints/src/test/resources/META-INF/services/org.onap.policy.common.endpoints.features.NetLoggerFeatureApi | 1 | ||||
-rw-r--r-- | policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSinkTest.json | 20 | ||||
-rw-r--r-- | policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSourceTest.json | 19 | ||||
-rw-r--r-- | policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/RestServerParameters_invalid.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json) | 0 | ||||
-rw-r--r-- | policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/RestServerParameters_valid.json (renamed from policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json) | 0 | ||||
-rw-r--r-- | policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_all_params.json | 62 | ||||
-rw-r--r-- | policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_invalid.json | 6 | ||||
-rw-r--r-- | policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_missing_mandatory.json | 12 | ||||
-rw-r--r-- | policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_valid.json | 30 | ||||
-rw-r--r-- | pom.xml | 9 | ||||
-rw-r--r-- | spring-utils/pom.xml | 10 | ||||
-rw-r--r-- | utils-test/pom.xml | 75 | ||||
-rw-r--r-- | utils/pom.xml | 56 | ||||
-rw-r--r-- | utils/src/main/java/org/onap/policy/common/utils/properties/PropertyUtils.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/PropertyUtils.java) | 2 | ||||
-rw-r--r-- | utils/src/main/java/org/onap/policy/common/utils/report/HealthCheckReport.java (renamed from policy-endpoints/src/main/java/org/onap/policy/common/endpoints/report/HealthCheckReport.java) | 7 | ||||
-rw-r--r-- | utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java | 21 | ||||
-rw-r--r-- | utils/src/test/java/org/onap/policy/common/utils/properties/PropertyUtilsTest.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java) | 2 | ||||
-rw-r--r-- | utils/src/test/java/org/onap/policy/common/utils/report/TestHealthCheckReport.java (renamed from policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java) | 32 | ||||
-rw-r--r-- | utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java | 2 |
149 files changed, 1739 insertions, 1235 deletions
diff --git a/common-parameters/pom.xml b/common-parameters/pom.xml index 3257d3b3..5c112a91 100644 --- a/common-parameters/pom.xml +++ b/common-parameters/pom.xml @@ -19,7 +19,8 @@ SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.policy.common</groupId> @@ -29,17 +30,18 @@ <artifactId>common-parameters</artifactId> <name>${project.artifactId}</name> - <description>[${project.parent.artifactId}] module provides common property and parameter handling the ONAP Policy Framework</description> + <description>[${project.parent.artifactId}] module provides common property and parameter handling the ONAP Policy + Framework + </description> <dependencies> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <scope>provided</scope> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> </dependency> <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> + <groupId>com.google.re2j</groupId> + <artifactId>re2j</artifactId> </dependency> <dependency> <groupId>jakarta.validation</groupId> @@ -50,21 +52,22 @@ <artifactId>commons-lang3</artifactId> </dependency> <dependency> - <groupId>com.google.re2j</groupId> - <artifactId>re2j</artifactId> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> </dependency> <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> </dependency> <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> </dependency> </dependencies> </project> diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java index ab610933..c26b7b44 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterGroup.java @@ -1,8 +1,9 @@ /*- - * ============LICENSE_START======================================================= + * ============LICENSE_START========================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * Modifications Copyright (C) 2024 Nordix Foundation. + * ================================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -33,14 +34,14 @@ public interface ParameterGroup { * * @return the group name */ - public String getName(); + String getName(); /** * Set the group name. * * @param name the group name */ - public void setName(final String name); + void setName(final String name); /** * Validate parameters. diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java index 309fd001..e6017410 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResult.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -29,14 +30,14 @@ public interface ValidationResult { * * @return the name */ - public String getName(); + String getName(); /** * Gets the status of validation. * * @return the status */ - public ValidationStatus getStatus(); + ValidationStatus getStatus(); /** * Checks if the result is valid. @@ -44,7 +45,7 @@ public interface ValidationResult { * @return true, if is valid */ default boolean isValid() { - return getStatus().isValid(); + return getStatus().isValid(); } /** @@ -53,7 +54,7 @@ public interface ValidationResult { * @return true, if is clean */ default boolean isClean() { - return getStatus().isClean(); + return getStatus().isClean(); } /** @@ -63,25 +64,26 @@ public interface ValidationResult { */ default String getResult() { return getResult( - ParameterConstants.DEFAULT_INITIAL_RESULT_INDENTATION, - ParameterConstants.DEFAULT_RESULT_INDENTATION, - ParameterConstants.DO_NOT_SHOW_CLEAN_RESULTS); + ParameterConstants.DEFAULT_INITIAL_RESULT_INDENTATION, + ParameterConstants.DEFAULT_RESULT_INDENTATION, + ParameterConstants.DO_NOT_SHOW_CLEAN_RESULTS); } /** * Gets the validation result. * * @param initialIndentation the indentation to use on the main result output - * @param subIndentation the indentation to use on sub parts of the result output - * @param showClean output information on clean fields + * @param subIndentation the indentation to use on sub parts of the result output + * @param showClean output information on clean fields * @return the result */ - public String getResult(final String initialIndentation, final String subIndentation, final boolean showClean); - + String getResult(final String initialIndentation, final String subIndentation, final boolean showClean); + /** - * Set a validation result. - * @param status The validation status the field is receiving + * Set a validation result. + * + * @param status The validation status the field is receiving * @param message The validation message explaining the validation status */ - public void setResult(final ValidationStatus status, final String message); + void setResult(final ValidationStatus status, final String message); }
\ No newline at end of file diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestClientParameters.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/rest/RestClientParameters.java index 5d02e753..bb03c066 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestClientParameters.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/rest/RestClientParameters.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * Copyright (C) 2021, 2024 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,12 +19,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.parameters; +package org.onap.policy.common.parameters.rest; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.ParameterGroup; import org.onap.policy.common.parameters.ValidationStatus; +import org.onap.policy.common.parameters.topic.BusTopicParams; public class RestClientParameters extends BusTopicParams implements ParameterGroup { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestServerParameters.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/rest/RestServerParameters.java index 9ffe5cb7..8684b163 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/RestServerParameters.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/rest/RestServerParameters.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019,2023 Nordix Foundation. + * Copyright (C) 2019, 2023-2024 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.parameters; +package org.onap.policy.common.parameters.rest; import lombok.Getter; import org.onap.policy.common.parameters.ParameterGroupImpl; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/topic/BusTopicParams.java index 53a6ab66..66ac57c5 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/topic/BusTopicParams.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.parameters.topic; import java.util.List; import java.util.Map; @@ -109,11 +109,11 @@ public class BusTopicParams { return StringUtils.isBlank(longitude); } - boolean isConsumerInstanceInvalid() { + public boolean isConsumerInstanceInvalid() { return StringUtils.isBlank(consumerInstance); } - boolean isConsumerGroupInvalid() { + public boolean isConsumerGroupInvalid() { return StringUtils.isBlank(consumerGroup); } @@ -127,14 +127,14 @@ public class BusTopicParams { boolean isServersInvalid() { return (servers == null || servers.isEmpty() - || (servers.size() == 1 && ("".equals(servers.get(0))))); + || (servers.size() == 1 && ("".equals(servers.get(0))))); } - boolean isTopicInvalid() { + public boolean isTopicInvalid() { return StringUtils.isBlank(topic); } - boolean isPartitionIdInvalid() { + public boolean isPartitionIdInvalid() { return StringUtils.isBlank(partitionId); } @@ -143,7 +143,7 @@ public class BusTopicParams { } public boolean isPortInvalid() { - return (getPort() <= 0 || getPort() >= 65535); + return (getPort() <= 0 || getPort() >= 65535); } /** @@ -166,7 +166,7 @@ public class BusTopicParams { return StringUtils.isNotBlank(password); } - boolean isAdditionalPropsValid() { + public boolean isAdditionalPropsValid() { return additionalProps != null; } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/topic/TopicParameterGroup.java index d63134bc..c9d5e3e8 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroup.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/topic/TopicParameterGroup.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.parameters; +package org.onap.policy.common.parameters.topic; import java.util.List; import lombok.Getter; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameters.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/topic/TopicParameters.java index 94042441..2b8bfbdb 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/parameters/TopicParameters.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/topic/TopicParameters.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2024 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,12 +19,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.parameters; +package org.onap.policy.common.parameters.topic; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.parameters.annotations.NotBlank; import org.onap.policy.common.parameters.annotations.NotNull; diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java index 2fc09949..ab733aed 100644 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java +++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidationResult.java @@ -112,7 +112,7 @@ class TestBeanValidationResult { @Test void testValidateNotNullList() { - List<ValidationResult> list = Arrays.asList(clean); + List<ValidationResult> list = List.of(clean); assertTrue(bean.validateNotNullList(MY_LIST, list, item -> item)); assertTrue(bean.isValid()); assertNull(bean.getResult()); @@ -141,7 +141,7 @@ class TestBeanValidationResult { assertTrue(bean.isValid()); assertNull(bean.getResult()); - list = Arrays.asList(clean); + list = List.of(clean); bean = new BeanValidationResult(NAME, OBJECT); assertTrue(bean.validateList(MY_LIST, list, item -> item)); assertTrue(bean.isValid()); diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java index 31c34209..c4211136 100644 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java +++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestBeanValidator.java @@ -82,9 +82,6 @@ class TestBeanValidator { data.strValue = STRING_VALUE; assertTrue(validator.validateTop(TOP, data).isValid()); - /** - * Repeat with a subclass. - */ @Getter class Derived extends Data { @Min(10) @@ -119,8 +116,8 @@ class TestBeanValidator { @Test void testVerNotNull() { + @Getter class NotNullCheck { - @Getter @Min(1) @NotNull Integer intValue; @@ -138,8 +135,8 @@ class TestBeanValidator { @Test void testVerNotBlank() { + @Getter class NotBlankCheck { - @Getter @NotBlank String strValue; } @@ -164,8 +161,8 @@ class TestBeanValidator { /* * Class with "blank" annotation on an integer. */ + @Getter class NotBlankInt { - @Getter @NotBlank int intValue; } @@ -180,8 +177,8 @@ class TestBeanValidator { */ @Test void testVerSizeCollection() { + @Getter class CollectionSizeCheck { - @Getter @Size(min = 3) Collection<Integer> items; } @@ -210,8 +207,8 @@ class TestBeanValidator { */ @Test void testVerSizeMap() { + @Getter class MapSizeCheck { - @Getter @Size(min = 3) Map<Integer, Integer> items; } @@ -240,8 +237,8 @@ class TestBeanValidator { */ @Test void testVerSizeOther() { + @Getter class OtherSizeCheck { - @Getter @Size(min = 3) Integer items; } @@ -254,8 +251,8 @@ class TestBeanValidator { @Test void testVerRegex() { + @Getter class RegexCheck { - @Getter @Pattern(regexp = "[a-f]*") String strValue; } @@ -272,8 +269,8 @@ class TestBeanValidator { assertTrue(validator.validateTop(TOP, regexCheck).isValid()); // invalid regex + @Getter class InvalidRegexCheck { - @Getter @Pattern(regexp = "[a-f") String strValue; } @@ -292,8 +289,8 @@ class TestBeanValidator { /* * Class with "regex" annotation on an integer. */ + @Getter class RegexInt { - @Getter @Pattern(regexp = "[a-f]*") int intValue; } @@ -309,8 +306,8 @@ class TestBeanValidator { /* * Field is not a number. */ + @Getter class NonNumeric { - @Getter @Max(100) String strValue; } @@ -322,68 +319,68 @@ class TestBeanValidator { /* * Integer field. */ + @Getter class IntField { - @Getter @Max(100) Integer intValue; } // ok value IntField intField = new IntField(); - assertNumeric("testVerMax-integer", intField, value -> { + assertNumeric(intField, value -> { intField.intValue = value; - }, INT_FIELD, "maximum", INT_VALUE, 100, 101); + }, INT_FIELD, "maximum", 100, 101); /* * Long field. */ + @Getter class LongField { - @Getter @Max(100) Long numValue; } // ok value LongField longField = new LongField(); - assertNumeric("testVerMax-long", longField, value -> { + assertNumeric(longField, value -> { longField.numValue = (long) value; - }, NUM_FIELD, "maximum", INT_VALUE, 100, 101); + }, NUM_FIELD, "maximum", 100, 101); /* * Float field. */ + @Getter class FloatField { - @Getter @Max(100) Float numValue; } // ok value FloatField floatField = new FloatField(); - assertNumeric("testVerMax-float", floatField, value -> { + assertNumeric(floatField, value -> { floatField.numValue = (float) value; - }, NUM_FIELD, "maximum", INT_VALUE, 100, 101); + }, NUM_FIELD, "maximum", 100, 101); /* * Double field. */ + @Getter class DoubleField { - @Getter @Max(100) Double numValue; } // ok value DoubleField doubleField = new DoubleField(); - assertNumeric("testVerMax-double", doubleField, value -> { + assertNumeric(doubleField, value -> { doubleField.numValue = (double) value; - }, NUM_FIELD, "maximum", INT_VALUE, 100, 101); + }, NUM_FIELD, "maximum", 100, 101); /* * Atomic Integer field (which is a subclass of Number). */ + @Getter class AtomIntValue { - @Getter @Max(100) AtomicInteger numValue; } @@ -403,8 +400,8 @@ class TestBeanValidator { /* * Field is not a number. */ + @Getter class NonNumeric { - @Getter @Min(10) String strValue; } @@ -416,68 +413,68 @@ class TestBeanValidator { /* * Integer field. */ + @Getter class IntField { - @Getter @Min(10) Integer intValue; } // ok value IntField intField = new IntField(); - assertNumeric("testVerMin-integer", intField, value -> { + assertNumeric(intField, value -> { intField.intValue = value; - }, INT_FIELD, "minimum", INT_VALUE, 10, 1); + }, INT_FIELD, "minimum", 10, 1); /* * Long field. */ + @Getter class LongField { - @Getter @Min(10) Long numValue; } // ok value LongField longField = new LongField(); - assertNumeric("testVerMin-long", longField, value -> { + assertNumeric(longField, value -> { longField.numValue = (long) value; - }, NUM_FIELD, "minimum", INT_VALUE, 10, 1); + }, NUM_FIELD, "minimum", 10, 1); /* * Float field. */ + @Getter class FloatField { - @Getter @Min(10) Float numValue; } // ok value FloatField floatField = new FloatField(); - assertNumeric("testVerMin-float", floatField, value -> { + assertNumeric(floatField, value -> { floatField.numValue = (float) value; - }, NUM_FIELD, "minimum", INT_VALUE, 10, 1); + }, NUM_FIELD, "minimum", 10, 1); /* * Double field. */ + @Getter class DoubleField { - @Getter @Min(10) Double numValue; } // ok value DoubleField doubleField = new DoubleField(); - assertNumeric("testVerMin-double", doubleField, value -> { + assertNumeric(doubleField, value -> { doubleField.numValue = (double) value; - }, NUM_FIELD, "minimum", INT_VALUE, 10, 1); + }, NUM_FIELD, "minimum", 10, 1); /* * Atomic Integer field (which is a subclass of Number). */ + @Getter class AtomIntValue { - @Getter @Min(10) AtomicInteger numValue; } @@ -494,8 +491,8 @@ class TestBeanValidator { @Test void testVerClassName() { + @Getter class ClassNameCheck { - @Getter @ClassName String strValue; } @@ -518,8 +515,8 @@ class TestBeanValidator { @Test void testVerCascade() { + @Getter class Item { - @Getter @NotNull Integer intValue; } @@ -626,27 +623,26 @@ class TestBeanValidator { @Test void testGetEntryName() { - assertThat(validator.getEntryName(makeEntry(null, 0))).isEmpty(); - assertThat(validator.getEntryName(makeEntry("", 0))).isEmpty(); - assertThat(validator.getEntryName(makeEntry(STRING_VALUE, 0))).isEqualTo(STRING_VALUE); + assertThat(validator.getEntryName(makeEntry(null))).isEmpty(); + assertThat(validator.getEntryName(makeEntry(""))).isEmpty(); + assertThat(validator.getEntryName(makeEntry(STRING_VALUE))).isEqualTo(STRING_VALUE); } /** * Makes a Map entry with the given key and value. * * @param key desired key - * @param value desired value * @return a new Map entry */ - private Map.Entry<String, Integer> makeEntry(String key, int value) { + private Map.Entry<String, Integer> makeEntry(String key) { HashMap<String, Integer> map = new HashMap<>(); - map.put(key, value); + map.put(key, 0); return map.entrySet().iterator().next(); } - private <T> void assertNumeric(String testName, T object, Consumer<Integer> setter, String fieldName, - String expectedText, int inside, int edge, int outside) { - setter.accept(inside); + private <T> void assertNumeric(T object, Consumer<Integer> setter, String fieldName, + String expectedText, int edge, int outside) { + setter.accept(TestBeanValidator.INT_VALUE); assertTrue(validator.validateTop(TOP, object).isValid()); // on the edge diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java index 0fb39b0f..0659ad81 100644 --- a/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java +++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/TestFieldValidator.java @@ -101,7 +101,7 @@ class TestFieldValidator extends ValidatorUtil { private int voidMethod; /** - * Accessor is {@link #getParameterizedMethod()}, which requires a parameter. + * Accessor is {@link #getParameterizedMethod(boolean)}, which requires a parameter. */ @Min(0) private int parameterizedMethod; @@ -357,7 +357,7 @@ class TestFieldValidator extends ValidatorUtil { } public int getParameterizedMethod(boolean flag) { - return 0; + return flag ? 0 : 1; } public int getExMethod() { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestClientParametersTest.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/rest/RestClientParametersTest.java index 6013ff2d..0e5df570 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestClientParametersTest.java +++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/rest/RestClientParametersTest.java @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.parameters; +package org.onap.policy.common.parameters.rest; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; diff --git a/common-parameters/src/test/java/org/onap/policy/common/parameters/topic/BusTopicParamsTest.java b/common-parameters/src/test/java/org/onap/policy/common/parameters/topic/BusTopicParamsTest.java new file mode 100644 index 00000000..c474e5fc --- /dev/null +++ b/common-parameters/src/test/java/org/onap/policy/common/parameters/topic/BusTopicParamsTest.java @@ -0,0 +1,201 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.common.parameters.topic; + +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 java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.function.BiConsumer; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.onap.policy.common.parameters.topic.BusTopicParams.TopicParamsBuilder; + +class BusTopicParamsTest { + + public static final String MY_AFT_ENV = "my-aft-env"; + public static final String MY_API_KEY = "my-api-key"; + public static final String MY_API_SECRET = "my-api-secret"; + public static final String MY_BASE_PATH = "my-base"; + public static final String MY_CLIENT_NAME = "my-client"; + public static final String MY_CONS_GROUP = "my-cons-group"; + public static final String MY_CONS_INST = "my-cons-inst"; + public static final String MY_ENV = "my-env"; + public static final int MY_FETCH_LIMIT = 100; + public static final int MY_FETCH_TIMEOUT = 101; + public static final String MY_HOST = "my-host"; + public static final String MY_LAT = "my-lat"; + public static final String MY_LONG = "my-long"; + public static final String MY_PARTNER = "my-partner"; + public static final String MY_PASS = "my-pass"; + public static final int MY_PORT = 102; + public static final String MY_TOPIC = "my-topic"; + public static final String MY_EFFECTIVE_TOPIC = "my-effective-topic"; + public static final String MY_USERNAME = "my-user"; + public static final String MY_PARTITION = "my-partition"; + public static final String MY_SERIALIZER = "org.apache.kafka.common.serialization.StringSerializer"; + + protected Map<String, String> addProps; + protected TopicParamsBuilder builder; + + @BeforeEach + public void setUp() { + addProps = new TreeMap<>(); + addProps.put("my-key-A", "my-value-A"); + addProps.put("my-key-B", "my-value-B"); + + builder = makeBuilder(); + } + + @Test + void testGetters() { + BusTopicParams params = makeBuilder().build(); + + Assertions.assertEquals(addProps, params.getAdditionalProps()); + Assertions.assertEquals(MY_AFT_ENV, params.getAftEnvironment()); + assertTrue(params.isAllowSelfSignedCerts()); + Assertions.assertEquals(MY_API_KEY, params.getApiKey()); + Assertions.assertEquals(MY_API_SECRET, params.getApiSecret()); + Assertions.assertEquals(MY_BASE_PATH, params.getBasePath()); + Assertions.assertEquals(MY_CLIENT_NAME, params.getClientName()); + Assertions.assertEquals(MY_CONS_GROUP, params.getConsumerGroup()); + Assertions.assertEquals(MY_CONS_INST, params.getConsumerInstance()); + Assertions.assertEquals(MY_ENV, params.getEnvironment()); + Assertions.assertEquals(MY_FETCH_LIMIT, params.getFetchLimit()); + Assertions.assertEquals(MY_FETCH_TIMEOUT, params.getFetchTimeout()); + Assertions.assertEquals(MY_HOST, params.getHostname()); + Assertions.assertEquals(MY_LAT, params.getLatitude()); + Assertions.assertEquals(MY_LONG, params.getLongitude()); + assertTrue(params.isManaged()); + Assertions.assertEquals(MY_PARTITION, params.getPartitionId()); + Assertions.assertEquals(MY_PARTNER, params.getPartner()); + Assertions.assertEquals(MY_PASS, params.getPassword()); + Assertions.assertEquals(MY_PORT, params.getPort()); + Assertions.assertEquals(List.of("localhost"), params.getServers()); + Assertions.assertEquals(MY_TOPIC, params.getTopic()); + Assertions.assertEquals(MY_EFFECTIVE_TOPIC, params.getEffectiveTopic()); + assertTrue(params.isUseHttps()); + Assertions.assertEquals(MY_USERNAME, params.getUserName()); + } + + @Test + void testBooleanGetters() { + // ensure that booleans are independent of each other + testBoolean("true:false:false", TopicParamsBuilder::allowSelfSignedCerts); + testBoolean("false:true:false", TopicParamsBuilder::managed); + testBoolean("false:false:true", TopicParamsBuilder::useHttps); + } + + @Test + void testValidators() { + BusTopicParams params = makeBuilder().build(); + + // test validity methods + assertTrue(params.isAdditionalPropsValid()); + assertFalse(params.isAftEnvironmentInvalid()); + assertTrue(params.isApiKeyValid()); + assertTrue(params.isApiSecretValid()); + assertFalse(params.isClientNameInvalid()); + assertFalse(params.isConsumerGroupInvalid()); + assertFalse(params.isConsumerInstanceInvalid()); + assertFalse(params.isEnvironmentInvalid()); + assertFalse(params.isHostnameInvalid()); + assertFalse(params.isLatitudeInvalid()); + assertFalse(params.isLongitudeInvalid()); + assertFalse(params.isPartitionIdInvalid()); + assertFalse(params.isPartnerInvalid()); + assertTrue(params.isPasswordValid()); + assertFalse(params.isPortInvalid()); + assertFalse(params.isServersInvalid()); + assertFalse(params.isTopicInvalid()); + assertTrue(params.isUserNameValid()); + } + + @Test + void testInvertedValidators() { + Assertions.assertFalse(makeBuilder().additionalProps(null).build().isAdditionalPropsValid()); + Assertions.assertTrue(makeBuilder().aftEnvironment("").build().isAftEnvironmentInvalid()); + Assertions.assertFalse(makeBuilder().apiKey("").build().isApiKeyValid()); + Assertions.assertFalse(makeBuilder().apiSecret("").build().isApiSecretValid()); + Assertions.assertTrue(makeBuilder().clientName("").build().isClientNameInvalid()); + Assertions.assertTrue(makeBuilder().consumerGroup("").build().isConsumerGroupInvalid()); + Assertions.assertTrue(makeBuilder().consumerInstance("").build().isConsumerInstanceInvalid()); + Assertions.assertTrue(makeBuilder().environment("").build().isEnvironmentInvalid()); + Assertions.assertTrue(makeBuilder().hostname("").build().isHostnameInvalid()); + Assertions.assertTrue(makeBuilder().latitude("").build().isLatitudeInvalid()); + Assertions.assertTrue(makeBuilder().longitude("").build().isLongitudeInvalid()); + Assertions.assertTrue(makeBuilder().partitionId("").build().isPartitionIdInvalid()); + Assertions.assertTrue(makeBuilder().partner("").build().isPartnerInvalid()); + Assertions.assertFalse(makeBuilder().password("").build().isPasswordValid()); + Assertions.assertTrue(makeBuilder().port(-1).build().isPortInvalid()); + Assertions.assertTrue(makeBuilder().port(65536).build().isPortInvalid()); + Assertions.assertTrue(makeBuilder().servers(null).build().isServersInvalid()); + Assertions.assertTrue(makeBuilder().servers(new LinkedList<>()).build().isServersInvalid()); + Assertions.assertTrue(makeBuilder().servers(List.of("")).build().isServersInvalid()); + Assertions.assertFalse(makeBuilder().servers(List.of("one-server")).build().isServersInvalid()); + Assertions.assertTrue(makeBuilder().topic("").build().isTopicInvalid()); + Assertions.assertFalse(makeBuilder().userName("").build().isUserNameValid()); + } + + /** + * Tests the boolean methods by applying a function, once with {@code false} and once + * with {@code true}. Verifies that all the boolean methods return the correct + * value by concatenating them. + * + * @param expectedTrue the string that is expected when {@code true} is passed to the + * method + * @param function function to be applied to the builder + */ + private void testBoolean(String expectedTrue, BiConsumer<TopicParamsBuilder, Boolean> function) { + TopicParamsBuilder topicParamsBuilder = BusTopicParams.builder(); + + // first try the "false" case + function.accept(topicParamsBuilder, false); + + BusTopicParams params = topicParamsBuilder.build(); + assertEquals("false:false:false", + params.isAllowSelfSignedCerts() + ":" + params.isManaged() + ":" + params.isUseHttps()); + + + // now try the "true" case + function.accept(topicParamsBuilder, true); + + params = topicParamsBuilder.build(); + assertEquals(expectedTrue, + params.isAllowSelfSignedCerts() + ":" + params.isManaged() + ":" + params.isUseHttps()); + } + + public TopicParamsBuilder makeBuilder() { + + return BusTopicParams.builder().additionalProps(addProps).aftEnvironment(MY_AFT_ENV).allowSelfSignedCerts(true) + .apiKey(MY_API_KEY).apiSecret(MY_API_SECRET).basePath(MY_BASE_PATH).clientName(MY_CLIENT_NAME) + .consumerGroup(MY_CONS_GROUP).consumerInstance(MY_CONS_INST).environment(MY_ENV) + .fetchLimit(MY_FETCH_LIMIT).fetchTimeout(MY_FETCH_TIMEOUT).hostname(MY_HOST).latitude(MY_LAT) + .longitude(MY_LONG).managed(true).partitionId(MY_PARTITION).partner(MY_PARTNER) + .password(MY_PASS).port(MY_PORT).servers(List.of("localhost")).topic(MY_TOPIC) + .effectiveTopic(MY_EFFECTIVE_TOPIC).useHttps(true).allowTracing(true).userName(MY_USERNAME) + .serializationProvider(MY_SERIALIZER); + } +} diff --git a/gson/pom.xml b/gson/pom.xml index f7dfdbc3..033a8f36 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -35,6 +35,14 @@ <dependencies> <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + </dependency> + <dependency> + <groupId>com.google.re2j</groupId> + <artifactId>re2j</artifactId> + </dependency> + <dependency> <groupId>jakarta.ws.rs</groupId> <artifactId>jakarta.ws.rs-api</artifactId> </dependency> @@ -43,18 +51,10 @@ <artifactId>lombok</artifactId> </dependency> <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - </dependency> - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> <dependency> - <groupId>com.google.re2j</groupId> - <artifactId>re2j</artifactId> - </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <scope>test</scope> diff --git a/gson/src/test/java/org/onap/policy/common/gson/internal/ClassWalkerTest.java b/gson/src/test/java/org/onap/policy/common/gson/internal/ClassWalkerTest.java index ee55c626..007724ae 100644 --- a/gson/src/test/java/org/onap/policy/common/gson/internal/ClassWalkerTest.java +++ b/gson/src/test/java/org/onap/policy/common/gson/internal/ClassWalkerTest.java @@ -36,7 +36,8 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.TreeSet; -import java.util.stream.Collectors; +import lombok.Getter; +import lombok.Setter; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter; @@ -63,20 +64,17 @@ class ClassWalkerTest { void testExamineClassOfQ_testExamineField_testExamineInField_testExamineOutField() { walker.walkClassHierarchy(DerivedFromBottom.class); - assertEquals("[Intfc1, Intfc2, Intfc1, Intfc3, Bottom, DerivedFromBottom]", walker.classes.toString()); + assertEquals("[InterfaceOne, InterfaceTwo, InterfaceOne, InterfaceThree, Bottom, DerivedFromBottom]", + walker.classes.toString()); - List<String> inFields = walker.getInProps(Field.class).stream().map(Field::getName) - .collect(Collectors.toList()); - Collections.sort(inFields); + List<String> inFields = walker.getInProps(Field.class).stream().map(Field::getName).sorted().toList(); assertEquals("[exposedField, overriddenValue, transField]", inFields.toString()); - List<String> outFields = walker.getInProps(Field.class).stream().map(Field::getName) - .collect(Collectors.toList()); - Collections.sort(outFields); + List<String> outFields = walker.getInProps(Field.class).stream().map(Field::getName).sorted().toList(); assertEquals("[exposedField, overriddenValue, transField]", outFields.toString()); // should work with interfaces without throwing an NPE - walker.walkClassHierarchy(Intfc1.class); + walker.walkClassHierarchy(InterfaceOne.class); } @Test @@ -127,17 +125,13 @@ class ClassWalkerTest { assertNotNull(walker.getAnyGetter()); assertEquals("getTheMap", walker.getAnyGetter().getName()); - List<String> getters = walker.getOutProps(Method.class).stream().map(Method::getName) - .collect(Collectors.toList()); - Collections.sort(getters); + List<String> getters = walker.getOutProps(Method.class).stream().map(Method::getName).sorted().toList(); assertEquals("[getId, getOnlyOut, getValue]", getters.toString()); assertNotNull(walker.getAnySetter()); assertEquals("setMapValue", walker.getAnySetter().getName()); - List<String> setters = walker.getInProps(Method.class).stream().map(Method::getName) - .collect(Collectors.toList()); - Collections.sort(setters); + List<String> setters = walker.getInProps(Method.class).stream().map(Method::getName).sorted().toList(); assertEquals("[setId, setOnlyIn, setValue]", setters.toString()); // getter with invalid parameter count @@ -189,8 +183,8 @@ class ClassWalkerTest { * Walker subclass that records items that are examined. */ private static class MyWalker extends ClassWalker { - private List<String> classes = new ArrayList<>(); - private List<String> methods = new ArrayList<>(); + private final List<String> classes = new ArrayList<>(); + private final List<String> methods = new ArrayList<>(); @Override protected void examine(Class<?> clazz) { @@ -218,19 +212,19 @@ class ClassWalkerTest { } } - protected static interface Intfc1 { - int id = 1000; + protected interface InterfaceOne { + int id = 1000; // NOSONAR I think this is meant to be accessible as fields, not constants } - protected static interface Intfc2 { - String text = "intfc2-text"; + protected interface InterfaceTwo { + String text = "intfc2-text"; // NOSONAR I think this is meant to be accessible as fields, not constants } - private static interface Intfc3 { + private interface InterfaceThree { } - protected static class Bottom implements Intfc1, Intfc3 { + protected static class Bottom implements InterfaceOne, InterfaceThree { private int id; public String value; @@ -259,7 +253,7 @@ class ClassWalkerTest { } } - protected static class DerivedFromBottom extends Bottom implements Intfc1, Intfc2 { + protected static class DerivedFromBottom extends Bottom implements InterfaceOne, InterfaceTwo { private String text; protected String anotherValue; @@ -277,29 +271,19 @@ class ClassWalkerTest { } } + @Setter protected static class Data { + @Getter private int id; + // this will be ignored, because there's already a field by this name private String text; - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - // not public, but property provided @GsonJsonProperty("text") protected String getText() { return text; } - // this will be ignored, because there's already a field by this name - public void setText(String text) { - this.text = text; - } - // should only show up in the output list public int getOnlyOut() { return 1100; diff --git a/message-bus/pom.xml b/message-bus/pom.xml new file mode 100644 index 00000000..54724798 --- /dev/null +++ b/message-bus/pom.xml @@ -0,0 +1,142 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ONAP Policy Engine - Common Modules + ================================================================================ + Copyright (C) 2024 Nordix Foundation. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.policy.common</groupId> + <artifactId>common-modules</artifactId> + <version>3.0.1-SNAPSHOT</version> + </parent> + + <artifactId>message-bus</artifactId> + + <properties> + <maven.compiler.source>17</maven.compiler.source> + <maven.compiler.target>17</maven.compiler.target> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>capabilities</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>common-parameters</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>gson</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </dependency> + <dependency> + <groupId>com.google.re2j</groupId> + <artifactId>re2j</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>io.opentelemetry</groupId> + <artifactId>opentelemetry-api</artifactId> + </dependency> + <dependency> + <groupId>io.opentelemetry</groupId> + <artifactId>opentelemetry-context</artifactId> + </dependency> + <dependency> + <groupId>io.opentelemetry.instrumentation</groupId> + <artifactId>opentelemetry-kafka-clients-2.6</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-collections4</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.kafka</groupId> + <artifactId>kafka-clients</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-junit-jupiter</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>utils-test</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/Topic.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/Topic.java index ce8e2387..48dbb715 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/Topic.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/Topic.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm; +package org.onap.policy.common.message.bus.event; import java.util.List; import org.onap.policy.common.capabilities.Lockable; @@ -83,7 +83,7 @@ public interface Topic extends TopicRegisterable, Startable, Lockable { /** * Get the more recent events in this topic entity. * - * @return list of most recent events + * @return array of most recent events */ String[] getRecentEvents(); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicEndpoint.java index bf261def..5511a82c 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpoint.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicEndpoint.java @@ -19,18 +19,18 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm; +package org.onap.policy.common.message.bus.event; import java.util.List; import java.util.Properties; import org.onap.policy.common.capabilities.Lockable; import org.onap.policy.common.capabilities.Startable; -import org.onap.policy.common.endpoints.event.comm.bus.KafkaTopicSink; -import org.onap.policy.common.endpoints.event.comm.bus.KafkaTopicSource; -import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink; -import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSource; -import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; -import org.onap.policy.common.endpoints.parameters.TopicParameters; +import org.onap.policy.common.message.bus.event.kafka.KafkaTopicSink; +import org.onap.policy.common.message.bus.event.kafka.KafkaTopicSource; +import org.onap.policy.common.message.bus.event.noop.NoopTopicSink; +import org.onap.policy.common.message.bus.event.noop.NoopTopicSource; +import org.onap.policy.common.parameters.topic.TopicParameterGroup; +import org.onap.policy.common.parameters.topic.TopicParameters; /** * Abstraction to manage the system's Networked Topic Endpoints, sources of all events input into diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicEndpointManager.java index fb18a307..40b9c235 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointManager.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicEndpointManager.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm; +package org.onap.policy.common.message.bus.event; import lombok.AccessLevel; import lombok.Getter; @@ -31,5 +32,5 @@ public class TopicEndpointManager { * Topic endpoint manager. */ @Getter - private static TopicEndpoint manager = new TopicEndpointProxy(); + static TopicEndpoint manager = new TopicEndpointProxy(); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicEndpointProxy.java index 98fbbf0b..9dbf5418 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxy.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicEndpointProxy.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm; +package org.onap.policy.common.message.bus.event; import java.util.ArrayList; import java.util.Collections; @@ -28,15 +28,15 @@ import java.util.Objects; import java.util.Properties; import lombok.Getter; import org.onap.policy.common.capabilities.Startable; -import org.onap.policy.common.endpoints.event.comm.bus.KafkaTopicFactories; -import org.onap.policy.common.endpoints.event.comm.bus.KafkaTopicSink; -import org.onap.policy.common.endpoints.event.comm.bus.KafkaTopicSource; -import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories; -import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink; -import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSource; -import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; -import org.onap.policy.common.endpoints.parameters.TopicParameters; import org.onap.policy.common.gson.annotation.GsonJsonIgnore; +import org.onap.policy.common.message.bus.event.kafka.KafkaTopicFactories; +import org.onap.policy.common.message.bus.event.kafka.KafkaTopicSink; +import org.onap.policy.common.message.bus.event.kafka.KafkaTopicSource; +import org.onap.policy.common.message.bus.event.noop.NoopTopicFactories; +import org.onap.policy.common.message.bus.event.noop.NoopTopicSink; +import org.onap.policy.common.message.bus.event.noop.NoopTopicSource; +import org.onap.policy.common.parameters.topic.TopicParameterGroup; +import org.onap.policy.common.parameters.topic.TopicParameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicListener.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicListener.java index dd6eedd0..f9896243 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicListener.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicListener.java @@ -1,15 +1,14 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm; +package org.onap.policy.common.message.bus.event; /** * Listener for event messages entering the Policy Engine. @@ -28,11 +27,11 @@ public interface TopicListener { /** * Notification of a new Event over a given Topic. - * + * * @param commType communication infrastructure type - * @param topic topic name - * @param event event message as a string + * @param topic topic name + * @param event event message as a string */ - public void onTopicEvent(Topic.CommInfrastructure commType, String topic, String event); + void onTopicEvent(Topic.CommInfrastructure commType, String topic, String event); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicRegisterable.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicRegisterable.java index 207ebc66..1d6873e9 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicRegisterable.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicRegisterable.java @@ -1,15 +1,14 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm; +package org.onap.policy.common.message.bus.event; /** * Marks a Topic entity as registerable. @@ -27,16 +26,16 @@ public interface TopicRegisterable { /** * Register for notification of events with this Topic Entity. - * + * * @param topicListener the listener of events */ - public void register(TopicListener topicListener); + void register(TopicListener topicListener); /** * Unregisters for notification of events with this Topic Entity. - * + * * @param topicListener the listener of events */ - public void unregister(TopicListener topicListener); + void unregister(TopicListener topicListener); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSink.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicSink.java index b67756e5..d5269b9a 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSink.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicSink.java @@ -1,16 +1,14 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm; +package org.onap.policy.common.message.bus.event; /** * Marks a given Topic Endpoint as able to send messages over a topic. @@ -28,12 +26,11 @@ public interface TopicSink extends Topic { /** * Sends a string message over this Topic Endpoint. - * + * * @param message message to send - * * @return true if the send operation succeeded, false otherwise * @throws IllegalArgumentException an invalid message has been provided - * @throws IllegalStateException the entity is in a state that prevents + * @throws IllegalStateException the entity is in a state that prevents * it from sending messages, for example, locked or stopped. */ boolean send(String message); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSource.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicSource.java index c1d0829c..f0dc3b74 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/TopicSource.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/TopicSource.java @@ -1,15 +1,14 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm; +package org.onap.policy.common.message.bus.event; /** * Marker for a Topic Entity, indicating that the entity is able to read @@ -27,11 +26,11 @@ package org.onap.policy.common.endpoints.event.comm; public interface TopicSource extends Topic { /** - * Pushes an event into the source programatically. - * + * Pushes an event into the source programmatically. + * * @param event the event in json format * @return true if it can be processed correctly, false otherwise */ - public boolean offer(String event); + boolean offer(String event); }
\ No newline at end of file diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/ApiKeyEnabled.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/ApiKeyEnabled.java index 0e06007f..360a88a2 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/ApiKeyEnabled.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/ApiKeyEnabled.java @@ -1,15 +1,14 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.base; /** * API. @@ -26,15 +25,15 @@ package org.onap.policy.common.endpoints.event.comm.bus; public interface ApiKeyEnabled { /** * Get API key. - * + * * @return api key */ - public String getApiKey(); + String getApiKey(); /** * Get API secret. - * + * * @return api secret */ - public String getApiSecret(); + String getApiSecret(); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusConsumer.java index b46c2715..925949aa 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumer.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusConsumer.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. * Modifications Copyright (C) 2020,2023 Bell Canada. All rights reserved. @@ -21,7 +19,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; + +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.DEFAULT_TIMEOUT_MS_FETCH; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanContext; @@ -48,7 +48,7 @@ import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.clients.consumer.OffsetAndMetadata; import org.apache.kafka.common.TopicPartition; import org.apache.kafka.common.header.Headers; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; +import org.onap.policy.common.parameters.topic.BusTopicParams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,12 +63,12 @@ public interface BusConsumer { * @return list of messages * @throws IOException when error encountered by underlying libraries */ - public Iterable<String> fetch() throws IOException; + Iterable<String> fetch() throws IOException; /** * close underlying library consumer. */ - public void close(); + void close(); /** * Consumer that handles fetch() failures by sleeping. @@ -102,10 +102,10 @@ public interface BusConsumer { this.fetchTimeout = busTopicParams.getFetchTimeout(); if (this.fetchTimeout <= 0) { - this.sleepTime = PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH; + this.sleepTime = DEFAULT_TIMEOUT_MS_FETCH; } else { // don't sleep too long, even if fetch timeout is large - this.sleepTime = Math.min(this.fetchTimeout, PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH); + this.sleepTime = Math.min(this.fetchTimeout, DEFAULT_TIMEOUT_MS_FETCH); } } @@ -188,7 +188,7 @@ public interface BusConsumer { if (busTopicParams.isAllowTracing()) { this.allowTracing = true; kafkaProps.setProperty(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG, - TracingConsumerInterceptor.class.getName()); + TracingConsumerInterceptor.class.getName()); } consumer = new KafkaConsumer<>(kafkaProps); @@ -233,8 +233,8 @@ public interface BusConsumer { } SpanContext spanContext = SpanContext.createFromRemoteParent( - traceParentInfo.getTraceId(), traceParentInfo.getSpanId(), - TraceFlags.getSampled(), TraceState.builder().build()); + traceParentInfo.getTraceId(), traceParentInfo.getSpanId(), + TraceFlags.getSampled(), TraceState.builder().build()); Context.current().with(Span.wrap(spanContext)).makeCurrent(); } @@ -243,7 +243,7 @@ public interface BusConsumer { TraceParentInfo traceParentInfo = new TraceParentInfo(); if (headers.lastHeader("traceparent") != null) { traceParentInfo.setParentTraceId(new String(headers.lastHeader( - "traceparent").value(), StandardCharsets.UTF_8)); + "traceparent").value(), StandardCharsets.UTF_8)); String[] parts = traceParentInfo.getParentTraceId().split("-"); traceParentInfo.setTraceId(parts[1]); diff --git a/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusPublisher.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusPublisher.java new file mode 100644 index 00000000..10c7db2d --- /dev/null +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusPublisher.java @@ -0,0 +1,43 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modifications Copyright (C) 2020,2023 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2022-2024 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.common.message.bus.event.base; + +public interface BusPublisher { + + String NO_MESSAGE_PROVIDED = "No message provided"; + String LOG_CLOSE = "{}: CLOSE"; + + /** + * sends a message. + * + * @param partitionId id + * @param message the message + * @return true if success, false otherwise + * @throws IllegalArgumentException if no message provided + */ + boolean send(String partitionId, String message); + + /** + * closes the publisher. + */ + void close(); +} diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusTopicBase.java index f8236d3d..6516945a 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBase.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusTopicBase.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,10 +20,10 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; import lombok.Getter; -import org.onap.policy.common.endpoints.event.comm.bus.ApiKeyEnabled; +import org.onap.policy.common.parameters.topic.BusTopicParams; /** * Bus Topic Base. @@ -51,7 +52,7 @@ public abstract class BusTopicBase extends TopicBase implements ApiKeyEnabled { protected boolean allowTracing; /** - * allow self signed certificates. + * allow self-signed certificates. */ protected boolean allowSelfSignedCerts; @@ -59,12 +60,13 @@ public abstract class BusTopicBase extends TopicBase implements ApiKeyEnabled { * Instantiates a new Bus Topic Base. * * <p>servers list of servers - * topic topic name - * apiKey API Key - * apiSecret API Secret - * useHttps does connection use HTTPS? - * allowTracing Is tracing allowed? - * allowSelfSignedCerts are self-signed certificates allow + * topic: the topic name + * apiKey: API Key + * apiSecret: API Secret + * useHttps: does connection use HTTPS? + * allowTracing: Is tracing allowed? + * allowSelfSignedCerts: are self-signed certificates allow + * * @param busTopicParams holds all our parameters * @throws IllegalArgumentException if invalid parameters are present */ @@ -101,7 +103,7 @@ public abstract class BusTopicBase extends TopicBase implements ApiKeyEnabled { @Override public String toString() { return "BusTopicBase [apiKey=" + apiKey + ", apiSecret=" + apiSecret + ", useHttps=" + useHttps - + ", allowSelfSignedCerts=" + allowSelfSignedCerts + ", toString()=" + super.toString() + "]"; + + ", allowSelfSignedCerts=" + allowSelfSignedCerts + ", toString()=" + super.toString() + "]"; } } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusTopicSink.java index ceb9255e..54b08619 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSink.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusTopicSink.java @@ -1,7 +1,5 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ @@ -19,9 +17,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.base; -import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.message.bus.event.TopicSink; /** * Topic Sink over Bus Infrastructure (KAFKA). diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusTopicSource.java index 87a06824..974c02bb 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicSource.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/BusTopicSource.java @@ -1,7 +1,5 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ @@ -19,9 +17,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.base; -import org.onap.policy.common.endpoints.event.comm.TopicSource; +import org.onap.policy.common.message.bus.event.TopicSource; /** * Generic Topic Source for Bus Communication Infrastructure. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/InlineBusTopicSink.java index 9b724072..6a30f00f 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSink.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/InlineBusTopicSink.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018-2019 Samsung Electronics Co., Ltd. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. @@ -21,14 +19,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; import java.util.UUID; import lombok.Getter; import lombok.Setter; -import org.onap.policy.common.endpoints.event.comm.bus.BusTopicSink; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.parameters.topic.BusTopicParams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +39,7 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi /** * Loggers. */ - private static Logger logger = LoggerFactory.getLogger(InlineBusTopicSink.class); + private static final Logger logger = LoggerFactory.getLogger(InlineBusTopicSink.class); /** * The partition key to publish to. @@ -58,14 +56,14 @@ public abstract class InlineBusTopicSink extends BusTopicBase implements BusTopi /** * Constructor for abstract sink. * @param busTopicParams contains below listed attributes - * servers servers - * topic topic - * apiKey api secret - * apiSecret api secret - * partitionId partition id - * useHttps does connection use HTTPS? - * allowTracing is tracing allowed? - * allowSelfSignedCerts are self-signed certificates allow * + * servers: servers + * topic: topic + * apiKey: api secret + * apiSecret: api secret + * partitionId: partition id + * useHttps: does connection use HTTPS? + * allowTracing: is tracing allowed? + * allowSelfSignedCerts: are self-signed certificates allow * * @throws IllegalArgumentException if invalid parameters are passed in */ protected InlineBusTopicSink(BusTopicParams busTopicParams) { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/SingleThreadedBusTopicSource.java index f98b481f..912b698c 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSource.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/SingleThreadedBusTopicSource.java @@ -1,10 +1,9 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018-2019 Samsung Electronics Co., Ltd. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +19,19 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; + +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.NO_LIMIT_FETCH; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.NO_TIMEOUT_MS_FETCH; import java.io.IOException; import java.net.MalformedURLException; import java.util.UUID; import lombok.Getter; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.bus.BusTopicSource; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.TopicListener; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.parameters.topic.BusTopicParams; import org.onap.policy.common.utils.network.NetworkUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,10 +44,10 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase implements Runnable, BusTopicSource { /** - * Not to be converted to PolicyLogger. This will contain all instract /out traffic and only + * Not to be converted to PolicyLogger. This will contain all in/out traffic and only * that in a single file in a concise format. */ - private static Logger logger = LoggerFactory.getLogger(SingleThreadedBusTopicSource.class); + private static final Logger logger = LoggerFactory.getLogger(SingleThreadedBusTopicSource.class); /** * Bus consumer group. @@ -112,13 +113,13 @@ public abstract class SingleThreadedBusTopicSource extends BusTopicBase } if (busTopicParams.getFetchTimeout() <= 0) { - this.fetchTimeout = PolicyEndPointProperties.NO_TIMEOUT_MS_FETCH; + this.fetchTimeout = NO_TIMEOUT_MS_FETCH; } else { this.fetchTimeout = busTopicParams.getFetchTimeout(); } if (busTopicParams.getFetchLimit() <= 0) { - this.fetchLimit = PolicyEndPointProperties.NO_LIMIT_FETCH; + this.fetchLimit = NO_LIMIT_FETCH; } else { this.fetchLimit = busTopicParams.getFetchLimit(); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBase.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/TopicBase.java index c63fbcc2..4d1fbc9e 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBase.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/TopicBase.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,15 +20,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; import java.util.ArrayList; import java.util.List; import lombok.AccessLevel; import lombok.Getter; import org.apache.commons.collections4.queue.CircularFifoQueue; -import org.onap.policy.common.endpoints.event.comm.Topic; -import org.onap.policy.common.endpoints.event.comm.TopicListener; +import org.onap.policy.common.message.bus.event.Topic; +import org.onap.policy.common.message.bus.event.TopicListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/TopicBaseFactory.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/TopicBaseFactory.java index a6b5b1d9..d98de653 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/TopicBaseFactory.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/TopicBaseFactory.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,12 +19,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.base; import java.util.List; import java.util.Properties; -import org.onap.policy.common.endpoints.event.comm.Topic; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.message.bus.event.Topic; +import org.onap.policy.common.parameters.topic.BusTopicParams; /** * Topic Base Factory. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/TopicBaseHashedFactory.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/TopicBaseHashedFactory.java index c785ef04..70ff04e4 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/TopicBaseHashedFactory.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/base/TopicBaseHashedFactory.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,15 +19,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.base; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Properties; -import org.onap.policy.common.endpoints.event.comm.Topic; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.message.bus.event.Topic; +import org.onap.policy.common.parameters.topic.BusTopicParams; /** * Topic Factory implementation that indexes T instances in a hash table. @@ -74,7 +75,7 @@ public abstract class TopicBaseHashedFactory<T extends Topic> implements TopicBa * @param topic topic. * @return an instance of T. */ - protected abstract T build(List<String> servers, String topic); + public abstract T build(List<String> servers, String topic); /** * {@inheritDoc}. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClient.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/BidirectionalTopicClient.java index 4f601fa8..6ffc188d 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClient.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/BidirectionalTopicClient.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,21 +19,20 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.client; +package org.onap.policy.common.message.bus.event.client; -import jakarta.validation.constraints.NotNull; import java.util.Collections; import java.util.List; import java.util.concurrent.BlockingDeque; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; import lombok.Getter; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; -import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.event.comm.TopicSource; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.TopicEndpoint; +import org.onap.policy.common.message.bus.event.TopicEndpointManager; +import org.onap.policy.common.message.bus.event.TopicListener; +import org.onap.policy.common.message.bus.event.TopicSink; +import org.onap.policy.common.message.bus.event.TopicSource; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -178,7 +177,6 @@ public class BidirectionalTopicClient { return checkerQueue.peek(); } - @NotNull private <T> TopicListener getTopicListener(T message) { @SuppressWarnings("unchecked") final Class<? extends T> clazz = (Class<? extends T>) message.getClass(); @@ -201,7 +199,7 @@ public class BidirectionalTopicClient { } /** - * Stops any listeners that are currently stuck in {@link #awaitReady(Object)} by + * Stops any listeners that are currently stuck in {@link #awaitReady(Object, long)} by * adding {@code false} to the queue. */ public void stopWaiting() { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientException.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/BidirectionalTopicClientException.java index 1037d3af..442c5243 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientException.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/BidirectionalTopicClientException.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.client; +package org.onap.policy.common.message.bus.event.client; import java.io.Serial; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/TopicSinkClient.java index 0ccc8a75..131bf2d7 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClient.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/TopicSinkClient.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * ONAP PAP + * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019, 2024 Nordix Foundation. @@ -19,13 +19,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.client; +package org.onap.policy.common.message.bus.event.client; import java.util.List; import lombok.Getter; import lombok.NonNull; -import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; -import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.message.bus.event.TopicEndpointManager; +import org.onap.policy.common.message.bus.event.TopicSink; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientException.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/TopicSinkClientException.java index 431d4f34..fad5e119 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientException.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/client/TopicSinkClientException.java @@ -1,9 +1,9 @@ /*- * ============LICENSE_START======================================================= - * ONAP PAP + * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019, 2023 Nordix Foundation. + * Modifications Copyright (C) 2019, 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.client; +package org.onap.policy.common.message.bus.event.client; import java.io.Serial; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSinkFactory.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/IndexedKafkaTopicSinkFactory.java index f913926e..0497f1f5 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSinkFactory.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/IndexedKafkaTopicSinkFactory.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation. + * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; + +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_KAFKA_SINK_TOPICS; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX; import com.google.re2j.Pattern; import java.util.ArrayList; @@ -24,11 +28,9 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import org.apache.commons.lang3.StringUtils; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; -import org.onap.policy.common.endpoints.event.comm.bus.internal.InlineKafkaTopicSink; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; -import org.onap.policy.common.endpoints.utils.KafkaPropertyUtils; -import org.onap.policy.common.endpoints.utils.PropertyUtils; +import org.onap.policy.common.message.bus.utils.KafkaPropertyUtils; +import org.onap.policy.common.parameters.topic.BusTopicParams; +import org.onap.policy.common.utils.properties.PropertyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +91,7 @@ class IndexedKafkaTopicSinkFactory implements KafkaTopicSinkFactory { @Override public List<KafkaTopicSink> build(Properties properties) { - String writeTopics = properties.getProperty(PolicyEndPointProperties.PROPERTY_KAFKA_SINK_TOPICS); + String writeTopics = properties.getProperty(PROPERTY_KAFKA_SINK_TOPICS); if (StringUtils.isBlank(writeTopics)) { logger.info("{}: no topic for KAFKA Sink", this); return new ArrayList<>(); @@ -110,20 +112,20 @@ class IndexedKafkaTopicSinkFactory implements KafkaTopicSinkFactory { return; } - String topicPrefix = PolicyEndPointProperties.PROPERTY_KAFKA_SINK_TOPICS + "." + topic; + String topicPrefix = PROPERTY_KAFKA_SINK_TOPICS + "." + topic; var props = new PropertyUtils(properties, topicPrefix, (name, value, ex) -> logger.warn("{}: {} {} is in invalid format for topic sink {} ", this, name, value, topic)); - String servers = properties.getProperty(topicPrefix + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX); + String servers = properties.getProperty(topicPrefix + PROPERTY_TOPIC_SERVERS_SUFFIX); if (StringUtils.isBlank(servers)) { logger.error("{}: no KAFKA servers configured for sink {}", this, topic); return; } KafkaTopicSink kafkaTopicWriter = this.build(KafkaPropertyUtils.makeBuilder(props, topic, servers) - .partitionId(props.getString(PolicyEndPointProperties.PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX, null)) + .partitionId(props.getString(PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX, null)) .build()); newKafkaTopicSinks.add(kafkaTopicWriter); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSourceFactory.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/IndexedKafkaTopicSourceFactory.java index 151d8f69..1aac89ce 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSourceFactory.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/IndexedKafkaTopicSourceFactory.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation. + * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,16 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; + +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.DEFAULT_LIMIT_FETCH; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.DEFAULT_TIMEOUT_MS_FETCH; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_KAFKA_SOURCE_TOPICS; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX; import com.google.re2j.Pattern; import java.util.ArrayList; @@ -24,11 +33,9 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import org.apache.commons.lang3.StringUtils; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; -import org.onap.policy.common.endpoints.event.comm.bus.internal.SingleThreadedKafkaTopicSource; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; -import org.onap.policy.common.endpoints.utils.KafkaPropertyUtils; -import org.onap.policy.common.endpoints.utils.PropertyUtils; +import org.onap.policy.common.message.bus.utils.KafkaPropertyUtils; +import org.onap.policy.common.parameters.topic.BusTopicParams; +import org.onap.policy.common.utils.properties.PropertyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,7 +82,7 @@ class IndexedKafkaTopicSourceFactory implements KafkaTopicSourceFactory { @Override public List<KafkaTopicSource> build(Properties properties) { - String readTopics = properties.getProperty(PolicyEndPointProperties.PROPERTY_KAFKA_SOURCE_TOPICS); + String readTopics = properties.getProperty(PROPERTY_KAFKA_SOURCE_TOPICS); if (StringUtils.isBlank(readTopics)) { logger.info("{}: no topic for KAFKA Source", this); return new ArrayList<>(); @@ -96,8 +103,8 @@ class IndexedKafkaTopicSourceFactory implements KafkaTopicSourceFactory { .servers(servers) .topic(topic) .managed(true) - .fetchTimeout(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH) - .fetchLimit(PolicyEndPointProperties.DEFAULT_LIMIT_FETCH) + .fetchTimeout(DEFAULT_TIMEOUT_MS_FETCH) + .fetchLimit(DEFAULT_LIMIT_FETCH) .useHttps(false).build()); } @@ -107,13 +114,13 @@ class IndexedKafkaTopicSourceFactory implements KafkaTopicSourceFactory { return; } - String topicPrefix = PolicyEndPointProperties.PROPERTY_KAFKA_SOURCE_TOPICS + "." + topic; + String topicPrefix = PROPERTY_KAFKA_SOURCE_TOPICS + "." + topic; var props = new PropertyUtils(properties, topicPrefix, (name, value, ex) -> logger.warn("{}: {} {} is in invalid format for topic source {} ", this, name, value, topic)); - String servers = properties.getProperty(topicPrefix + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX); + String servers = properties.getProperty(topicPrefix + PROPERTY_TOPIC_SERVERS_SUFFIX); if (StringUtils.isBlank(servers)) { logger.error("{}: no KAFKA servers configured for source {}", this, topic); return; @@ -121,14 +128,14 @@ class IndexedKafkaTopicSourceFactory implements KafkaTopicSourceFactory { var kafkaTopicSource = this.build(KafkaPropertyUtils.makeBuilder(props, topic, servers) .consumerGroup(props.getString( - PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX, null)) + PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX, null)) .consumerInstance(props.getString( - PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, null)) + PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, null)) .fetchTimeout(props.getInteger( - PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX, - PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH)) - .fetchLimit(props.getInteger(PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX, - PolicyEndPointProperties.DEFAULT_LIMIT_FETCH)) + PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX, + DEFAULT_TIMEOUT_MS_FETCH)) + .fetchLimit(props.getInteger(PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX, + DEFAULT_LIMIT_FETCH)) .build()); newKafkaTopicSources.add(kafkaTopicSource); diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSink.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/InlineKafkaTopicSink.java index 6354f762..4bdd2b0f 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSink.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/InlineKafkaTopicSink.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation. + * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.kafka; import java.util.Map; -import org.onap.policy.common.endpoints.event.comm.Topic; -import org.onap.policy.common.endpoints.event.comm.bus.KafkaTopicSink; +import org.onap.policy.common.message.bus.event.Topic; +import org.onap.policy.common.message.bus.event.base.InlineBusTopicSink; +import org.onap.policy.common.parameters.topic.BusTopicParams; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,7 +60,7 @@ public class InlineKafkaTopicSink extends InlineBusTopicSink implements KafkaTop @Override public void init() { - this.publisher = new BusPublisher.KafkaPublisherWrapper(BusTopicParams.builder() + this.publisher = new KafkaPublisherWrapper(BusTopicParams.builder() .servers(this.servers) .topic(this.effectiveTopic) .useHttps(this.useHttps) diff --git a/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaPublisherWrapper.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaPublisherWrapper.java new file mode 100644 index 00000000..86b9e936 --- /dev/null +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaPublisherWrapper.java @@ -0,0 +1,121 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.common.message.bus.event.kafka; + +import io.opentelemetry.instrumentation.kafkaclients.v2_6.TracingProducerInterceptor; +import java.util.Properties; +import java.util.UUID; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.Producer; +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.onap.policy.common.message.bus.event.base.BusPublisher; +import org.onap.policy.common.parameters.topic.BusTopicParams; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Kafka based library publisher. + */ +public class KafkaPublisherWrapper implements BusPublisher { + + private static final Logger logger = LoggerFactory.getLogger(KafkaPublisherWrapper.class); + private static final String KEY_SERIALIZER = "org.apache.kafka.common.serialization.StringSerializer"; + + private final String topic; + + /** + * Kafka publisher. + */ + private final Producer<String, String> producer; + protected Properties kafkaProps; + + /** + * Kafka Publisher Wrapper. + * + * @param busTopicParams topic parameters + */ + public KafkaPublisherWrapper(BusTopicParams busTopicParams) { + + if (busTopicParams.isTopicInvalid()) { + throw new IllegalArgumentException("No topic for Kafka"); + } + + this.topic = busTopicParams.getTopic(); + + // Setup Properties for consumer + kafkaProps = new Properties(); + kafkaProps.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, busTopicParams.getServers().get(0)); + if (busTopicParams.isAdditionalPropsValid()) { + kafkaProps.putAll(busTopicParams.getAdditionalProps()); + } + + if (kafkaProps.get(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG) == null) { + kafkaProps.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, KEY_SERIALIZER); + } + + if (kafkaProps.get(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG) == null) { + kafkaProps.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KEY_SERIALIZER); + } + + if (busTopicParams.isAllowTracing()) { + kafkaProps.setProperty(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, + TracingProducerInterceptor.class.getName()); + } + + producer = new KafkaProducer<>(kafkaProps); + } + + @Override + public boolean send(String partitionId, String message) { + if (message == null) { + throw new IllegalArgumentException(NO_MESSAGE_PROVIDED); + } + + try { + // Create the record + ProducerRecord<String, String> producerRecord = + new ProducerRecord<>(topic, UUID.randomUUID().toString(), message); + + this.producer.send(producerRecord); + producer.flush(); + } catch (Exception e) { + logger.warn("{}: SEND of {} cannot be performed because of {}", this, message, e.getMessage(), e); + return false; + } + return true; + } + + @Override + public void close() { + logger.info(LOG_CLOSE, this); + + try { + this.producer.close(); + } catch (Exception e) { + logger.warn("{}: CLOSE FAILED because of {}", this, e.getMessage(), e); + } + } + + @Override + public String toString() { + return "KafkaPublisherWrapper []"; + } + +} diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicFactories.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicFactories.java index 60db3857..c10285fc 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicFactories.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicFactories.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; import lombok.AccessLevel; import lombok.Getter; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSink.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSink.java index 960a02c5..f784a987 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSink.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSink.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; + +import org.onap.policy.common.message.bus.event.base.BusTopicSink; /** * Topic Writer over KAFKA Infrastructure. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkFactory.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSinkFactory.java index fa5e56f9..8feecbe0 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkFactory.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSinkFactory.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; import java.util.List; import java.util.Properties; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.parameters.topic.BusTopicParams; /** * KAFKA Topic Sink Factory. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSource.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSource.java index 03efd083..bddced7a 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSource.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSource.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; + +import org.onap.policy.common.message.bus.event.base.BusTopicSource; /** * Kafka Topic Source. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceFactory.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSourceFactory.java index e5642daa..06f4412c 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceFactory.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSourceFactory.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation. + * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; import java.util.List; import java.util.Properties; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.parameters.topic.BusTopicParams; /** * Kafka Topic Source Factory. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSource.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/SingleThreadedKafkaTopicSource.java index 869273f0..5691cb12 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSource.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/kafka/SingleThreadedKafkaTopicSource.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation. + * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.kafka; -import java.net.MalformedURLException; import java.util.Map; -import org.onap.policy.common.endpoints.event.comm.Topic; -import org.onap.policy.common.endpoints.event.comm.bus.KafkaTopicSource; +import org.onap.policy.common.message.bus.event.Topic; +import org.onap.policy.common.message.bus.event.base.BusConsumer; +import org.onap.policy.common.message.bus.event.base.SingleThreadedBusTopicSource; +import org.onap.policy.common.parameters.topic.BusTopicParams; /** * This topic source implementation specializes in reading messages over a Kafka Bus topic source and @@ -48,10 +49,10 @@ public class SingleThreadedKafkaTopicSource extends SingleThreadedBusTopicSource } /** - * Initialize the Cambria client. + * Initialize the client. */ @Override - public void init() throws MalformedURLException { + public void init() { BusTopicParams.TopicParamsBuilder builder = BusTopicParams.builder() .servers(this.servers) .topic(this.effectiveTopic) diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicEndpoint.java index 73ff6ed6..e25aca54 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpoint.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicEndpoint.java @@ -5,6 +5,7 @@ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +21,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import java.util.List; -import org.onap.policy.common.endpoints.event.comm.bus.internal.TopicBase; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.base.TopicBase; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +38,7 @@ public abstract class NoopTopicEndpoint extends TopicBase { /** * Logger. */ - private static Logger logger = LoggerFactory.getLogger(NoopTopicEndpoint.class); + private static final Logger logger = LoggerFactory.getLogger(NoopTopicEndpoint.class); /** * Constructs the object. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicFactories.java index c3e7e0a4..506cc9f9 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactories.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicFactories.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import lombok.AccessLevel; import lombok.Getter; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactory.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicFactory.java index dfe7c2c4..e81dfaea 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactory.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicFactory.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +19,10 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; + +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_MANAGED_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; import com.google.re2j.Pattern; import java.util.ArrayList; @@ -26,8 +30,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Properties; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.base.TopicBaseHashedFactory; /** * Noop Topic Factory. @@ -62,7 +66,7 @@ public abstract class NoopTopicFactory<T extends NoopTopicEndpoint> extends Topi protected List<String> getServers(String topicName, Properties properties) { String servers = properties.getProperty(getTopicsPropertyName() + "." + topicName - + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX); + + PROPERTY_TOPIC_SERVERS_SUFFIX); if (servers == null || servers.isEmpty()) { servers = CommInfrastructure.NOOP.toString(); @@ -77,8 +81,7 @@ public abstract class NoopTopicFactory<T extends NoopTopicEndpoint> extends Topi @Override protected boolean isManaged(String topicName, Properties properties) { var managedString = - properties.getProperty(getTopicsPropertyName() - + "." + topicName + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX); + properties.getProperty(getTopicsPropertyName() + "." + topicName + PROPERTY_MANAGED_SUFFIX); var managed = true; if (managedString != null && !managedString.isEmpty()) { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSink.java index e7accad5..b7d78ff4 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSink.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSink.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +19,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import java.util.List; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.TopicSink; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; /** * No Operation Topic Sink. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactory.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSinkFactory.java index 0c38d196..cdf4a17b 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactory.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSinkFactory.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,10 +19,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; + +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_NOOP_SINK_TOPICS; import java.util.List; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; /** * Noop Topic Sink Factory. @@ -33,14 +35,14 @@ public class NoopTopicSinkFactory extends NoopTopicFactory<NoopTopicSink> { */ @Override protected String getTopicsPropertyName() { - return PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS; + return PROPERTY_NOOP_SINK_TOPICS; } /** * {@inheritDoc}. */ @Override - protected NoopTopicSink build(List<String> servers, String topic) { + public NoopTopicSink build(List<String> servers, String topic) { return new NoopTopicSink(servers, topic); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSource.java index 6f2c4a1e..6e7d0216 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSource.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSource.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +19,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import java.util.List; -import org.onap.policy.common.endpoints.event.comm.TopicSource; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.TopicSource; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; /** * No Operation Topic Source. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSourceFactory.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSourceFactory.java index ca5e41d3..5e3a365a 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSourceFactory.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSourceFactory.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,10 +19,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; + +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_NOOP_SOURCE_TOPICS; import java.util.List; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; /** * No Operation Topic Source Factory. @@ -33,14 +35,14 @@ public class NoopTopicSourceFactory extends NoopTopicFactory<NoopTopicSource> { */ @Override protected String getTopicsPropertyName() { - return PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS; + return PROPERTY_NOOP_SOURCE_TOPICS; } /** * {@inheritDoc}. */ @Override - protected NoopTopicSource build(List<String> servers, String topic) { + public NoopTopicSource build(List<String> servers, String topic) { return new NoopTopicSource(servers, topic); } diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/features/NetLoggerFeatureApi.java index a99ecd26..6e3b8301 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApi.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/features/NetLoggerFeatureApi.java @@ -1,8 +1,7 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,10 +17,10 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.features; +package org.onap.policy.common.message.bus.features; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.services.OrderedService; import org.slf4j.Logger; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/features/NetLoggerFeatureProviders.java index ba84b551..4f57ab2a 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureProviders.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/features/NetLoggerFeatureProviders.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.features; +package org.onap.policy.common.message.bus.features; import lombok.AccessLevel; import lombok.Getter; diff --git a/message-bus/src/main/java/org/onap/policy/common/message/bus/properties/MessageBusProperties.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/properties/MessageBusProperties.java new file mode 100644 index 00000000..9aa529f3 --- /dev/null +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/properties/MessageBusProperties.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START=============================================== + * Copyright (C) 2024 Nordix Foundation. + * ======================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END================================================= + */ + +package org.onap.policy.common.message.bus.properties; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class MessageBusProperties { + + /* Generic property suffixes */ + + public static final String PROPERTY_TOPIC_SERVERS_SUFFIX = ".servers"; + public static final String PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX = ".effectiveTopic"; + + public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX = ".consumerGroup"; + public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX = ".consumerInstance"; + public static final String PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX = ".fetchTimeout"; + public static final String PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX = ".fetchLimit"; + public static final String PROPERTY_MANAGED_SUFFIX = ".managed"; + public static final String PROPERTY_ADDITIONAL_PROPS_SUFFIX = ".additionalProps"; + + public static final String PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX = ".partitionKey"; + + public static final String PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX = ".selfSignedCertificates"; + + public static final String PROPERTY_NOOP_SOURCE_TOPICS = "noop.source.topics"; + public static final String PROPERTY_NOOP_SINK_TOPICS = "noop.sink.topics"; + + /* KAFKA Properties */ + + public static final String PROPERTY_KAFKA_SOURCE_TOPICS = "kafka.source.topics"; + public static final String PROPERTY_KAFKA_SINK_TOPICS = "kafka.sink.topics"; + + /* HTTP Server Properties */ + + public static final String PROPERTY_HTTP_HTTPS_SUFFIX = ".https"; + + /* Topic Sink Values */ + + /* Topic Source values */ + + /** + * Default Timeout fetching in milliseconds. + */ + public static final int DEFAULT_TIMEOUT_MS_FETCH = 15000; + + /** + * Default maximum number of messages fetch at the time. + */ + public static final int DEFAULT_LIMIT_FETCH = 100; + + /** + * Definition of No Timeout fetching. + */ + public static final int NO_TIMEOUT_MS_FETCH = -1; + + /** + * Definition of No limit fetching. + */ + public static final int NO_LIMIT_FETCH = -1; +} diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/KafkaPropertyUtils.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/utils/KafkaPropertyUtils.java index 2e137ce7..cfe62208 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/KafkaPropertyUtils.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/utils/KafkaPropertyUtils.java @@ -2,8 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2022-2024 Nordix Foundation. + * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.utils; +package org.onap.policy.common.message.bus.utils; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_ADDITIONAL_PROPS_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_ADDITIONAL_PROPS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_MANAGED_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.re2j.Pattern; @@ -35,8 +34,9 @@ import java.util.List; import java.util.Map; import lombok.AccessLevel; import lombok.NoArgsConstructor; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder; +import org.onap.policy.common.parameters.topic.BusTopicParams; +import org.onap.policy.common.parameters.topic.BusTopicParams.TopicParamsBuilder; +import org.onap.policy.common.utils.properties.PropertyUtils; @NoArgsConstructor(access = AccessLevel.PRIVATE) public class KafkaPropertyUtils { diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java b/message-bus/src/main/java/org/onap/policy/common/message/bus/utils/NetLoggerUtil.java index 6002c3f6..b5454e5c 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/NetLoggerUtil.java +++ b/message-bus/src/main/java/org/onap/policy/common/message/bus/utils/NetLoggerUtil.java @@ -1,8 +1,7 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +17,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.utils; +package org.onap.policy.common.message.bus.utils; import lombok.Getter; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.features.NetLoggerFeatureProviders; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.features.NetLoggerFeatureProviders; import org.onap.policy.common.utils.services.FeatureApiUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/CommonTestData.java index ce0f58de..ecd2f20c 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/CommonTestData.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/CommonTestData.java @@ -2,7 +2,6 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019, 2024 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,17 +19,16 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.parameters; +package org.onap.policy.common.message.bus.event; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.TreeMap; import org.onap.policy.common.parameters.ParameterGroup; +import org.onap.policy.common.parameters.topic.TopicParameters; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -42,36 +40,28 @@ import org.onap.policy.common.utils.coder.StandardCoder; */ public class CommonTestData { - public static final String REST_SERVER_PASS = "zb!XztG34"; - public static final String REST_SERVER_USER = "healthcheck"; - public static final int REST_SERVER_PORT = 6969; - public static final String REST_SERVER_HOST = "0.0.0.0"; - public static final boolean REST_SERVER_HTTPS = true; - public static final boolean REST_SERVER_AAF = false; - public static final String TOPIC_NAME = "policy-pdp-pap"; public static final String TOPIC_INFRA = "kafka"; public static final String TOPIC_SERVER = "kafka:9092"; public static final List<TopicParameters> TOPIC_PARAMS = - Arrays.asList(getTopicParameters(TOPIC_NAME, TOPIC_INFRA, TOPIC_SERVER)); + List.of(getTopicParameters(TOPIC_NAME, TOPIC_INFRA, TOPIC_SERVER)); protected static final Coder coder = new StandardCoder(); /** * Create topic parameters for test cases. * - * @param topicName name of topic - * @param topicInfra topicCommInfrastructure + * @param topicName name of topic + * @param topicInfra topicCommInfrastructure * @param topicServer topic server - * * @return topic parameters */ public static TopicParameters getTopicParameters(String topicName, String topicInfra, String topicServer) { final TopicParameters topicParams = new TopicParameters(); topicParams.setTopic(topicName); topicParams.setTopicCommInfrastructure(topicInfra); - topicParams.setServers(Arrays.asList(topicServer)); + topicParams.setServers(List.of(topicServer)); return topicParams; } @@ -79,7 +69,7 @@ public class CommonTestData { * Converts the contents of a map to a parameter class. * * @param source property map - * @param clazz class of object to be created from the map + * @param clazz class of object to be created from the map * @return a new object represented by the map */ public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) { @@ -92,27 +82,6 @@ public class CommonTestData { } /** - * Returns a property map for a RestServerParameters map for test cases. - * - * @param isEmpty boolean value to represent that object created should be empty or not - * @return a property map suitable for constructing an object - */ - public Map<String, Object> getRestServerParametersMap(final boolean isEmpty) { - final Map<String, Object> map = new TreeMap<>(); - map.put("https", REST_SERVER_HTTPS); - map.put("aaf", REST_SERVER_AAF); - - if (!isEmpty) { - map.put("host", REST_SERVER_HOST); - map.put("port", REST_SERVER_PORT); - map.put("userName", REST_SERVER_USER); - map.put("password", REST_SERVER_PASS); - } - - return map; - } - - /** * Returns a property map for a TopicParameters map for test cases. * * @param isEmpty boolean value to represent that object created should be empty or not @@ -137,6 +106,6 @@ public class CommonTestData { */ public String getParameterGroupAsString(String filePath) throws IOException { File file = new File(filePath); - return new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); + return Files.readString(file.toPath()); } } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/TopicEndpointProxyTest.java index a30904dd..6f0e38dd 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/TopicEndpointProxyTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm; +package org.onap.policy.common.message.bus.event; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -35,14 +35,14 @@ import java.util.List; import java.util.Properties; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.bus.KafkaTopicFactories; -import org.onap.policy.common.endpoints.event.comm.bus.KafkaTopicPropertyBuilder; -import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories; -import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicPropertyBuilder; -import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; -import org.onap.policy.common.endpoints.parameters.TopicParameters; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.kafka.KafkaTopicFactories; +import org.onap.policy.common.message.bus.event.kafka.KafkaTopicPropertyBuilder; +import org.onap.policy.common.message.bus.event.noop.NoopTopicFactories; +import org.onap.policy.common.message.bus.event.noop.NoopTopicPropertyBuilder; +import org.onap.policy.common.message.bus.properties.MessageBusProperties; +import org.onap.policy.common.parameters.topic.TopicParameterGroup; +import org.onap.policy.common.parameters.topic.TopicParameters; import org.onap.policy.common.utils.gson.GsonTestUtils; class TopicEndpointProxyTest { @@ -64,19 +64,19 @@ class TopicEndpointProxyTest { group.setTopicSources(new LinkedList<>()); NoopTopicPropertyBuilder noopSourceBuilder = - new NoopTopicPropertyBuilder(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS) + new NoopTopicPropertyBuilder(MessageBusProperties.PROPERTY_NOOP_SOURCE_TOPICS) .makeTopic(NOOP_SOURCE_TOPIC); configuration.putAll(noopSourceBuilder.build()); group.getTopicSources().add(noopSourceBuilder.getParams()); NoopTopicPropertyBuilder noopSinkBuilder = - new NoopTopicPropertyBuilder(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS) + new NoopTopicPropertyBuilder(MessageBusProperties.PROPERTY_NOOP_SINK_TOPICS) .makeTopic(NOOP_SINK_TOPIC); configuration.putAll(noopSinkBuilder.build()); group.getTopicSinks().add(noopSinkBuilder.getParams()); TopicParameters invalidCommInfraParams = - new NoopTopicPropertyBuilder(PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS) + new NoopTopicPropertyBuilder(MessageBusProperties.PROPERTY_NOOP_SOURCE_TOPICS) .makeTopic(NOOP_SOURCE_TOPIC).getParams(); invalidCommInfraParams.setTopicCommInfrastructure(Topic.CommInfrastructure.REST.name()); group.getTopicSources().add(invalidCommInfraParams); @@ -145,7 +145,7 @@ class TopicEndpointProxyTest { TopicEndpoint manager = new TopicEndpointProxy(); KafkaTopicPropertyBuilder kafkaTopicPropertyBuilder = - new KafkaTopicPropertyBuilder(PolicyEndPointProperties.PROPERTY_KAFKA_SOURCE_TOPICS) + new KafkaTopicPropertyBuilder(MessageBusProperties.PROPERTY_KAFKA_SOURCE_TOPICS) .makeTopic(KAFKA_SOURCE_TOPIC); configuration.putAll(kafkaTopicPropertyBuilder.build()); @@ -189,7 +189,7 @@ class TopicEndpointProxyTest { assertSame(1, sinks.size()); KafkaTopicPropertyBuilder kafkaTopicPropertyBuilder = - new KafkaTopicPropertyBuilder(PolicyEndPointProperties.PROPERTY_KAFKA_SINK_TOPICS) + new KafkaTopicPropertyBuilder(MessageBusProperties.PROPERTY_KAFKA_SINK_TOPICS) .makeTopic(KAFKA_SINK_TOPIC); configuration.putAll(kafkaTopicPropertyBuilder.build()); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/TopicParameterGroupTest.java index a81263a9..db28892e 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/TopicParameterGroupTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/TopicParameterGroupTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.parameters; +package org.onap.policy.common.message.bus.event; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -32,8 +32,10 @@ import java.lang.reflect.Modifier; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.parameters.ValidationResult; +import org.onap.policy.common.parameters.topic.BusTopicParams; +import org.onap.policy.common.parameters.topic.TopicParameterGroup; +import org.onap.policy.common.parameters.topic.TopicParameters; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -44,8 +46,9 @@ import org.onap.policy.common.utils.coder.StandardCoder; * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ class TopicParameterGroupTest { - private static CommonTestData testData = new CommonTestData(); + private static final CommonTestData testData = new CommonTestData(); private static final Coder coder = new StandardCoder(); + private final String packageDir = "src/test/resources/org/onap/policy/common/message/bus/parameters/"; @Test void test() throws CoderException { @@ -76,7 +79,7 @@ class TopicParameterGroupTest { @Test void test_valid() throws Exception { String json = testData.getParameterGroupAsString( - "src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json"); + packageDir + "TopicParameters_valid.json"); TopicParameterGroup topicParameterGroup = coder.decode(json, TopicParameterGroup.class); final ValidationResult result = topicParameterGroup.validate(); assertNull(result.getResult()); @@ -86,7 +89,7 @@ class TopicParameterGroupTest { @Test void test_invalid() throws Exception { String json = testData.getParameterGroupAsString( - "src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_invalid.json"); + packageDir + "TopicParameters_invalid.json"); TopicParameterGroup topicParameterGroup = coder.decode(json, TopicParameterGroup.class); final ValidationResult result = topicParameterGroup.validate(); assertFalse(result.isValid()); @@ -96,7 +99,7 @@ class TopicParameterGroupTest { @Test void test_missing_mandatory_params() throws Exception { String json = testData.getParameterGroupAsString( - "src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json"); + packageDir + "TopicParameters_missing_mandatory.json"); TopicParameterGroup topicParameterGroup = coder.decode(json, TopicParameterGroup.class); final ValidationResult result = topicParameterGroup.validate(); assertTrue(result.getResult().contains("Mandatory parameters are missing")); @@ -104,9 +107,9 @@ class TopicParameterGroupTest { } @Test - void test_allparams() throws Exception { + void test_allParams() throws Exception { String json = testData.getParameterGroupAsString( - "src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json"); + packageDir + "TopicParameters_all_params.json"); TopicParameterGroup topicParameterGroup = coder.decode(json, TopicParameterGroup.class); final ValidationResult result = topicParameterGroup.validate(); assertNull(result.getResult()); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/BusConsumerTest.java index 36efff90..207023e5 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusConsumerTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/BusConsumerTest.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ @@ -19,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; @@ -51,10 +49,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.FetchingBusConsumer; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusConsumer.KafkaConsumerWrapper; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; +import org.onap.policy.common.message.bus.event.base.BusConsumer.FetchingBusConsumer; +import org.onap.policy.common.message.bus.event.base.BusConsumer.KafkaConsumerWrapper; +import org.onap.policy.common.message.bus.properties.MessageBusProperties; +import org.onap.policy.common.parameters.topic.BusTopicParams; class BusConsumerTest extends TopicTestBase { @@ -83,16 +81,16 @@ class BusConsumerTest extends TopicTestBase { void testFetchingBusConsumer() { // should not be negative var cons = new FetchingBusConsumerImpl(makeBuilder().fetchTimeout(-1).build()); - assertThat(cons.getSleepTime()).isEqualTo(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH); + assertThat(cons.getSleepTime()).isEqualTo(MessageBusProperties.DEFAULT_TIMEOUT_MS_FETCH); // should not be zero cons = new FetchingBusConsumerImpl(makeBuilder().fetchTimeout(0).build()); - assertThat(cons.getSleepTime()).isEqualTo(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH); + assertThat(cons.getSleepTime()).isEqualTo(MessageBusProperties.DEFAULT_TIMEOUT_MS_FETCH); // should not be too large cons = new FetchingBusConsumerImpl( - makeBuilder().fetchTimeout(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH + 100).build()); - assertThat(cons.getSleepTime()).isEqualTo(PolicyEndPointProperties.DEFAULT_TIMEOUT_MS_FETCH); + makeBuilder().fetchTimeout(MessageBusProperties.DEFAULT_TIMEOUT_MS_FETCH + 100).build()); + assertThat(cons.getSleepTime()).isEqualTo(MessageBusProperties.DEFAULT_TIMEOUT_MS_FETCH); // should not be what was specified cons = new FetchingBusConsumerImpl(makeBuilder().fetchTimeout(100).build()); @@ -226,7 +224,7 @@ class BusConsumerTest extends TopicTestBase { } @Test - void testFetchWithMessagesAndTraceparent() { + void testFetchWithMessagesAndTraceParent() { // Setup KafkaConsumerWrapper kafkaConsumerWrapper = new KafkaConsumerWrapper(makeKafkaBuilder().build()); kafkaConsumerWrapper.consumer = mockedKafkaConsumer; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/BusTopicBaseTest.java index f24f7e2e..343a56a8 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/BusTopicBaseTest.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -19,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -30,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.parameters.topic.BusTopicParams; import org.onap.policy.common.utils.gson.GsonTestUtils; class BusTopicBaseTest extends TopicTestBase { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/BusTopicFactoryTestBase.java index b2a35408..bd531114 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/BusTopicFactoryTestBase.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/BusTopicFactoryTestBase.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -19,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.base; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -29,17 +27,16 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_HTTP_HTTPS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_MANAGED_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; -import java.util.Arrays; import java.util.List; import java.util.Properties; import java.util.function.Predicate; -import org.onap.policy.common.endpoints.event.comm.Topic; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.message.bus.event.Topic; +import org.onap.policy.common.parameters.topic.BusTopicParams; /** * Base class for Topic Factory tests that use BusTopicParams. @@ -75,7 +72,7 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact /** * Tests building a topic using BusTopicParams. */ - void testBuildBusTopicParams() { + public void testBuildBusTopicParams() { initFactory(); // two unmanaged topics @@ -112,7 +109,7 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact /** * Tests exception cases when building a topic using BusTopicParams. */ - void testBuildBusTopicParams_Ex() { + public void testBuildBusTopicParams_Ex() { // null topic assertThatIllegalArgumentException().isThrownBy(() -> buildTopic(makeBuilder().topic(null).build())); @@ -123,7 +120,7 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact /** * Tests building a topic using a list of servers and a topic. */ - void testBuildListOfStringString() { + public void testBuildListOfStringString() { initFactory(); T item1 = buildTopic(servers, MY_TOPIC); @@ -133,8 +130,8 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact BusTopicParams params = getLastParams(); assertEquals(servers, params.getServers()); assertEquals(MY_TOPIC, params.getTopic()); - assertEquals(true, params.isManaged()); - assertEquals(false, params.isUseHttps()); + assertTrue(params.isManaged()); + assertFalse(params.isUseHttps()); T item2 = buildTopic(servers, TOPIC2); assertNotNull(item2); @@ -149,7 +146,7 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact * Tests building a topic using Properties. Verifies parameters specific to Bus * topics. */ - void testBuildProperties() { + public void testBuildProperties() { initFactory(); List<T> topics = buildTopics(makePropBuilder().makeTopic(MY_TOPIC).build()); @@ -158,12 +155,12 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact assertEquals(MY_EFFECTIVE_TOPIC, topics.get(0).getEffectiveTopic()); BusTopicParams params = getLastParams(); - assertEquals(true, params.isManaged()); - assertEquals(true, params.isUseHttps()); - assertEquals(true, params.isAllowSelfSignedCerts()); + assertTrue(params.isManaged()); + assertTrue(params.isUseHttps()); + assertTrue(params.isAllowSelfSignedCerts()); assertEquals(MY_API_KEY, params.getApiKey()); assertEquals(MY_API_SECRET, params.getApiSecret()); - assertEquals(Arrays.asList(SERVER), params.getServers()); + assertEquals(List.of(SERVER), params.getServers()); assertEquals(MY_TOPIC, params.getTopic()); assertEquals(MY_EFFECTIVE_TOPIC, params.getEffectiveTopic()); @@ -223,7 +220,7 @@ public abstract class BusTopicFactoryTestBase<T extends Topic> extends TopicFact * @param builderName name of the builder property * @param addName name of the "additional" property */ - protected void expectNullAddProp(String builderName, String addName) { + public void expectNullAddProp(String builderName, String addName) { // remove the property initFactory(); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/InlineBusTopicSinkTest.java index ce363269..820fc2c3 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/InlineBusTopicSinkTest.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ @@ -19,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -38,9 +36,9 @@ import java.util.List; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.TopicListener; +import org.onap.policy.common.parameters.topic.BusTopicParams; import org.onap.policy.common.utils.gson.GsonTestUtils; class InlineBusTopicSinkTest extends TopicTestBase { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/SingleThreadedBusTopicSourceTest.java index bc2d3779..8ad8e8fd 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/SingleThreadedBusTopicSourceTest.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -19,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; @@ -43,9 +41,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.TopicListener; +import org.onap.policy.common.parameters.topic.BusTopicParams; import org.onap.policy.common.utils.gson.GsonTestUtils; import org.onap.policy.common.utils.network.NetworkUtil; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicBaseTest.java index fe719848..5ecde258 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicBaseTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.base; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -32,14 +32,12 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import java.util.Arrays; import java.util.Collections; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.TopicListener; import org.onap.policy.common.utils.gson.GsonTestUtils; class TopicBaseTest extends TopicTestBase { @@ -109,16 +107,16 @@ class TopicBaseTest extends TopicTestBase { void testRegister() { TopicListener listener = mock(TopicListener.class); base.register(listener); - assertEquals(Arrays.asList(listener), base.snapshotTopicListeners()); + assertEquals(List.of(listener), base.snapshotTopicListeners()); // re-register - list should be unchanged base.register(listener); - assertEquals(Arrays.asList(listener), base.snapshotTopicListeners()); + assertEquals(List.of(listener), base.snapshotTopicListeners()); // register a new listener TopicListener listener2 = mock(TopicListener.class); base.register(listener2); - assertEquals(Arrays.asList(listener, listener2), base.snapshotTopicListeners()); + assertEquals(List.of(listener, listener2), base.snapshotTopicListeners()); } @Test @@ -136,7 +134,7 @@ class TopicBaseTest extends TopicTestBase { // unregister one base.unregister(listener); - assertEquals(Arrays.asList(listener2), base.snapshotTopicListeners()); + assertEquals(List.of(listener2), base.snapshotTopicListeners()); // unregister the other base.unregister(listener2); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicFactoryTestBase.java index 0efbf3c2..8444b482 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicFactoryTestBase.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -19,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.base; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; @@ -28,11 +26,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; import java.util.List; import java.util.Properties; -import org.onap.policy.common.endpoints.event.comm.Topic; +import org.onap.policy.common.message.bus.event.Topic; /** * Base class for XxxTopicFactory tests. @@ -107,22 +105,22 @@ public abstract class TopicFactoryTestBase<T extends Topic> extends TopicTestBas // null servers assertTrue(buildTopics(makePropBuilder().makeTopic(MY_TOPIC).removeTopicProperty(PROPERTY_TOPIC_SERVERS_SUFFIX) - .build()).isEmpty()); + .build()).isEmpty()); // empty servers assertTrue(buildTopics(makePropBuilder().makeTopic(MY_TOPIC).setTopicProperty(PROPERTY_TOPIC_SERVERS_SUFFIX, "") - .build()).isEmpty()); + .build()).isEmpty()); } /** * Tests building multiple topics using Properties. */ - void testBuildProperties_Multiple() { + public void testBuildProperties_Multiple() { initFactory(); // make two fully-defined topics, and add two duplicate topic names to the list TopicPropertyBuilder builder = - makePropBuilder().makeTopic(MY_TOPIC).makeTopic(TOPIC2).addTopic(MY_TOPIC).addTopic(MY_TOPIC); + makePropBuilder().makeTopic(MY_TOPIC).makeTopic(TOPIC2).addTopic(MY_TOPIC).addTopic(MY_TOPIC); List<T> lst = buildTopics(builder.build()); assertEquals(4, lst.size()); @@ -137,7 +135,7 @@ public abstract class TopicFactoryTestBase<T extends Topic> extends TopicTestBas /** * Tests destroy(topic), get(topic), and inventory() methods. */ - void testDestroyString_testGet_testInventory() { + public void testDestroyString_testGet_testInventory() { initFactory(); List<T> lst = buildTopics(makePropBuilder().makeTopic(MY_TOPIC).makeTopic(TOPIC2).build()); @@ -178,7 +176,7 @@ public abstract class TopicFactoryTestBase<T extends Topic> extends TopicTestBas /** * Tests exception cases with destroy(topic). */ - void testDestroyString_Ex() { + public void testDestroyString_Ex() { // null topic assertThatIllegalArgumentException().as("null topic").isThrownBy(() -> destroyTopic(null)); @@ -189,7 +187,7 @@ public abstract class TopicFactoryTestBase<T extends Topic> extends TopicTestBas /** * Tests the destroy() method. */ - void testDestroy() { + public void testDestroy() { initFactory(); List<T> lst = buildTopics(makePropBuilder().makeTopic(MY_TOPIC).makeTopic(TOPIC2).build()); @@ -211,7 +209,7 @@ public abstract class TopicFactoryTestBase<T extends Topic> extends TopicTestBas /** * Tests exception cases with get(topic). */ - void testGet_Ex() { + public void testGet_Ex() { // null topic assertThatIllegalArgumentException().as("null topic").isThrownBy(() -> getTopic(null)); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicPropertyBuilder.java index e8031c1a..29c5306b 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicPropertyBuilder.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicPropertyBuilder.java @@ -3,6 +3,7 @@ * ONAP Policy Engine - Common Modules * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.base; import java.util.Properties; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicTestBase.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicTestBase.java index 00111fb2..8d5c3535 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicTestBase.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/base/TopicTestBase.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ @@ -19,14 +17,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.base; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.TreeMap; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder; +import org.onap.policy.common.parameters.topic.BusTopicParams; +import org.onap.policy.common.parameters.topic.BusTopicParams.TopicParamsBuilder; /** * Base class for Topic Test classes. @@ -56,10 +54,7 @@ public class TopicTestBase { public static final String MY_MESSAGE = "my-message"; public static final String MY_PARTITION = "my-partition"; public static final String MY_MESSAGE2 = "my-message-2"; - public static final String MY_PARTITION2 = "my-partition-2"; - public static final String ROUTE_PROP = "routeOffer"; - public static final String MY_ROUTE = "my-route"; public static final String MY_SERIALIZER = "org.apache.kafka.common.serialization.StringSerializer"; public static final int KAFKA_PORT = 9092; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/client/BidirectionalTopicClientTest.java index 890fa720..ba33ff9a 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/BidirectionalTopicClientTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/client/BidirectionalTopicClientTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.client; +package org.onap.policy.common.message.bus.event.client; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -51,12 +51,12 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; -import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.event.comm.TopicSource; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.TopicEndpoint; +import org.onap.policy.common.message.bus.event.TopicEndpointManager; +import org.onap.policy.common.message.bus.event.TopicListener; +import org.onap.policy.common.message.bus.event.TopicSink; +import org.onap.policy.common.message.bus.event.TopicSource; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -153,19 +153,19 @@ class BidirectionalTopicClientTest { @Test void testBidirectionalTopicClientExceptions() { assertThatThrownBy(() -> new BidirectionalTopicClient2("unknown-sink", SOURCE_TOPIC)) - .isInstanceOf(BidirectionalTopicClientException.class) - .hasMessage("no sinks for topic: unknown-sink"); + .isInstanceOf(BidirectionalTopicClientException.class) + .hasMessage("no sinks for topic: unknown-sink"); assertThatThrownBy(() -> new BidirectionalTopicClient2(SINK_TOPIC, "unknown-source")) - .isInstanceOf(BidirectionalTopicClientException.class) - .hasMessage("no sources for topic: unknown-source"); + .isInstanceOf(BidirectionalTopicClientException.class) + .hasMessage("no sources for topic: unknown-source"); // too many sources when(endpoint.getTopicSources(Arrays.asList(SOURCE_TOPIC))).thenReturn(Arrays.asList(source, source)); assertThatThrownBy(() -> new BidirectionalTopicClient2(SINK_TOPIC, SOURCE_TOPIC)) - .isInstanceOf(BidirectionalTopicClientException.class) - .hasMessage("too many sources for topic: my-source-topic"); + .isInstanceOf(BidirectionalTopicClientException.class) + .hasMessage("too many sources for topic: my-source-topic"); } /** @@ -296,7 +296,7 @@ class BidirectionalTopicClientTest { * Verifies that awaitReceipt() returns {@code true}. * * @throws InterruptedException if interrupted while waiting for the thread to - * terminate + * terminate */ private void verifyReceipt() throws InterruptedException { assertThat(context.join()).isTrue(); @@ -311,7 +311,7 @@ class BidirectionalTopicClientTest { * Verifies that awaitReceipt() returns {@code false}. * * @throws InterruptedException if interrupted while waiting for the thread to - * terminate + * terminate */ private void verifyNoReceipt() throws InterruptedException { assertThat(context.join()).isTrue(); @@ -351,7 +351,7 @@ class BidirectionalTopicClientTest { private class BidirectionalTopicClient2 extends BidirectionalTopicClient { public BidirectionalTopicClient2(String sinkTopic, String sourceTopic) - throws BidirectionalTopicClientException { + throws BidirectionalTopicClientException { super(sinkTopic, sourceTopic); } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicClientExceptionTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/client/TopicClientExceptionTest.java index ba935822..1ea2f1bc 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicClientExceptionTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/client/TopicClientExceptionTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.client; +package org.onap.policy.common.message.bus.event.client; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/client/TopicSinkClientTest.java index 81621195..67b15ec9 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/client/TopicSinkClientTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/client/TopicSinkClientTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.client; +package org.onap.policy.common.message.bus.event.client; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -38,8 +38,8 @@ import java.util.concurrent.atomic.AtomicReference; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; -import org.onap.policy.common.endpoints.event.comm.TopicSink; +import org.onap.policy.common.message.bus.event.TopicEndpointManager; +import org.onap.policy.common.message.bus.event.TopicSink; class TopicSinkClientTest { private static final String TOPIC = "my-topic"; @@ -101,7 +101,7 @@ class TopicSinkClientTest { // unknown topic -> should throw exception sinks = new LinkedList<>(); assertThatThrownBy(() -> new TopicSinkClient2(TOPIC)).isInstanceOf(TopicSinkClientException.class) - .hasMessage("no sinks for topic: my-topic"); + .hasMessage("no sinks for topic: my-topic"); } @Test @@ -109,9 +109,10 @@ class TopicSinkClientTest { assertEquals(TOPIC, new TopicSinkClient(TopicEndpointManager.getManager().getNoopTopicSink(TOPIC)).getTopic()); assertEquals(TOPIC, new TopicSinkClient(TOPIC).getTopic()); - assertThatThrownBy(() -> new TopicSinkClient((TopicSink) null)).isInstanceOf(IllegalArgumentException.class); + assertThatThrownBy(() -> new TopicSinkClient((TopicSink) null)) + .hasMessageContaining("sink is marked non-null but is null"); assertThatThrownBy(() -> new TopicSinkClient("blah")).isInstanceOf(TopicSinkClientException.class) - .hasMessage("no sinks for topic: blah"); + .hasMessage("no sinks for topic: blah"); } @Test diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSourceFactoryTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/IndexedKafkaTopicSourceFactoryTest.java index 80229419..a901b07b 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/IndexedKafkaTopicSourceFactoryTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/IndexedKafkaTopicSourceFactoryTest.java @@ -16,23 +16,18 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.List; -import org.apache.kafka.clients.ClientUtils; import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.parameters.topic.BusTopicParams; class IndexedKafkaTopicSourceFactoryTest { private IndexedKafkaTopicSourceFactory factory; - @Mock - ClientUtils mockClientUtils; - @Test void testBuild() { factory = new IndexedKafkaTopicSourceFactory(); @@ -64,11 +59,5 @@ class IndexedKafkaTopicSourceFactoryTest { assertThatThrownBy(() -> factory.build(params)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("A topic must be provided"); - - params.setTopic("topic01"); - - assertThatThrownBy(() -> factory.build(servers, "topic1")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessageContaining("cannot create topic"); } } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSinkTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/InlineKafkaTopicSinkTest.java index 91412ff6..c8d6e21e 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSinkTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/InlineKafkaTopicSinkTest.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +16,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.kafka; import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -27,8 +25,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.base.TopicTestBase; class InlineKafkaTopicSinkTest extends TopicTestBase { private InlineKafkaTopicSink sink; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/KafkaPublisherWrapperTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaPublisherWrapperTest.java index 1f7c2cf7..8e13af23 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/KafkaPublisherWrapperTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaPublisherWrapperTest.java @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.kafka; import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,10 +34,11 @@ import org.apache.kafka.clients.producer.ProducerRecord; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; +import org.onap.policy.common.parameters.topic.BusTopicParams; class KafkaPublisherWrapperTest { - private BusPublisher.KafkaPublisherWrapper kafkaPublisherWrapper; + private KafkaPublisherWrapper kafkaPublisherWrapper; private Producer<String, String> mockProducer; private BusTopicParams mockBusTopicParams; @@ -52,8 +53,8 @@ class KafkaPublisherWrapperTest { when(mockBusTopicParams.isAdditionalPropsValid()).thenReturn(false); when(mockBusTopicParams.isAllowTracing()).thenReturn(false); - kafkaPublisherWrapper = new BusPublisher.KafkaPublisherWrapper(mockBusTopicParams) { - protected Producer<String, String> createProducer(Properties props) { // NOSONAR instance creation + kafkaPublisherWrapper = new KafkaPublisherWrapper(mockBusTopicParams) { + private Producer<String, String> createProducer(Properties props) { // NOSONAR instance creation return mockProducer; } }; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicFactoryTestBase.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicFactoryTestBase.java index 084e0404..1085ee90 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicFactoryTestBase.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicFactoryTestBase.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,12 +16,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import java.util.Collections; -import org.onap.policy.common.endpoints.event.comm.Topic; +import org.onap.policy.common.message.bus.event.Topic; +import org.onap.policy.common.message.bus.event.base.BusTopicFactoryTestBase; /** * Base class for KafkaTopicXxxFactory tests. @@ -33,7 +32,7 @@ import org.onap.policy.common.endpoints.event.comm.Topic; public abstract class KafkaTopicFactoryTestBase<T extends Topic> extends BusTopicFactoryTestBase<T> { @Override - void testBuildBusTopicParams_Ex() { + public void testBuildBusTopicParams_Ex() { super.testBuildBusTopicParams_Ex(); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicPropertyBuilder.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicPropertyBuilder.java index b49f58e2..6a1be7a0 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicPropertyBuilder.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicPropertyBuilder.java @@ -16,15 +16,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; -import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_EFFECTIVE_TOPIC; -import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_PARTITION; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX; +import static org.onap.policy.common.message.bus.event.base.TopicTestBase.MY_EFFECTIVE_TOPIC; +import static org.onap.policy.common.message.bus.event.base.TopicTestBase.MY_PARTITION; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_HTTP_HTTPS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_MANAGED_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -32,7 +32,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; import lombok.Getter; -import org.onap.policy.common.endpoints.parameters.TopicParameters; +import org.onap.policy.common.message.bus.event.base.TopicPropertyBuilder; +import org.onap.policy.common.parameters.topic.TopicParameters; @Getter public class KafkaTopicPropertyBuilder extends TopicPropertyBuilder { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkFactoryTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSinkFactoryTest.java index 5ff6782f..62210361 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkFactoryTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSinkFactoryTest.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2022, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,14 +16,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_KAFKA_SINK_TOPICS; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_KAFKA_SINK_TOPICS; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; import java.util.Deque; import java.util.LinkedList; @@ -34,7 +32,8 @@ import java.util.Properties; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.message.bus.event.base.TopicPropertyBuilder; +import org.onap.policy.common.parameters.topic.BusTopicParams; class KafkaTopicSinkFactoryTest extends KafkaTopicFactoryTestBase<KafkaTopicSink> { @@ -59,14 +58,14 @@ class KafkaTopicSinkFactoryTest extends KafkaTopicFactoryTestBase<KafkaTopicSink @Test @Override - void testBuildBusTopicParams() { + public void testBuildBusTopicParams() { super.testBuildBusTopicParams(); super.testBuildBusTopicParams_Ex(); } @Test @Override - void testBuildListOfStringString() { + public void testBuildListOfStringString() { super.testBuildListOfStringString(); // check parameters that were used @@ -76,7 +75,7 @@ class KafkaTopicSinkFactoryTest extends KafkaTopicFactoryTestBase<KafkaTopicSink @Test @Override - void testBuildProperties() { + public void testBuildProperties() { List<KafkaTopicSink> topics = buildTopics(makePropBuilder().makeTopic(MY_TOPIC).build()); assertEquals(1, topics.size()); assertEquals(MY_TOPIC, topics.get(0).getTopic()); @@ -111,14 +110,14 @@ class KafkaTopicSinkFactoryTest extends KafkaTopicFactoryTestBase<KafkaTopicSink @Test @Override - void testDestroyString_testGet_testInventory() { + public void testDestroyString_testGet_testInventory() { super.testDestroyString_testGet_testInventory(); super.testDestroyString_Ex(); } @Test @Override - void testDestroy() { + public void testDestroy() { super.testDestroy(); } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSinkTest.java index a34dac74..8818a27f 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSinkTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSinkTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; import static org.junit.jupiter.api.Assertions.assertNotNull; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceFactoryTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSourceFactoryTest.java index 3e4ffda5..c91e548b 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceFactoryTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSourceFactoryTest.java @@ -18,12 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; 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.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_KAFKA_SOURCE_TOPICS; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_KAFKA_SOURCE_TOPICS; import java.util.Deque; import java.util.LinkedList; @@ -32,7 +32,8 @@ import java.util.Properties; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.message.bus.event.base.TopicPropertyBuilder; +import org.onap.policy.common.parameters.topic.BusTopicParams; class KafkaTopicSourceFactoryTest extends KafkaTopicFactoryTestBase<KafkaTopicSource> { @@ -58,7 +59,7 @@ class KafkaTopicSourceFactoryTest extends KafkaTopicFactoryTestBase<KafkaTopicSo @Test @Override - void testBuildProperties() { + public void testBuildProperties() { initFactory(); @@ -77,14 +78,14 @@ class KafkaTopicSourceFactoryTest extends KafkaTopicFactoryTestBase<KafkaTopicSo @Test @Override - void testDestroyString_testGet_testInventory() { + public void testDestroyString_testGet_testInventory() { super.testDestroyString_testGet_testInventory(); super.testDestroyString_Ex(); } @Test @Override - void testDestroy() { + public void testDestroy() { super.testDestroy(); } @@ -156,7 +157,7 @@ class KafkaTopicSourceFactoryTest extends KafkaTopicFactoryTestBase<KafkaTopicSo * Factory that records the parameters of all the sources it creates. */ private static class SourceFactory extends IndexedKafkaTopicSourceFactory { - private Deque<BusTopicParams> params = new LinkedList<>(); + private final Deque<BusTopicParams> params = new LinkedList<>(); @Override protected KafkaTopicSource makeSource(BusTopicParams busTopicParams) { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSourceTest.java index 6afe5576..5572bc01 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/KafkaTopicSourceTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/KafkaTopicSourceTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.kafka; import static org.junit.jupiter.api.Assertions.assertNotNull; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSourceTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/SingleThreadedKafkaTopicSourceTest.java index 84df1228..0c732ba7 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSourceTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/kafka/SingleThreadedKafkaTopicSourceTest.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -19,18 +17,16 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus.internal; +package org.onap.policy.common.message.bus.event.kafka; -import static org.assertj.core.api.Assertions.assertThatCode; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; -import org.onap.policy.common.utils.gson.GsonTestUtils; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.base.TopicTestBase; class SingleThreadedKafkaTopicSourceTest extends TopicTestBase { private SingleThreadedKafkaTopicSource source; @@ -51,11 +47,6 @@ class SingleThreadedKafkaTopicSourceTest extends TopicTestBase { source.shutdown(); } - void testSerialize() { - assertThatCode(() -> new GsonTestUtils().compareGson(source, SingleThreadedKafkaTopicSourceTest.class)) - .doesNotThrowAnyException(); - } - @Test void testToString() { assertTrue(source.toString().startsWith("SingleThreadedKafkaTopicSource [")); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpointTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicEndpointTest.java index fd8f3a96..3ebec83c 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicEndpointTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicEndpointTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -33,8 +33,9 @@ import java.util.Arrays; import java.util.Collections; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.TopicListener; +import org.onap.policy.common.message.bus.event.base.TopicTestBase; public abstract class NoopTopicEndpointTest<F extends NoopTopicFactory<T>, T extends NoopTopicEndpoint> extends TopicTestBase { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactoryTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicFactoryTest.java index 3a0ec95f..4dcba86e 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicFactoryTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicFactoryTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -28,11 +28,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_MANAGED_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Properties; @@ -40,13 +39,16 @@ import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.base.TopicFactoryTestBase; +import org.onap.policy.common.message.bus.event.base.TopicPropertyBuilder; +import org.onap.policy.common.message.bus.event.base.TopicTestBase; +import org.onap.policy.common.parameters.topic.BusTopicParams; public abstract class NoopTopicFactoryTest<F extends NoopTopicFactory<T>, T extends NoopTopicEndpoint> extends TopicFactoryTestBase<T> { - private static final List<String> NOOP_SERVERS = Arrays.asList(CommInfrastructure.NOOP.toString()); + private static final List<String> NOOP_SERVERS = List.of(CommInfrastructure.NOOP.toString()); private F factory = null; protected abstract F buildFactory(); @@ -70,7 +72,7 @@ public abstract class NoopTopicFactoryTest<F extends NoopTopicFactory<T>, T exte void testBuildBusTopicParams() { initFactory(); - T item1 = buildTopic(makeParams(servers, MY_TOPIC, true)); + T item1 = buildTopic(makeParams(servers)); assertNotNull(item1); assertEquals(servers, item1.getServers()); @@ -180,14 +182,14 @@ public abstract class NoopTopicFactoryTest<F extends NoopTopicFactory<T>, T exte @Test @Override - void testDestroyString_testGet_testInventory() { + public void testDestroyString_testGet_testInventory() { super.testDestroyString_testGet_testInventory(); super.testDestroyString_Ex(); } @Test @Override - void testDestroy() { + public void testDestroy() { super.testDestroy(); } @@ -243,12 +245,12 @@ public abstract class NoopTopicFactoryTest<F extends NoopTopicFactory<T>, T exte return new NoopTopicPropertyBuilder(factory.getTopicsPropertyName()); } - private BusTopicParams makeParams(List<String> servers, String topic, boolean managed) { + private BusTopicParams makeParams(List<String> servers) { BusTopicParams params = new BusTopicParams(); params.setServers(servers); - params.setTopic(topic); - params.setManaged(managed); + params.setTopic(TopicTestBase.MY_TOPIC); + params.setManaged(true); return params; } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicPropertyBuilder.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicPropertyBuilder.java index 3f0553f8..57b78435 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicPropertyBuilder.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicPropertyBuilder.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,26 +19,26 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; -import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_EFFECTIVE_TOPIC; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; +import static org.onap.policy.common.message.bus.event.base.TopicTestBase.MY_EFFECTIVE_TOPIC; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_HTTP_HTTPS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_MANAGED_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; -import java.util.Arrays; +import java.util.List; import lombok.Getter; -import org.onap.policy.common.endpoints.parameters.TopicParameters; +import org.onap.policy.common.message.bus.event.base.TopicPropertyBuilder; +import org.onap.policy.common.parameters.topic.TopicParameters; +@Getter public class NoopTopicPropertyBuilder extends TopicPropertyBuilder { public static final String SERVER = "my-server"; - public static final String TOPIC2 = "my-topic-2"; - @Getter - private TopicParameters params = new TopicParameters(); + private final TopicParameters params = new TopicParameters(); /** * Constructs the object. @@ -69,7 +70,7 @@ public class NoopTopicPropertyBuilder extends TopicPropertyBuilder { params.setManaged(true); params.setUseHttps(true); params.setAllowSelfSignedCerts(true); - params.setServers(Arrays.asList(SERVER)); + params.setServers(List.of(SERVER)); return this; } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactoryTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSinkFactoryTest.java index 872fabf9..ecd4df1e 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkFactoryTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSinkFactoryTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSinkTest.java index 26de1647..ecba379f 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSinkTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSinkTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSourceFactoryTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSourceFactoryTest.java index fe5343f5..c9038068 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSourceFactoryTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSourceFactoryTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSourceTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSourceTest.java index a28a619e..51ff109b 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/NoopTopicSourceTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/event/noop/NoopTopicSourceTest.java @@ -1,7 +1,5 @@ /* * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -19,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.event.comm.bus; +package org.onap.policy.common.message.bus.event.noop; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApiTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/features/NetLoggerFeatureApiTest.java index 2ea64239..776c5d57 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/features/NetLoggerFeatureApiTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/features/NetLoggerFeatureApiTest.java @@ -16,7 +16,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.features; +package org.onap.policy.common.message.bus.features; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -25,8 +25,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; import org.slf4j.Logger; @ExtendWith(MockitoExtension.class) diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/KafkaPropertyUtilsTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/utils/KafkaPropertyUtilsTest.java index 52caa470..55f6a69f 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/KafkaPropertyUtilsTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/utils/KafkaPropertyUtilsTest.java @@ -1,7 +1,5 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,13 +16,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.utils; +package org.onap.policy.common.message.bus.utils; -import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_ADDITIONAL_PROPS_SUFFIX; +import static org.onap.policy.common.message.bus.properties.MessageBusProperties.PROPERTY_ADDITIONAL_PROPS_SUFFIX; import java.util.Properties; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.onap.policy.common.utils.properties.PropertyUtils; class KafkaPropertyUtilsTest { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java b/message-bus/src/test/java/org/onap/policy/common/message/bus/utils/NetLoggerUtilTest.java index 123d1a77..df621f5b 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/NetLoggerUtilTest.java +++ b/message-bus/src/test/java/org/onap/policy/common/message/bus/utils/NetLoggerUtilTest.java @@ -1,7 +1,5 @@ /*- * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -19,7 +17,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.utils; +package org.onap.policy.common.message.bus.utils; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -30,10 +28,10 @@ import java.util.List; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.features.NetLoggerFeatureApi; -import org.onap.policy.common.endpoints.features.NetLoggerFeatureProviders; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.features.NetLoggerFeatureApi; +import org.onap.policy.common.message.bus.features.NetLoggerFeatureProviders; +import org.onap.policy.common.message.bus.utils.NetLoggerUtil.EventType; import org.slf4j.Logger; /** @@ -205,7 +203,7 @@ class NetLoggerUtilTest { * Sets the return value for the before/after hooks. * * @param beforeVal beforeLog() return value - * @param afterVal afterLog() return value + * @param afterVal afterLog() return value */ public void setReturnValue(boolean beforeVal, boolean afterVal) { this.beforeReturn = beforeVal; @@ -239,7 +237,7 @@ class NetLoggerUtilTest { */ @Override public boolean beforeLog(Logger eventLogger, EventType type, CommInfrastructure protocol, String topic, - String message) { + String message) { if (beforeException) { throw new RuntimeException("beforeLog exception"); @@ -255,7 +253,7 @@ class NetLoggerUtilTest { */ @Override public boolean afterLog(Logger eventLogger, EventType type, CommInfrastructure protocol, String topic, - String message) { + String message) { if (afterException) { throw new RuntimeException("afterLog exception"); diff --git a/message-bus/src/test/resources/META-INF/services/org.onap.policy.common.message.bus.features.NetLoggerFeatureApi b/message-bus/src/test/resources/META-INF/services/org.onap.policy.common.message.bus.features.NetLoggerFeatureApi new file mode 100644 index 00000000..7889cb8f --- /dev/null +++ b/message-bus/src/test/resources/META-INF/services/org.onap.policy.common.message.bus.features.NetLoggerFeatureApi @@ -0,0 +1 @@ +org.onap.policy.common.message.bus.utils.NetLoggerUtilTest$NetLoggerFeature
\ No newline at end of file diff --git a/message-bus/src/test/resources/logback-test.xml b/message-bus/src/test/resources/logback-test.xml new file mode 100644 index 00000000..ddf4f8bb --- /dev/null +++ b/message-bus/src/test/resources/logback-test.xml @@ -0,0 +1,42 @@ +<!-- + ============LICENSE_START======================================================= + ONAP + ================================================================================ + Copyright (C) 2024 Nordix Foundation. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> +<configuration> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> + <Pattern> + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n + </Pattern> + </encoder> + </appender> + + <appender name="testAppender" class="org.onap.policy.common.message.bus.utils.NetLoggerUtilTest$TestAppender"/> + + <logger name="org.onap.policy.drools.http.server.test" level="INFO"/> + + <logger name="network" level="INFO"> + <appender-ref ref="testAppender"/> + </logger> + + <root level="WARN"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration>
\ No newline at end of file diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/TopicEndpointProxyTest.json index 5b2e712a..5b2e712a 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/TopicEndpointProxyTest.json +++ b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/TopicEndpointProxyTest.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/BusTopicBaseTest.json index 462278a4..462278a4 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicBaseTest.json +++ b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/BusTopicBaseTest.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/InlineBusTopicSinkTest.json index 1f2fb55f..1f2fb55f 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineBusTopicSinkTest.json +++ b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/InlineBusTopicSinkTest.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/SingleThreadedBusTopicSourceTest.json index 305620c8..305620c8 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedBusTopicSourceTest.json +++ b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/SingleThreadedBusTopicSourceTest.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/TopicBaseTest.json index b72b4efd..b72b4efd 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/TopicBaseTest.json +++ b/message-bus/src/test/resources/org/onap/policy/common/message/bus/event/base/TopicBaseTest.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json b/message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_all_params.json index 89e464dd..89e464dd 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_all_params.json +++ b/message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_all_params.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_invalid.json b/message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_invalid.json index 775b4886..775b4886 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_invalid.json +++ b/message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_invalid.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json b/message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_missing_mandatory.json index 216c11ec..216c11ec 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_missing_mandatory.json +++ b/message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_missing_mandatory.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json b/message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_valid.json index 2603bfdc..2603bfdc 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/TopicParameters_valid.json +++ b/message-bus/src/test/resources/org/onap/policy/common/message/bus/parameters/TopicParameters_valid.json diff --git a/policy-endpoints/pom.xml b/policy-endpoints/pom.xml index cacd36c8..4afcf020 100644 --- a/policy-endpoints/pom.xml +++ b/policy-endpoints/pom.xml @@ -53,28 +53,35 @@ <groupId>org.onap.policy.common</groupId> <artifactId>capabilities</artifactId> <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>org.onap.policy.common</groupId> - <artifactId>gson</artifactId> + <artifactId>common-parameters</artifactId> <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>org.onap.policy.common</groupId> - <artifactId>utils</artifactId> + <artifactId>gson</artifactId> <version>${project.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.onap.policy.common</groupId> - <artifactId>common-parameters</artifactId> + <artifactId>message-bus</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.onap.policy.common</groupId> - <artifactId>utils-test</artifactId> + <artifactId>utils</artifactId> <version>${project.version}</version> - <scope>test</scope> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>com.google.guava</groupId> @@ -82,28 +89,27 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.glassfish.jaxb</groupId> - <artifactId>jaxb-runtime</artifactId> + <groupId>com.google.re2j</groupId> + <artifactId>re2j</artifactId> <scope>provided</scope> </dependency> <dependency> - <groupId>org.glassfish.jersey.containers</groupId> - <artifactId>jersey-container-servlet-core</artifactId> + <groupId>io.prometheus</groupId> + <artifactId>simpleclient_hotspot</artifactId> </dependency> <dependency> - <groupId>org.glassfish.jersey.core</groupId> - <artifactId>jersey-server</artifactId> - <version>${version.jersey}</version> + <groupId>io.prometheus</groupId> + <artifactId>simpleclient_servlet_jakarta</artifactId> </dependency> <dependency> - <groupId>org.glassfish.jersey.inject</groupId> - <artifactId>jersey-hk2</artifactId> - <version>${version.jersey}</version> + <groupId>jakarta.ws.rs</groupId> + <artifactId>jakarta.ws.rs-api</artifactId> <scope>provided</scope> </dependency> <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlet</artifactId> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> @@ -114,47 +120,86 @@ <artifactId>jetty-server</artifactId> </dependency> <dependency> - <groupId>org.apache.kafka</groupId> - <artifactId>kafka-clients</artifactId> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlet</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-util</artifactId> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.toolchain</groupId> + <artifactId>jetty-jakarta-servlet-api</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-servlet-core</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-server</artifactId> + <version>${version.jersey}</version> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> <scope>provided</scope> </dependency> <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-collections4</artifactId> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> </dependency> <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-jexl3</artifactId> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> <scope>provided</scope> </dependency> <dependency> - <groupId>io.swagger.core.v3</groupId> - <artifactId>swagger-annotations</artifactId> - <scope>test</scope> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <scope>provided</scope> </dependency> <dependency> - <groupId>io.opentelemetry.instrumentation</groupId> - <artifactId>opentelemetry-kafka-clients-2.6</artifactId> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <scope>provided</scope> </dependency> <dependency> - <groupId>io.swagger.core.v3</groupId> - <artifactId>swagger-jaxrs2-jakarta</artifactId> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.inject</groupId> + <artifactId>jersey-hk2</artifactId> + <version>${version.jersey}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>io.swagger.core.v3</groupId> - <artifactId>swagger-jaxrs2-servlet-initializer-v2-jakarta</artifactId> + <artifactId>swagger-annotations</artifactId> <scope>provided</scope> </dependency> <dependency> - <groupId>io.prometheus</groupId> - <artifactId>simpleclient_hotspot</artifactId> + <groupId>io.swagger.core.v3</groupId> + <artifactId>swagger-jaxrs2-jakarta</artifactId> <scope>provided</scope> </dependency> <dependency> - <groupId>io.prometheus</groupId> - <artifactId>simpleclient_servlet_jakarta</artifactId> - <scope>provided</scope> + <groupId>org.onap.policy.common</groupId> + <artifactId>utils-test</artifactId> + <version>${project.version}</version> + <scope>test</scope> </dependency> <dependency> <groupId>org.assertj</groupId> @@ -163,7 +208,7 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-junit-jupiter</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java deleted file mode 100644 index 1b57e48e..00000000 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusPublisher.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ - * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. - * Modifications Copyright (C) 2020,2023 Bell Canada. All rights reserved. - * Modifications Copyright (C) 2022-2024 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.common.endpoints.event.comm.bus.internal; - -import io.opentelemetry.instrumentation.kafkaclients.v2_6.TracingProducerInterceptor; -import java.util.Properties; -import java.util.UUID; -import org.apache.kafka.clients.producer.KafkaProducer; -import org.apache.kafka.clients.producer.Producer; -import org.apache.kafka.clients.producer.ProducerConfig; -import org.apache.kafka.clients.producer.ProducerRecord; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public interface BusPublisher { - - String NO_MESSAGE_PROVIDED = "No message provided"; - String LOG_CLOSE = "{}: CLOSE"; - String LOG_CLOSE_FAILED = "{}: CLOSE FAILED"; - - /** - * sends a message. - * - * @param partitionId id - * @param message the message - * @return true if success, false otherwise - * @throws IllegalArgumentException if no message provided - */ - boolean send(String partitionId, String message); - - /** - * closes the publisher. - */ - void close(); - - /** - * Kafka based library publisher. - */ - class KafkaPublisherWrapper implements BusPublisher { - - private static final Logger logger = LoggerFactory.getLogger(KafkaPublisherWrapper.class); - private static final String KEY_SERIALIZER = "org.apache.kafka.common.serialization.StringSerializer"; - - private final String topic; - - /** - * Kafka publisher. - */ - private final Producer<String, String> producer; - protected Properties kafkaProps; - - /** - * Kafka Publisher Wrapper. - * - * @param busTopicParams topic parameters - */ - protected KafkaPublisherWrapper(BusTopicParams busTopicParams) { - - if (busTopicParams.isTopicInvalid()) { - throw new IllegalArgumentException("No topic for Kafka"); - } - - this.topic = busTopicParams.getTopic(); - - // Setup Properties for consumer - kafkaProps = new Properties(); - kafkaProps.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, busTopicParams.getServers().get(0)); - if (busTopicParams.isAdditionalPropsValid()) { - kafkaProps.putAll(busTopicParams.getAdditionalProps()); - } - if (kafkaProps.get(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG) == null) { - kafkaProps.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, KEY_SERIALIZER); - } - if (kafkaProps.get(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG) == null) { - kafkaProps.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KEY_SERIALIZER); - } - - if (busTopicParams.isAllowTracing()) { - kafkaProps.setProperty(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, - TracingProducerInterceptor.class.getName()); - } - - producer = new KafkaProducer<>(kafkaProps); - } - - @Override - public boolean send(String partitionId, String message) { - if (message == null) { - throw new IllegalArgumentException(NO_MESSAGE_PROVIDED); - } - - try { - // Create the record - ProducerRecord<String, String> producerRecord = - new ProducerRecord<>(topic, UUID.randomUUID().toString(), message); - - this.producer.send(producerRecord); - producer.flush(); - } catch (Exception e) { - logger.warn("{}: SEND of {} cannot be performed because of {}", this, message, e.getMessage(), e); - return false; - } - return true; - } - - @Override - public void close() { - logger.info(LOG_CLOSE, this); - - try { - this.producer.close(); - } catch (Exception e) { - logger.warn("{}: CLOSE FAILED because of {}", this, e.getMessage(), e); - } - } - - @Override - public String toString() { - return "KafkaPublisherWrapper []"; - } - - } -} diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java index b155f729..0c76d5fa 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +24,7 @@ package org.onap.policy.common.endpoints.http.client; import java.util.List; import java.util.Properties; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.parameters.topic.BusTopicParams; /** * Http Client Factory. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java index 5f0b1d6e..16d1a263 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,10 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import org.apache.commons.lang3.StringUtils; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.internal.JerseyClient; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; -import org.onap.policy.common.endpoints.utils.PropertyUtils; +import org.onap.policy.common.parameters.topic.BusTopicParams; +import org.onap.policy.common.utils.properties.PropertyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java index 130b6c15..d708d7c0 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. - * Modifications Copyright (C) 2019, 2023 Nordix Foundation. + * Modifications Copyright (C) 2019, 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,8 +43,8 @@ import lombok.ToString; import org.apache.commons.lang3.StringUtils; import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClient; +import org.onap.policy.common.parameters.topic.BusTopicParams; import org.onap.policy.common.utils.network.NetworkUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/IndexedHttpServletServerFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/IndexedHttpServletServerFactory.java index 7c9aca4c..a67c47fb 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/IndexedHttpServletServerFactory.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/IndexedHttpServletServerFactory.java @@ -31,7 +31,7 @@ import org.apache.commons.lang3.StringUtils; import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer; import org.onap.policy.common.endpoints.http.server.internal.JettyStaticResourceServer; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; -import org.onap.policy.common.endpoints.utils.PropertyUtils; +import org.onap.policy.common.utils.properties.PropertyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java index 7e6ce866..10acc179 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/RestServer.java @@ -29,9 +29,9 @@ import java.util.Optional; import java.util.Properties; import java.util.stream.Collectors; import lombok.ToString; -import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.common.parameters.rest.RestServerParameters; import org.onap.policy.common.utils.services.ServiceManagerContainer; /** diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java index 2e171070..90c8338f 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/JsonListener.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +24,8 @@ package org.onap.policy.common.endpoints.listeners; import lombok.AccessLevel; import lombok.NoArgsConstructor; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.TopicListener; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java index 41f9abdb..6639b416 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcher.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +22,7 @@ package org.onap.policy.common.endpoints.listeners; import java.util.concurrent.ConcurrentHashMap; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java index e575e33b..368fd42b 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcher.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +24,7 @@ package org.onap.policy.common.endpoints.listeners; import com.google.common.base.Strings; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java index dc6ff12a..bdb30eb1 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/ScoListener.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +24,7 @@ package org.onap.policy.common.endpoints.listeners; import lombok.AccessLevel; import lombok.AllArgsConstructor; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/TypedMessageListener.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/TypedMessageListener.java index eea1622b..a879db03 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/TypedMessageListener.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/listeners/TypedMessageListener.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ package org.onap.policy.common.endpoints.listeners; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; /** * Listener for messages of a certain type. diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java index 5d36a313..bfb29bdf 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/properties/PolicyEndPointProperties.java @@ -29,34 +29,9 @@ public final class PolicyEndPointProperties { /* Generic property suffixes */ - public static final String PROPERTY_TOPIC_SERVERS_SUFFIX = ".servers"; - public static final String PROPERTY_TOPIC_TOPICS_SUFFIX = ".topics"; - public static final String PROPERTY_TOPIC_API_KEY_SUFFIX = ".apiKey"; - public static final String PROPERTY_TOPIC_API_SECRET_SUFFIX = ".apiSecret"; - public static final String PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX = ".effectiveTopic"; - public static final String PROPERTY_TOPIC_EVENTS_SUFFIX = ".events"; - public static final String PROPERTY_TOPIC_EVENTS_FILTER_SUFFIX = ".filter"; - public static final String PROPERTY_TOPIC_EVENTS_CUSTOM_MODEL_CODER_GSON_SUFFIX = ".events.custom.gson"; - - public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX = ".consumerGroup"; - public static final String PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX = ".consumerInstance"; - public static final String PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX = ".fetchTimeout"; - public static final String PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX = ".fetchLimit"; public static final String PROPERTY_MANAGED_SUFFIX = ".managed"; - public static final String PROPERTY_ADDITIONAL_PROPS_SUFFIX = ".additionalProps"; - - public static final String PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX = ".partitionKey"; - public static final String PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX = ".selfSignedCertificates"; - public static final String PROPERTY_NOOP_SOURCE_TOPICS = "noop.source.topics"; - public static final String PROPERTY_NOOP_SINK_TOPICS = "noop.sink.topics"; - - /* KAFKA Properties */ - - public static final String PROPERTY_KAFKA_SOURCE_TOPICS = "kafka.source.topics"; - public static final String PROPERTY_KAFKA_SINK_TOPICS = "kafka.sink.topics"; - /* HTTP Server Properties */ public static final String PROPERTY_HTTP_SERVER_SERVICES = "http.server.services"; @@ -90,33 +65,4 @@ public final class PolicyEndPointProperties { public static final String PROPERTY_HTTP_URL_SUFFIX = PROPERTY_HTTP_CONTEXT_URIPATH_SUFFIX; - /* Topic Sink Values */ - - /** - * Log Failures after X number of retries. - */ - public static final int DEFAULT_LOG_SEND_FAILURES_AFTER = 1; - - - /* Topic Source values */ - - /** - * Default Timeout fetching in milliseconds. - */ - public static final int DEFAULT_TIMEOUT_MS_FETCH = 15000; - - /** - * Default maximum number of messages fetch at the time. - */ - public static final int DEFAULT_LIMIT_FETCH = 100; - - /** - * Definition of No Timeout fetching. - */ - public static final int NO_TIMEOUT_MS_FETCH = -1; - - /** - * Definition of No limit fetching. - */ - public static final int NO_LIMIT_FETCH = -1; } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParamsTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParamsTest.java deleted file mode 100644 index e016ca2b..00000000 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParamsTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ - * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2024 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.common.endpoints.event.comm.bus.internal; - -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 java.util.LinkedList; -import java.util.List; -import java.util.function.BiConsumer; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder; - -class BusTopicParamsTest extends TopicTestBase { - - @BeforeEach - @Override - public void setUp() { - super.setUp(); - } - - @Test - void testGetters() { - BusTopicParams params = makeBuilder().build(); - - assertEquals(addProps, params.getAdditionalProps()); - assertEquals(MY_AFT_ENV, params.getAftEnvironment()); - assertTrue(params.isAllowSelfSignedCerts()); - assertEquals(MY_API_KEY, params.getApiKey()); - assertEquals(MY_API_SECRET, params.getApiSecret()); - assertEquals(MY_BASE_PATH, params.getBasePath()); - assertEquals(MY_CLIENT_NAME, params.getClientName()); - assertEquals(MY_CONS_GROUP, params.getConsumerGroup()); - assertEquals(MY_CONS_INST, params.getConsumerInstance()); - assertEquals(MY_ENV, params.getEnvironment()); - assertEquals(MY_FETCH_LIMIT, params.getFetchLimit()); - assertEquals(MY_FETCH_TIMEOUT, params.getFetchTimeout()); - assertEquals(MY_HOST, params.getHostname()); - assertEquals(MY_LAT, params.getLatitude()); - assertEquals(MY_LONG, params.getLongitude()); - assertTrue(params.isManaged()); - assertEquals(MY_PARTITION, params.getPartitionId()); - assertEquals(MY_PARTNER, params.getPartner()); - assertEquals(MY_PASS, params.getPassword()); - assertEquals(MY_PORT, params.getPort()); - assertEquals(servers, params.getServers()); - assertEquals(MY_TOPIC, params.getTopic()); - assertEquals(MY_EFFECTIVE_TOPIC, params.getEffectiveTopic()); - assertTrue(params.isUseHttps()); - assertEquals(MY_USERNAME, params.getUserName()); - } - - @Test - void testBooleanGetters() { - // ensure that booleans are independent of each other - testBoolean("true:false:false", TopicParamsBuilder::allowSelfSignedCerts); - testBoolean("false:true:false", TopicParamsBuilder::managed); - testBoolean("false:false:true", TopicParamsBuilder::useHttps); - } - - @Test - void testValidators() { - BusTopicParams params = makeBuilder().build(); - - // test validity methods - assertTrue(params.isAdditionalPropsValid()); - assertFalse(params.isAftEnvironmentInvalid()); - assertTrue(params.isApiKeyValid()); - assertTrue(params.isApiSecretValid()); - assertFalse(params.isClientNameInvalid()); - assertFalse(params.isConsumerGroupInvalid()); - assertFalse(params.isConsumerInstanceInvalid()); - assertFalse(params.isEnvironmentInvalid()); - assertFalse(params.isHostnameInvalid()); - assertFalse(params.isLatitudeInvalid()); - assertFalse(params.isLongitudeInvalid()); - assertFalse(params.isPartitionIdInvalid()); - assertFalse(params.isPartnerInvalid()); - assertTrue(params.isPasswordValid()); - assertFalse(params.isPortInvalid()); - assertFalse(params.isServersInvalid()); - assertFalse(params.isTopicInvalid()); - assertTrue(params.isUserNameValid()); - } - - @Test - void testInvertedValidators() { - assertFalse(makeBuilder().additionalProps(null).build().isAdditionalPropsValid()); - assertTrue(makeBuilder().aftEnvironment("").build().isAftEnvironmentInvalid()); - assertFalse(makeBuilder().apiKey("").build().isApiKeyValid()); - assertFalse(makeBuilder().apiSecret("").build().isApiSecretValid()); - assertTrue(makeBuilder().clientName("").build().isClientNameInvalid()); - assertTrue(makeBuilder().consumerGroup("").build().isConsumerGroupInvalid()); - assertTrue(makeBuilder().consumerInstance("").build().isConsumerInstanceInvalid()); - assertTrue(makeBuilder().environment("").build().isEnvironmentInvalid()); - assertTrue(makeBuilder().hostname("").build().isHostnameInvalid()); - assertTrue(makeBuilder().latitude("").build().isLatitudeInvalid()); - assertTrue(makeBuilder().longitude("").build().isLongitudeInvalid()); - assertTrue(makeBuilder().partitionId("").build().isPartitionIdInvalid()); - assertTrue(makeBuilder().partner("").build().isPartnerInvalid()); - assertFalse(makeBuilder().password("").build().isPasswordValid()); - assertTrue(makeBuilder().port(-1).build().isPortInvalid()); - assertTrue(makeBuilder().port(65536).build().isPortInvalid()); - assertTrue(makeBuilder().servers(null).build().isServersInvalid()); - assertTrue(makeBuilder().servers(new LinkedList<>()).build().isServersInvalid()); - assertTrue(makeBuilder().servers(List.of("")).build().isServersInvalid()); - assertFalse(makeBuilder().servers(List.of("one-server")).build().isServersInvalid()); - assertTrue(makeBuilder().topic("").build().isTopicInvalid()); - assertFalse(makeBuilder().userName("").build().isUserNameValid()); - } - - /** - * Tests the boolean methods by applying a function, once with {@code false} and once - * with {@code true}. Verifies that all the boolean methods return the correct - * value by concatenating them. - * - * @param expectedTrue the string that is expected when {@code true} is passed to the - * method - * @param function function to be applied to the builder - */ - private void testBoolean(String expectedTrue, BiConsumer<TopicParamsBuilder, Boolean> function) { - TopicParamsBuilder builder = BusTopicParams.builder(); - - // first try the "false" case - function.accept(builder, false); - - BusTopicParams params = builder.build(); - assertEquals("false:false:false", - params.isAllowSelfSignedCerts() + ":" + params.isManaged() + ":" + params.isUseHttps()); - - - // now try the "true" case - function.accept(builder, true); - - params = builder.build(); - assertEquals(expectedTrue, - params.isAllowSelfSignedCerts() + ":" + params.isManaged() + ":" + params.isUseHttps()); - } -} diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java index 3d80aa81..10d40051 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpClientTest.java @@ -41,11 +41,11 @@ import java.util.TreeMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import lombok.Getter; +import lombok.Setter; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.common.endpoints.http.client.HttpClientConfigException; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; @@ -53,6 +53,7 @@ import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; +import org.onap.policy.common.parameters.topic.BusTopicParams; import org.onap.policy.common.utils.network.NetworkUtil; class HttpClientTest { @@ -532,6 +533,8 @@ class HttpClientTest { } + @Setter + @Getter static class MyEntity { private String myParameter; @@ -540,14 +543,6 @@ class HttpClientTest { this.myParameter = myParameter; } - public void setMyParameter(final String myParameter) { - this.myParameter = myParameter; - } - - public String getMyParameter() { - return myParameter; - } - } static class MyCallback implements InvocationCallback<Response> { @@ -557,7 +552,7 @@ class HttpClientTest { @Getter private Throwable throwable; - private CountDownLatch latch = new CountDownLatch(1); + private final CountDownLatch latch = new CountDownLatch(1); @Override public void completed(Response response) { diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java index 818851ff..399754a6 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java @@ -242,7 +242,7 @@ class HttpServerTest { */ @Test void testExplicitPrometheusServer() throws Exception { - logger.info("-- testPrometheusServer() --"); + logger.info("-- testExplicitPrometheusServer() --"); HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory() .build(PROMETHEUS, LOCALHOST, port, "/", false, true); @@ -261,7 +261,7 @@ class HttpServerTest { */ @Test void testPrometheusJaxRsFilterSwaggerServer() throws Exception { - logger.info("-- testPrometheusServer() --"); + logger.info("-- testPrometheusJaxRsFilterSwaggerServer() --"); HttpServletServer server = HttpServletServerFactoryInstance.getServerFactory() .build(PROMETHEUS, LOCALHOST, port, "/", true, true); diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java index 18030409..431dae7c 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/RestServerTest.java @@ -65,9 +65,9 @@ import org.onap.policy.common.endpoints.http.server.RestServer; import org.onap.policy.common.endpoints.http.server.RestServer.Factory; import org.onap.policy.common.endpoints.http.server.YamlExceptionMapper; import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler; -import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.common.parameters.rest.RestServerParameters; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.network.NetworkUtil; import org.springframework.test.util.ReflectionTestUtils; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/JsonListenerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/JsonListenerTest.java index 11cd3c56..c2e5f90d 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/JsonListenerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/JsonListenerTest.java @@ -36,7 +36,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.common.utils.test.log.logback.ExtractAppender; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcherTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcherTest.java index 95dd9f53..e0184bd1 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcherTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/MessageTypeDispatcherTest.java @@ -37,7 +37,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.common.utils.test.log.logback.ExtractAppender; import org.slf4j.LoggerFactory; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java index 1158a4c9..ac61ae7c 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/RequestIdDispatcherTest.java @@ -37,7 +37,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java index 4236a77c..cb8fb70d 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/listeners/ScoListenerTest.java @@ -34,7 +34,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -62,8 +62,6 @@ class ScoListenerTest { private static final Coder coder = new StandardCoder(); private ScoListener<MyMessage> primary; - private MyMessage status; - private StandardCoderObject sco; /** * Initializes statics. @@ -108,8 +106,8 @@ class ScoListenerTest { void testOnTopicEvent() { primary = spy(primary); - status = new MyMessage(NAME); - sco = makeSco(status); + MyMessage status = new MyMessage(NAME); + StandardCoderObject sco = makeSco(status); primary.onTopicEvent(INFRA, TOPIC, sco); verify(primary).onTopicEvent(INFRA, TOPIC, sco, status); @@ -117,7 +115,7 @@ class ScoListenerTest { // undecodable message logger.addAppender(appender); - primary.onTopicEvent(INFRA, TOPIC, makeSco("[]")); + primary.onTopicEvent(INFRA, TOPIC, makeSco()); verify(primary, times(1)).onTopicEvent(INFRA, TOPIC, sco, status); assertTrue(appender.getExtracted().toString().contains("unable to decode")); } @@ -125,12 +123,11 @@ class ScoListenerTest { /** * Makes a standard object from a JSON string. * - * @param source message to be converted * @return a standard object representing the message */ - private StandardCoderObject makeSco(String source) { + private StandardCoderObject makeSco() { try { - return coder.decode(source, StandardCoderObject.class); + return coder.decode("[]", StandardCoderObject.class); } catch (CoderException e) { throw new RuntimeException(e); @@ -184,13 +181,10 @@ class ScoListenerTest { } MyMessage other = (MyMessage) obj; if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; + return other.name == null; + } else { + return name.equals(other.name); } - return true; } } } diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/rest/CommonTestData.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/rest/CommonTestData.java new file mode 100644 index 00000000..3e16b8a5 --- /dev/null +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/rest/CommonTestData.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019, 2024 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.common.endpoints.rest; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.Map; +import java.util.TreeMap; +import org.onap.policy.common.parameters.ParameterGroup; +import org.onap.policy.common.utils.coder.Coder; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; + +/** + * Class to hold/create all parameters for test cases. + * + * @author Ajith Sreekumar (ajith.sreekumar@est.tech) + */ +public class CommonTestData { + + public static final String REST_SERVER_PASS = "zb!XztG34"; + public static final String REST_SERVER_USER = "healthcheck"; + public static final int REST_SERVER_PORT = 6969; + public static final String REST_SERVER_HOST = "0.0.0.0"; + public static final boolean REST_SERVER_HTTPS = true; + public static final boolean REST_SERVER_AAF = false; + + protected static final Coder coder = new StandardCoder(); + + /** + * Converts the contents of a map to a parameter class. + * + * @param source property map + * @param clazz class of object to be created from the map + * @return a new object represented by the map + */ + public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) { + try { + return coder.decode(coder.encode(source), clazz); + + } catch (final CoderException e) { + throw new RuntimeException("cannot create " + clazz.getName() + " from map", e); + } + } + + /** + * Returns a property map for a RestServerParameters map for test cases. + * + * @param isEmpty boolean value to represent that object created should be empty or not + * @return a property map suitable for constructing an object + */ + public Map<String, Object> getRestServerParametersMap(final boolean isEmpty) { + final Map<String, Object> map = new TreeMap<>(); + map.put("https", REST_SERVER_HTTPS); + map.put("aaf", REST_SERVER_AAF); + + if (!isEmpty) { + map.put("host", REST_SERVER_HOST); + map.put("port", REST_SERVER_PORT); + map.put("userName", REST_SERVER_USER); + map.put("password", REST_SERVER_PASS); + } + + return map; + } + + /** + * Gets the standard parameter group as a String. + * + * @param filePath path of the file + * @return the standard parameters + * @throws IOException when file read operation fails + */ + public String getParameterGroupAsString(String filePath) throws IOException { + File file = new File(filePath); + return Files.readString(file.toPath()); + } +} diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/rest/RestServerParametersTest.java index 6492b900..ccabc455 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/parameters/RestServerParametersTest.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/rest/RestServerParametersTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.parameters; +package org.onap.policy.common.endpoints.rest; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -29,6 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import org.onap.policy.common.parameters.ValidationResult; +import org.onap.policy.common.parameters.rest.RestServerParameters; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.StandardCoder; @@ -39,7 +40,7 @@ import org.onap.policy.common.utils.coder.StandardCoder; */ class RestServerParametersTest { - private static CommonTestData testData = new CommonTestData(); + private static final CommonTestData testData = new CommonTestData(); private static final Coder coder = new StandardCoder(); @Test @@ -68,7 +69,7 @@ class RestServerParametersTest { @Test void test_valid() throws Exception { String json = testData.getParameterGroupAsString( - "src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json"); + "src/test/resources/org/onap/policy/common/endpoints/rest/RestServerParameters_valid.json"); RestServerParameters restServerParameters = coder.decode(json, RestServerParameters.class); final ValidationResult result = restServerParameters.validate(); assertNull(result.getResult()); @@ -78,7 +79,7 @@ class RestServerParametersTest { @Test void test_invalid() throws Exception { String json = testData.getParameterGroupAsString( - "src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json"); + "src/test/resources/org/onap/policy/common/endpoints/rest/RestServerParameters_invalid.json"); RestServerParameters restServerParameters = coder.decode(json, RestServerParameters.class); final ValidationResult result = restServerParameters.validate(); assertFalse(result.isValid()); diff --git a/policy-endpoints/src/test/resources/META-INF/services/org.onap.policy.common.endpoints.features.NetLoggerFeatureApi b/policy-endpoints/src/test/resources/META-INF/services/org.onap.policy.common.endpoints.features.NetLoggerFeatureApi deleted file mode 100644 index c861ad18..00000000 --- a/policy-endpoints/src/test/resources/META-INF/services/org.onap.policy.common.endpoints.features.NetLoggerFeatureApi +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.common.endpoints.utils.NetLoggerUtilTest$NetLoggerFeature diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSinkTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSinkTest.json deleted file mode 100644 index dc1f1f75..00000000 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/InlineKafkaTopicSinkTest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "servers": [ - "svra", - "svrb" - ], - "topic": "my-topic", - "effectiveTopic": "my-effective-topic", - "recentEvents": [], - "alive": false, - "locked": false, - "useHttps": false, - "allowTracing": false, - "topicCommInfrastructure": "KAFKA", - "partitionKey": "my-partition", - "additionalProps": { - "security.protocol": "SASL_PLAINTEXT", - "sasl.mechanism": "SCRAM-SHA-512", - "sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=abc password=abc serviceName=kafka;" - } -} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSourceTest.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSourceTest.json deleted file mode 100644 index a101d235..00000000 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/event/comm/bus/internal/SingleThreadedKafkaTopicSourceTest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "servers": [ - "localhost:9092", - "10.1.2.3:9092" - ], - "topic": "my-topic", - "effectiveTopic": "my-effective-topic", - "recentEvents": [], - "alive": false, - "locked": false, - "useHttps": false, - "allowTracing": false, - "topicCommInfrastructure": "KAFKA", - "additionalProps": { - "security.protocol": "SASL_PLAINTEXT", - "sasl.mechanism": "SCRAM-SHA-512", - "sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=abc password=abc serviceName=kafka;" - } -} diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/RestServerParameters_invalid.json index a7455525..a7455525 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_invalid.json +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/RestServerParameters_invalid.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/RestServerParameters_valid.json index 61d793a8..61d793a8 100644 --- a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/parameters/RestServerParameters_valid.json +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/RestServerParameters_valid.json diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_all_params.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_all_params.json new file mode 100644 index 00000000..89e464dd --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_all_params.json @@ -0,0 +1,62 @@ +{ + "topicSources" : [ { + "topic" : "policy-pdp-pap1", + "servers" : [ "kafka2, kafka3" ], + "topicCommInfrastructure" : "kafka", + "effectiveTopic" : "my-effective-topic", + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "port": 123, + "useHttps" : true, + "allowTracing": true, + "allowSelfSignedCerts" : true, + "consumerGroup" : "consumer group", + "consumerInstance" : "consumer instance", + "fetchTimeout" : 15000, + "fetchLimit" : 100, + "userName": "username", + "password": "password", + "managed": true, + "environment": "environment1", + "aftEnvironment": "aftEnvironment1", + "partner": "partner1", + "latitude": "1234", + "longitude": "1234", + "partitionId": "partition_id", + "additionalProps": {"xyz":"xyz"}, + "clientName": "clientName1", + "hostname": "hostname1", + "basePath": "basePath1", + "serializationProvider": "serializationProvider1" + }], + "topicSinks" : [ { + "topic" : "policy-pdp-pap1", + "servers" : [ "kafka2, kafka3" ], + "topicCommInfrastructure" : "kafka", + "effectiveTopic" : "my-effective-topic", + "apiKey" : "my-api-key", + "apiSecret" : "my-api-secret", + "port": 123, + "useHttps" : true, + "allowTracing": true, + "allowSelfSignedCerts" : true, + "consumerGroup" : "consumer group", + "consumerInstance" : "consumer instance", + "fetchTimeout" : 15000, + "fetchLimit" : 100, + "userName": "username", + "password": "password", + "managed": true, + "environment": "environment1", + "aftEnvironment": "aftEnvironment1", + "partner": "partner1", + "latitude": "1234", + "longitude": "1234", + "partitionId": "partition_id", + "additionalProps": {"xyz":"xyz"}, + "clientName": "clientName1", + "hostname": "hostname1", + "basePath": "basePath1", + "serializationProvider": "serializationProvider1" + }] +}
\ No newline at end of file diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_invalid.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_invalid.json new file mode 100644 index 00000000..775b4886 --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_invalid.json @@ -0,0 +1,6 @@ +{ + "topicSources" : [{ + "topic" : "ueb-source", + "servers" : ["my-server"] + }] +}
\ No newline at end of file diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_missing_mandatory.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_missing_mandatory.json new file mode 100644 index 00000000..216c11ec --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_missing_mandatory.json @@ -0,0 +1,12 @@ +{ + "topicSources" : [ { + "topic" : "policy-pdp-pap1", + "servers" : [], + "topicCommInfrastructure" : "kafka" + }], + "topicSinks" : [ { + "topic" : "policy-pdp-pap2", + "servers" : [ "kafka1, kafka2" ], + "topicCommInfrastructure" : "kafka" + }] +}
\ No newline at end of file diff --git a/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_valid.json b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_valid.json new file mode 100644 index 00000000..2603bfdc --- /dev/null +++ b/policy-endpoints/src/test/resources/org/onap/policy/common/endpoints/rest/TopicParameters_valid.json @@ -0,0 +1,30 @@ +{ + "topicSources" : [ { + "topic" : "ueb-source", + "servers" : [ "my-server" ], + "topicCommInfrastructure" : "ueb" + },{ + "topic" : "policy-pdp-pap1", + "servers" : [ "kafka1, kafka2" ], + "topicCommInfrastructure" : "kafka" + },{ + "topic" : "policy-pdp-pap2", + "servers" : [ "kafka2, kafka3" ], + "topicCommInfrastructure" : "kafka" + }], + "topicSinks" : [ { + "topic" : "ueb-sink", + "servers" : [ "my-server" ], + "topicCommInfrastructure" : "ueb" + },{ + "topic" : "policy-pdp-pap2", + "servers" : [ "kafka1, kafka2" ], + "topicCommInfrastructure" : "kafka" + },{ + "topic" : "policy-pdp-pap3", + "servers" : [ "kafka2, kafka3" ], + "topicCommInfrastructure" : "kafka", + "effectiveTopic":"effectiveTopic1", + "allowSelfSignedCerts":true + }] +}
\ No newline at end of file @@ -49,12 +49,13 @@ <modules> <module>capabilities</module> - <module>utils-test</module> - <module>utils</module> - <module>gson</module> <module>common-parameters</module> - <module>policy-endpoints</module> + <module>gson</module> + <module>utils</module> + <module>utils-test</module> <module>spring-utils</module> + <module>message-bus</module> + <module>policy-endpoints</module> </modules> <build> diff --git a/spring-utils/pom.xml b/spring-utils/pom.xml index d5d5d848..d81b4f07 100644 --- a/spring-utils/pom.xml +++ b/spring-utils/pom.xml @@ -42,6 +42,10 @@ </dependency> <dependency> <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> <dependency> @@ -50,13 +54,9 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-junit-jupiter</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/utils-test/pom.xml b/utils-test/pom.xml index 6338cc08..a8a282e8 100644 --- a/utils-test/pom.xml +++ b/utils-test/pom.xml @@ -3,7 +3,7 @@ ONAP Policy Engine - Common Modules ================================================================================ Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. - Modificaitons Copyright (C) 2023-2024 Nordix Foundation. + Modifications Copyright (C) 2023-2024 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -19,7 +19,8 @@ ============LICENSE_END========================================================= --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -40,26 +41,43 @@ <dependencies> <dependency> - <groupId>org.bouncycastle</groupId> - <artifactId>bcpkix-fips</artifactId> + <groupId>org.onap.policy.common</groupId> + <artifactId>utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.common</groupId> + <artifactId>gson</artifactId> + <version>${project.version}</version> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-jexl3</artifactId> + </dependency> + <dependency> + <groupId>org.bouncycastle</groupId> + <artifactId>bcpkix-fips</artifactId> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> <scope>provided</scope> </dependency> <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>utils</artifactId> - <version>${project.version}</version> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> <scope>provided</scope> </dependency> - - <!-- from parent --> - <dependency> - <groupId>org.awaitility</groupId> - <artifactId>awaitility</artifactId> - <scope>test</scope> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.re2j</groupId> + <artifactId>re2j</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>com.openpojo</groupId> @@ -67,16 +85,41 @@ <scope>compile</scope> </dependency> <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest</artifactId> + <scope>compile</scope> + </dependency> + <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <scope>compile</scope> </dependency> <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <scope>test</scope> </dependency> <dependency> + <groupId>org.awaitility</groupId> + <artifactId>awaitility</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-junit-jupiter</artifactId> <scope>test</scope> @@ -86,11 +129,5 @@ <artifactId>spring-test</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - <version>2.2</version> - <scope>compile</scope> - </dependency> </dependencies> </project> diff --git a/utils/pom.xml b/utils/pom.xml index 791a048a..18550e4e 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -45,12 +45,21 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>commons-net</groupId> - <artifactId>commons-net</artifactId> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> </dependency> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.re2j</groupId> + <artifactId>re2j</artifactId> <scope>provided</scope> </dependency> <dependency> @@ -62,42 +71,59 @@ <artifactId>commons-io</artifactId> </dependency> <dependency> - <groupId>jakarta.persistence</groupId> - <artifactId>jakarta.persistence-api</artifactId> + <groupId>commons-net</groupId> + <artifactId>commons-net</artifactId> </dependency> <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> + <groupId>jakarta.persistence</groupId> + <artifactId>jakarta.persistence-api</artifactId> </dependency> <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-core</artifactId> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> - <groupId>com.google.re2j</groupId> - <artifactId>re2j</artifactId> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> </dependency> <dependency> + <groupId>com.openpojo</groupId> + <artifactId>openpojo</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <scope>test</scope> </dependency> <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-junit-jupiter</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>jakarta.xml.bind</groupId> - <artifactId>jakarta.xml.bind-api</artifactId> + <groupId>org.mockito</groupId> + <artifactId>mockito-junit-jupiter</artifactId> + <scope>test</scope> </dependency> </dependencies> </project> diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/PropertyUtils.java b/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyUtils.java index 904f9535..7155323b 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/utils/PropertyUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyUtils.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.utils; +package org.onap.policy.common.utils.properties; import java.util.Properties; import lombok.AllArgsConstructor; diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/report/HealthCheckReport.java b/utils/src/main/java/org/onap/policy/common/utils/report/HealthCheckReport.java index bb80fccb..78356cfb 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/report/HealthCheckReport.java +++ b/utils/src/main/java/org/onap/policy/common/utils/report/HealthCheckReport.java @@ -1,8 +1,9 @@ /*- - * ============LICENSE_START======================================================= + * ============LICENSE_START=============================================================== * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * Modifications Copyright (C) 2024 Nordix Foundation. + * ======================================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -19,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.report; +package org.onap.policy.common.utils.report; import lombok.Getter; import lombok.Setter; diff --git a/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java b/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java index 998d6742..3726ef89 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java +++ b/utils/src/main/java/org/onap/policy/common/utils/services/OrderedServiceImpl.java @@ -3,6 +3,7 @@ * utils * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,22 +36,22 @@ import org.slf4j.LoggerFactory; */ public class OrderedServiceImpl<T extends OrderedService> { // logger - private static Logger logger = LoggerFactory.getLogger(OrderedServiceImpl.class); + private static final Logger logger = LoggerFactory.getLogger(OrderedServiceImpl.class); // sorted list of instances implementing the service private List<T> implementers = null; // 'ServiceLoader' that is used to discover and create the services - private ServiceLoader<T> serviceLoader = null; + private final ServiceLoader<T> serviceLoader; // use this to ensure that we only use one unique instance of each class - private static Map<Class<?>, OrderedService> classToSingleton = new HashMap<>(); + private static final Map<Class<?>, OrderedService> classToSingleton = new HashMap<>(); /** * Constructor - create the 'ServiceLoader' instance. * * @param clazz the class object associated with 'T' (I supposed it could - * be a subclass, but I'm not sure this is useful) + * be a subclass, but I'm not sure if this is useful) */ public OrderedServiceImpl(Class<T> clazz) { // This constructor wouldn't be needed if 'T.class' was legal @@ -60,8 +61,7 @@ public class OrderedServiceImpl<T extends OrderedService> { /** * Get List of implementers. * - * @return the sorted list of services implementing interface 'T' discovered - * by 'ServiceLoader'. + * @return the sorted list of services implementing interface 'T' discovered by 'ServiceLoader'. */ public synchronized List<T> getList() { if (implementers == null) { @@ -78,12 +78,11 @@ public class OrderedServiceImpl<T extends OrderedService> { * expensive operation in terms of CPU and elapsed time, so it is best if it * isn't invoked too frequently. * - * @return the sorted list of services implementing interface 'T' discovered - * by 'ServiceLoader'. + * @return the sorted list of services implementing interface 'T' discovered by 'ServiceLoader'. */ @SuppressWarnings("unchecked") public synchronized List<T> rebuildList() { - // build a list of all of the current implementors + // build a list of all the current implementors List<T> tmp = new LinkedList<>(); for (T service : serviceLoader) { tmp.add((T) getSingleton(service)); @@ -91,7 +90,7 @@ public class OrderedServiceImpl<T extends OrderedService> { // Sort the list according to sequence number, and then alphabetically // according to full class name. - Collections.sort(tmp, (o1, o2) -> { + tmp.sort((o1, o2) -> { int s1 = o1.getSequenceNumber(); int s2 = o2.getSequenceNumber(); if (s1 < s2) { @@ -112,7 +111,7 @@ public class OrderedServiceImpl<T extends OrderedService> { /** * If a service implements multiple APIs managed by 'ServiceLoader', a * separate instance is created for each API. This method ensures that - * the first instance is used in all of the lists. + * the first instance is used in all the lists. * * @param service this is the object created by ServiceLoader * @return the object to use in place of 'service'. If 'service' is the first diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java b/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyUtilsTest.java index a639382f..a8b37f57 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/utils/PropertyUtilsTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyUtilsTest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.utils; +package org.onap.policy.common.utils.properties; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java b/utils/src/test/java/org/onap/policy/common/utils/report/TestHealthCheckReport.java index 62db30b2..3a207022 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/report/TestHealthCheckReport.java +++ b/utils/src/test/java/org/onap/policy/common/utils/report/TestHealthCheckReport.java @@ -20,17 +20,24 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.common.endpoints.report; +package org.onap.policy.common.utils.report; +import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.anything; + +import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.filters.FilterClassName; import com.openpojo.validation.Validator; import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.affirm.Affirm; import com.openpojo.validation.rule.impl.GetterMustExistRule; import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.Tester; import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; +import com.openpojo.validation.utils.ValidationHelper; +import org.hamcrest.Matcher; import org.junit.jupiter.api.Test; -import org.onap.policy.common.utils.test.ToStringTester; /** * Class to perform unit test of HealthCheckReport. @@ -47,4 +54,25 @@ class TestHealthCheckReport { validator.validate(HealthCheckReport.class.getPackage().getName(), new FilterClassName(HealthCheckReport.class.getName())); } + + static class ToStringTester implements Tester { + + private final Matcher<?> matcher; + + public ToStringTester() { + matcher = anything(); + } + + @Override + public void run(final PojoClass pojoClass) { + final Class<?> clazz = pojoClass.getClazz(); + if (anyOf(matcher).matches(clazz)) { + final Object classInstance = ValidationHelper.getBasicInstance(pojoClass); + + Affirm.affirmFalse("Found default toString output", + classInstance.toString().matches(Object.class.getName() + "@" + "\\w+")); + } + + } + } } diff --git a/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java b/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java index d1e891ca..9db367cf 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/resources/ResourceUtilsTest.java @@ -313,7 +313,7 @@ class ResourceUtilsTest { normalizePath(resultD2.iterator().next())); Set<String> resultJ0 = ResourceUtils.getDirectoryContents("com"); - assertTrue(resultJ0.contains("com/google/gson/")); + assertTrue(resultJ0.contains("com/google/")); assertEquals("com/google/", normalizePath(resultJ0.iterator().next())); Set<String> resultJ1 = ResourceUtils.getDirectoryContents("com/google/gson"); |