aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerExceptionTest.java9
-rw-r--r--feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java335
-rw-r--r--feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockPropertiesTest.java15
-rw-r--r--feature-healthcheck/src/main/feature/config/feature-healthcheck.properties2
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java27
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java39
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java21
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java23
-rw-r--r--feature-healthcheck/src/test/resources/echo.drl3
-rw-r--r--feature-healthcheck/src/test/resources/echo.kmodule3
-rw-r--r--feature-legacy-config/src/main/feature/config/feature-legacy-config.properties33
-rw-r--r--feature-legacy-config/src/main/java/org/onap/policy/drools/legacy/config/LegacyConfig.java6
-rw-r--r--feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigFeatureTest.java23
-rw-r--r--feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigTest.java24
-rw-r--r--feature-legacy-config/src/test/java/org/onap/policy/drools/server/restful/RestLegacyConfigTest.java19
-rw-r--r--feature-lifecycle/src/main/feature/config/feature-lifecycle.properties41
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java8
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java7
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java2
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java2
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java23
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java36
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java67
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java24
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java34
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java50
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java9
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateSafeTest.java9
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java44
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTestTest.java9
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java11
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java19
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java25
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java28
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java36
-rw-r--r--feature-lifecycle/src/test/resources/echo.kmodule3
-rw-r--r--feature-lifecycle/src/test/resources/lifecycle.kmodule3
-rw-r--r--feature-lifecycle/src/test/resources/tosca-policy-native-controller-example.json4
-rw-r--r--feature-no-locking/src/test/java/org/onap/policy/no/locking/NoLockManagerTest.java34
-rw-r--r--feature-pooling-messages/pom.xml (renamed from feature-pooling-dmaap/pom.xml)21
-rw-r--r--feature-pooling-messages/src/assembly/assemble_zip.xml (renamed from feature-pooling-dmaap/src/assembly/assemble_zip.xml)8
-rw-r--r--feature-pooling-messages/src/main/feature/config/feature-pooling-messages.properties (renamed from feature-pooling-dmaap/src/main/feature/config/feature-pooling-dmaap.properties)44
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java)5
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java)4
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java)4
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java)27
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java)7
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/Serializer.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java)3
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/TopicMessageManager.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java)19
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java)5
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Identification.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Leader.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Message.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java)7
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Offline.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Query.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java)7
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/IdleState.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/IdleState.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java)11
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java)2
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/StartState.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/State.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java)1
-rw-r--r--feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.java (renamed from feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.java)1
-rw-r--r--feature-pooling-messages/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi (renamed from feature-pooling-dmaap/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi)0
-rw-r--r--feature-pooling-messages/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi (renamed from feature-pooling-dmaap/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi)0
-rw-r--r--feature-pooling-messages/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi (renamed from feature-pooling-dmaap/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi)0
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java)53
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java)109
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java)9
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java)9
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java)93
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java)221
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java)65
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java)15
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/TopicMessageManagerTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/DmaapManagerTest.java)105
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/feature-pooling-messages.properties (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/feature-pooling-dmaap.properties)1
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java)53
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/HeartbeatTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/HeartbeatTest.java)3
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/IdentificationTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/IdentificationTest.java)13
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/LeaderTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/LeaderTest.java)16
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java)15
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/OfflineTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/OfflineTest.java)1
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/QueryTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/QueryTest.java)1
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.java)11
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/SupportMessageWithAssignmentsTester.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportMessageWithAssignmentsTester.java)28
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java)70
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java)21
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java)26
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java)99
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java)72
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java)38
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java)99
-rw-r--r--feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/SupportBasicStateTester.java (renamed from feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/SupportBasicStateTester.java)4
-rw-r--r--feature-pooling-messages/src/test/resources/logback-test.xml (renamed from feature-pooling-dmaap/src/test/resources/logback-test.xml)0
-rw-r--r--feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionAdditionalTest.java41
-rw-r--r--feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionFeatureTest.java27
-rw-r--r--feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java23
-rw-r--r--packages/docker/src/main/docker/pdpd-entrypoint.sh8
-rw-r--r--packages/install/pom.xml4
-rw-r--r--packages/install/src/files/base.conf17
-rw-r--r--packages/install/src/files/feature-pooling-messages.conf (renamed from packages/install/src/files/feature-pooling-dmaap.conf)0
-rw-r--r--policy-core/pom.xml4
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java15
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java11
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java3
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java3
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java3
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java5
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/DroolsContainerTest.java41
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiMock.java16
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiTest.java16
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionTest.java27
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/jmx/PdpJmxTest.java25
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysFailLockTest.java19
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysLockBaseTest.java9
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysSuccessLockTest.java23
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/core/lock/LockImplTest.java47
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/util/FeatureEnabledCheckerTest.java11
-rw-r--r--policy-core/src/test/java/org/onap/policy/drools/util/KieUtilsTest.java35
-rw-r--r--policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/META-INF/kmodule.xml2
-rw-r--r--policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/META-INF/kmodule.xml2
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java18
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java13
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/artifact/ArtifactPolicyTest.java9
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerPolicyTest.java11
-rw-r--r--policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java36
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java13
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java6
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java44
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java42
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafBase.java35
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafTelemetryAuthFilter.java41
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java7
-rw-r--r--policy-management/src/main/resources/openapi/openapi.yaml4
-rw-r--r--policy-management/src/main/resources/swagger/swagger.json3
-rw-r--r--policy-management/src/main/server-gen/bin/add-secured-participant3
-rw-r--r--policy-management/src/main/server-gen/bin/create-api-key3
-rw-r--r--policy-management/src/main/server-gen/bin/create-secured-topic3
-rw-r--r--policy-management/src/main/server-gen/bin/pdpd-configuration5
-rw-r--r--policy-management/src/main/server/config/aaf-cadi.keyfile27
-rw-r--r--policy-management/src/main/server/config/aaf-system.properties43
-rw-r--r--policy-management/src/main/server/config/engine.properties5
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java29
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java361
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java92
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.java37
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java132
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java35
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java9
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java58
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java27
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java17
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java15
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java16
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java122
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/server/restful/test/TestAafTelemetryAuthFilter.java43
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsManagerTest.java9
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsTest.java9
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/PolicyControllerFactoryTest.java58
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/PolicyDroolsPdpRuntimeExceptionTest.java9
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java127
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java55
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java127
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java115
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java52
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerExceptionTest.java9
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java138
-rw-r--r--policy-management/src/test/resources/echo.kmodule3
-rw-r--r--policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestAdd.json1
-rw-r--r--policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestConfig.json1
-rw-r--r--policy-management/src/test/resources/rules.kmodule3
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java7
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java42
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/metrics/MetricTest.java43
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Metadata.java5
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Nested.java5
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Properties.java5
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java36
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java25
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/utils/ReferenceTest.java19
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/utils/ReflectionUtilTest.java36
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java11
-rw-r--r--policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java29
-rw-r--r--pom.xml14
188 files changed, 2591 insertions, 2750 deletions
diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerExceptionTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerExceptionTest.java
index 9c172545..59833c29 100644
--- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerExceptionTest.java
+++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerExceptionTest.java
@@ -3,6 +3,7 @@
* feature-distributed-locking
* ================================================================================
* 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.
@@ -20,15 +21,15 @@
package org.onap.policy.distributed.locking;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class DistributedLockManagerExceptionTest extends ExceptionsTester {
+class DistributedLockManagerExceptionTest extends ExceptionsTester {
@Test
- public void test() {
+ void test() {
assertEquals(1, test(DistributedLockManagerException.class));
}
diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java
index 9646a88c..74a3c761 100644
--- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java
+++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockManagerTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2022 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.
@@ -25,18 +25,19 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+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.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
@@ -47,6 +48,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.Serial;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
@@ -66,16 +68,17 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.dbcp2.BasicDataSource;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+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.junit.jupiter.api.extension.ExtendWith;
import org.kie.api.runtime.KieSession;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.utils.services.OrderedServiceImpl;
import org.onap.policy.distributed.locking.DistributedLockManager.DistributedLock;
import org.onap.policy.drools.core.PolicySession;
@@ -88,8 +91,8 @@ import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.drools.system.PolicyEngineConstants;
import org.springframework.test.util.ReflectionTestUtils;
-@RunWith(MockitoJUnitRunner.class)
-public class DistributedLockManagerTest {
+@ExtendWith(MockitoExtension.class)
+class DistributedLockManagerTest {
private static final long EXPIRE_SEC = 900L;
private static final long RETRY_SEC = 60L;
private static final String POLICY_ENGINE_EXECUTOR_FIELD = "executorService";
@@ -142,19 +145,20 @@ public class DistributedLockManagerTest {
private BasicDataSource datasrc;
private DistributedLock lock;
- private PolicySession session;
private AtomicInteger nactive;
private AtomicInteger nsuccesses;
private DistributedLockManager feature;
+ AutoCloseable closeable;
+
/**
* Configures the location of the property files and creates the DB.
*
* @throws SQLException if the DB cannot be created
*/
- @BeforeClass
- public static void setUpBeforeClass() throws SQLException {
+ @BeforeAll
+ static void setUpBeforeClass() throws SQLException {
SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
PolicyEngineConstants.getManager().configure(new Properties());
@@ -175,8 +179,8 @@ public class DistributedLockManagerTest {
/**
* Restores static fields.
*/
- @AfterClass
- public static void tearDownAfterClass() throws SQLException {
+ @AfterAll
+ static void tearDownAfterClass() throws SQLException {
ReflectionTestUtils.setField(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, saveExec);
realExec.shutdown();
conn.close();
@@ -188,10 +192,11 @@ public class DistributedLockManagerTest {
*
* @throws SQLException if the lock records cannot be deleted from the DB
*/
- @Before
- public void setUp() throws SQLException {
+ @BeforeEach
+ void setUp() throws SQLException {
+ closeable = MockitoAnnotations.openMocks(this);
// grant() and deny() calls will come through here and be immediately executed
- session = new PolicySession(null, null, kieSess) {
+ PolicySession session = new PolicySession(null, null, kieSess) {
@Override
public void insertDrools(Object object) {
((Runnable) object).run();
@@ -208,10 +213,11 @@ public class DistributedLockManagerTest {
feature = new MyLockingFeature(true);
}
- @After
- public void tearDown() throws SQLException {
+ @AfterEach
+ void tearDown() throws Exception {
shutdownFeature();
cleanDb();
+ closeable.close();
}
private void cleanDb() throws SQLException {
@@ -231,18 +237,18 @@ public class DistributedLockManagerTest {
* Tests that the feature is found in the expected service sets.
*/
@Test
- public void testServiceApis() {
+ void testServiceApis() {
assertTrue(new OrderedServiceImpl<>(PolicyEngineFeatureApi.class).getList().stream()
.anyMatch(obj -> obj instanceof DistributedLockManager));
}
@Test
- public void testGetSequenceNumber() {
+ void testGetSequenceNumber() {
assertEquals(1000, feature.getSequenceNumber());
}
@Test
- public void testBeforeCreateLockManager() {
+ void testBeforeCreateLockManager() {
assertSame(feature, feature.beforeCreateLockManager(engine, new Properties()));
}
@@ -250,7 +256,7 @@ public class DistributedLockManagerTest {
* Tests beforeCreate(), when getProperties() throws a runtime exception.
*/
@Test
- public void testBeforeCreateLockManagerEx() {
+ void testBeforeCreateLockManagerEx() {
shutdownFeature();
feature = new MyLockingFeature(false) {
@@ -266,7 +272,7 @@ public class DistributedLockManagerTest {
}
@Test
- public void testAfterStart() {
+ void testAfterStart() {
// verify that cleanup & expire check are both added to the queue
verify(exsvc).execute(any());
verify(exsvc).schedule(any(Runnable.class), anyLong(), any());
@@ -276,7 +282,7 @@ public class DistributedLockManagerTest {
* Tests afterStart(), when thread pool throws a runtime exception.
*/
@Test
- public void testAfterStartExInThreadPool() {
+ void testAfterStartExInThreadPool() {
shutdownFeature();
feature = new MyLockingFeature(false);
@@ -287,7 +293,7 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDeleteExpiredDbLocks() throws SQLException {
+ void testDeleteExpiredDbLocks() throws SQLException {
// add records: two expired, one not
insertRecord(RESOURCE, feature.getUuidString(), -1);
insertRecord(RESOURCE2, feature.getUuidString(), HOLD_SEC2);
@@ -315,7 +321,7 @@ public class DistributedLockManagerTest {
*
*/
@Test
- public void testDeleteExpiredDbLocksEx() {
+ void testDeleteExpiredDbLocksEx() {
feature = new InvalidDbLockingFeature(TRANSIENT);
// get the clean-up function and execute it
@@ -329,7 +335,7 @@ public class DistributedLockManagerTest {
}
@Test
- public void testAfterStop() {
+ void testAfterStop() {
shutdownFeature();
verify(checker).cancel(anyBoolean());
@@ -345,7 +351,7 @@ public class DistributedLockManagerTest {
*
*/
@Test
- public void testAfterStopEx() {
+ void testAfterStopEx() {
shutdownFeature();
// use a data source that throws an exception when closed
@@ -355,24 +361,24 @@ public class DistributedLockManagerTest {
}
@Test
- public void testCreateLock() throws SQLException {
+ void testCreateLock() throws SQLException {
verify(exsvc).execute(any());
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
assertTrue(lock.isWaiting());
verify(exsvc, times(PRE_LOCK_EXECS + 1)).execute(any());
// this lock should fail
LockCallback callback2 = mock(LockCallback.class);
- DistributedLock lock2 = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback2, false);
+ DistributedLock lock2 = getLock(RESOURCE, callback2);
assertTrue(lock2.isUnavailable());
verify(callback2, never()).lockAvailable(lock2);
verify(callback2).lockUnavailable(lock2);
// this should fail, too
LockCallback callback3 = mock(LockCallback.class);
- DistributedLock lock3 = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback3, false);
+ DistributedLock lock3 = getLock(RESOURCE, callback3);
assertTrue(lock3.isUnavailable());
verify(callback3, never()).lockAvailable(lock3);
verify(callback3).lockUnavailable(lock3);
@@ -395,11 +401,11 @@ public class DistributedLockManagerTest {
verify(callback, never()).lockUnavailable(lock);
// this should succeed
- DistributedLock lock4 = getLock(RESOURCE2, OWNER_KEY, HOLD_SEC, callback, false);
+ DistributedLock lock4 = getLock(RESOURCE2, callback);
assertTrue(lock4.isWaiting());
// after running checker, original records should still remain
- runChecker(0, 0, EXPIRE_SEC);
+ runChecker(0, EXPIRE_SEC);
assertEquals(1, getRecordCount());
verify(callback, never()).lockUnavailable(lock);
}
@@ -408,7 +414,7 @@ public class DistributedLockManagerTest {
* Tests createLock() when the feature is not the latest instance.
*/
@Test
- public void testCreateLockNotLatestInstance() {
+ void testCreateLockNotLatestInstance() {
DistributedLockManager.setLatestInstance(null);
Lock lock = feature.createLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
@@ -418,24 +424,24 @@ public class DistributedLockManagerTest {
}
@Test
- public void testCheckExpired() throws SQLException {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testCheckExpired() throws SQLException {
+ lock = getLock(RESOURCE, callback);
runLock(0, 0);
LockCallback callback2 = mock(LockCallback.class);
- final DistributedLock lock2 = getLock(RESOURCE2, OWNER_KEY, HOLD_SEC, callback2, false);
+ final DistributedLock lock2 = getLock(RESOURCE2, callback2);
runLock(1, 0);
LockCallback callback3 = mock(LockCallback.class);
- final DistributedLock lock3 = getLock(RESOURCE3, OWNER_KEY, HOLD_SEC, callback3, false);
+ final DistributedLock lock3 = getLock(RESOURCE3, callback3);
runLock(2, 0);
LockCallback callback4 = mock(LockCallback.class);
- final DistributedLock lock4 = getLock(RESOURCE4, OWNER_KEY, HOLD_SEC, callback4, false);
+ final DistributedLock lock4 = getLock(RESOURCE4, callback4);
runLock(3, 0);
LockCallback callback5 = mock(LockCallback.class);
- final DistributedLock lock5 = getLock(RESOURCE5, OWNER_KEY, HOLD_SEC, callback5, false);
+ final DistributedLock lock5 = getLock(RESOURCE5, callback5);
runLock(4, 0);
assertEquals(5, getRecordCount());
@@ -450,7 +456,7 @@ public class DistributedLockManagerTest {
updateRecord(RESOURCE5, feature.getPdpName(), OTHER_OWNER, HOLD_SEC);
// run the checker
- runChecker(0, 0, EXPIRE_SEC);
+ runChecker(0, EXPIRE_SEC);
// check lock states
assertTrue(lock.isUnavailable());
@@ -471,33 +477,33 @@ public class DistributedLockManagerTest {
verify(callback4, never()).lockUnavailable(lock4);
// another check should have been scheduled, with the normal interval
- runChecker(1, 0, EXPIRE_SEC);
+ runChecker(1, EXPIRE_SEC);
}
/**
* Tests checkExpired(), when schedule() throws an exception.
*/
@Test
- public void testCheckExpiredExecRejected() {
+ void testCheckExpiredExecRejected() {
// arrange for execution to be rejected
when(exsvc.schedule(any(Runnable.class), anyLong(), any()))
.thenThrow(new RejectedExecutionException(EXPECTED_EXCEPTION));
- runChecker(0, 0, EXPIRE_SEC);
+ runChecker(0, EXPIRE_SEC);
}
/**
* Tests checkExpired(), when getConnection() throws an exception.
*/
@Test
- public void testCheckExpiredSqlEx() {
+ void testCheckExpiredSqlEx() {
// use a data source that throws an exception when getConnection() is called
feature = new InvalidDbLockingFeature(TRANSIENT);
- runChecker(0, 0, EXPIRE_SEC);
+ runChecker(0, EXPIRE_SEC);
// it should have scheduled another check, sooner
- runChecker(0, 0, RETRY_SEC);
+ runChecker(0, RETRY_SEC);
}
/**
@@ -505,7 +511,7 @@ public class DistributedLockManagerTest {
* no longer alive.
*/
@Test
- public void testCheckExpiredSqlExFeatureStopped() {
+ void testCheckExpiredSqlExFeatureStopped() {
// use a data source that throws an exception when getConnection() is called
feature = new InvalidDbLockingFeature(TRANSIENT) {
@Override
@@ -515,14 +521,14 @@ public class DistributedLockManagerTest {
}
};
- runChecker(0, 0, EXPIRE_SEC);
+ runChecker(0, EXPIRE_SEC);
// it should NOT have scheduled another check
verify(exsvc, times(1)).schedule(any(Runnable.class), anyLong(), any());
}
@Test
- public void testExpireLocks() throws SQLException {
+ void testExpireLocks() throws SQLException {
AtomicReference<DistributedLock> freeLock = new AtomicReference<>(null);
feature = new MyLockingFeature(true) {
@@ -548,19 +554,19 @@ public class DistributedLockManagerTest {
}
};
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
runLock(0, 0);
LockCallback callback2 = mock(LockCallback.class);
- final DistributedLock lock2 = getLock(RESOURCE2, OWNER_KEY, HOLD_SEC, callback2, false);
+ final DistributedLock lock2 = getLock(RESOURCE2, callback2);
runLock(1, 0);
LockCallback callback3 = mock(LockCallback.class);
- final DistributedLock lock3 = getLock(RESOURCE3, OWNER_KEY, HOLD_SEC, callback3, false);
+ final DistributedLock lock3 = getLock(RESOURCE3, callback3);
// don't run doLock for lock3 - leave it in the waiting state
LockCallback callback4 = mock(LockCallback.class);
- final DistributedLock lock4 = getLock(RESOURCE4, OWNER_KEY, HOLD_SEC, callback4, false);
+ final DistributedLock lock4 = getLock(RESOURCE4, callback4);
runLock(3, 0);
assertEquals(3, getRecordCount());
@@ -572,7 +578,7 @@ public class DistributedLockManagerTest {
freeLock.set(lock4);
// run the checker
- runChecker(0, 0, EXPIRE_SEC);
+ runChecker(0, EXPIRE_SEC);
// check lock states
assertTrue(lock.isUnavailable());
@@ -590,7 +596,7 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockNoArgs() {
+ void testDistributedLockNoArgs() {
DistributedLock lock = new DistributedLock();
assertNull(lock.getResourceId());
assertNull(lock.getOwnerKey());
@@ -599,7 +605,7 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLock() {
+ void testDistributedLock() {
assertThatIllegalArgumentException()
.isThrownBy(() -> feature.createLock(RESOURCE, OWNER_KEY, -1, callback, false))
.withMessageContaining("holdSec");
@@ -609,8 +615,8 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockSerializable() throws Exception {
- DistributedLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockSerializable() throws Exception {
+ DistributedLock lock = getLock(RESOURCE, callback);
lock = roundTrip(lock);
assertTrue(lock.isWaiting());
@@ -622,8 +628,8 @@ public class DistributedLockManagerTest {
}
@Test
- public void testGrant() {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testGrant() {
+ lock = getLock(RESOURCE, callback);
assertFalse(lock.isActive());
// execute the doLock() call
@@ -636,12 +642,12 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockDeny() {
+ void testDistributedLockDeny() {
// get a lock
feature.createLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
// get another lock - should fail
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
assertTrue(lock.isUnavailable());
@@ -653,8 +659,8 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockFree() {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockFree() {
+ lock = getLock(RESOURCE, callback);
assertTrue(lock.free());
assertTrue(lock.isUnavailable());
@@ -673,7 +679,7 @@ public class DistributedLockManagerTest {
verify(exsvc, times(PRE_LOCK_EXECS + 2)).execute(any());
// new lock should succeed
- DistributedLock lock2 = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ DistributedLock lock2 = getLock(RESOURCE, callback);
assertNotSame(lock2, lock);
assertTrue(lock2.isWaiting());
}
@@ -684,8 +690,8 @@ public class DistributedLockManagerTest {
* @throws Exception if an error occurs
*/
@Test
- public void testDistributedLockFreeSerialized() throws Exception {
- DistributedLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockFreeSerialized() throws Exception {
+ DistributedLock lock = getLock(RESOURCE, callback);
feature = new MyLockingFeature(true);
@@ -700,8 +706,8 @@ public class DistributedLockManagerTest {
* @throws Exception if an error occurs
*/
@Test
- public void testDistributedLockFreeNoFeature() throws Exception {
- DistributedLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockFreeNoFeature() throws Exception {
+ DistributedLock lock = getLock(RESOURCE, callback);
DistributedLockManager.setLatestInstance(null);
@@ -715,10 +721,10 @@ public class DistributedLockManagerTest {
* isUnavailable() and the call to compute().
*/
@Test
- public void testDistributedLockFreeUnlocked() {
+ void testDistributedLockFreeUnlocked() {
feature = new FreeWithFreeLockingFeature(true);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
assertFalse(lock.free());
assertTrue(lock.isUnavailable());
@@ -729,21 +735,21 @@ public class DistributedLockManagerTest {
* call to isUnavailable() and the call to compute().
*/
@Test
- public void testDistributedLockFreeLockFreed() {
+ void testDistributedLockFreeLockFreed() {
feature = new FreeWithFreeLockingFeature(false);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
assertFalse(lock.free());
assertTrue(lock.isUnavailable());
}
@Test
- public void testDistributedLockExtend() {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockExtend() {
+ lock = getLock(RESOURCE, callback);
// lock2 should be denied - called back by this thread
- DistributedLock lock2 = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ DistributedLock lock2 = getLock(RESOURCE, callback);
verify(callback, never()).lockAvailable(lock2);
verify(callback).lockUnavailable(lock2);
@@ -782,8 +788,8 @@ public class DistributedLockManagerTest {
* @throws Exception if an error occurs
*/
@Test
- public void testDistributedLockExtendSerialized() throws Exception {
- DistributedLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockExtendSerialized() throws Exception {
+ DistributedLock lock = getLock(RESOURCE, callback);
// run doLock
runLock(0, 0);
@@ -813,8 +819,8 @@ public class DistributedLockManagerTest {
* @throws Exception if an error occurs
*/
@Test
- public void testDistributedLockExtendNoFeature() throws Exception {
- DistributedLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockExtendNoFeature() throws Exception {
+ DistributedLock lock = getLock(RESOURCE, callback);
// run doLock
runLock(0, 0);
@@ -839,10 +845,10 @@ public class DistributedLockManagerTest {
* isUnavailable() and the call to compute().
*/
@Test
- public void testDistributedLockExtendUnlocked() {
+ void testDistributedLockExtendUnlocked() {
feature = new FreeWithFreeLockingFeature(true);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
lock.extend(HOLD_SEC2, callback);
assertTrue(lock.isUnavailable());
@@ -854,10 +860,10 @@ public class DistributedLockManagerTest {
* call to isUnavailable() and the call to compute().
*/
@Test
- public void testDistributedLockExtendLockFreed() {
+ void testDistributedLockExtendLockFreed() {
feature = new FreeWithFreeLockingFeature(false);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
lock.extend(HOLD_SEC2, callback);
assertTrue(lock.isUnavailable());
@@ -865,20 +871,20 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockScheduleRequest() {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockScheduleRequest() {
+ lock = getLock(RESOURCE, callback);
runLock(0, 0);
verify(callback).lockAvailable(lock);
}
@Test
- public void testDistributedLockRescheduleRequest() {
+ void testDistributedLockRescheduleRequest() {
// use a data source that throws an exception when getConnection() is called
InvalidDbLockingFeature invfeat = new InvalidDbLockingFeature(TRANSIENT);
feature = invfeat;
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// invoke doLock - should fail and reschedule
runLock(0, 0);
@@ -891,7 +897,7 @@ public class DistributedLockManagerTest {
invfeat.freeLock = true;
// try scheduled request - should just invoke doUnlock
- runSchedule(0, 0);
+ runSchedule(0);
// should still be waiting
assertTrue(lock.isUnavailable());
@@ -902,8 +908,8 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockGetNextRequest() {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockGetNextRequest() {
+ lock = getLock(RESOURCE, callback);
/*
* run doLock. This should cause getNextRequest() to be called twice, once with a
@@ -917,11 +923,11 @@ public class DistributedLockManagerTest {
* time it's called.
*/
@Test
- public void testDistributedLockGetNextRequestSameRequest() {
+ void testDistributedLockGetNextRequestSameRequest() {
// force reschedule to be invoked
feature = new InvalidDbLockingFeature(TRANSIENT);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
/*
* run doLock. This should cause getNextRequest() to be called twice, once with a
@@ -933,8 +939,8 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockDoRequest() {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockDoRequest() {
+ lock = getLock(RESOURCE, callback);
assertTrue(lock.isWaiting());
@@ -948,7 +954,7 @@ public class DistributedLockManagerTest {
* Tests doRequest(), when doRequest() is already running within another thread.
*/
@Test
- public void testDistributedLockDoRequestBusy() {
+ void testDistributedLockDoRequestBusy() {
/*
* this feature will invoke a request in a background thread while it's being run
* in a foreground thread.
@@ -961,6 +967,7 @@ public class DistributedLockManagerTest {
protected DistributedLock makeLock(LockState state, String resourceId, String ownerKey, int holdSec,
LockCallback callback) {
return new DistributedLock(state, resourceId, ownerKey, holdSec, callback, feature) {
+ @Serial
private static final long serialVersionUID = 1L;
@Override
@@ -994,7 +1001,7 @@ public class DistributedLockManagerTest {
}
};
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// run doLock
runLock(0, 0);
@@ -1008,7 +1015,7 @@ public class DistributedLockManagerTest {
* @throws SQLException if an error occurs
*/
@Test
- public void testDistributedLockDoRequestRunExWaiting() throws SQLException {
+ void testDistributedLockDoRequestRunExWaiting() throws SQLException {
// throw run-time exception
when(datasrc.getConnection()).thenThrow(new IllegalStateException(EXPECTED_EXCEPTION));
@@ -1020,7 +1027,7 @@ public class DistributedLockManagerTest {
}
};
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// invoke doLock - should NOT reschedule
runLock(0, 0);
@@ -1038,7 +1045,7 @@ public class DistributedLockManagerTest {
* @throws SQLException if an error occurs
*/
@Test
- public void testDistributedLockDoRequestRunExUnavailable() throws SQLException {
+ void testDistributedLockDoRequestRunExUnavailable() throws SQLException {
// throw run-time exception
when(datasrc.getConnection()).thenAnswer(answer -> {
lock.free();
@@ -1053,7 +1060,7 @@ public class DistributedLockManagerTest {
}
};
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// invoke doLock - should NOT reschedule
runLock(0, 0);
@@ -1068,11 +1075,11 @@ public class DistributedLockManagerTest {
* Tests doRequest() when the retry count gets exhausted.
*/
@Test
- public void testDistributedLockDoRequestRetriesExhaustedWhileLocking() {
+ void testDistributedLockDoRequestRetriesExhaustedWhileLocking() {
// use a data source that throws an exception when getConnection() is called
feature = new InvalidDbLockingFeature(TRANSIENT);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// invoke doLock - should fail and reschedule
runLock(0, 0);
@@ -1082,14 +1089,14 @@ public class DistributedLockManagerTest {
verify(callback, never()).lockUnavailable(lock);
// try again, via SCHEDULER - first retry fails
- runSchedule(0, 0);
+ runSchedule(0);
// should still be waiting
assertTrue(lock.isWaiting());
verify(callback, never()).lockUnavailable(lock);
// try again, via SCHEDULER - final retry fails
- runSchedule(1, 0);
+ runSchedule(1);
assertTrue(lock.isUnavailable());
// now callback should have been called
@@ -1100,14 +1107,14 @@ public class DistributedLockManagerTest {
* Tests doRequest() when a non-transient DB exception is thrown.
*/
@Test
- public void testDistributedLockDoRequestNotTransient() {
+ void testDistributedLockDoRequestNotTransient() {
/*
* use a data source that throws a PERMANENT exception when getConnection() is
* called
*/
feature = new InvalidDbLockingFeature(PERMANENT);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// invoke doLock - should fail
runLock(0, 0);
@@ -1121,8 +1128,8 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockDoLock() throws SQLException {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockDoLock() throws SQLException {
+ lock = getLock(RESOURCE, callback);
// invoke doLock - should simply do an insert
long tbegin = System.currentTimeMillis();
@@ -1139,8 +1146,8 @@ public class DistributedLockManagerTest {
* @throws SQLException if an error occurs
*/
@Test
- public void testDistributedLockDoLockFreed() throws SQLException {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockDoLockFreed() throws SQLException {
+ lock = getLock(RESOURCE, callback);
lock.setState(LockState.UNAVAILABLE);
@@ -1156,11 +1163,11 @@ public class DistributedLockManagerTest {
* Tests doLock() when a DB exception is thrown.
*/
@Test
- public void testDistributedLockDoLockEx() {
+ void testDistributedLockDoLockEx() {
// use a data source that throws an exception when getConnection() is called
feature = new InvalidDbLockingFeature(PERMANENT);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// invoke doLock - should simply do an insert
runLock(0, 0);
@@ -1174,11 +1181,11 @@ public class DistributedLockManagerTest {
* to be called.
*/
@Test
- public void testDistributedLockDoLockNeedingUpdate() throws SQLException {
+ void testDistributedLockDoLockNeedingUpdate() throws SQLException {
// insert an expired record
insertRecord(RESOURCE, feature.getUuidString(), 0);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// invoke doLock - should simply do an update
runLock(0, 0);
@@ -1189,11 +1196,11 @@ public class DistributedLockManagerTest {
* Tests doLock() when a locked record already exists.
*/
@Test
- public void testDistributedLockDoLockAlreadyLocked() throws SQLException {
+ void testDistributedLockDoLockAlreadyLocked() throws SQLException {
// insert an expired record
insertRecord(RESOURCE, OTHER_OWNER, HOLD_SEC);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// invoke doLock
runLock(0, 0);
@@ -1203,8 +1210,8 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockDoUnlock() throws SQLException {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockDoUnlock() throws SQLException {
+ lock = getLock(RESOURCE, callback);
// invoke doLock()
runLock(0, 0);
@@ -1230,10 +1237,10 @@ public class DistributedLockManagerTest {
*
*/
@Test
- public void testDistributedLockDoUnlockEx() {
+ void testDistributedLockDoUnlockEx() {
feature = new InvalidDbLockingFeature(PERMANENT);
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
// do NOT invoke doLock() - it will fail without a DB connection
@@ -1250,8 +1257,8 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockDoExtend() throws SQLException {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockDoExtend() throws SQLException {
+ lock = getLock(RESOURCE, callback);
runLock(0, 0);
LockCallback callback2 = mock(LockCallback.class);
@@ -1281,8 +1288,8 @@ public class DistributedLockManagerTest {
* @throws SQLException if an error occurs
*/
@Test
- public void testDistributedLockDoExtendFreed() throws SQLException {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockDoExtendFreed() throws SQLException {
+ lock = getLock(RESOURCE, callback);
lock.extend(HOLD_SEC2, callback);
lock.setState(LockState.UNAVAILABLE);
@@ -1302,8 +1309,8 @@ public class DistributedLockManagerTest {
* @throws SQLException if an error occurs
*/
@Test
- public void testDistributedLockDoExtendInsertNeeded() throws SQLException {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockDoExtendInsertNeeded() throws SQLException {
+ lock = getLock(RESOURCE, callback);
runLock(0, 0);
LockCallback callback2 = mock(LockCallback.class);
@@ -1335,7 +1342,7 @@ public class DistributedLockManagerTest {
*
*/
@Test
- public void testDistributedLockDoExtendNeitherSucceeds() {
+ void testDistributedLockDoExtendNeitherSucceeds() {
/*
* this feature will create a lock that returns false when doDbUpdate() is
* invoked, or when doDbInsert() is invoked a second time
@@ -1345,6 +1352,7 @@ public class DistributedLockManagerTest {
protected DistributedLock makeLock(LockState state, String resourceId, String ownerKey, int holdSec,
LockCallback callback) {
return new DistributedLock(state, resourceId, ownerKey, holdSec, callback, feature) {
+ @Serial
private static final long serialVersionUID = 1L;
private int ntimes = 0;
@@ -1365,7 +1373,7 @@ public class DistributedLockManagerTest {
}
};
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ lock = getLock(RESOURCE, callback);
runLock(0, 0);
LockCallback callback2 = mock(LockCallback.class);
@@ -1391,8 +1399,8 @@ public class DistributedLockManagerTest {
* @throws SQLException if an error occurs
*/
@Test
- public void testDistributedLockDoExtendEx() throws SQLException {
- lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testDistributedLockDoExtendEx() throws SQLException {
+ lock = getLock(RESOURCE, callback);
runLock(0, 0);
/*
@@ -1420,14 +1428,14 @@ public class DistributedLockManagerTest {
}
@Test
- public void testDistributedLockToString() {
- String text = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false).toString();
+ void testDistributedLockToString() {
+ String text = getLock(RESOURCE, callback).toString();
assertNotNull(text);
assertThat(text).doesNotContain("ownerInfo").doesNotContain("callback");
}
@Test
- public void testMakeThreadPool() {
+ void testMakeThreadPool() {
// use a REAL feature to test this
feature = new DistributedLockManager();
@@ -1439,13 +1447,13 @@ public class DistributedLockManagerTest {
}
/**
- * Performs a multi-threaded test of the locking facility.
+ * Performs a multithreaded test of the locking facility.
*
* @throws InterruptedException if the current thread is interrupted while waiting for
* the background threads to complete
*/
@Test
- public void testMultiThreaded() throws InterruptedException {
+ void testMultiThreaded() throws InterruptedException {
ReflectionTestUtils.setField(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, realExec);
feature = new DistributedLockManager();
@@ -1473,9 +1481,9 @@ public class DistributedLockManagerTest {
assertTrue(nsuccesses.get() > 0);
}
- private DistributedLock getLock(String resource, String ownerKey, int holdSec, LockCallback callback,
- boolean waitForLock) {
- return (DistributedLock) feature.createLock(resource, ownerKey, holdSec, callback, waitForLock);
+ private DistributedLock getLock(String resource, LockCallback callback) {
+ return (DistributedLock) feature.createLock(resource, DistributedLockManagerTest.OWNER_KEY,
+ DistributedLockManagerTest.HOLD_SEC, callback, false);
}
private DistributedLock roundTrip(DistributedLock lock) throws Exception {
@@ -1493,14 +1501,12 @@ public class DistributedLockManagerTest {
/**
* Runs the checkExpired() action.
*
- * @param nskip number of actions in the work queue to skip
- * @param nadditional number of additional actions that appear in the work queue
- * <i>after</i> the checkExpired action
+ * @param nskip number of actions in the work queue to skip
* @param schedSec number of seconds for which the checker should have been scheduled
*/
- private void runChecker(int nskip, int nadditional, long schedSec) {
+ private void runChecker(int nskip, long schedSec) {
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
- verify(exsvc, times(nskip + nadditional + 1)).schedule(captor.capture(), eq(schedSec), eq(TimeUnit.SECONDS));
+ verify(exsvc, times(nskip + 1)).schedule(captor.capture(), eq(schedSec), eq(TimeUnit.SECONDS));
Runnable action = captor.getAllValues().get(nskip);
action.run();
}
@@ -1524,12 +1530,10 @@ public class DistributedLockManagerTest {
* Runs a scheduled action (e.g., "retry" action).
*
* @param nskip number of actions in the work queue to skip
- * @param nadditional number of additional actions that appear in the work queue
- * <i>after</i> the desired action
*/
- void runSchedule(int nskip, int nadditional) {
+ void runSchedule(int nskip) {
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
- verify(exsvc, times(PRE_SCHED_EXECS + nskip + nadditional + 1)).schedule(captor.capture(), anyLong(), any());
+ verify(exsvc, times(PRE_SCHED_EXECS + nskip + 1)).schedule(captor.capture(), anyLong(), any());
Runnable action = captor.getAllValues().get(PRE_SCHED_EXECS + nskip);
action.run();
@@ -1645,7 +1649,7 @@ public class DistributedLockManagerTest {
shutdownFeature();
exsvc = mock(ScheduledExecutorService.class);
- when(exsvc.schedule(any(Runnable.class), anyLong(), any())).thenAnswer(ans -> checker);
+ lenient().when(exsvc.schedule(any(Runnable.class), anyLong(), any())).thenAnswer(ans -> checker);
ReflectionTestUtils.setField(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, exsvc);
if (init) {
@@ -1660,10 +1664,10 @@ public class DistributedLockManagerTest {
* Feature whose data source all throws exceptions.
*/
private class InvalidDbLockingFeature extends MyLockingFeature {
- private boolean isTransient;
+ private final boolean isTransient;
private boolean freeLock = false;
- public InvalidDbLockingFeature(boolean isTransient) {
+ InvalidDbLockingFeature(boolean isTransient) {
// pass "false" because we have to set the error code BEFORE calling
// afterStart()
super(false);
@@ -1677,7 +1681,7 @@ public class DistributedLockManagerTest {
@Override
protected BasicDataSource makeDataSource() throws Exception {
- when(datasrc.getConnection()).thenAnswer(answer -> {
+ lenient().when(datasrc.getConnection()).thenAnswer(answer -> {
if (freeLock) {
freeLock = false;
lock.free();
@@ -1705,7 +1709,7 @@ public class DistributedLockManagerTest {
* Feature whose locks free themselves while free() is already running.
*/
private class FreeWithFreeLockingFeature extends MyLockingFeature {
- private boolean relock;
+ private final boolean relock;
public FreeWithFreeLockingFeature(boolean relock) {
super(true);
@@ -1717,6 +1721,7 @@ public class DistributedLockManagerTest {
LockCallback callback) {
return new DistributedLock(state, resourceId, ownerKey, holdSec, callback, feature) {
+ @Serial
private static final long serialVersionUID = 1L;
private boolean checked = false;
@@ -1746,7 +1751,7 @@ public class DistributedLockManagerTest {
}
/**
- * Thread used with the multi-threaded test. It repeatedly attempts to get a lock,
+ * Thread used with the multithreaded test. It repeatedly attempts to get a lock,
* extend it, and then unlock it.
*/
private class MyThread extends Thread {
diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockPropertiesTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockPropertiesTest.java
index 5abca889..8cfb3eab 100644
--- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockPropertiesTest.java
+++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockPropertiesTest.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,22 +21,22 @@
package org.onap.policy.distributed.locking;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Properties;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.properties.exception.PropertyException;
-public class DistributedLockPropertiesTest {
+class DistributedLockPropertiesTest {
private Properties props;
/**
* Populates {@link #props}.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
props = new Properties();
props.setProperty(DistributedLockProperties.DB_DRIVER, "my driver");
@@ -48,7 +49,7 @@ public class DistributedLockPropertiesTest {
}
@Test
- public void test() throws PropertyException {
+ void test() throws PropertyException {
DistributedLockProperties dlp = new DistributedLockProperties(props);
assertEquals("my driver", dlp.getDbDriver());
diff --git a/feature-healthcheck/src/main/feature/config/feature-healthcheck.properties b/feature-healthcheck/src/main/feature/config/feature-healthcheck.properties
index 98247a89..d8e22b4f 100644
--- a/feature-healthcheck/src/main/feature/config/feature-healthcheck.properties
+++ b/feature-healthcheck/src/main/feature/config/feature-healthcheck.properties
@@ -3,6 +3,7 @@
# ONAP
# ================================================================================
# Copyright (C) 2017-2019,2022 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.
@@ -28,7 +29,6 @@ http.server.services.HEALTHCHECK.swagger=true
http.server.services.HEALTHCHECK.userName=${envd:HEALTHCHECK_USER}
http.server.services.HEALTHCHECK.password=${envd:HEALTHCHECK_PASSWORD}
http.server.services.HEALTHCHECK.https=${envd:HTTP_SERVER_HTTPS:false}
-http.server.services.HEALTHCHECK.aaf=${envd:AAF:false}
http.server.services.HEALTHCHECK.serialization.provider=org.onap.policy.common.gson.JacksonHandler,org.onap.policy.common.endpoints.http.server.YamlJacksonHandler
http.server.services.LIVENESS.host=0.0.0.0
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
index 0567595f..7cf7ed5f 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-2019,2022 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,9 +21,9 @@
package org.onap.policy.drools.healthcheck;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
@@ -38,9 +39,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import org.eclipse.jetty.http.HttpStatus;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.kie.api.builder.ReleaseId;
import org.mockito.AdditionalAnswers;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
@@ -65,7 +66,7 @@ public class HealthCheckFeatureTest {
/**
* Set up.
*/
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException {
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
@@ -92,7 +93,7 @@ public class HealthCheckFeatureTest {
/**
* Tear down.
*/
- @AfterClass
+ @AfterAll
public static void teardown() {
PolicyControllerConstants.getFactory().destroy();
HttpClientFactoryInstance.getClientFactory().destroy();
@@ -100,7 +101,7 @@ public class HealthCheckFeatureTest {
}
@Test
- public void test() throws InterruptedException {
+ void test() throws InterruptedException {
var manager = spy(HealthCheckManager.class);
var feature = new HealthCheckFeatureImpl(manager);
when(manager.isEngineAlive()).thenReturn(true);
@@ -167,12 +168,12 @@ public class HealthCheckFeatureTest {
}
@Test
- public void testGetSequenceNumber() {
+ void testGetSequenceNumber() {
assertEquals(1000, new HealthCheckFeature().getSequenceNumber());
}
@Test
- public void testAfterStart() {
+ void testAfterStart() {
HealthCheck checker = mock(HealthCheck.class);
HealthCheckFeature feature = new HealthCheckFeatureImpl(checker);
@@ -187,7 +188,7 @@ public class HealthCheckFeatureTest {
}
@Test
- public void testAfterOpen() {
+ void testAfterOpen() {
HealthCheck checker = mock(HealthCheck.class);
HealthCheckFeature feature = new HealthCheckFeatureImpl(checker);
@@ -203,7 +204,7 @@ public class HealthCheckFeatureTest {
}
@Test
- public void testAfterShutdown() {
+ void testAfterShutdown() {
HealthCheck checker = mock(HealthCheck.class);
HealthCheckFeature feature = new HealthCheckFeatureImpl(checker);
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java
index 9e081015..8553301f 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 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,11 +21,11 @@
package org.onap.policy.drools.healthcheck;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -41,8 +42,8 @@ import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import org.eclipse.jetty.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.AdditionalAnswers;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
@@ -57,7 +58,7 @@ import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class HealthCheckManagerTest {
+class HealthCheckManagerTest {
private static final Logger logger = LoggerFactory.getLogger(HealthCheckManagerTest.class);
@@ -101,7 +102,7 @@ public class HealthCheckManagerTest {
/**
* Initializes the object to be tested.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
properties = new Properties();
mocks();
@@ -186,7 +187,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testHealthcheck() {
+ void testHealthcheck() {
/* engine not alive */
when(engineMgr.isAlive()).thenReturn(false);
@@ -210,7 +211,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testControllerHealthcheck() {
+ void testControllerHealthcheck() {
/* engine not alive */
when(engineMgr.isAlive()).thenReturn(false);
@@ -248,7 +249,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testClientHealthcheck() {
+ void testClientHealthcheck() {
/* engine not alive */
when(engineMgr.isAlive()).thenReturn(false);
@@ -278,7 +279,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void reportOnController() {
+ void reportOnController() {
/* controller not alive */
@@ -336,7 +337,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testReportOnUnknown() {
+ void testReportOnUnknown() {
var reports = monitor.summary(monitor.engineHealthcheck(), monitor.futures(List.of(1)));
logger.info("{}", reports);
@@ -346,7 +347,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testStart() {
+ void testStart() {
// good start
when(server1.start()).thenReturn(true);
@@ -381,7 +382,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testOpen() {
+ void testOpen() {
/* nothing done */
@@ -412,7 +413,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
monitor.healthcheckServer = server1;
monitor.livenessServer = server2;
monitor.clients = List.of(client1, client2, client3);
@@ -429,12 +430,12 @@ public class HealthCheckManagerTest {
}
@Test
- public void testIsAlive() {
+ void testIsAlive() {
assertFalse(monitor.isAlive());
}
@Test
- public void testToString() {
+ void testToString() {
assertTrue(monitor.toString().contains("HealthCheckManager"));
}
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
index 01f5063d..375c1622 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2021-2022 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,27 +21,27 @@
package org.onap.policy.drools.healthcheck;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.healthcheck.HealthCheck.Report;
import org.onap.policy.drools.healthcheck.HealthCheck.Reports;
-public class HealthCheckTest {
+class HealthCheckTest {
private static final long RPT_CODE = 100;
private static final String RPT_MSG = "report-message";
private static final String RPT_NAME = "report-name";
private static final String RPT_URL = "report-url";
@Test
- public void testReport() {
+ void testReport() {
Report rpt = new Report();
assertNotNull(rpt.toString());
@@ -73,7 +74,7 @@ public class HealthCheckTest {
}
@Test
- public void testReports() {
+ void testReports() {
Reports reports = new Reports();
// toString should work with un-populated data
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java
index 2ab1fe82..63825fa8 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 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,15 +21,15 @@
package org.onap.policy.drools.healthcheck;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import jakarta.ws.rs.core.Response;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+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.HttpClientFactory;
@@ -60,7 +61,7 @@ public class RestHealthCheckTest {
* Set up.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
LoggerUtils.setLevel("org.eclipse", "ERROR");
@@ -103,26 +104,26 @@ public class RestHealthCheckTest {
* Tear down.
*/
- @AfterClass
+ @AfterAll
public static void tearDown() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
- public void healthcheck() {
+ void healthcheck() {
when(healthcheckManager.healthCheck()).thenReturn(summary);
assertHttp("/");
}
@Test
- public void engine() {
+ void engine() {
when(healthcheckManager.engineHealthcheck()).thenReturn(summary);
assertHttp("engine");
}
@Test
- public void controllers() {
+ void controllers() {
when(healthcheckManager.controllerHealthcheck()).thenReturn(summary);
assertHttp("controllers");
@@ -140,7 +141,7 @@ public class RestHealthCheckTest {
}
@Test
- public void clients() {
+ void clients() {
when(healthcheckManager.clientHealthcheck()).thenReturn(summary);
assertHttp("clients");
diff --git a/feature-healthcheck/src/test/resources/echo.drl b/feature-healthcheck/src/test/resources/echo.drl
index 54847da9..189c8a51 100644
--- a/feature-healthcheck/src/test/resources/echo.drl
+++ b/feature-healthcheck/src/test/resources/echo.drl
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 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.
@@ -29,7 +30,7 @@ end
rule "ECHO"
when
- $o : Object();
+ $o : Object()
then
System.out.println("ECHO: " + $o.toString());
end
diff --git a/feature-healthcheck/src/test/resources/echo.kmodule b/feature-healthcheck/src/test/resources/echo.kmodule
index 7a1acc70..fd972ab0 100644
--- a/feature-healthcheck/src/test/resources/echo.kmodule
+++ b/feature-healthcheck/src/test/resources/echo.kmodule
@@ -4,6 +4,7 @@
ONAP
================================================================================
Copyright (C) 2022 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.
@@ -19,7 +20,7 @@
============LICENSE_END=========================================================
-->
-<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="onap.policies.drools.healthcheck">
<ksession name="echo"/>
</kbase>
diff --git a/feature-legacy-config/src/main/feature/config/feature-legacy-config.properties b/feature-legacy-config/src/main/feature/config/feature-legacy-config.properties
index 15a35b8b..47a4e229 100644
--- a/feature-legacy-config/src/main/feature/config/feature-legacy-config.properties
+++ b/feature-legacy-config/src/main/feature/config/feature-legacy-config.properties
@@ -2,6 +2,7 @@
# ONAP
# ================================================================================
# 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.
@@ -16,25 +17,13 @@
# limitations under the License.
# ============LICENSE_END=========================================================
-dmaap.source.topics=PDPD-CONFIGURATION
-
-dmaap.source.topics.PDPD-CONFIGURATION.servers=${envd:DMAAP_SERVERS}
-dmaap.source.topics.PDPD-CONFIGURATION.effectiveTopic=${envd:PDPD_CONFIGURATION_TOPIC}
-dmaap.source.topics.PDPD-CONFIGURATION.apiKey=${envd:PDPD_CONFIGURATION_API_KEY}
-dmaap.source.topics.PDPD-CONFIGURATION.apiSecret=${envd:PDPD_CONFIGURATION_API_SECRET}
-dmaap.source.topics.PDPD-CONFIGURATION.consumerGroup=${envd:PDPD_CONFIGURATION_CONSUMER_GROUP}
-dmaap.source.topics.PDPD-CONFIGURATION.consumerInstance=${envd:PDPD_CONFIGURATION_CONSUMER_INSTANCE}
-dmaap.source.topics.PDPD-CONFIGURATION.managed=false
-dmaap.source.topics.PDPD-CONFIGURATION.https=${envd:DMAAP_HTTPS:true}
-
-#Replace the properties with the following to use kafka message broker
-#kafka.source.topics=pdpd-configuration
-#kafka.source.topics.fetchTimeout=15000
-#kafka.source.topics.pdpd-configuration.servers=${envd:DMAAP_SERVERS}
-#kafka.source.topics.pdpd-configuration.effectiveTopic=${envd:PDPD_CONFIGURATION_TOPIC}
-#kafka.source.topics.pdpd-configuration.apiKey=${envd:PDPD_CONFIGURATION_API_KEY}
-#kafka.source.topics.pdpd-configuration.apiSecret=${envd:PDPD_CONFIGURATION_API_SECRET}
-#kafka.source.topics.pdpd-configuration.consumerGroup=${envd:PDPD_CONFIGURATION_CONSUMER_GROUP}
-#kafka.source.topics.pdpd-configuration.consumerInstance=${envd:PDPD_CONFIGURATION_CONSUMER_INSTANCE}
-#kafka.source.topics.pdpd-configuration.managed=false
-#kafka.source.topics.pdpd-configuration.https=${envd:DMAAP_HTTPS:true}
+kafka.source.topics=pdpd-configuration
+kafka.source.topics.fetchTimeout=15000
+kafka.source.topics.pdpd-configuration.servers=${envd:KAFKA_SERVERS}
+kafka.source.topics.pdpd-configuration.effectiveTopic=${envd:PDPD_CONFIGURATION_TOPIC}
+kafka.source.topics.pdpd-configuration.apiKey=${envd:PDPD_CONFIGURATION_API_KEY}
+kafka.source.topics.pdpd-configuration.apiSecret=${envd:PDPD_CONFIGURATION_API_SECRET}
+kafka.source.topics.pdpd-configuration.consumerGroup=${envd:PDPD_CONFIGURATION_CONSUMER_GROUP}
+kafka.source.topics.pdpd-configuration.consumerInstance=${envd:PDPD_CONFIGURATION_CONSUMER_INSTANCE}
+kafka.source.topics.pdpd-configuration.managed=false
+kafka.source.topics.pdpd-configuration.https=${envd:KAFKA_HTTPS:true}
diff --git a/feature-legacy-config/src/main/java/org/onap/policy/drools/legacy/config/LegacyConfig.java b/feature-legacy-config/src/main/java/org/onap/policy/drools/legacy/config/LegacyConfig.java
index 01cc3b34..7ca4632c 100644
--- a/feature-legacy-config/src/main/java/org/onap/policy/drools/legacy/config/LegacyConfig.java
+++ b/feature-legacy-config/src/main/java/org/onap/policy/drools/legacy/config/LegacyConfig.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -36,16 +37,15 @@ import org.slf4j.LoggerFactory;
/**
* Legacy Configurator.
*/
+@Getter
public class LegacyConfig implements Startable, TopicListener {
private static final Logger logger = LoggerFactory.getLogger(LegacyConfig.class);
private static final String CONFIGURATION_PROPERTIES_NAME = "feature-legacy-config";
- @Getter
private final Properties properties;
- @Getter
- private TopicSource source;
+ private final TopicSource source;
/**
* Constructor.
diff --git a/feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigFeatureTest.java b/feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigFeatureTest.java
index d73817b8..c8371895 100644
--- a/feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigFeatureTest.java
+++ b/feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigFeatureTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,25 +21,25 @@
package org.onap.policy.drools.legacy.config;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+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 org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+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.NoopTopicFactories;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyEngineConstants;
-public class LegacyConfigFeatureTest {
+class LegacyConfigFeatureTest {
private LegacyConfigFeature configF;
/**
* Set up.
*/
- @Before
+ @BeforeEach
public void setUp() {
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
configF = new LegacyConfigFeature();
@@ -47,7 +48,7 @@ public class LegacyConfigFeatureTest {
/**
* Tear down.
*/
- @After
+ @AfterEach
public void tearDown() {
NoopTopicFactories.getSourceFactory().destroy();
NoopTopicFactories.getSinkFactory().destroy();
@@ -55,12 +56,12 @@ public class LegacyConfigFeatureTest {
}
@Test
- public void getSequenceNumber() {
+ void getSequenceNumber() {
assertEquals(LegacyConfigFeature.SEQNO, new LegacyConfigFeature().getSequenceNumber());
}
@Test
- public void afterOpenBeforeShutdown() {
+ void afterOpenBeforeShutdown() {
assertFalse(LegacyConfigFeature.getLegacyConfig().isAlive());
configF.afterOpen(PolicyEngineConstants.getManager());
assertTrue(LegacyConfigFeature.getLegacyConfig().isAlive());
diff --git a/feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigTest.java b/feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigTest.java
index eb8860d2..09e03b3e 100644
--- a/feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigTest.java
+++ b/feature-legacy-config/src/test/java/org/onap/policy/drools/legacy/config/LegacyConfigTest.java
@@ -22,26 +22,26 @@
package org.onap.policy.drools.legacy.config;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+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 org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+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;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
-public class LegacyConfigTest {
+class LegacyConfigTest {
private static final String PDPD_CONFIGURATION_TOPIC = "pdpd-configuration";
/**
* Set up.
*/
- @Before
+ @BeforeEach
public void setUp() {
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
}
@@ -49,7 +49,7 @@ public class LegacyConfigTest {
/**
* Tear down.
*/
- @After
+ @AfterEach
public void tearDown() {
NoopTopicFactories.getSourceFactory().destroy();
NoopTopicFactories.getSinkFactory().destroy();
@@ -57,7 +57,7 @@ public class LegacyConfigTest {
}
@Test
- public void testStartStop() {
+ void testStartStop() {
LegacyConfig config = new LegacyConfig();
assertFalse(config.isAlive());
@@ -75,7 +75,7 @@ public class LegacyConfigTest {
}
@Test
- public void testConstructors() {
+ void testConstructors() {
LegacyConfig config = new LegacyConfig();
assertNotNull(config.getProperties());
assertEquals(PDPD_CONFIGURATION_TOPIC, config.getSource().getTopic());
diff --git a/feature-legacy-config/src/test/java/org/onap/policy/drools/server/restful/RestLegacyConfigTest.java b/feature-legacy-config/src/test/java/org/onap/policy/drools/server/restful/RestLegacyConfigTest.java
index 46bdb0f8..5180c486 100644
--- a/feature-legacy-config/src/test/java/org/onap/policy/drools/server/restful/RestLegacyConfigTest.java
+++ b/feature-legacy-config/src/test/java/org/onap/policy/drools/server/restful/RestLegacyConfigTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* 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.
@@ -18,14 +19,14 @@
package org.onap.policy.drools.server.restful;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import jakarta.ws.rs.core.Response;
import java.util.Properties;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+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.HttpClientFactoryInstance;
@@ -45,7 +46,7 @@ public class RestLegacyConfigTest {
/**
* Set up.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
@@ -79,7 +80,7 @@ public class RestLegacyConfigTest {
/**
* Tear down.
*/
- @AfterClass
+ @AfterAll
public static void tearDown() {
LegacyConfigFeature.getLegacyConfig().shutdown();
HttpClientFactoryInstance.getClientFactory().destroy();
@@ -88,7 +89,7 @@ public class RestLegacyConfigTest {
}
@Test
- public void properties() {
+ void properties() {
Response response = client.get("properties");
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(LegacyConfigFeature.getLegacyConfig().getProperties(),
@@ -96,7 +97,7 @@ public class RestLegacyConfigTest {
}
@Test
- public void topic() {
+ void topic() {
Response response = client.get("source");
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
diff --git a/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties b/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
index 27799543..06fa87e5 100644
--- a/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
+++ b/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
@@ -2,6 +2,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.
@@ -22,33 +23,17 @@ lifecycle.pdp.type=${envd:POLICY_PDP_PAP_TYPE:drools}
# Mandatory policy types that this PDP-D must support at a minimum
lifecycle.pdp.policytypes=${envd:POLICY_PDP_PAP_POLICYTYPES}
-dmaap.source.topics=POLICY-PDP-PAP
-dmaap.sink.topics=POLICY-PDP-PAP
+kafka.source.topics=POLICY-PDP-PAP
+kafka.sink.topics=POLICY-PDP-PAP
-dmaap.source.topics.POLICY-PDP-PAP.servers=${envd:DMAAP_SERVERS}
-dmaap.source.topics.POLICY-PDP-PAP.effectiveTopic=${envd:POLICY_PDP_PAP_TOPIC}
-dmaap.source.topics.POLICY-PDP-PAP.apiKey=${envd:POLICY_PDP_PAP_API_KEY}
-dmaap.source.topics.POLICY-PDP-PAP.apiSecret=${envd:POLICY_PDP_PAP_API_SECRET}
-dmaap.source.topics.POLICY-PDP-PAP.https=${envd:DMAAP_HTTPS:true}
+kafka.source.topics.POLICY-PDP-PAP.servers=${envd:KAFKA_SERVERS}
+kafka.source.topics.POLICY-PDP-PAP.effectiveTopic=${envd:POLICY_PDP_PAP_TOPIC}
+kafka.source.topics.POLICY-PDP-PAP.apiKey=${envd:POLICY_PDP_PAP_API_KEY}
+kafka.source.topics.POLICY-PDP-PAP.apiSecret=${envd:POLICY_PDP_PAP_API_SECRET}
+kafka.source.topics.POLICY-PDP-PAP.https=${envd:KAFKA_HTTPS:true}
-dmaap.sink.topics.POLICY-PDP-PAP.servers=${envd:DMAAP_SERVERS}
-dmaap.sink.topics.POLICY-PDP-PAP.effectiveTopic=${envd:POLICY_PDP_PAP_TOPIC}
-dmaap.sink.topics.POLICY-PDP-PAP.apiKey=${envd:POLICY_PDP_PAP_API_KEY}
-dmaap.sink.topics.POLICY-PDP-PAP.apiSecret=${envd:POLICY_PDP_PAP_API_SECRET}
-dmaap.sink.topics.POLICY-PDP-PAP.https=${envd:DMAAP_HTTPS:true}
-
-#Replace the properties with the following to use kafka message broker
-#kafka.source.topics=policy-pdp-pap
-#kafka.source.topics.fetchTimeout=15000
-#kafka.sink.topics=policy-pdp-pap
-#kafka.source.topics.policy-pdp-pap.servers=${envd:DMAAP_SERVERS}
-#kafka.source.topics.policy-pdp-pap.effectiveTopic=${envd:POLICY_PDP_PAP_TOPIC}
-#kafka.source.topics.policy-pdp-pap.apiKey=${envd:POLICY_PDP_PAP_API_KEY}
-#kafka.source.topics.policy-pdp-pap.apiSecret=${envd:POLICY_PDP_PAP_API_SECRET}
-#kafka.source.topics.policy-pdp-pap.https=${envd:DMAAP_HTTPS:true}
-
-#kafka.sink.topics.policy-pdp-pap.servers=${envd:DMAAP_SERVERS}
-#kafka.sink.topics.policy-pdp-pap.effectiveTopic=${envd:POLICY_PDP_PAP_TOPIC}
-#kafka.sink.topics.policy-pdp-pap.apiKey=${envd:POLICY_PDP_PAP_API_KEY}
-#kafka.sink.topics.policy-pdp-pap.apiSecret=${envd:POLICY_PDP_PAP_API_SECRET}
-#kafka.sink.topics.policy-pdp-pap.https=${envd:DMAAP_HTTPS:true}
+kafka.sink.topics.POLICY-PDP-PAP.servers=${envd:KAFKA_SERVERS}
+kafka.sink.topics.POLICY-PDP-PAP.effectiveTopic=${envd:POLICY_PDP_PAP_TOPIC}
+kafka.sink.topics.POLICY-PDP-PAP.apiKey=${envd:POLICY_PDP_PAP_API_KEY}
+kafka.sink.topics.POLICY-PDP-PAP.apiSecret=${envd:POLICY_PDP_PAP_API_SECRET}
+kafka.sink.topics.POLICY-PDP-PAP.https=${envd:KAFKA_HTTPS:true}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index c67367e0..e7656ae6 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -23,8 +23,6 @@ package org.onap.policy.drools.lifecycle;
import com.google.re2j.Pattern;
import io.prometheus.client.Counter;
-import java.lang.reflect.InvocationTargetException;
-import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -42,7 +40,6 @@ import java.util.stream.Collectors;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
-import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.capabilities.Startable;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
@@ -286,8 +283,7 @@ public class LifecycleFsm implements Startable {
policyTypesMap.values().stream()
.filter(PolicyTypeDroolsController.class::isInstance)
.map(PolicyTypeDroolsController.class::cast)
- .filter(opController -> opController.getControllers().containsKey(controller.getName()))
- .collect(Collectors.toList());
+ .filter(opController -> opController.getControllers().containsKey(controller.getName())).toList();
for (PolicyTypeDroolsController opController : opControllers) {
opController.remove(controller);
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
index 202eb98b..02fc7a93 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Bell Canada.
- * 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.
@@ -25,7 +25,6 @@ package org.onap.policy.drools.lifecycle;
import java.util.Collections;
import lombok.NonNull;
import lombok.ToString;
-import org.jetbrains.annotations.NotNull;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.enums.PdpResponseStatus;
import org.onap.policy.models.pdp.enums.PdpState;
@@ -46,12 +45,12 @@ public class LifecycleStateActive extends LifecycleStateRunning {
}
@Override
- protected boolean stateChangeToActive(@NotNull PdpStateChange change) {
+ protected boolean stateChangeToActive(@NonNull PdpStateChange change) {
return fsm.statusAction(response(change.getRequestId(), PdpResponseStatus.SUCCESS, null));
}
@Override
- protected boolean stateChangeToPassive(@NotNull PdpStateChange change) {
+ protected boolean stateChangeToPassive(@NonNull PdpStateChange change) {
undeployPolicies(Collections.emptyList());
fsm.transitionToAction(new LifecycleStatePassive(fsm));
return fsm.statusAction(response(change.getRequestId(), PdpResponseStatus.SUCCESS, null));
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
index fc62b947..2d5c66b3 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
@@ -217,7 +217,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
}
protected List<ToscaPolicy> reApplyNonNativePolicies(Map<String, List<ToscaPolicy>> preActivePoliciesMap) {
- // only need to re-apply non native policies if there are new native artifact policies
+ // only need to re-apply non-native policies if there are new native artifact policies
Map<String, List<ToscaPolicy>> activePoliciesByType = fsm.groupPoliciesByPolicyType(fsm.getActivePolicies());
List<ToscaPolicy> activeNativeArtifactPolicies = fsm.getNativeArtifactPolicies(activePoliciesByType);
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
index 6973745c..6e248e8d 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
@@ -179,7 +179,7 @@ public class PolicyTypeNativeDroolsController implements PolicyTypeController {
List<TopicSink> sinks =
TopicEndpointManager.getManager().getTopicSinks(List.of(configSinkTopic.getTopicName()));
if (sinks.size() != 1) {
- logger.warn("Topic {} is not present or ambigous {}", configSinkTopic.getTopicName(), sinks);
+ logger.warn("Topic {} is not present or ambiguous {}", configSinkTopic.getTopicName(), sinks);
return false;
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java
index 4e0b4bf7..858e8495 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/ControllerSupport.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,6 @@ package org.onap.policy.drools.lifecycle;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
import java.nio.file.Paths;
import java.util.List;
import java.util.Properties;
@@ -39,6 +39,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Controller Test Support.
*/
+@Getter
public class ControllerSupport {
protected static final String JUNIT_KMODULE_DRL_PATH = "src/test/resources/lifecycle.drl";
@@ -52,7 +53,6 @@ public class ControllerSupport {
protected static final String SESSION_NAME = "junits";
- @Getter
private final String name;
public ControllerSupport(@NonNull String name) {
@@ -73,21 +73,26 @@ public class ControllerSupport {
ReleaseId coordinates = installArtifact();
+ Properties controllerProps = getControllerProps(coordinates);
+
+ return PolicyControllerConstants.getFactory().build(name, controllerProps);
+ }
+
+ private Properties getControllerProps(ReleaseId coordinates) {
Properties controllerProps = new Properties();
controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, name);
controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_POLICY_TYPES, getPolicyType());
controllerProps.put(DroolsPropertyConstants.RULES_GROUPID, coordinates.getGroupId());
controllerProps.put(DroolsPropertyConstants.RULES_ARTIFACTID, coordinates.getArtifactId());
controllerProps.put(DroolsPropertyConstants.RULES_VERSION, coordinates.getVersion());
-
- return PolicyControllerConstants.getFactory().build(name, controllerProps);
+ return controllerProps;
}
/**
* Install a maven artifact.
*/
public static ReleaseId installArtifact(File kmodule, File pom,
- String drlKjarPath, List<File> drls) throws IOException {
+ String drlKjarPath, List<File> drls) throws IOException {
return KieUtils.installArtifact(kmodule, pom, drlKjarPath, drls);
}
@@ -96,9 +101,9 @@ public class ControllerSupport {
*/
public ReleaseId installArtifact() throws IOException {
return ControllerSupport.installArtifact(Paths.get(JUNIT_KMODULE_PATH).toFile(),
- Paths.get(JUNIT_KMODULE_POM_PATH).toFile(),
- JUNIT_KJAR_DRL_PATH,
- List.of(Paths.get(JUNIT_KMODULE_DRL_PATH).toFile()));
+ Paths.get(JUNIT_KMODULE_POM_PATH).toFile(),
+ JUNIT_KJAR_DRL_PATH,
+ List.of(Paths.get(JUNIT_KMODULE_DRL_PATH).toFile()));
}
/**
@@ -146,7 +151,7 @@ public class ControllerSupport {
* Reassign static field.
*/
public static <T, E> void setStaticField(Class<T> clazz, String fieldName, E newValue)
- throws NoSuchFieldException, IllegalAccessException {
+ throws NoSuchFieldException, IllegalAccessException {
unsetFinalStaticAccess(clazz, fieldName).set(null, newValue);
}
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
index e5fc13a8..cae3bb3b 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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 +21,7 @@
package org.onap.policy.drools.lifecycle;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.nio.file.Files;
@@ -32,9 +32,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.logging.LoggerUtils;
@@ -98,7 +98,7 @@ public class LifecycleFsmTest {
/**
* Test initialization.
*/
- @Before
+ @BeforeEach
public void beforeTest() throws CoderException, IOException {
LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "INFO");
LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
@@ -130,7 +130,7 @@ public class LifecycleFsmTest {
resetExecutionStats();
}
- @AfterClass
+ @AfterAll
public static void afterClass() {
resetExecutionStats();
}
@@ -141,14 +141,8 @@ public class LifecycleFsmTest {
PolicyEngineConstants.getManager().getStats().getGroupStat().setPolicyExecutedSuccessCount(0L);
}
- private void setExecutionCounts() {
- PolicyEngineConstants.getManager().getStats().getGroupStat().setPolicyExecutedCount(7L);
- PolicyEngineConstants.getManager().getStats().getGroupStat().setPolicyExecutedFailCount(2L);
- PolicyEngineConstants.getManager().getStats().getGroupStat().setPolicyExecutedSuccessCount(5L);
- }
-
@Test
- public void testGetDeployableActions() {
+ void testGetDeployableActions() {
List<ToscaPolicy> expectedDeployOrder =
List.of(controllerPolicy, controller2Policy, artifact2Policy, artifactPolicy,
op2Policy, opPolicy, unvalPolicy, valPolicy);
@@ -165,7 +159,7 @@ public class LifecycleFsmTest {
}
@Test
- public void testGetUndeployableActions() {
+ void testGetUndeployableActions() {
deployAllPolicies();
List<ToscaPolicy> expectedUndeployOrder =
List.of(opPolicy, op2Policy, unvalPolicy, valPolicy, artifactPolicy,
@@ -177,7 +171,7 @@ public class LifecycleFsmTest {
}
@Test
- public void testGetNativeArtifactPolicies() {
+ void testGetNativeArtifactPolicies() {
deployAllPolicies();
Map<String, List<ToscaPolicy>> deployedPolicies = fsm.groupPoliciesByPolicyType(fsm.getActivePolicies());
@@ -186,24 +180,24 @@ public class LifecycleFsmTest {
}
@Test
- public void testSetGroup() {
+ void testSetGroup() {
fsm.setGroup("bar");
assertEquals("bar", fsm.getGroup());
}
@Test
- public void testSetSubGroup() {
+ void testSetSubGroup() {
fsm.setSubGroup("foo");
assertEquals("foo", fsm.getSubGroup());
}
@Test
- public void testPdpType() {
+ void testPdpType() {
assertEquals("foo", fsm.getPdpType());
}
@Test
- public void testMergePolicies() {
+ void testMergePolicies() {
assertEquals(List.of(), fsm.getActivePolicies());
assertEquals(List.of(), fsm.mergePolicies(List.of(), List.of()));
@@ -229,7 +223,7 @@ public class LifecycleFsmTest {
}
@Test
- public void testGetPolicyIdsMessages() {
+ void testGetPolicyIdsMessages() {
assertEquals("[operational.modifyconfig 1.0.0, example.controller 1.0.0]",
fsm.getPolicyIds(List.of(opPolicy, controllerPolicy)).toString());
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
index 0ab9f888..8f0c19db 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleFsmUpdateTest.java
@@ -22,9 +22,9 @@
package org.onap.policy.drools.lifecycle;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+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 com.google.common.base.Strings;
import java.io.IOException;
@@ -37,10 +37,10 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ScheduledExecutorService;
import java.util.stream.Collectors;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+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.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -116,7 +116,7 @@ public class LifecycleFsmUpdateTest {
/**
* Set up.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() throws IOException {
LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "INFO");
LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
@@ -149,7 +149,7 @@ public class LifecycleFsmUpdateTest {
/**
* Tear Down.
*/
- @AfterClass
+ @AfterAll
public static void tearDown() throws NoSuchFieldException, IllegalAccessException {
PolicyControllerConstants.getFactory().destroy();
@@ -170,7 +170,7 @@ public class LifecycleFsmUpdateTest {
/**
* Test initialization.
*/
- @Before
+ @BeforeEach
public void init() throws CoderException, IOException, NoSuchFieldException, IllegalAccessException {
fsm = new LifecycleFsm() {
@Override
@@ -208,7 +208,7 @@ public class LifecycleFsmUpdateTest {
}
@Test
- public void testUpdate() throws CoderException {
+ void testUpdate() throws CoderException {
verifyInitState();
// native controller policy - deploy
@@ -369,8 +369,8 @@ public class LifecycleFsmUpdateTest {
protected void verifyExists(boolean exists, String controller, List<ToscaPolicy> policies) {
assertTrue(PolicyControllerConstants.getFactory().get(controller).getDrools().isBrained());
for (ToscaPolicy policy : policies) {
- assertEquals("ID: " + controller + ":" + policy.getIdentifier(), exists,
- PolicyControllerConstants.getFactory().get(controller).getDrools().exists(policy));
+ assertEquals(exists, PolicyControllerConstants.getFactory().get(controller).getDrools().exists(policy),
+ "ID: " + controller + ":" + policy.getIdentifier());
}
}
@@ -383,10 +383,10 @@ public class LifecycleFsmUpdateTest {
// verify that each policy is tracked in the active lists
for (ToscaPolicy policy : testPolicies) {
- assertTrue(policy.getIdentifier().toString(), fsm.getActivePolicies().contains(policy));
+ assertTrue(fsm.getActivePolicies().contains(policy), policy.getIdentifier().toString());
if (!nativeDisables.contains(policy.getIdentifier())) {
- assertTrue(policy.getIdentifier().toString(),
- fsm.getPolicyTypesMap().containsKey(policy.getTypeIdentifier()));
+ assertTrue(fsm.getPolicyTypesMap().containsKey(policy.getTypeIdentifier()),
+ policy.getIdentifier().toString());
}
}
assertEquals(testPolicies.size(), fsm.getActivePolicies().size());
@@ -451,17 +451,19 @@ public class LifecycleFsmUpdateTest {
String artifactControllerName = artifactPolicy.getProperties().getController().getName();
// brained controller check
- assertTrue(artifactControllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory().get(artifactControllerName).getDrools().isBrained());
+ assertTrue(PolicyControllerConstants.getFactory().get(artifactControllerName).getDrools().isBrained(),
+ artifactControllerName + ":" + testPolicy.getIdentifier());
- // non native tosca policy as a fact in drools
+ // non-native tosca policy as a fact in drools
if (PolicyControllerConstants.getFactory().get(artifactControllerName).getPolicyTypes()
.contains(testPolicy.getTypeIdentifier())) {
- assertTrue(artifactControllerName + ":" + testPolicy.getIdentifier(), PolicyControllerConstants
- .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
+ assertTrue(PolicyControllerConstants.getFactory()
+ .get(artifactControllerName).getDrools().exists(testPolicy),
+ artifactControllerName + ":" + testPolicy.getIdentifier());
} else {
- assertFalse(artifactControllerName + ":" + testPolicy.getIdentifier(), PolicyControllerConstants
- .getFactory().get(artifactControllerName).getDrools().exists(testPolicy));
+ assertFalse(PolicyControllerConstants.getFactory()
+ .get(artifactControllerName).getDrools().exists(testPolicy),
+ artifactControllerName + ":" + testPolicy.getIdentifier());
}
// there should always be a controller policy for each artifact policy
@@ -489,10 +491,10 @@ public class LifecycleFsmUpdateTest {
getNativeArtifactPolicies(nativeArtifactPolicies, controllerName);
if (candidateNativeArtifactPolicies.size() == 1) {
- assertTrue(controllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().isBrained());
- assertTrue(controllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory().get(controllerName).getDrools().exists(testPolicy));
+ assertTrue(PolicyControllerConstants.getFactory().get(controllerName).getDrools().isBrained(),
+ controllerName + ":" + testPolicy.getIdentifier());
+ assertTrue(PolicyControllerConstants.getFactory().get(controllerName).getDrools().exists(testPolicy),
+ controllerName + ":" + testPolicy.getIdentifier());
// verify that the other brained controllers don't have this non-native policy
@@ -502,10 +504,9 @@ public class LifecycleFsmUpdateTest {
assertTrue(PolicyControllerConstants.getFactory()
.get(nativePolicy.getProperties().getController().getName())
.getDrools().isBrained());
- assertFalse(controllerName + ":" + testPolicy.getIdentifier(),
- PolicyControllerConstants.getFactory()
- .get(nativePolicy.getProperties().getController().getName())
- .getDrools().exists(testPolicy));
+ assertFalse(PolicyControllerConstants.getFactory()
+ .get(nativePolicy.getProperties().getController().getName()).getDrools().exists(testPolicy),
+ controllerName + ":" + testPolicy.getIdentifier());
}
// @formatter:on
@@ -514,8 +515,8 @@ public class LifecycleFsmUpdateTest {
// at this point the only valid possibility is that there is no native artifact policies
- assertTrue("There is more than 1 native artifact policy for " + controllerName,
- candidateNativeArtifactPolicies.isEmpty());
+ assertTrue(candidateNativeArtifactPolicies.isEmpty(),
+ "There is more than 1 native artifact policy for " + controllerName);
}
protected List<NativeArtifactPolicy> getNativeArtifactPoliciesBut(List<ToscaPolicy> nativePolicies,
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
index 653a4694..2ed368d4 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActivePoliciesTest.java
@@ -22,20 +22,20 @@
package org.onap.policy.drools.lifecycle;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
+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.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.coder.CoderException;
@@ -51,7 +51,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Lifecycle State Active Test.
*/
-public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest {
+class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest {
private static final String EXAMPLE_NATIVE_DROOLS_CONTROLLER_POLICY_NAME = "example.controller";
private static final String EXAMPLE_NATIVE_DROOLS_ARTIFACT_POLICY_NAME = "example.artifact";
@@ -67,7 +67,7 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest
/**
* Start tests in the Active state.
*/
- @Before
+ @BeforeEach
public void startActive() throws CoderException {
fsm = makeFsmWithPseudoTime();
@@ -86,7 +86,7 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest
}
@Test
- public void testMandatoryPolicyTypes() {
+ void testMandatoryPolicyTypes() {
assertEquals(Set.of("onap.policies.native.drools.Artifact", "onap.policies.native.drools.Controller"),
fsm.getMandatoryPolicyTypes());
assertEquals(fsm.getMandatoryPolicyTypes(), fsm.getCurrentPolicyTypes());
@@ -102,7 +102,7 @@ public class LifecycleStateActivePoliciesTest extends LifecycleStateRunningTest
}
@Test
- public void testUpdatePolicies() throws IOException, CoderException {
+ void testUpdatePolicies() throws IOException, CoderException {
assertEquals(2, fsm.policyTypesMap.size());
assertNotNull(fsm.getPolicyTypesMap().get(
new ToscaConceptIdentifier("onap.policies.native.drools.Controller", "1.0.0")));
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
index d00c8a41..86e6ce3c 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -22,11 +22,11 @@
package org.onap.policy.drools.lifecycle;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -36,8 +36,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.drools.system.PolicyEngineConstants;
@@ -51,7 +51,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Lifecycle State Active Test.
*/
-public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
+class LifecycleStateActiveTest extends LifecycleStateRunningTest {
private static final String POLICY_COMPLIANT_VCPE_BAD_INTEGER_JSON =
"src/test/resources/tosca-policy-compliant-vcpe-bad-integer.json";
@@ -59,7 +59,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
/**
* Start tests in the Active state.
*/
- @Before
+ @BeforeEach
public void startActive() throws CoderException {
fsm = makeFsmWithPseudoTime();
@@ -83,13 +83,13 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
}
@Test
- public void constructor() {
+ void constructor() {
assertThatIllegalArgumentException().isThrownBy(() -> new LifecycleStateActive(null));
fsm.shutdown();
}
@Test
- public void testStart() {
+ void testStart() {
assertActive();
assertFalse(fsm.start());
assertActive();
@@ -106,7 +106,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
}
@Test
- public void testStop() {
+ void testStop() {
assertTrue(fsm.stop());
assertBasicTerminated();
@@ -121,7 +121,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
fsm.shutdown();
assertBasicTerminated();
@@ -131,7 +131,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
}
@Test
- public void testStatus() {
+ void testStatus() {
waitUntil(fsm.getStatusTimerSeconds() + 1, TimeUnit.SECONDS, isStatus(PdpState.ACTIVE));
int preCount = fsm.client.getSink().getRecentEvents().length;
@@ -147,7 +147,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
}
@Test
- public void testStateChange() throws CoderException {
+ void testStateChange() throws CoderException {
assertActive();
/* no name and mismatching group info */
@@ -184,7 +184,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
}
@Test
- public void testUpdate() throws IOException, CoderException {
+ void testUpdate() throws IOException, CoderException {
// TODO: extract repeated similar assertion blocks into their own helper methods
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
index d6c94996..01fb90b5 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -22,17 +22,17 @@
package org.onap.policy.drools.lifecycle;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.drools.system.PolicyEngineConstants;
@@ -48,12 +48,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Lifecycle State Passive Tests.
*/
-public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
+class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
/**
* Start tests in the Passive state.
*/
- @Before
+ @BeforeEach
public void startPassive() {
/* start every test in passive mode */
fsm = makeFsmWithPseudoTime();
@@ -62,13 +62,13 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
}
@Test
- public void constructor() {
+ void constructor() {
assertThatIllegalArgumentException().isThrownBy(() -> new LifecycleStatePassive(null));
fsm.shutdown();
}
@Test
- public void testController() {
+ void testController() {
fsm.start(controllerSupport.getController());
assertSame(controllerSupport.getController(),
((PolicyTypeDroolsController) fsm.getController(
@@ -84,7 +84,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
}
@Test
- public void testStart() {
+ void testStart() {
assertEquals(0, fsm.client.getSink().getRecentEvents().length);
assertFalse(fsm.start());
assertBasicPassive();
@@ -93,7 +93,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
}
@Test
- public void stop() {
+ void stop() {
simpleStop();
assertBasicTerminated();
}
@@ -109,7 +109,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
}
@Test
- public void testShutdown() throws Exception {
+ void testShutdown() throws Exception {
simpleStop();
fsm.shutdown();
@@ -117,28 +117,28 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
}
@Test
- public void testStatus() {
+ void testStatus() {
assertTrue(fsm.client.getSink().isAlive());
assertTrue(fsm.status());
assertSame(1, fsm.client.getSink().getRecentEvents().length);
fsm.start(controllerSupport.getController());
- status(PdpState.PASSIVE, 1);
+ status();
fsm.stop(controllerSupport.getController());
fsm.shutdown();
}
- private void status(PdpState state, int initial) {
- waitUntil(5, TimeUnit.SECONDS, isStatus(state, initial));
- waitUntil(fsm.statusTimerSeconds + 2, TimeUnit.SECONDS, isStatus(state, initial + 1));
- waitUntil(fsm.statusTimerSeconds + 2, TimeUnit.SECONDS, isStatus(state, initial + 2));
+ private void status() {
+ waitUntil(5, TimeUnit.SECONDS, isStatus(PdpState.PASSIVE, 1));
+ waitUntil(fsm.statusTimerSeconds + 2, TimeUnit.SECONDS, isStatus(PdpState.PASSIVE, 1 + 1));
+ waitUntil(fsm.statusTimerSeconds + 2, TimeUnit.SECONDS, isStatus(PdpState.PASSIVE, 1 + 2));
assertTrue(fsm.status());
- waitUntil(200, TimeUnit.MILLISECONDS, isStatus(state, initial + 3));
+ waitUntil(200, TimeUnit.MILLISECONDS, isStatus(PdpState.PASSIVE, 1 + 3));
}
@Test
- public void testUpdate() throws CoderException {
+ void testUpdate() throws CoderException {
controllerSupport.getController().getDrools().delete(ToscaPolicy.class);
assertEquals(0, controllerSupport.getController().getDrools().factCount("junits"));
@@ -253,7 +253,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
}
@Test
- public void testStateChange() throws CoderException {
+ void testStateChange() throws CoderException {
/* no name */
PdpStateChange change = new PdpStateChange();
change.setPdpGroup("A");
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
index 7b210db8..c9d12165 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2022 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.
@@ -26,8 +27,8 @@ import java.nio.file.Paths;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -54,7 +55,7 @@ public abstract class LifecycleStateRunningTest {
/**
* Set up.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() throws IOException {
LoggerUtils.setLevel(LoggerUtils.ROOT_LOGGER, "INFO");
LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
@@ -66,7 +67,7 @@ public abstract class LifecycleStateRunningTest {
/**
* Tear Down.
*/
- @AfterClass
+ @AfterAll
public static void tearDown() {
controllerSupport.destroyController();
NoopTopicFactories.getSourceFactory().destroy();
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateSafeTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateSafeTest.java
index 81ce85f1..4c292b42 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateSafeTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateSafeTest.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,15 +21,15 @@
package org.onap.policy.drools.lifecycle;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.models.pdp.enums.PdpState;
/**
* TEST State Junits.
*/
-public class LifecycleStateSafeTest extends LifecycleStateUnsupportedTest {
+class LifecycleStateSafeTest extends LifecycleStateUnsupportedTest {
public LifecycleStateSafeTest() {
super(new LifecycleStateSafe(new LifecycleFsm()));
@@ -46,7 +47,7 @@ public class LifecycleStateSafeTest extends LifecycleStateUnsupportedTest {
}
@Test
- public void state() {
+ void state() {
assertEquals(PdpState.SAFE, state.state());
}
} \ No newline at end of file
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
index 23643302..bd7561fd 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTerminatedTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -22,17 +22,17 @@
package org.onap.policy.drools.lifecycle;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyEngineConstants;
@@ -46,19 +46,19 @@ import org.onap.policy.models.pdp.enums.PdpState;
public class LifecycleStateTerminatedTest {
private LifecycleFsm fsm = new LifecycleFsm();
- @BeforeClass
+ @BeforeAll
public static void setUp() {
SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
SystemPersistenceConstants.getManager().setConfigurationDir(null);
}
@Test
- public void testConstructor() {
+ void testConstructor() {
assertThatIllegalArgumentException().isThrownBy(() -> new LifecycleStateTerminated(null));
LifecycleState state = new LifecycleStateTerminated(new LifecycleFsm());
@@ -72,7 +72,7 @@ public class LifecycleStateTerminatedTest {
}
@Test
- public void testStop() {
+ void testStop() {
assertEquals(PdpState.TERMINATED, fsm.state.state());
assertFalse(fsm.isAlive());
@@ -90,7 +90,7 @@ public class LifecycleStateTerminatedTest {
}
@Test
- public void testBounce() {
+ void testBounce() {
assertBasicTerminated();
simpleStart();
simpleStop();
@@ -101,13 +101,13 @@ public class LifecycleStateTerminatedTest {
}
@Test
- public void doubleBounce() {
+ void doubleBounce() {
testBounce();
testBounce();
}
@Test
- public void testDoubleStartBounce() {
+ void testDoubleStartBounce() {
simpleStart();
assertFalse(fsm.start());
assertBasicPassive();
@@ -115,7 +115,7 @@ public class LifecycleStateTerminatedTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
assertBasicTerminated();
fsm.shutdown();
assertBasicTerminated();
@@ -124,20 +124,20 @@ public class LifecycleStateTerminatedTest {
}
@Test
- public void testStatus() {
+ void testStatus() {
assertBasicTerminated();
assertFalse(fsm.status());
assertBasicTerminated();
}
@Test
- public void changeState() {
+ void changeState() {
assertFalse(fsm.state.transitionToState(new LifecycleStateTerminated(fsm)));
assertEquals(PdpState.TERMINATED, fsm.state.state());
}
@Test
- public void testUpdate() {
+ void testUpdate() {
PdpUpdate update = new PdpUpdate();
update.setName(PolicyEngineConstants.getManager().getPdpName());
update.setPdpGroup("A");
@@ -152,7 +152,7 @@ public class LifecycleStateTerminatedTest {
}
@Test
- public void testStateChange() {
+ void testStateChange() {
PdpStateChange change = new PdpStateChange();
change.setPdpGroup("A");
change.setPdpSubgroup("a");
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTestTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTestTest.java
index c086dfb4..89aae201 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTestTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateTestTest.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,15 +21,15 @@
package org.onap.policy.drools.lifecycle;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.models.pdp.enums.PdpState;
/**
* TEST State Junits.
*/
-public class LifecycleStateTestTest extends LifecycleStateUnsupportedTest {
+class LifecycleStateTestTest extends LifecycleStateUnsupportedTest {
public LifecycleStateTestTest() {
super(new LifecycleStateTest(new LifecycleFsm()));
@@ -46,7 +47,7 @@ public class LifecycleStateTestTest extends LifecycleStateUnsupportedTest {
}
@Test
- public void state() {
+ void state() {
assertEquals(PdpState.TEST, state.state());
}
} \ No newline at end of file
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java
index 400aa169..b5ec6aca 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupportedTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -23,9 +24,9 @@ package org.onap.policy.drools.lifecycle;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
@@ -37,12 +38,12 @@ public abstract class LifecycleStateUnsupportedTest {
protected final LifecycleState state;
- @BeforeClass
+ @BeforeAll
public static void setUp() {
SystemPersistenceConstants.getManager().setConfigurationDir("src/test/resources");
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
SystemPersistenceConstants.getManager().setConfigurationDir(null);
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
index a3b8d8c9..999860a0 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020-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.
@@ -20,13 +21,13 @@
package org.onap.policy.drools.lifecycle;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.drools.domain.models.operational.OperationalPolicy;
import org.onap.policy.drools.system.PolicyControllerConstants;
@@ -35,7 +36,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Drools Controller Policy Test.
*/
-public class PolicyTypeDroolsControllerTest extends LifecycleStateRunningTest {
+class PolicyTypeDroolsControllerTest extends LifecycleStateRunningTest {
// Operational vCPE Policies
private static final String OP_POLICY_NAME_VCPE = "operational.restart";
@@ -48,7 +49,7 @@ public class PolicyTypeDroolsControllerTest extends LifecycleStateRunningTest {
/**
* Test initialization.
*/
- @Before
+ @BeforeEach
public void init() throws CoderException {
fsm = makeFsmWithPseudoTime();
policy = getExamplesPolicy(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, OP_POLICY_NAME_VCPE);
@@ -71,7 +72,7 @@ public class PolicyTypeDroolsControllerTest extends LifecycleStateRunningTest {
}
@Test
- public void testDeployUndeploy() {
+ void testDeployUndeploy() {
/* non-existing controller */
assertFalse(controller.undeploy(policy));
assertFalse(controller.deploy(policy));
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
index 05ed41a4..26e6bbe4 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -22,14 +22,15 @@
package org.onap.policy.drools.lifecycle;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.drools.controller.DroolsControllerConstants;
import org.onap.policy.drools.controller.internal.MavenDroolsController;
@@ -42,7 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Rules Controller Test.
*/
-public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunningTest {
+class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunningTest {
// Native Drools Policy
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_NAME = "example.artifact";
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_JSON =
@@ -55,7 +56,7 @@ public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunnin
/**
* Test Set initialization.
*/
- @Before
+ @BeforeEach
public void init() throws IOException, CoderException {
fsm = makeFsmWithPseudoTime();
policy = getPolicyFromFile(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
@@ -88,7 +89,7 @@ public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunnin
}
@Test
- public void testUndeployDeploy() {
+ void testUndeployDeploy() {
undeploy();
deploy();
@@ -128,7 +129,7 @@ public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunnin
nativePolicy.getProperties()
.getRulesArtifact()
.getArtifactId()));
- assertTrue(controllerSupport.getController().getDrools() instanceof NullDroolsController);
+ assertInstanceOf(NullDroolsController.class, controllerSupport.getController().getDrools());
assertEquals(DroolsControllerConstants.NO_GROUP_ID, controllerSupport.getController().getDrools().getGroupId());
assertEquals(DroolsControllerConstants.NO_ARTIFACT_ID,
controllerSupport.getController().getDrools().getArtifactId());
@@ -144,7 +145,7 @@ public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunnin
PolicyControllerConstants.getFactory().get(
nativePolicy.getProperties().getRulesArtifact().getGroupId(),
nativePolicy.getProperties().getRulesArtifact().getArtifactId()));
- assertTrue(controllerSupport.getController().getDrools() instanceof MavenDroolsController);
+ assertInstanceOf(MavenDroolsController.class, controllerSupport.getController().getDrools());
}
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
index 95f0ff55..a964d134 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
@@ -22,16 +22,16 @@
package org.onap.policy.drools.lifecycle;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Properties;
-import org.junit.Before;
-import org.junit.Test;
+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.properties.PolicyEndPointProperties;
import org.onap.policy.common.utils.coder.CoderException;
@@ -43,7 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Native Controller Policy Test.
*/
-public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningTest {
+class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningTest {
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_NAME = "example.controller";
private static final String EXAMPLE_NATIVE_DROOLS_POLICY_JSON =
"src/test/resources/tosca-policy-native-controller-example.json";
@@ -51,13 +51,13 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
/**
* Test initialization.
*/
- @Before
+ @BeforeEach
public void init() {
fsm = makeFsmWithPseudoTime();
}
@Test
- public void testDeployUndeploy() throws IOException, CoderException {
+ void testDeployUndeploy() throws IOException, CoderException {
fsm = makeFsmWithPseudoTime();
assertTrue(controllerSupport.getController().getDrools().isBrained());
@@ -91,7 +91,7 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
}
@Test
- public void testControllerProperties() throws CoderException {
+ void testControllerProperties() throws CoderException {
Properties noopTopicProperties = new Properties();
String noopSources = String.join(",", TestConstants.DCAE_TOPIC, TestConstants.APPC_CL_TOPIC,
TestConstants.APPC_LCM_WRITE_TOPIC, TestConstants.SDNR_CL_RSP_TOPIC);
@@ -139,12 +139,12 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
assertEquals("org.onap.policy.appc.util.Serialization,gsonPretty",
properties.getProperty("noop.source.topics.appc-cl.events.custom.gson"));
- assertEquals("org.onap.policy.appclcm.AppcLcmDmaapWrapper",
+ assertEquals("org.onap.policy.appclcm.AppcLcmMessageWrapper",
properties.getProperty("noop.source.topics.appc-lcm-write.events"));
assertEquals("[?($.type == 'response')]",
properties
.getProperty("noop.source.topics.appc-lcm-write.events."
- + "org.onap.policy.appclcm.AppcLcmDmaapWrapper.filter"));
+ + "org.onap.policy.appclcm.AppcLcmMessageWrapper.filter"));
assertEquals("org.onap.policy.appclcm.util.Serialization,gson",
properties.getProperty("noop.source.topics.appc-lcm-write.events.custom.gson"));
@@ -161,7 +161,7 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
assertEquals("org.onap.policy.appc.util.Serialization,gsonPretty",
properties.getProperty("noop.sink.topics.appc-cl.events.custom.gson"));
- assertEquals("org.onap.policy.appclcm.AppcLcmDmaapWrapper",
+ assertEquals("org.onap.policy.appclcm.AppcLcmMessageWrapper",
properties.getProperty("noop.sink.topics.appc-lcm-read.events"));
assertEquals("org.onap.policy.appclcm.util.Serialization,gson",
properties.getProperty("noop.sink.topics.appc-lcm-read.events.custom.gson"));
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
index 37c1e8d8..23d3e24a 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java
@@ -21,9 +21,9 @@ package org.onap.policy.drools.server.restful;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+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 jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Response;
@@ -35,9 +35,9 @@ import java.util.Collections;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+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.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
@@ -107,7 +107,7 @@ public class RestLifecycleManagerTest {
/**
* Set up.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
@@ -158,7 +158,7 @@ public class RestLifecycleManagerTest {
/**
* Tear down.
*/
- @After
+ @AfterEach
public void tearDown() {
fsm.shutdown();
@@ -174,7 +174,7 @@ public class RestLifecycleManagerTest {
}
@Test
- public void testMultiPolicyFlow() throws IOException, CoderException {
+ void testMultiPolicyFlow() throws IOException, CoderException {
/* group assignments */
group();
@@ -204,7 +204,7 @@ public class RestLifecycleManagerTest {
assertTrue(fsm.start());
- booleanPut("state/ACTIVE", "", Status.OK.getStatusCode(), Boolean.TRUE);
+ booleanPut(Status.OK.getStatusCode());
assertEquals(PdpState.ACTIVE,
HttpClient.getBody(get("state", Status.OK.getStatusCode()), PdpState.class));
@@ -270,7 +270,7 @@ public class RestLifecycleManagerTest {
ToscaPolicy toscaPolicyValError =
getPolicyFromFile(EXAMPLE_OTHER_VAL_ERROR_POLICY_JSON, EXAMPLE_OTHER_VAL_ERROR_POLICY_NAME);
assertThat(
- listPost("policies/operations/validation", toString(toscaPolicyValError),
+ listPost(toString(toscaPolicyValError),
Status.NOT_ACCEPTABLE.getStatusCode())).isNotEmpty();
booleanPost("policies", toString(toscaPolicyValError),
@@ -338,7 +338,7 @@ public class RestLifecycleManagerTest {
assertThatIllegalArgumentException().isThrownBy(() -> PolicyControllerConstants.getFactory().get("lifecycle"));
opPolicy.getMetadata().remove("policy-id");
assertThat(
- listPost("policies/operations/validation", toString(opPolicy),
+ listPost(toString(opPolicy),
Status.NOT_ACCEPTABLE.getStatusCode())).isNotEmpty();
metrics();
@@ -346,7 +346,7 @@ public class RestLifecycleManagerTest {
private void testNotNativePolicy(ToscaPolicy toscaPolicy) throws CoderException {
assertThat(
- listPost("policies/operations/validation", toString(toscaPolicy),
+ listPost(toString(toscaPolicy),
Status.OK.getStatusCode())).isEmpty();
booleanPost("policies", toString(toscaPolicy), Status.OK.getStatusCode(), Boolean.TRUE);
@@ -384,13 +384,13 @@ public class RestLifecycleManagerTest {
assertEquals(bool, HttpClient.getBody(response, Boolean.class));
}
- private void booleanPut(String contextPath, String body, int statusCode, Boolean bool) {
- Response response = client.put(contextPath, Entity.json(body), Collections.emptyMap());
- booleanResponse(response, statusCode, bool);
+ private void booleanPut(int statusCode) {
+ Response response = client.put("state/ACTIVE", Entity.json(""), Collections.emptyMap());
+ booleanResponse(response, statusCode, Boolean.TRUE);
}
- private List<?> listPost(String contextPath, String body, int statusCode) {
- Response response = client.post(contextPath, Entity.json(body), Collections.emptyMap());
+ private List<?> listPost(String body, int statusCode) {
+ Response response = client.post("policies/operations/validation", Entity.json(body), Collections.emptyMap());
assertEquals(statusCode, response.getStatus());
return HttpClient.getBody(response, List.class);
}
diff --git a/feature-lifecycle/src/test/resources/echo.kmodule b/feature-lifecycle/src/test/resources/echo.kmodule
index 98d80a90..c0cb5078 100644
--- a/feature-lifecycle/src/test/resources/echo.kmodule
+++ b/feature-lifecycle/src/test/resources/echo.kmodule
@@ -4,6 +4,7 @@
ONAP
================================================================================
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.
@@ -19,7 +20,7 @@
============LICENSE_END=========================================================
-->
-<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="onap.policies.typeA" default="false" equalsBehavior="equality"/>
<kbase name="onap.policies.type1.type2" includes="onap.policies.typeA">
<ksession name="echo"/>
diff --git a/feature-lifecycle/src/test/resources/lifecycle.kmodule b/feature-lifecycle/src/test/resources/lifecycle.kmodule
index 9ea1670a..9e77501f 100644
--- a/feature-lifecycle/src/test/resources/lifecycle.kmodule
+++ b/feature-lifecycle/src/test/resources/lifecycle.kmodule
@@ -4,6 +4,7 @@
ONAP
================================================================================
Copyright (C) 2019-2020, 2022 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.
@@ -19,7 +20,7 @@
============LICENSE_END=========================================================
-->
-<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="onap.policies.typeA" default="false" equalsBehavior="equality"/>
<kbase name="onap.policies.controlloop.operational.common.Drools"
includes="onap.policies.typeA" default="false" equalsBehavior="equality"/>
diff --git a/feature-lifecycle/src/test/resources/tosca-policy-native-controller-example.json b/feature-lifecycle/src/test/resources/tosca-policy-native-controller-example.json
index 642ecc0e..65279859 100644
--- a/feature-lifecycle/src/test/resources/tosca-policy-native-controller-example.json
+++ b/feature-lifecycle/src/test/resources/tosca-policy-native-controller-example.json
@@ -15,7 +15,7 @@
"controllerName": "lifecycle",
"sourceTopics": [
{
- "topicName": "DCAE_TOPIC",
+ "topicName": "dcae_topic",
"events": [
{
"eventClass": "java.util.HashMap",
@@ -30,7 +30,7 @@
],
"sinkTopics": [
{
- "topicName": "APPC-CL",
+ "topicName": "appc-cl",
"events": [
{
"eventClass": "java.util.HashMap",
diff --git a/feature-no-locking/src/test/java/org/onap/policy/no/locking/NoLockManagerTest.java b/feature-no-locking/src/test/java/org/onap/policy/no/locking/NoLockManagerTest.java
index 376fc04e..5b5e0964 100644
--- a/feature-no-locking/src/test/java/org/onap/policy/no/locking/NoLockManagerTest.java
+++ b/feature-no-locking/src/test/java/org/onap/policy/no/locking/NoLockManagerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -21,17 +22,18 @@
package org.onap.policy.no.locking;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import java.util.List;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.core.lock.AlwaysSuccessLock;
import org.onap.policy.drools.core.lock.Lock;
import org.onap.policy.drools.core.lock.LockCallback;
@@ -46,7 +48,7 @@ public class NoLockManagerTest {
/**
* Set up Junits.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() {
List<PolicyEngineFeatureApi> engineServices = PolicyEngineFeatureApiConstants.getProviders().getList();
assertThat(engineServices).hasSize(1);
@@ -55,50 +57,50 @@ public class NoLockManagerTest {
}
@Test
- public void testLock() {
+ void testLock() {
assertTrue(nlm.lock());
}
@Test
- public void testUnlock() {
+ void testUnlock() {
assertTrue(nlm.unlock());
}
@Test
- public void testIsLocked() {
+ void testIsLocked() {
assertFalse(nlm.isLocked());
}
@Test
- public void testStart() {
+ void testStart() {
assertTrue(nlm.start());
}
@Test
- public void testStop() {
+ void testStop() {
assertTrue(nlm.stop());
}
@Test
- public void testIsAlive() {
+ void testIsAlive() {
assertTrue(nlm.isAlive());
}
@Test
- public void testGetSeqNo() {
+ void testGetSeqNo() {
assertEquals(NoLockManager.SEQNO, nlm.getSequenceNumber());
}
@Test
- public void testBeforeCreateLockManager() {
+ void testBeforeCreateLockManager() {
assertEquals(nlm, nlm.beforeCreateLockManager(null, null));
}
@Test
- public void testCreateLock() {
+ void testCreateLock() {
Lock lock = nlm.createLock("x", "y", 1, callback, false);
assertTrue(lock.isActive());
- assertTrue(lock instanceof AlwaysSuccessLock);
+ assertInstanceOf(AlwaysSuccessLock.class, lock);
verify(callback).lockAvailable(lock);
verify(callback, never()).lockUnavailable(any());
}
diff --git a/feature-pooling-dmaap/pom.xml b/feature-pooling-messages/pom.xml
index 5252c445..756abcab 100644
--- a/feature-pooling-dmaap/pom.xml
+++ b/feature-pooling-messages/pom.xml
@@ -3,6 +3,7 @@
ONAP Policy Engine - Drools PDP
================================================================================
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.
@@ -29,14 +30,15 @@
<version>2.1.1-SNAPSHOT</version>
</parent>
- <artifactId>feature-pooling-dmaap</artifactId>
+ <artifactId>feature-pooling-messages</artifactId>
- <name>feature-pooling-dmaap</name>
+ <name>feature-pooling-messages</name>
<description>Endpoints</description>
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
@@ -85,21 +87,6 @@
<dependencies>
<dependency>
- <groupId>com.att.nsa</groupId>
- <artifactId>cambriaClient</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.att.nsa</groupId>
- <artifactId>saClientLibrary</artifactId>
- </exclusion>
- </exclusions>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>provided</scope>
diff --git a/feature-pooling-dmaap/src/assembly/assemble_zip.xml b/feature-pooling-messages/src/assembly/assemble_zip.xml
index 9908a2b9..67424116 100644
--- a/feature-pooling-dmaap/src/assembly/assemble_zip.xml
+++ b/feature-pooling-messages/src/assembly/assemble_zip.xml
@@ -1,6 +1,6 @@
<!--
============LICENSE_START=======================================================
- feature-pooling-dmaap
+ feature-pooling-messages
================================================================================
Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
================================================================================
@@ -24,13 +24,13 @@
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>feature-pooling-dmaap</id>
+ <id>feature-pooling-messages</id>
<formats>
<format>zip</format>
</formats>
<!-- we want "system" and related files right at the root level as this
- file is suppose to be unzip on top of a karaf distro. -->
+ file is supposed to be unzipped on top of a karaf distro. -->
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
@@ -38,7 +38,7 @@
<directory>target</directory>
<outputDirectory>lib/feature</outputDirectory>
<includes>
- <include>feature-pooling-dmaap-${project.version}.jar</include>
+ <include>feature-pooling-messages-${project.version}.jar</include>
</includes>
</fileSet>
<fileSet>
diff --git a/feature-pooling-dmaap/src/main/feature/config/feature-pooling-dmaap.properties b/feature-pooling-messages/src/main/feature/config/feature-pooling-messages.properties
index 59c4b472..925d1698 100644
--- a/feature-pooling-dmaap/src/main/feature/config/feature-pooling-dmaap.properties
+++ b/feature-pooling-messages/src/main/feature/config/feature-pooling-messages.properties
@@ -1,8 +1,9 @@
###
# ============LICENSE_START=======================================================
-# feature-pooling-dmaap
+# feature-pooling-messages
# ================================================================================
# 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.
@@ -24,10 +25,10 @@
#
# The available properties and their default values are shown below.
-# Whether or not the feature is enabled.
+# Whether the feature is enabled.
#pooling.enabled=false
-# The internal DMaaP topic used by a controller. Note: the controller
+# The internal kafka topic used by a controller. Note: the controller
# name is required for this property.
#pooling.<controller-name>.topic =
@@ -36,18 +37,18 @@
#pooling.offline.queue.limit=1000
# Maximum age, in milliseconds, of events to be retained in the queue.
-# Events older than this are discarded.
+# Events older than this are discarded.
#pooling.offline.queue.age.milliseconds=60000
# Time, in milliseconds, to wait for an "Offline" message to be published
-# to DMaaP before the connection may be closed.
+# to topic manager before the connection may be closed.
#pooling.offline.publish.wait.milliseconds=3000
# Time, in milliseconds, to wait for this host's initial heart beat. This
-# is used to verify connectivity to the internal DMaaP topic.
+# is used to verify connectivity to the internal topic.
#pooling.start.heartbeat.milliseconds=100000
-# Time, in milliseconds, to wait before attempting to re-active this
+# Time, in milliseconds, to wait before attempting to reactivate this
# host when it was not assigned any work.
#pooling.reactivate.milliseconds=50000
@@ -66,22 +67,23 @@
# pooling.<controller-name>.topic=XXX
# Each controller that is enabled should have its own topic and the
-# corresponding dmaap.xxx properties. However, for now, just assume that
-# the usecases features will not both be enabled at the same time.
+# corresponding ${topicManager}.xxx properties (using kafka as default).
+# However, for now, just assume that the usecases features will not both
+# be enabled at the same time.
pooling.usecases.enabled=true
pooling.usecases.topic=${env:POOLING_TOPIC}
# the list of sources and sinks should be identical
-dmaap.source.topics=POOLING_TOPIC
-dmaap.sink.topics=POOLING_TOPIC
-
-dmaap.source.topics.POOLING_TOPIC.servers=${env:DMAAP_SERVERS}
-dmaap.source.topics.POOLING_TOPIC.effectiveTopic=${env:POOLING_TOPIC}
-dmaap.source.topics.POOLING_TOPIC.apiKey=
-dmaap.source.topics.POOLING_TOPIC.apiSecret=
-
-dmaap.sink.topics.POOLING_TOPIC.servers=${env:DMAAP_SERVERS}
-dmaap.sink.topics.POOLING_TOPIC.effectiveTopic=${env:POOLING_TOPIC}
-dmaap.sink.topics.POOLING_TOPIC.apiKey=
-dmaap.sink.topics.POOLING_TOPIC.apiSecret=
+kafka.source.topics=POOLING_TOPIC
+kafka.sink.topics=POOLING_TOPIC
+
+kafka.source.topics.POOLING_TOPIC.servers=${env:KAFKA_SERVERS}
+kafka.source.topics.POOLING_TOPIC.effectiveTopic=${env:POOLING_TOPIC}
+kafka.source.topics.POOLING_TOPIC.apiKey=
+kafka.source.topics.POOLING_TOPIC.apiSecret=
+
+kafka.sink.topics.POOLING_TOPIC.servers=${env:kafka_SERVERS}
+kafka.sink.topics.POOLING_TOPIC.effectiveTopic=${env:POOLING_TOPIC}
+kafka.sink.topics.POOLING_TOPIC.apiKey=
+kafka.sink.topics.POOLING_TOPIC.apiSecret=
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.java
index f0d3b267..4e9112e6 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/CancellableScheduledTask.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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
index 5c61fb85..6411dd81 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -240,7 +241,7 @@ public class PoolingFeature implements PolicyEngineFeatureApi, PolicyControllerF
String topic = offerTopics.get();
if (topic == null) {
- logger.warn("missing arguments for feature-pooling-dmaap in beforeInsert");
+ logger.warn("missing arguments for feature-pooling-messages in beforeInsert");
return false;
}
@@ -315,7 +316,7 @@ public class PoolingFeature implements PolicyEngineFeatureApi, PolicyControllerF
private void deleteManager(PolicyController controller) {
String name = controller.getName();
- logger.info("remove feature-pool-dmaap manager for {}", name);
+ logger.info("remove feature-pooling-messages manager for {}", name);
ctlr2pool.remove(name);
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java
index c3c81879..5d7b9f76 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureException.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,10 +21,13 @@
package org.onap.policy.drools.pooling;
+import java.io.Serial;
+
/**
* Exception thrown by the pooling feature.
*/
public class PoolingFeatureException extends Exception {
+ @Serial
private static final long serialVersionUID = 1L;
public PoolingFeatureException() {
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java
index 6fdb6c69..5d0a2755 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingFeatureRtException.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,10 +21,13 @@
package org.onap.policy.drools.pooling;
+import java.io.Serial;
+
/**
* A runtime exception thrown by the pooling feature.
*/
public class PoolingFeatureRtException extends RuntimeException {
+ @Serial
private static final long serialVersionUID = 1L;
public PoolingFeatureRtException() {
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java
index cc8e3a4d..5e358e61 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingManager.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
index a50997c2..7c0436eb 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -98,7 +99,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
/**
* Manager for the internal DMaaP topic.
*/
- private final DmaapManager dmaapMgr;
+ private final TopicMessageManager topicMessageManager;
/**
* Lock used while updating {@link #current}. In general, public methods must use
@@ -128,7 +129,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
private ScheduledThreadPoolExecutor scheduler = null;
/**
- * Constructs the manager, initializing all of the data structures.
+ * Constructs the manager, initializing all the data structures.
*
* @param host name/uuid of this host
* @param controller controller with which this is associated
@@ -146,7 +147,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
try {
this.serializer = new Serializer();
this.topic = props.getPoolingTopic();
- this.dmaapMgr = makeDmaapManager(props.getPoolingTopic());
+ this.topicMessageManager = makeTopicMessagesManager(props.getPoolingTopic());
this.current = new IdleState(this);
logger.info("allocating host {} to controller {} for topic {}", host, controller.getName(), topic);
@@ -179,7 +180,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
public void beforeStart() {
synchronized (curLocker) {
if (scheduler == null) {
- dmaapMgr.startPublisher();
+ topicMessageManager.startPublisher();
logger.debug("make scheduler thread for topic {}", getTopic());
scheduler = makeScheduler();
@@ -204,7 +205,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
public void afterStart() {
synchronized (curLocker) {
if (current instanceof IdleState) {
- dmaapMgr.startConsumer(this);
+ topicMessageManager.startConsumer(this);
changeState(new StartState(this));
}
}
@@ -223,7 +224,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
if (!(current instanceof IdleState)) {
changeState(new IdleState(this));
- dmaapMgr.stopConsumer(this);
+ topicMessageManager.stopConsumer(this);
publishAdmin(new Offline(getHost()));
}
@@ -246,7 +247,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
* stop the publisher, but allow time for any Offline message to be
* transmitted
*/
- dmaapMgr.stopPublisher(properties.getOfflinePubWaitMs());
+ topicMessageManager.stopPublisher(properties.getOfflinePubWaitMs());
}
}
@@ -326,7 +327,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
msg.checkValidity();
String txt = serializer.encodeMsg(msg);
- dmaapMgr.publish(txt);
+ topicMessageManager.publish(txt);
} catch (JsonParseException e) {
logger.error("failed to serialize message for topic {} channel {}", topic, channel, e);
@@ -363,7 +364,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
* need to be forwarded, thus in that case, they are decoded and forwarded.
*
* <p>On the other hand, if the controller is not locked, then we just return immediately
- * and let {@link #beforeInsert(Object, String, String, Object) beforeInsert()} handle
+ * and let {@link #beforeInsert(String, Object) beforeInsert()} handle
* it instead, as it already has the decoded message.
*
* @param topic2 topic
@@ -600,11 +601,11 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
* Creates a DMaaP manager.
*
* @param topic name of the internal DMaaP topic
- * @return a new DMaaP manager
+ * @return a new topic messages manager
* @throws PoolingFeatureException if an error occurs
*/
- protected DmaapManager makeDmaapManager(String topic) throws PoolingFeatureException {
- return new DmaapManager(topic);
+ protected TopicMessageManager makeTopicMessagesManager(String topic) throws PoolingFeatureException {
+ return new TopicMessageManager(topic);
}
/**
@@ -636,7 +637,7 @@ public class PoolingManagerImpl implements PoolingManager, TopicListener {
* @param event event text to be decoded
* @return the decoded event
* @throws IllegalArgumentException illegal argument
- * @throw UnsupportedOperationException unsupported operation
+ * @throws UnsupportedOperationException unsupported operation
* @throws IllegalStateException illegal state
*/
protected Object decodeEventWrapper(DroolsController drools, String topic, String event) {
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
index 08b2753f..fd1c3d3d 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -38,7 +39,7 @@ public class PoolingProperties {
/**
* The feature name, used to retrieve properties.
*/
- public static final String FEATURE_NAME = "feature-pooling-dmaap";
+ public static final String FEATURE_NAME = "feature-pooling-messages";
/**
* Feature properties all begin with this prefix.
@@ -93,7 +94,7 @@ public class PoolingProperties {
/**
* Time, in milliseconds, to wait for an "Offline" message to be published
- * to DMaaP.
+ * to topic.
*/
@Property(name = OFFLINE_PUB_WAIT_MS, defaultValue = "3000")
private long offlinePubWaitMs;
@@ -106,7 +107,7 @@ public class PoolingProperties {
private long startHeartbeatMs;
/**
- * Time, in milliseconds, to wait before attempting to re-active this
+ * Time, in milliseconds, to wait before attempting to reactivate this
* host when it has no bucket assignments.
*/
@Property(name = REACTIVATE_MS, defaultValue = "50000")
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/Serializer.java
index 15c98e0d..2894b1da 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/Serializer.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/Serializer.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -44,7 +45,7 @@ public class Serializer {
/**
* Used to encode & decode JSON messages sent & received, respectively, on the
- * internal DMaaP topic.
+ * internal topic.
*/
private final Gson gson = new Gson();
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/TopicMessageManager.java
index c0358f65..4c9b3f34 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/DmaapManager.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/TopicMessageManager.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -31,15 +32,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Manages the internal DMaaP topic. Assumes all topics are managed by
- * {@link TopicEndpoint#manager}.
+ * Manages the internal topic. Assumes all topics are managed by
+ * {@link TopicEndpoint}.
*/
-public class DmaapManager {
+public class TopicMessageManager {
- private static final Logger logger = LoggerFactory.getLogger(DmaapManager.class);
+ private static final Logger logger = LoggerFactory.getLogger(TopicMessageManager.class);
/**
- * Name of the DMaaP topic.
+ * Name of the topic.
*/
@Getter
private final String topic;
@@ -67,10 +68,10 @@ public class DmaapManager {
/**
* Constructs the manager, but does not start the source or sink.
*
- * @param topic name of the internal DMaaP topic
+ * @param topic name of the internal topic
* @throws PoolingFeatureException if an error occurs
*/
- public DmaapManager(String topic) throws PoolingFeatureException {
+ public TopicMessageManager(String topic) throws PoolingFeatureException {
logger.info("initializing bus for topic {}", topic);
@@ -87,7 +88,7 @@ public class DmaapManager {
}
/**
- * Finds the topic source associated with the internal DMaaP topic.
+ * Finds the topic source associated with the internal topic.
*
* @return the topic source
* @throws PoolingFeatureException if the source doesn't exist or is not filterable
@@ -103,7 +104,7 @@ public class DmaapManager {
}
/**
- * Finds the topic sink associated with the internal DMaaP topic.
+ * Finds the topic sink associated with the internal topic.
*
* @return the topic sink
* @throws PoolingFeatureException if the sink doesn't exist
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
index 584edcec..485a9d2e 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/BucketAssignments.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -114,9 +115,9 @@ public class BucketAssignments {
}
/**
- * Gets all of the hosts that have an assignment.
+ * Gets all the hosts that have an assignment.
*
- * @return all of the hosts that have an assignment
+ * @return all the hosts that have an assignment
*/
public Set<String> getAllHosts() {
Set<String> set = new HashSet<>();
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
index 0721fe7a..4a8bdc3b 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Heartbeat.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
index 2ca4dd75..b8fd8414 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Identification.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
index 239f7491..10c33382 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Leader.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Message.java
index 0154fc7c..bb973142 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Message.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Message.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
index adf17b25..b8521dd8 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/MessageWithAssignments.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-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.
@@ -28,14 +29,14 @@ import org.onap.policy.drools.pooling.PoolingFeatureException;
/**
* A Message that includes bucket assignments.
*/
+@Setter
+@Getter
@NoArgsConstructor
public class MessageWithAssignments extends Message {
/**
* Bucket assignments, as known by the source host.
*/
- @Getter
- @Setter
private BucketAssignments assignments;
@@ -43,7 +44,7 @@ public class MessageWithAssignments extends Message {
* Constructor.
*
* @param source host on which the message originated
- * @param assignments assignements
+ * @param assignments assignments
*/
public MessageWithAssignments(String source, BucketAssignments assignments) {
super(source);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
index 7a3a3b47..3ff7bf1e 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Offline.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Query.java
index d349a789..4c856bb7 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/message/Query.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/message/Query.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
index a53e7572..cafcb45b 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/ActiveState.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020-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.
@@ -32,7 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * The active state. In this state, this host has one more more bucket assignments and
+ * The active state. In this state, this host has one more bucket assignments and
* processes any events associated with one of its buckets. Other events are forwarded to
* appropriate target hosts.
*/
@@ -244,10 +245,10 @@ public class ActiveState extends ProcessingState {
/*
* Case 1: We are the leader.
*
- * Case 2: Our predecessor was the leader and it has gone offline - we should
+ * Case 2: Our predecessor was the leader, and it has gone offline - we should
* become the leader.
*
- * In either case, we are now the leader and we must re-balance the buckets
+ * In either case, we are now the leader, and we must re-balance the buckets
* since one of the hosts has gone offline.
*/
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/IdleState.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/IdleState.java
index 4878c241..06418280 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/IdleState.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/IdleState.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java
index 579dc16d..7fc220a0 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/InactiveState.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
index 8bbb6ad8..76914b75 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/ProcessingState.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -41,6 +42,7 @@ import org.slf4j.LoggerFactory;
/**
* Any state in which events are being processed locally and forwarded, as appropriate.
*/
+@Setter
@Getter
public class ProcessingState extends State {
@@ -50,7 +52,6 @@ public class ProcessingState extends State {
* Current known leader, never {@code null}.
*/
@NonNull
- @Setter
private String leader;
/**
@@ -61,13 +62,9 @@ public class ProcessingState extends State {
* leader. Never {@code null}
* @throws IllegalArgumentException if an argument is invalid
*/
- public ProcessingState(PoolingManager mgr, String leader) {
+ public ProcessingState(PoolingManager mgr, @NonNull String leader) {
super(mgr);
- if (leader == null) {
- throw new IllegalArgumentException("null leader");
- }
-
BucketAssignments assignments = mgr.getAssignments();
if (assignments != null) {
@@ -264,6 +261,7 @@ public class ProcessingState extends State {
for (Integer index : buckets) {
// add it to the host with the shortest bucket list
HostBucket newhb = assignments.pollFirst();
+ assert newhb != null;
newhb.add(index);
// put the item back into the queue, with its new count
@@ -291,6 +289,7 @@ public class ProcessingState extends State {
HostBucket smaller = assignments.pollFirst();
HostBucket larger = assignments.pollLast();
+ assert larger != null && smaller != null;
if (larger.size() - smaller.size() <= 1) {
// it's as balanced as it will get
break;
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java
index 3e6f9d58..ef401dcb 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/QueryState.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) Nordix Foundation.
+ * 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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
index c582d6e0..73717d7c 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/StartState.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020-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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/State.java
index 66728ee2..e2cf9586 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/State.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/State.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020-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.
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.java b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.java
index e4607f81..892a1767 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.java
+++ b/feature-pooling-messages/src/main/java/org/onap/policy/drools/pooling/state/StateTimerTask.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.
diff --git a/feature-pooling-dmaap/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi b/feature-pooling-messages/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi
index cd59e469..cd59e469 100644
--- a/feature-pooling-dmaap/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi
+++ b/feature-pooling-messages/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi
diff --git a/feature-pooling-dmaap/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi b/feature-pooling-messages/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi
index cd59e469..cd59e469 100644
--- a/feature-pooling-dmaap/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi
+++ b/feature-pooling-messages/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi
diff --git a/feature-pooling-dmaap/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi b/feature-pooling-messages/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi
index cd59e469..cd59e469 100644
--- a/feature-pooling-dmaap/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi
+++ b/feature-pooling-messages/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java
index b8970f1f..31ad207c 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/EndToEndFeatureTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,8 +21,8 @@
package org.onap.policy.drools.pooling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -41,12 +42,12 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+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;
@@ -77,17 +78,17 @@ public class EndToEndFeatureTest {
/**
* UEB servers for both internal & external topics.
*/
- private static final String UEB_SERVERS = "";
+ private static final String UEB_SERVERS = "ueb-server";
/**
* Name of the topic used for inter-host communication.
*/
- private static final String INTERNAL_TOPIC = "";
+ private static final String INTERNAL_TOPIC = "internal-topic";
/**
* Name of the topic from which "external" events "arrive".
*/
- private static final String EXTERNAL_TOPIC = "";
+ private static final String EXTERNAL_TOPIC = "external-topic";
/**
* Consumer group to use when polling the external topic.
@@ -141,7 +142,7 @@ public class EndToEndFeatureTest {
* Setup before class.
*
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
externalSink = TopicEndpointManager.getManager().addTopicSinks(makeSinkProperties(EXTERNAL_TOPIC)).get(0);
externalSink.start();
@@ -154,7 +155,7 @@ public class EndToEndFeatureTest {
* Tear down after class.
*
*/
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
externalSink.stop();
internalSink.stop();
@@ -163,7 +164,7 @@ public class EndToEndFeatureTest {
/**
* Setup.
*/
- @Before
+ @BeforeEach
public void setUp() {
ctx = null;
}
@@ -171,7 +172,7 @@ public class EndToEndFeatureTest {
/**
* Tear down.
*/
- @After
+ @AfterEach
public void tearDown() {
if (ctx != null) {
ctx.destroy();
@@ -179,30 +180,30 @@ public class EndToEndFeatureTest {
}
/*
- * This test should only be run manually, after configuring all of the fields,
+ * This test should only be run manually, after configuring all the fields,
* thus it is ignored.
*/
- @Ignore
+ @Disabled
@Test
public void test_SingleHost() throws Exception { // NOSONAR
run(70, 1);
}
/*
- * This test should only be run manually, after configuring all of the fields,
+ * This test should only be run manually, after configuring all the fields,
* thus it is ignored.
*/
- @Ignore
+ @Disabled
@Test
public void test_TwoHosts() throws Exception { // NOSONAR
run(200, 2);
}
/*
- * This test should only be run manually, after configuring all of the fields,
+ * This test should only be run manually, after configuring all the fields,
* thus it is ignored.
*/
- @Ignore
+ @Disabled
@Test
public void test_ThreeHosts() throws Exception { // NOSONAR
run(200, 3);
@@ -363,7 +364,7 @@ public class EndToEndFeatureTest {
public void checkAllSawAMsg() {
int msgs = 0;
for (Host host : hosts) {
- assertTrue("msgs=" + msgs, host.messageSeen());
+ assertTrue(host.messageSeen(), "msgs=" + msgs);
++msgs;
}
}
@@ -758,8 +759,8 @@ public class EndToEndFeatureTest {
}
@Override
- protected DmaapManager makeDmaapManager(String topic) throws PoolingFeatureException {
- return new DmaapManagerImpl(topic);
+ protected TopicMessageManager makeTopicMessagesManager(String topic) throws PoolingFeatureException {
+ return new TopicMessageManagerImpl(topic);
}
@Override
@@ -776,7 +777,7 @@ public class EndToEndFeatureTest {
/**
* DMaaP Manager with overrides.
*/
- private static class DmaapManagerImpl extends DmaapManager {
+ private static class TopicMessageManagerImpl extends TopicMessageManager {
/**
* Constructor.
@@ -784,7 +785,7 @@ public class EndToEndFeatureTest {
* @param topic the topic
* @throws PoolingFeatureException if an error occurs
*/
- public DmaapManagerImpl(String topic) throws PoolingFeatureException {
+ public TopicMessageManagerImpl(String topic) throws PoolingFeatureException {
super(topic);
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
index bbd4c19f..e9bd3cb5 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 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,8 +21,8 @@
package org.onap.policy.drools.pooling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -31,7 +31,6 @@ import static org.onap.policy.drools.pooling.PoolingProperties.PREFIX;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
-import java.util.Arrays;
import java.util.Deque;
import java.util.IdentityHashMap;
import java.util.LinkedList;
@@ -49,9 +48,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import lombok.Getter;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+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;
@@ -80,7 +79,7 @@ import org.slf4j.LoggerFactory;
* <p>Invoke {@link #runSlow()}, before the test, to slow things down.
*/
-public class FeatureTest {
+class FeatureTest {
private static final Logger logger = LoggerFactory.getLogger(FeatureTest.class);
/**
* Name of the topic used for inter-host communication.
@@ -115,19 +114,21 @@ public class FeatureTest {
* Context for the current test case.
*/
private Context ctx;
+
/**
* Setup.
*/
- @Before
+ @BeforeEach
public void setUp() {
ctx = null;
}
+
/**
* Tear down.
*/
- @After
+ @AfterEach
public void tearDown() {
if (ctx != null) {
ctx.destroy();
@@ -135,17 +136,17 @@ public class FeatureTest {
}
@Test
- public void test_SingleHost() throws Exception {
+ void test_SingleHost() throws Exception {
run(70, 1);
}
@Test
- public void test_TwoHosts() throws Exception {
+ void test_TwoHosts() throws Exception {
run(200, 2);
}
@Test
- public void test_ThreeHosts() throws Exception {
+ void test_ThreeHosts() throws Exception {
run(200, 3);
}
@@ -167,6 +168,7 @@ public class FeatureTest {
private String makeMessage(int reqnum) {
return "{\"reqid\":\"req" + reqnum + "\", \"data\":\"hello " + reqnum + "\"}";
}
+
/**
* Invoke this to slow the timers down.
*/
@@ -182,6 +184,7 @@ public class FeatureTest {
stdInterPollMs = 2000;
stdEventWaitSec = 1000;
}
+
/**
* Decodes an event.
*
@@ -197,6 +200,7 @@ public class FeatureTest {
return null;
}
}
+
/**
* Context used for a single test case.
*/
@@ -222,10 +226,12 @@ public class FeatureTest {
* Number of events we're still waiting to receive.
*/
private final CountDownLatch eventCounter;
+
/**
* The current host. Set by {@link #withHost(Host, VoidFunction)} and used by
* {@link #getCurrentHost()}.
*/
+ @Getter
private Host currentHost = null;
/**
@@ -237,6 +243,7 @@ public class FeatureTest {
public Context(int events) {
eventCounter = new CountDownLatch(events);
}
+
/**
* Destroys the context, stopping any hosts that remain.
*/
@@ -281,7 +288,7 @@ public class FeatureTest {
public void checkAllSawAMsg() {
int msgs = 0;
for (Host host : hosts) {
- assertTrue("msgs=" + msgs, host.messageSeen());
+ assertTrue(host.messageSeen(), "msgs=" + msgs);
++msgs;
}
}
@@ -317,7 +324,7 @@ public class FeatureTest {
* Adds an internal channel to the set of channels.
*
* @param channel channel
- * @param queue the channel's queue
+ * @param queue the channel's queue
*/
public void addInternal(String channel, BlockingQueue<String> queue) {
@@ -337,7 +344,7 @@ public class FeatureTest {
/**
* Associates a controller with its drools controller.
*
- * @param controller controller
+ * @param controller controller
* @param droolsController drools controller
*/
@@ -396,7 +403,7 @@ public class FeatureTest {
/**
* Waits, for a period of time, for all events to be processed.
*
- * @param time time
+ * @param time time
* @param units units
* @return {@code true} if all events have been processed, {@code false} otherwise
* @throws InterruptedException throws interrupted
@@ -406,16 +413,6 @@ public class FeatureTest {
return eventCounter.await(time, units);
}
- /**
- * Gets the current host, provided this is used from within a call to
- * {@link #withHost(Host, VoidFunction)}.
- *
- * @return the current host, or {@code null} if there is no current host
- */
-
- public Host getCurrentHost() {
- return currentHost;
- }
}
/**
@@ -519,8 +516,8 @@ public class FeatureTest {
* Offers an event to the feature, before the policy controller handles it.
*
* @param protocol protocol
- * @param topic2 topic
- * @param event event
+ * @param topic2 topic
+ * @param event event
* @return {@code true} if the event was handled, {@code false} otherwise
*/
@@ -532,9 +529,9 @@ public class FeatureTest {
* Offers an event to the feature, after the policy controller handles it.
*
* @param protocol protocol
- * @param topic topic
- * @param event event
- * @param success success
+ * @param topic topic
+ * @param event event
+ * @param success success
* @return {@code true} if the event was handled, {@code false} otherwise
*/
@@ -556,9 +553,9 @@ public class FeatureTest {
/**
* Offers an event to the feature, after the drools controller handles it.
*
- * @param fact fact
+ * @param fact fact
* @param successInsert {@code true} if it was successfully inserted by the drools
- * controller, {@code false} otherwise
+ * controller, {@code false} otherwise
* @return {@code true} if the event was handled, {@code false} otherwise
*/
@@ -577,8 +574,7 @@ public class FeatureTest {
/**
* Message seen.
*
- * @return {@code true} if a message was seen for this host, {@code false}
- * otherwise
+ * @return {@code true} if a message was seen for this host, {@code false} otherwise
*/
public boolean messageSeen() {
@@ -694,7 +690,7 @@ public class FeatureTest {
/**
* Constructor.
*
- * @param type topic type
+ * @param type topic type
* @param queue topic from which to read
*/
@@ -787,7 +783,7 @@ public class FeatureTest {
/**
* Polls for messages from the topic and offers them to the listener.
*
- * @param stopped triggered if processing should stop
+ * @param stopped triggered if processing should stop
* @param listener listener
* @throws InterruptedException throws interrupted exception
*/
@@ -918,16 +914,13 @@ public class FeatureTest {
props.setProperty(specialize(PoolingProperties.POOLING_TOPIC, CONTROLLER1), INTERNAL_TOPIC);
props.setProperty(specialize(PoolingProperties.OFFLINE_LIMIT, CONTROLLER1), "10000");
props.setProperty(specialize(PoolingProperties.OFFLINE_AGE_MS, CONTROLLER1), "1000000");
- props.setProperty(specialize(PoolingProperties.OFFLINE_PUB_WAIT_MS, CONTROLLER1),
- "" + stdOfflinePubWaitMs);
- props.setProperty(specialize(PoolingProperties.START_HEARTBEAT_MS, CONTROLLER1),
- "" + stdStartHeartbeatMs);
+ props.setProperty(specialize(PoolingProperties.OFFLINE_PUB_WAIT_MS, CONTROLLER1), "" + stdOfflinePubWaitMs);
+ props.setProperty(specialize(PoolingProperties.START_HEARTBEAT_MS, CONTROLLER1), "" + stdStartHeartbeatMs);
props.setProperty(specialize(PoolingProperties.REACTIVATE_MS, CONTROLLER1), "" + stdReactivateWaitMs);
props.setProperty(specialize(PoolingProperties.IDENTIFICATION_MS, CONTROLLER1), "" + stdIdentificationMs);
props.setProperty(specialize(PoolingProperties.ACTIVE_HEARTBEAT_MS, CONTROLLER1),
- "" + stdActiveHeartbeatMs);
- props.setProperty(specialize(PoolingProperties.INTER_HEARTBEAT_MS, CONTROLLER1),
- "" + stdInterHeartbeatMs);
+ "" + stdActiveHeartbeatMs);
+ props.setProperty(specialize(PoolingProperties.INTER_HEARTBEAT_MS, CONTROLLER1), "" + stdInterHeartbeatMs);
return props;
}
@@ -940,7 +933,7 @@ public class FeatureTest {
* Embeds a specializer within a property name, after the prefix.
*
* @param propnm property name into which it should be embedded
- * @param spec specializer to be embedded
+ * @param spec specializer to be embedded
* @return the property name, with the specializer embedded within it
*/
@@ -951,7 +944,7 @@ public class FeatureTest {
@Override
protected PoolingManagerImpl makeManager(String host, PolicyController controller, PoolingProperties props,
- CountDownLatch activeLatch) {
+ CountDownLatch activeLatch) {
currentContext.set(context);
return new PoolingManagerTest(host, controller, props, activeLatch);
}
@@ -966,20 +959,20 @@ public class FeatureTest {
/**
* Constructor.
*
- * @param host the host
- * @param controller the controller
- * @param props the properties
+ * @param host the host
+ * @param controller the controller
+ * @param props the properties
* @param activeLatch the latch
*/
public PoolingManagerTest(String host, PolicyController controller, PoolingProperties props,
- CountDownLatch activeLatch) {
+ CountDownLatch activeLatch) {
super(host, controller, props, activeLatch);
}
@Override
- protected DmaapManager makeDmaapManager(String topic) throws PoolingFeatureException {
- return new DmaapManagerImpl(topic);
+ protected TopicMessageManager makeTopicMessagesManager(String topic) throws PoolingFeatureException {
+ return new TopicMessageManagerImpl(topic);
}
@Override
@@ -997,7 +990,7 @@ public class FeatureTest {
* DMaaP Manager with overrides.
*/
- private static class DmaapManagerImpl extends DmaapManager {
+ private static class TopicMessageManagerImpl extends TopicMessageManager {
/**
* Constructor.
@@ -1006,19 +999,19 @@ public class FeatureTest {
* @throws PoolingFeatureException if an error occurs
*/
- public DmaapManagerImpl(String topic) throws PoolingFeatureException {
+ public TopicMessageManagerImpl(String topic) throws PoolingFeatureException {
super(topic);
}
@Override
protected List<TopicSource> getTopicSources() {
- return Arrays.asList(new TopicSourceImpl(INTERNAL_TOPIC,
- currentContext.get().getCurrentHost().getInternalQueue()));
+ return List.of(
+ new TopicSourceImpl(INTERNAL_TOPIC, currentContext.get().getCurrentHost().getInternalQueue()));
}
@Override
protected List<TopicSink> getTopicSinks() {
- return Arrays.asList(new TopicSinkImpl(currentContext.get()));
+ return List.of(new TopicSinkImpl(currentContext.get()));
}
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java
index 731736a1..1bfba19c 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureExceptionTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,15 +21,15 @@
package org.onap.policy.drools.pooling;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class PoolingFeatureExceptionTest extends ExceptionsTester {
+class PoolingFeatureExceptionTest extends ExceptionsTester {
@Test
- public void test() {
+ void test() {
assertEquals(5, test(PoolingFeatureException.class));
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java
index f505ccdf..a4305a7f 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureRtExceptionTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,15 +21,15 @@
package org.onap.policy.drools.pooling;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class PoolingFeatureRtExceptionTest extends ExceptionsTester {
+class PoolingFeatureRtExceptionTest extends ExceptionsTester {
@Test
- public void test() {
+ void test() {
assertEquals(5, test(PoolingFeatureRtException.class));
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java
index 02a4db5c..1b05e021 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingFeatureTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 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,11 +21,12 @@
package org.onap.policy.drools.pooling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -40,8 +41,8 @@ import java.util.List;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Before;
-import org.junit.Test;
+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.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
@@ -49,7 +50,7 @@ import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyEngine;
-public class PoolingFeatureTest {
+class PoolingFeatureTest {
private static final String CONTROLLER1 = "controllerA";
private static final String CONTROLLER2 = "controllerB";
@@ -87,7 +88,7 @@ public class PoolingFeatureTest {
*
* @throws Exception exception
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
props = initProperties();
engine = mock(PolicyEngine.class);
@@ -119,12 +120,12 @@ public class PoolingFeatureTest {
}
@Test
- public void test() {
+ void test() {
assertEquals(2, managers.size());
}
@Test
- public void testGetHost() {
+ void testGetHost() {
String host = pool.getHost();
assertNotNull(host);
@@ -137,19 +138,19 @@ public class PoolingFeatureTest {
}
@Test
- public void testGetSequenceNumber() {
+ void testGetSequenceNumber() {
assertEquals(0, pool.getSequenceNumber());
}
@Test
- public void testBeforeStartEngine() {
+ void testBeforeStartEngine() {
pool = new PoolingFeatureImpl();
assertFalse(pool.beforeStart(engine));
}
@Test
- public void testAfterCreate() {
+ void testAfterCreate() {
managers.clear();
pool = new PoolingFeatureImpl();
pool.beforeStart(engine);
@@ -167,7 +168,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testAfterCreate_NotEnabled() {
+ void testAfterCreate_NotEnabled() {
managers.clear();
pool = new PoolingFeatureImpl();
pool.beforeStart(engine);
@@ -176,26 +177,26 @@ public class PoolingFeatureTest {
assertTrue(managers.isEmpty());
}
- @Test(expected = PoolingFeatureRtException.class)
- public void testAfterCreate_PropertyEx() {
+ @Test
+ void testAfterCreate_PropertyEx() {
managers.clear();
pool = new PoolingFeatureImpl();
pool.beforeStart(engine);
- pool.afterCreate(controllerException);
+ assertThrows(PoolingFeatureRtException.class, () -> pool.afterCreate(controllerException));
}
- @Test(expected = PoolingFeatureRtException.class)
- public void testAfterCreate_NoProps() {
+ @Test
+ void testAfterCreate_NoProps() {
pool = new PoolingFeatureImpl();
// did not perform globalInit, which is an error
- pool.afterCreate(controller1);
+ assertThrows(PoolingFeatureRtException.class, () -> pool.afterCreate(controller1));
}
@Test
- public void testAfterCreate_NoFeatProps() {
+ void testAfterCreate_NoFeatProps() {
managers.clear();
pool = new PoolingFeatureImpl();
pool.beforeStart(engine);
@@ -205,7 +206,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeStart() throws Exception {
+ void testBeforeStart() throws Exception {
assertFalse(pool.beforeStart(controller1));
verify(mgr1).beforeStart();
@@ -217,7 +218,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testAfterStart() {
+ void testAfterStart() {
assertFalse(pool.afterStart(controller1));
verify(mgr1).afterStart();
@@ -229,7 +230,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeStop() {
+ void testBeforeStop() {
assertFalse(pool.beforeStop(controller1));
verify(mgr1).beforeStop();
@@ -241,7 +242,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testAfterStop() {
+ void testAfterStop() {
assertFalse(pool.afterStop(controller1));
verify(mgr1).afterStop();
@@ -252,7 +253,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testAfterHalt() {
+ void testAfterHalt() {
assertFalse(pool.afterHalt(controller1));
assertFalse(pool.afterHalt(controller1));
@@ -262,7 +263,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testAfterShutdown() {
+ void testAfterShutdown() {
assertFalse(pool.afterShutdown(controller1));
assertFalse(pool.afterShutdown(controller1));
@@ -272,7 +273,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeLock() {
+ void testBeforeLock() {
assertFalse(pool.beforeLock(controller1));
verify(mgr1).beforeLock();
@@ -284,7 +285,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testAfterUnlock() {
+ void testAfterUnlock() {
assertFalse(pool.afterUnlock(controller1));
verify(mgr1).afterUnlock();
@@ -296,7 +297,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeOffer() {
+ void testBeforeOffer() {
assertFalse(pool.beforeOffer(controller1, CommInfrastructure.UEB, TOPIC1, EVENT1));
verify(mgr1).beforeOffer(TOPIC1, EVENT1);
@@ -318,12 +319,12 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeOffer_NotFound() {
+ void testBeforeOffer_NotFound() {
assertFalse(pool.beforeOffer(controllerDisabled, CommInfrastructure.UEB, TOPIC1, EVENT1));
}
@Test
- public void testBeforeOffer_MgrTrue() {
+ void testBeforeOffer_MgrTrue() {
// manager will return true
when(mgr1.beforeOffer(any(), any())).thenReturn(true);
@@ -339,7 +340,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeInsert() {
+ void testBeforeInsert() {
pool.beforeOffer(controller1, CommInfrastructure.UEB, TOPIC1, EVENT1);
assertFalse(pool.beforeInsert(drools1, OBJECT1));
verify(mgr1).beforeInsert(TOPIC1, OBJECT1);
@@ -354,7 +355,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeInsert_NoArgs() {
+ void testBeforeInsert_NoArgs() {
// call beforeInsert without beforeOffer
assertFalse(pool.beforeInsert(drools1, OBJECT1));
@@ -365,7 +366,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeInsert_ArgEx() {
+ void testBeforeInsert_ArgEx() {
// generate exception
pool = new PoolingFeatureImpl() {
@Override
@@ -380,7 +381,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeInsert_StateEx() {
+ void testBeforeInsert_StateEx() {
// generate exception
pool = new PoolingFeatureImpl() {
@Override
@@ -395,7 +396,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeInsert_NullController() {
+ void testBeforeInsert_NullController() {
// return null controller
pool = new PoolingFeatureImpl() {
@@ -411,14 +412,14 @@ public class PoolingFeatureTest {
}
@Test
- public void testBeforeInsert_NotFound() {
+ void testBeforeInsert_NotFound() {
pool.beforeOffer(controllerDisabled, CommInfrastructure.UEB, TOPIC2, EVENT2);
assertFalse(pool.beforeInsert(droolsDisabled, OBJECT1));
}
@Test
- public void testAfterOffer() {
+ void testAfterOffer() {
// this will create OfferArgs
pool.beforeOffer(controller1, CommInfrastructure.UEB, TOPIC1, EVENT1);
@@ -433,7 +434,7 @@ public class PoolingFeatureTest {
}
@Test
- public void testDoManager() throws Exception {
+ void testDoManager() {
assertFalse(pool.beforeStart(controller1));
verify(mgr1).beforeStart();
@@ -455,17 +456,17 @@ public class PoolingFeatureTest {
}
@Test
- public void testDoManager_NotFound() {
+ void testDoManager_NotFound() {
assertFalse(pool.beforeStart(controllerDisabled));
}
- @Test(expected = RuntimeException.class)
- public void testDoManager_Ex() throws Exception {
+ @Test
+ void testDoManager_Ex() {
// generate exception
doThrow(new RuntimeException()).when(mgr1).beforeStart();
- pool.beforeStart(controller1);
+ assertThrows(RuntimeException.class, () -> pool.beforeStart(controller1));
}
private Properties initProperties() {
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java
index 21bd62d1..ac60ae27 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingManagerImplTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -22,9 +23,10 @@ package org.onap.policy.drools.pooling;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.Mockito.doThrow;
@@ -41,8 +43,8 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicListener;
@@ -59,7 +61,7 @@ import org.onap.policy.drools.pooling.state.StartState;
import org.onap.policy.drools.pooling.state.State;
import org.onap.policy.drools.system.PolicyController;
-public class PoolingManagerImplTest {
+class PoolingManagerImplTest {
protected static final long STD_HEARTBEAT_WAIT_MS = 10;
protected static final long STD_REACTIVATE_WAIT_MS = STD_HEARTBEAT_WAIT_MS + 1;
@@ -81,7 +83,7 @@ public class PoolingManagerImplTest {
private static final Object DECODED_EVENT = new Object();
/**
- * Number of dmaap.publish() invocations that should be issued when the manager is
+ * Number of publish() invocations that should be issued when the manager is
* started.
*/
private static final int START_PUB = 1;
@@ -93,8 +95,8 @@ public class PoolingManagerImplTest {
private PoolingProperties poolProps;
private ListeningController controller;
- private DmaapManager dmaap;
- private boolean gotDmaap;
+ private TopicMessageManager topicMessageManager;
+ private boolean gotManager;
private ScheduledThreadPoolExecutor sched;
private int schedCount;
private DroolsController drools;
@@ -108,7 +110,7 @@ public class PoolingManagerImplTest {
*
* @throws Exception throws exception
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Properties plainProps = new Properties();
@@ -126,8 +128,8 @@ public class PoolingManagerImplTest {
ser = new Serializer();
active = new CountDownLatch(1);
- dmaap = mock(DmaapManager.class);
- gotDmaap = false;
+ topicMessageManager = mock(TopicMessageManager.class);
+ gotManager = false;
controller = mock(ListeningController.class);
sched = mock(ScheduledThreadPoolExecutor.class);
schedCount = 0;
@@ -156,31 +158,31 @@ public class PoolingManagerImplTest {
}
@Test
- public void testPoolingManagerImpl() throws Exception {
- assertTrue(gotDmaap);
+ void testPoolingManagerImpl() {
+ assertTrue(gotManager);
State st = mgr.getCurrent();
- assertTrue(st instanceof IdleState);
+ assertInstanceOf(IdleState.class, st);
// ensure the state is attached to the manager
assertEquals(mgr.getHost(), st.getHost());
}
@Test
- public void testPoolingManagerImpl_PoolEx() throws PoolingFeatureException {
- // throw an exception when we try to create the dmaap manager
+ void testPoolingManagerImpl_PoolEx() {
+ // throw an exception when we try to create the topic messages manager
PoolingFeatureException ex = new PoolingFeatureException();
assertThatThrownBy(() -> new PoolingManagerTest(MY_HOST, controller, poolProps, active) {
@Override
- protected DmaapManager makeDmaapManager(String topic) throws PoolingFeatureException {
+ protected TopicMessageManager makeTopicMessagesManager(String topic) throws PoolingFeatureException {
throw ex;
}
}).isInstanceOf(PoolingFeatureRtException.class).hasCause(ex);
}
@Test
- public void testGetCurrent() throws Exception {
+ void testGetCurrent() throws Exception {
assertEquals(IdleState.class, mgr.getCurrent().getClass());
startMgr();
@@ -189,7 +191,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testGetHost() {
+ void testGetHost() {
assertEquals(MY_HOST, mgr.getHost());
mgr = new PoolingManagerTest(HOST2, controller, poolProps, active);
@@ -197,21 +199,21 @@ public class PoolingManagerImplTest {
}
@Test
- public void testGetTopic() {
+ void testGetTopic() {
assertEquals(MY_TOPIC, mgr.getTopic());
}
@Test
- public void testGetProperties() {
+ void testGetProperties() {
assertEquals(poolProps, mgr.getProperties());
}
@Test
- public void testBeforeStart() throws Exception {
+ void testBeforeStart() {
// not running yet
mgr.beforeStart();
- verify(dmaap).startPublisher();
+ verify(topicMessageManager).startPublisher();
assertEquals(1, schedCount);
verify(sched).setMaximumPoolSize(1);
@@ -221,7 +223,7 @@ public class PoolingManagerImplTest {
// try again - nothing should happen
mgr.beforeStart();
- verify(dmaap).startPublisher();
+ verify(topicMessageManager).startPublisher();
assertEquals(1, schedCount);
verify(sched).setMaximumPoolSize(1);
@@ -229,13 +231,13 @@ public class PoolingManagerImplTest {
}
@Test
- public void testAfterStart() throws Exception {
+ void testAfterStart() throws Exception {
startMgr();
- verify(dmaap).startConsumer(mgr);
+ verify(topicMessageManager).startConsumer(mgr);
State st = mgr.getCurrent();
- assertTrue(st instanceof StartState);
+ assertInstanceOf(StartState.class, st);
// ensure the state is attached to the manager
assertEquals(mgr.getHost(), st.getHost());
@@ -251,41 +253,41 @@ public class PoolingManagerImplTest {
// already started - nothing else happens
mgr.afterStart();
- verify(dmaap).startConsumer(mgr);
+ verify(topicMessageManager).startConsumer(mgr);
- assertTrue(mgr.getCurrent() instanceof StartState);
+ assertInstanceOf(StartState.class, mgr.getCurrent());
verify(sched).schedule(any(Runnable.class), any(Long.class), any(TimeUnit.class));
}
@Test
- public void testBeforeStop() throws Exception {
+ void testBeforeStop() throws Exception {
startMgr();
mgr.startDistributing(makeAssignments(false));
- verify(dmaap, times(START_PUB)).publish(any());
+ verify(topicMessageManager, times(START_PUB)).publish(any());
mgr.beforeStop();
- verify(dmaap).stopConsumer(mgr);
+ verify(topicMessageManager).stopConsumer(mgr);
verify(sched).shutdownNow();
- verify(dmaap, times(START_PUB + 1)).publish(any());
- verify(dmaap).publish(contains("offline"));
+ verify(topicMessageManager, times(START_PUB + 1)).publish(any());
+ verify(topicMessageManager).publish(contains("offline"));
- assertTrue(mgr.getCurrent() instanceof IdleState);
+ assertInstanceOf(IdleState.class, mgr.getCurrent());
// verify that next message is handled locally
assertFalse(mgr.beforeInsert(TOPIC2, DECODED_EVENT));
- verify(dmaap, times(START_PUB + 1)).publish(any());
+ verify(topicMessageManager, times(START_PUB + 1)).publish(any());
}
@Test
- public void testBeforeStop_NotRunning() throws Exception {
+ void testBeforeStop_NotRunning() {
final State st = mgr.getCurrent();
mgr.beforeStop();
- verify(dmaap, never()).stopConsumer(any());
+ verify(topicMessageManager, never()).stopConsumer(any());
verify(sched, never()).shutdownNow();
// hasn't changed states either
@@ -293,7 +295,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testBeforeStop_AfterPartialStart() throws Exception {
+ void testBeforeStop_AfterPartialStart() {
// call beforeStart but not afterStart
mgr.beforeStart();
@@ -304,33 +306,33 @@ public class PoolingManagerImplTest {
// should still shut the scheduler down
verify(sched).shutdownNow();
- verify(dmaap, never()).stopConsumer(any());
+ verify(topicMessageManager, never()).stopConsumer(any());
// hasn't changed states
assertEquals(st, mgr.getCurrent());
}
@Test
- public void testAfterStop() throws Exception {
+ void testAfterStop() throws Exception {
startMgr();
mgr.beforeStop();
mgr.afterStop();
- verify(dmaap).stopPublisher(STD_OFFLINE_PUB_WAIT_MS);
+ verify(topicMessageManager).stopPublisher(STD_OFFLINE_PUB_WAIT_MS);
}
@Test
- public void testBeforeLock() throws Exception {
+ void testBeforeLock() throws Exception {
startMgr();
mgr.beforeLock();
- assertTrue(mgr.getCurrent() instanceof IdleState);
+ assertInstanceOf(IdleState.class, mgr.getCurrent());
}
@Test
- public void testAfterUnlock_AliveIdle() throws Exception {
+ void testAfterUnlock_AliveIdle() {
// this really shouldn't happen
lockMgr();
@@ -338,21 +340,21 @@ public class PoolingManagerImplTest {
mgr.afterUnlock();
// stays in idle state, because it has no scheduler
- assertTrue(mgr.getCurrent() instanceof IdleState);
+ assertInstanceOf(IdleState.class, mgr.getCurrent());
}
@Test
- public void testAfterUnlock_AliveStarted() throws Exception {
+ void testAfterUnlock_AliveStarted() throws Exception {
startMgr();
lockMgr();
mgr.afterUnlock();
- assertTrue(mgr.getCurrent() instanceof StartState);
+ assertInstanceOf(StartState.class, mgr.getCurrent());
}
@Test
- public void testAfterUnlock_StoppedIdle() throws Exception {
+ void testAfterUnlock_StoppedIdle() throws Exception {
startMgr();
lockMgr();
@@ -361,11 +363,11 @@ public class PoolingManagerImplTest {
mgr.afterUnlock();
- assertTrue(mgr.getCurrent() instanceof IdleState);
+ assertInstanceOf(IdleState.class, mgr.getCurrent());
}
@Test
- public void testAfterUnlock_StoppedStarted() throws Exception {
+ void testAfterUnlock_StoppedStarted() throws Exception {
startMgr();
// Note: don't lockMgr()
@@ -375,11 +377,11 @@ public class PoolingManagerImplTest {
mgr.afterUnlock();
- assertTrue(mgr.getCurrent() instanceof StartState);
+ assertInstanceOf(StartState.class, mgr.getCurrent());
}
@Test
- public void testChangeState() throws Exception {
+ void testChangeState() throws Exception {
// start should invoke changeState()
startMgr();
@@ -405,7 +407,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testSchedule() throws Exception {
+ void testSchedule() throws Exception {
// must start the scheduler
startMgr();
@@ -433,7 +435,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testScheduleWithFixedDelay() throws Exception {
+ void testScheduleWithFixedDelay() throws Exception {
// must start the scheduler
startMgr();
@@ -464,45 +466,45 @@ public class PoolingManagerImplTest {
}
@Test
- public void testPublishAdmin() throws Exception {
+ void testPublishAdmin() throws Exception {
Offline msg = new Offline(mgr.getHost());
mgr.publishAdmin(msg);
assertEquals(Message.ADMIN, msg.getChannel());
- verify(dmaap).publish(any());
+ verify(topicMessageManager).publish(any());
}
@Test
- public void testPublish() throws Exception {
+ void testPublish() throws Exception {
Offline msg = new Offline(mgr.getHost());
mgr.publish("my.channel", msg);
assertEquals("my.channel", msg.getChannel());
- verify(dmaap).publish(any());
+ verify(topicMessageManager).publish(any());
}
@Test
- public void testPublish_InvalidMsg() throws Exception {
+ void testPublish_InvalidMsg() throws Exception {
// message is missing data
mgr.publish(Message.ADMIN, new Offline());
// should not have attempted to publish it
- verify(dmaap, never()).publish(any());
+ verify(topicMessageManager, never()).publish(any());
}
@Test
- public void testPublish_DmaapEx() throws Exception {
+ void testPublish_TopicMessageMngEx() throws Exception {
// generate exception
- doThrow(new PoolingFeatureException()).when(dmaap).publish(any());
+ doThrow(new PoolingFeatureException()).when(topicMessageManager).publish(any());
assertThatCode(() -> mgr.publish(Message.ADMIN, new Offline(mgr.getHost()))).doesNotThrowAnyException();
}
@Test
- public void testOnTopicEvent() throws Exception {
+ void testOnTopicEvent() throws Exception {
startMgr();
StartState st = (StartState) mgr.getCurrent();
@@ -517,18 +519,18 @@ public class PoolingManagerImplTest {
mgr.onTopicEvent(CommInfrastructure.UEB, MY_TOPIC, msg);
- assertTrue(mgr.getCurrent() instanceof QueryState);
+ assertInstanceOf(QueryState.class, mgr.getCurrent());
}
@Test
- public void testOnTopicEvent_NullEvent() throws Exception {
+ void testOnTopicEvent_NullEvent() throws Exception {
startMgr();
assertThatCode(() -> mgr.onTopicEvent(CommInfrastructure.UEB, TOPIC2, null)).doesNotThrowAnyException();
}
@Test
- public void testBeforeOffer_Unlocked() throws Exception {
+ void testBeforeOffer_Unlocked() throws Exception {
startMgr();
// route the message to another host
@@ -538,7 +540,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testBeforeOffer_Locked() throws Exception {
+ void testBeforeOffer_Locked() throws Exception {
startMgr();
lockMgr();
@@ -549,7 +551,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testBeforeInsert() throws Exception {
+ void testBeforeInsert() throws Exception {
startMgr();
lockMgr();
@@ -560,56 +562,56 @@ public class PoolingManagerImplTest {
}
@Test
- public void testHandleExternalCommInfrastructureStringStringString_NullReqId() throws Exception {
+ void testHandleExternalCommInfrastructureStringStringString_NullReqId() throws Exception {
validateHandleReqId(null);
}
@Test
- public void testHandleExternalCommInfrastructureStringStringString_EmptyReqId() throws Exception {
+ void testHandleExternalCommInfrastructureStringStringString_EmptyReqId() throws Exception {
validateHandleReqId("");
}
@Test
- public void testHandleExternalCommInfrastructureStringStringString_InvalidMsg() throws Exception {
+ void testHandleExternalCommInfrastructureStringStringString_InvalidMsg() throws Exception {
startMgr();
assertFalse(mgr.beforeInsert(TOPIC2, "invalid message"));
}
@Test
- public void testHandleExternalCommInfrastructureStringStringString() throws Exception {
+ void testHandleExternalCommInfrastructureStringStringString() throws Exception {
validateUnhandled();
}
@Test
- public void testHandleExternalForward_NoAssignments() throws Exception {
+ void testHandleExternalForward_NoAssignments() throws Exception {
validateUnhandled();
}
@Test
- public void testHandleExternalForward() throws Exception {
+ void testHandleExternalForward() throws Exception {
validateNoForward();
}
@Test
- public void testHandleEvent_NullTarget() throws Exception {
+ void testHandleEvent_NullTarget() throws Exception {
// buckets have null targets
validateDiscarded(new BucketAssignments(new String[] {null, null}));
}
@Test
- public void testHandleEvent_SameHost() throws Exception {
+ void testHandleEvent_SameHost() throws Exception {
validateNoForward();
}
@Test
- public void testHandleEvent_DiffHost() throws Exception {
+ void testHandleEvent_DiffHost() throws Exception {
// route the message to the *OTHER* host
validateDiscarded(makeAssignments(false));
}
@Test
- public void testDecodeEvent_CannotDecode() throws Exception {
+ void testDecodeEvent_CannotDecode() throws Exception {
mgr = new PoolingManagerTest(MY_HOST, controller, poolProps, active) {
@Override
@@ -629,7 +631,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testDecodeEvent_UnsuppEx() throws Exception {
+ void testDecodeEvent_UnsuppEx() throws Exception {
// generate exception
mgr = new PoolingManagerTest(MY_HOST, controller, poolProps, active) {
@@ -650,7 +652,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testDecodeEvent_ArgEx() throws Exception {
+ void testDecodeEvent_ArgEx() throws Exception {
// generate exception
mgr = new PoolingManagerTest(MY_HOST, controller, poolProps, active) {
@Override
@@ -670,7 +672,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testDecodeEvent_StateEx() throws Exception {
+ void testDecodeEvent_StateEx() throws Exception {
// generate exception
mgr = new PoolingManagerTest(MY_HOST, controller, poolProps, active) {
@Override
@@ -690,7 +692,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testDecodeEvent() throws Exception {
+ void testDecodeEvent() throws Exception {
startMgr();
when(controller.isLocked()).thenReturn(true);
@@ -702,7 +704,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testHandleInternal() throws Exception {
+ void testHandleInternal() throws Exception {
startMgr();
StartState st = (StartState) mgr.getCurrent();
@@ -717,20 +719,20 @@ public class PoolingManagerImplTest {
mgr.onTopicEvent(CommInfrastructure.UEB, MY_TOPIC, msg);
- assertTrue(mgr.getCurrent() instanceof QueryState);
+ assertInstanceOf(QueryState.class, mgr.getCurrent());
}
@Test
- public void testHandleInternal_IoEx() throws Exception {
+ void testHandleInternal_IoEx() throws Exception {
startMgr();
mgr.onTopicEvent(CommInfrastructure.UEB, MY_TOPIC, "invalid message");
- assertTrue(mgr.getCurrent() instanceof StartState);
+ assertInstanceOf(StartState.class, mgr.getCurrent());
}
@Test
- public void testHandleInternal_PoolEx() throws Exception {
+ void testHandleInternal_PoolEx() throws Exception {
startMgr();
StartState st = (StartState) mgr.getCurrent();
@@ -746,18 +748,18 @@ public class PoolingManagerImplTest {
mgr.onTopicEvent(CommInfrastructure.UEB, MY_TOPIC, msg);
- assertTrue(mgr.getCurrent() instanceof StartState);
+ assertInstanceOf(StartState.class, mgr.getCurrent());
}
@Test
- public void testStartDistributing() throws Exception {
+ void testStartDistributing() throws Exception {
validateNoForward();
// null assignments should cause message to be processed locally
mgr.startDistributing(null);
assertFalse(mgr.beforeInsert(TOPIC2, DECODED_EVENT));
- verify(dmaap, times(START_PUB)).publish(any());
+ verify(topicMessageManager, times(START_PUB)).publish(any());
// message for this host
@@ -771,47 +773,47 @@ public class PoolingManagerImplTest {
}
@Test
- public void testGoStart() {
+ void testGoStart() {
State st = mgr.goStart();
- assertTrue(st instanceof StartState);
+ assertInstanceOf(StartState.class, st);
assertEquals(mgr.getHost(), st.getHost());
}
@Test
- public void testGoQuery() {
+ void testGoQuery() {
BucketAssignments asgn = new BucketAssignments(new String[] {HOST2});
mgr.startDistributing(asgn);
State st = mgr.goQuery();
- assertTrue(st instanceof QueryState);
+ assertInstanceOf(QueryState.class, st);
assertEquals(mgr.getHost(), st.getHost());
assertEquals(asgn, mgr.getAssignments());
}
@Test
- public void testGoActive() {
+ void testGoActive() {
BucketAssignments asgn = new BucketAssignments(new String[] {HOST2});
mgr.startDistributing(asgn);
State st = mgr.goActive();
- assertTrue(st instanceof ActiveState);
+ assertInstanceOf(ActiveState.class, st);
assertEquals(mgr.getHost(), st.getHost());
assertEquals(asgn, mgr.getAssignments());
assertEquals(0, active.getCount());
}
@Test
- public void testGoInactive() {
+ void testGoInactive() {
State st = mgr.goInactive();
- assertTrue(st instanceof InactiveState);
+ assertInstanceOf(InactiveState.class, st);
assertEquals(mgr.getHost(), st.getHost());
assertEquals(1, active.getCount());
}
@Test
- public void testTimerActionRun() throws Exception {
+ void testTimerActionRun() throws Exception {
// must start the scheduler
startMgr();
@@ -834,7 +836,7 @@ public class PoolingManagerImplTest {
}
@Test
- public void testTimerActionRun_DiffState() throws Exception {
+ void testTimerActionRun_DiffState() throws Exception {
// must start the scheduler
startMgr();
@@ -859,7 +861,7 @@ public class PoolingManagerImplTest {
mgr.onTopicEvent(CommInfrastructure.UEB, MY_TOPIC, msg);
- assertTrue(mgr.getCurrent() instanceof QueryState);
+ assertInstanceOf(QueryState.class, mgr.getCurrent());
// execute it
taskCap.getValue().run();
@@ -882,7 +884,7 @@ public class PoolingManagerImplTest {
assertFalse(mgr.beforeInsert(TOPIC2, DECODED_EVENT));
- verify(dmaap, times(START_PUB)).publish(any());
+ verify(topicMessageManager, times(START_PUB)).publish(any());
}
private void validateUnhandled() throws PoolingFeatureException {
@@ -902,7 +904,7 @@ public class PoolingManagerImplTest {
/**
* Makes an assignment with two buckets.
*
- * @param sameHost {@code true} if the {@link #REQUEST_ID} should hash to the
+ * @param sameHost {@code true} if the REQUEST_ID should hash to the
* manager's bucket, {@code false} if it should hash to the other host's bucket
* @return a new bucket assignment
*/
@@ -924,9 +926,8 @@ public class PoolingManagerImplTest {
/**
* Invokes methods necessary to start the manager.
*
- * @throws PoolingFeatureException if an error occurs
*/
- private void startMgr() throws PoolingFeatureException {
+ private void startMgr() {
mgr.beforeStart();
mgr.afterStart();
}
@@ -966,9 +967,9 @@ public class PoolingManagerImplTest {
}
@Override
- protected DmaapManager makeDmaapManager(String topic) throws PoolingFeatureException {
- gotDmaap = true;
- return dmaap;
+ protected TopicMessageManager makeTopicMessagesManager(String topic) throws PoolingFeatureException {
+ gotManager = true;
+ return topicMessageManager;
}
@Override
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java
index b15908dc..383e0071 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -21,7 +22,7 @@
package org.onap.policy.drools.pooling;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.onap.policy.drools.pooling.PoolingProperties.ACTIVE_HEARTBEAT_MS;
import static org.onap.policy.drools.pooling.PoolingProperties.FEATURE_ENABLED;
import static org.onap.policy.drools.pooling.PoolingProperties.IDENTIFICATION_MS;
@@ -36,8 +37,8 @@ import static org.onap.policy.drools.pooling.PoolingProperties.START_HEARTBEAT_M
import java.util.Properties;
import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.properties.exception.PropertyException;
public class PoolingPropertiesTest {
@@ -52,7 +53,6 @@ public class PoolingPropertiesTest {
public static final long STD_START_HEARTBEAT_MS = 3000L;
public static final long STD_REACTIVATE_MS = 4000L;
public static final long STD_IDENTIFICATION_MS = 5000L;
- public static final long STD_LEADER_MS = 6000L;
public static final long STD_ACTIVE_HEARTBEAT_MS = 7000L;
public static final long STD_INTER_HEARTBEAT_MS = 8000L;
@@ -64,7 +64,7 @@ public class PoolingPropertiesTest {
*
* @throws Exception throws an exception
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
plain = makeProperties();
@@ -72,58 +72,58 @@ public class PoolingPropertiesTest {
}
@Test
- public void testPoolingProperties() throws PropertyException {
+ void testPoolingProperties() {
// ensure no exceptions
assertThatCode(() -> new PoolingProperties(CONTROLLER, plain)).doesNotThrowAnyException();
}
@Test
- public void testGetSource() {
+ void testGetSource() {
assertEquals(plain, pooling.getSource());
}
@Test
- public void testGetPoolingTopic() {
+ void testGetPoolingTopic() {
assertEquals(STD_POOLING_TOPIC, pooling.getPoolingTopic());
}
@Test
- public void testGetOfflineLimit() throws PropertyException {
+ void testGetOfflineLimit() throws PropertyException {
doTest(OFFLINE_LIMIT, STD_OFFLINE_LIMIT, 1000, xxx -> pooling.getOfflineLimit());
}
@Test
- public void testGetOfflineAgeMs() throws PropertyException {
+ void testGetOfflineAgeMs() throws PropertyException {
doTest(OFFLINE_AGE_MS, STD_OFFLINE_AGE_MS, 60000L, xxx -> pooling.getOfflineAgeMs());
}
@Test
- public void testGetOfflinePubWaitMs() throws PropertyException {
+ void testGetOfflinePubWaitMs() throws PropertyException {
doTest(OFFLINE_PUB_WAIT_MS, STD_OFFLINE_PUB_WAIT_MS, 3000L, xxx -> pooling.getOfflinePubWaitMs());
}
@Test
- public void testGetStartHeartbeatMs() throws PropertyException {
+ void testGetStartHeartbeatMs() throws PropertyException {
doTest(START_HEARTBEAT_MS, STD_START_HEARTBEAT_MS, 100000L, xxx -> pooling.getStartHeartbeatMs());
}
@Test
- public void testGetReactivateMs() throws PropertyException {
+ void testGetReactivateMs() throws PropertyException {
doTest(REACTIVATE_MS, STD_REACTIVATE_MS, 50000L, xxx -> pooling.getReactivateMs());
}
@Test
- public void testGetIdentificationMs() throws PropertyException {
+ void testGetIdentificationMs() throws PropertyException {
doTest(IDENTIFICATION_MS, STD_IDENTIFICATION_MS, 50000L, xxx -> pooling.getIdentificationMs());
}
@Test
- public void testGetActiveHeartbeatMs() throws PropertyException {
+ void testGetActiveHeartbeatMs() throws PropertyException {
doTest(ACTIVE_HEARTBEAT_MS, STD_ACTIVE_HEARTBEAT_MS, 50000L, xxx -> pooling.getActiveHeartbeatMs());
}
@Test
- public void testGetInterHeartbeatMs() throws PropertyException {
+ void testGetInterHeartbeatMs() throws PropertyException {
doTest(INTER_HEARTBEAT_MS, STD_INTER_HEARTBEAT_MS, 15000L, xxx -> pooling.getInterHeartbeatMs());
}
@@ -143,19 +143,19 @@ public class PoolingPropertiesTest {
* With specialized property
*/
pooling = new PoolingProperties(CONTROLLER, plain);
- assertEquals("special " + propnm, specValue, func.apply(null));
+ assertEquals(specValue, func.apply(null), "special " + propnm);
/*
* Without the property - should use the default value.
*/
- plain.remove(specialize(propnm, CONTROLLER));
+ plain.remove(specialize(propnm));
plain.remove(propnm);
pooling = new PoolingProperties(CONTROLLER, plain);
- assertEquals("default " + propnm, dfltValue, func.apply(null));
+ assertEquals(dfltValue, func.apply(null), "default " + propnm);
}
/**
- * Makes a set of properties, where all of the properties are specialized for the
+ * Makes a set of properties, where all the properties are specialized for the
* controller.
*
* @return a new property set
@@ -163,16 +163,16 @@ public class PoolingPropertiesTest {
private Properties makeProperties() {
Properties props = new Properties();
- props.setProperty(specialize(POOLING_TOPIC, CONTROLLER), STD_POOLING_TOPIC);
- props.setProperty(specialize(FEATURE_ENABLED, CONTROLLER), "" + STD_FEATURE_ENABLED);
- props.setProperty(specialize(OFFLINE_LIMIT, CONTROLLER), "" + STD_OFFLINE_LIMIT);
- props.setProperty(specialize(OFFLINE_AGE_MS, CONTROLLER), "" + STD_OFFLINE_AGE_MS);
- props.setProperty(specialize(OFFLINE_PUB_WAIT_MS, CONTROLLER), "" + STD_OFFLINE_PUB_WAIT_MS);
- props.setProperty(specialize(START_HEARTBEAT_MS, CONTROLLER), "" + STD_START_HEARTBEAT_MS);
- props.setProperty(specialize(REACTIVATE_MS, CONTROLLER), "" + STD_REACTIVATE_MS);
- props.setProperty(specialize(IDENTIFICATION_MS, CONTROLLER), "" + STD_IDENTIFICATION_MS);
- props.setProperty(specialize(ACTIVE_HEARTBEAT_MS, CONTROLLER), "" + STD_ACTIVE_HEARTBEAT_MS);
- props.setProperty(specialize(INTER_HEARTBEAT_MS, CONTROLLER), "" + STD_INTER_HEARTBEAT_MS);
+ props.setProperty(specialize(POOLING_TOPIC), STD_POOLING_TOPIC);
+ props.setProperty(specialize(FEATURE_ENABLED), "" + STD_FEATURE_ENABLED);
+ props.setProperty(specialize(OFFLINE_LIMIT), "" + STD_OFFLINE_LIMIT);
+ props.setProperty(specialize(OFFLINE_AGE_MS), "" + STD_OFFLINE_AGE_MS);
+ props.setProperty(specialize(OFFLINE_PUB_WAIT_MS), "" + STD_OFFLINE_PUB_WAIT_MS);
+ props.setProperty(specialize(START_HEARTBEAT_MS), "" + STD_START_HEARTBEAT_MS);
+ props.setProperty(specialize(REACTIVATE_MS), "" + STD_REACTIVATE_MS);
+ props.setProperty(specialize(IDENTIFICATION_MS), "" + STD_IDENTIFICATION_MS);
+ props.setProperty(specialize(ACTIVE_HEARTBEAT_MS), "" + STD_ACTIVE_HEARTBEAT_MS);
+ props.setProperty(specialize(INTER_HEARTBEAT_MS), "" + STD_INTER_HEARTBEAT_MS);
return props;
}
@@ -181,11 +181,10 @@ public class PoolingPropertiesTest {
* Embeds a specializer within a property name, after the prefix.
*
* @param propnm property name into which it should be embedded
- * @param spec specializer to be embedded
* @return the property name, with the specializer embedded within it
*/
- private String specialize(String propnm, String spec) {
+ private String specialize(String propnm) {
String suffix = propnm.substring(PREFIX.length());
- return PREFIX + spec + "." + suffix;
+ return PREFIX + PoolingPropertiesTest.CONTROLLER + "." + suffix;
}
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java
index f4cd940c..a81ea68b 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/SerializerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -22,23 +23,23 @@ package org.onap.policy.drools.pooling;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.google.gson.JsonParseException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.message.Message;
import org.onap.policy.drools.pooling.message.Query;
-public class SerializerTest {
+class SerializerTest {
@Test
- public void testSerializer() {
- assertThatCode(() -> new Serializer()).doesNotThrowAnyException();
+ void testSerializer() {
+ assertThatCode(Serializer::new).doesNotThrowAnyException();
}
@Test
- public void testEncodeMsg_testDecodeMsg() throws Exception {
+ void testEncodeMsg_testDecodeMsg() {
Serializer ser = new Serializer();
Query msg = new Query("hostA");
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/DmaapManagerTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/TopicMessageManagerTest.java
index ec554fc9..74098487 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/DmaapManagerTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/TopicMessageManagerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -22,9 +23,10 @@ package org.onap.policy.drools.pooling;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -36,13 +38,13 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
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;
-public class DmaapManagerTest {
+class TopicMessageManagerTest {
private static final String EXPECTED = "expected";
private static final String MY_TOPIC = "my.topic";
@@ -53,14 +55,14 @@ public class DmaapManagerTest {
private boolean gotSources;
private TopicSink sink;
private boolean gotSinks;
- private DmaapManager mgr;
+ private TopicMessageManager mgr;
/**
* Setup.
*
* @throws Exception throws an exception
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
listener = mock(TopicListener.class);
source = mock(TopicSource.class);
@@ -73,86 +75,87 @@ public class DmaapManagerTest {
when(sink.getTopic()).thenReturn(MY_TOPIC);
when(sink.send(any())).thenReturn(true);
- mgr = new DmaapManagerImpl(MY_TOPIC);
+ mgr = new TopicMessageManagerImpl(MY_TOPIC);
}
@Test
- public void testDmaapManager() {
+ void testTopicMessageManager() {
// verify that the init methods were called
assertTrue(gotSources);
assertTrue(gotSinks);
}
- @Test(expected = PoolingFeatureException.class)
- public void testDmaapManager_PoolingEx() throws PoolingFeatureException {
+ @Test
+ void testTopicMessageManager_PoolingEx() {
// force error by having no topics match
when(source.getTopic()).thenReturn("");
- new DmaapManagerImpl(MY_TOPIC);
+ assertThrows(PoolingFeatureException.class, () -> new TopicMessageManagerImpl(MY_TOPIC));
}
- @Test(expected = PoolingFeatureException.class)
- public void testDmaapManager_IllegalArgEx() throws PoolingFeatureException {
+ @Test
+ void testTopicMessageManager_IllegalArgEx() {
// force error
- new DmaapManagerImpl(MY_TOPIC) {
+ assertThrows(PoolingFeatureException.class, () ->
+ new TopicMessageManagerImpl(MY_TOPIC) {
@Override
protected List<TopicSource> getTopicSources() {
throw new IllegalArgumentException(EXPECTED);
}
- };
+ });
}
@Test
- public void testGetTopic() {
+ void testGetTopic() {
assertEquals(MY_TOPIC, mgr.getTopic());
}
- @Test(expected = PoolingFeatureException.class)
- public void testFindTopicSource_NotFound() throws PoolingFeatureException {
+ @Test
+ void testFindTopicSource_NotFound() {
// one item in list, and its topic doesn't match
- new DmaapManagerImpl(MY_TOPIC) {
+ assertThrows(PoolingFeatureException.class, () -> new TopicMessageManagerImpl(MY_TOPIC) {
@Override
protected List<TopicSource> getTopicSources() {
- return Arrays.asList(mock(TopicSource.class));
+ return Collections.singletonList(mock(TopicSource.class));
}
- };
+ });
}
- @Test(expected = PoolingFeatureException.class)
- public void testFindTopicSource_EmptyList() throws PoolingFeatureException {
+ @Test
+ void testFindTopicSource_EmptyList() {
// empty list
- new DmaapManagerImpl(MY_TOPIC) {
+ assertThrows(PoolingFeatureException.class, () -> new TopicMessageManagerImpl(MY_TOPIC) {
@Override
protected List<TopicSource> getTopicSources() {
return Collections.emptyList();
}
- };
+ });
}
- @Test(expected = PoolingFeatureException.class)
- public void testFindTopicSink_NotFound() throws PoolingFeatureException {
+ @Test
+ void testFindTopicSink_NotFound() {
// one item in list, and its topic doesn't match
- new DmaapManagerImpl(MY_TOPIC) {
+ assertThrows(PoolingFeatureException.class, () -> new TopicMessageManagerImpl(MY_TOPIC) {
@Override
protected List<TopicSink> getTopicSinks() {
- return Arrays.asList(mock(TopicSink.class));
+ return Collections.singletonList(mock(TopicSink.class));
}
- };
+ });
}
- @Test(expected = PoolingFeatureException.class)
- public void testFindTopicSink_EmptyList() throws PoolingFeatureException {
+ @Test
+ void testFindTopicSink_EmptyList() {
// empty list
- new DmaapManagerImpl(MY_TOPIC) {
+ assertThrows(PoolingFeatureException.class, () -> new TopicMessageManagerImpl(MY_TOPIC) {
@Override
protected List<TopicSink> getTopicSinks() {
return Collections.emptyList();
}
- };
+ });
}
@Test
- public void testStartPublisher() throws PoolingFeatureException {
+ void testStartPublisher() throws PoolingFeatureException {
mgr.startPublisher();
@@ -165,7 +168,7 @@ public class DmaapManagerTest {
}
@Test
- public void testStopPublisher() throws PoolingFeatureException {
+ void testStopPublisher() {
// not publishing yet, so stopping should have no effect
mgr.stopPublisher(0);
@@ -180,7 +183,7 @@ public class DmaapManagerTest {
}
@Test
- public void testStopPublisher_WithDelay() throws PoolingFeatureException {
+ void testStopPublisher_WithDelay() {
mgr.startPublisher();
@@ -192,7 +195,7 @@ public class DmaapManagerTest {
}
@Test
- public void testStopPublisher_WithDelayInterrupted() throws Exception {
+ void testStopPublisher_WithDelayInterrupted() throws Exception {
mgr.startPublisher();
@@ -219,7 +222,7 @@ public class DmaapManagerTest {
}
@Test
- public void testStartConsumer() {
+ void testStartConsumer() {
// not started yet
verify(source, never()).register(any());
@@ -232,7 +235,7 @@ public class DmaapManagerTest {
}
@Test
- public void testStopConsumer() {
+ void testStopConsumer() {
// not consuming yet, so stopping should have no effect
mgr.stopConsumer(listener);
verify(source, never()).unregister(any());
@@ -250,7 +253,7 @@ public class DmaapManagerTest {
}
@Test
- public void testPublish() throws PoolingFeatureException {
+ void testPublish() throws PoolingFeatureException {
// cannot publish before starting
assertThatThrownBy(() -> mgr.publish(MSG)).as("publish,pre").isInstanceOf(PoolingFeatureException.class);
@@ -271,32 +274,32 @@ public class DmaapManagerTest {
assertThatThrownBy(() -> mgr.publish(MSG)).as("publish,stopped").isInstanceOf(PoolingFeatureException.class);
}
- @Test(expected = PoolingFeatureException.class)
- public void testPublish_SendFailed() throws PoolingFeatureException {
+ @Test
+ void testPublish_SendFailed() {
mgr.startPublisher();
// arrange for send() to fail
when(sink.send(MSG)).thenReturn(false);
- mgr.publish(MSG);
+ assertThrows(PoolingFeatureException.class, () -> mgr.publish(MSG));
}
- @Test(expected = PoolingFeatureException.class)
- public void testPublish_SendEx() throws PoolingFeatureException {
+ @Test
+ void testPublish_SendEx() {
mgr.startPublisher();
// arrange for send() to throw an exception
doThrow(new IllegalStateException(EXPECTED)).when(sink).send(MSG);
- mgr.publish(MSG);
+ assertThrows(PoolingFeatureException.class, () -> mgr.publish(MSG));
}
/**
* Manager with overrides.
*/
- private class DmaapManagerImpl extends DmaapManager {
+ private class TopicMessageManagerImpl extends TopicMessageManager {
- public DmaapManagerImpl(String topic) throws PoolingFeatureException {
+ public TopicMessageManagerImpl(String topic) throws PoolingFeatureException {
super(topic);
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/feature-pooling-dmaap.properties b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/feature-pooling-messages.properties
index 3273a21e..b89e4062 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/feature-pooling-dmaap.properties
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/feature-pooling-messages.properties
@@ -1,4 +1,5 @@
# Copyright 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.
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java
index 5eaeddca..ca47f9c1 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/BucketAssignmentsTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -21,54 +22,54 @@
package org.onap.policy.drools.pooling.message;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.Arrays;
import java.util.SortedSet;
import java.util.TreeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.PoolingFeatureException;
-public class BucketAssignmentsTest {
+class BucketAssignmentsTest {
@Test
- public void testBucketAssignments() {
- assertThatCode(() -> new BucketAssignments()).doesNotThrowAnyException();
+ void testBucketAssignments() {
+ assertThatCode(BucketAssignments::new).doesNotThrowAnyException();
}
@Test
- public void testBucketAssignmentsStringArray() {
+ void testBucketAssignmentsStringArray() {
String[] arr = {"abc", "def"};
BucketAssignments asgn = new BucketAssignments(arr);
assertNotNull(asgn.getHostArray());
- assertEquals(arr.toString(), asgn.getHostArray().toString());
+ assertEquals(Arrays.toString(arr), Arrays.toString(asgn.getHostArray()));
}
@Test
- public void testGetHostArray_testSetHostArray() {
+ void testGetHostArray_testSetHostArray() {
String[] arr = {"abc", "def"};
BucketAssignments asgn = new BucketAssignments(arr);
assertNotNull(asgn.getHostArray());
- assertEquals(arr.toString(), asgn.getHostArray().toString());
+ assertEquals(Arrays.toString(arr), Arrays.toString(asgn.getHostArray()));
String[] arr2 = {"xyz"};
asgn.setHostArray(arr2);
assertNotNull(asgn.getHostArray());
- assertEquals(arr2.toString(), asgn.getHostArray().toString());
+ assertEquals(Arrays.toString(arr2), Arrays.toString(asgn.getHostArray()));
}
@Test
- public void testGetLeader() {
+ void testGetLeader() {
// host array is null
BucketAssignments asgn = new BucketAssignments();
assertNull(asgn.getLeader());
@@ -107,7 +108,7 @@ public class BucketAssignmentsTest {
}
@Test
- public void testHasAssignment() {
+ void testHasAssignment() {
// host array is null
BucketAssignments asgn = new BucketAssignments();
assertFalse(asgn.hasAssignment("abc"));
@@ -146,7 +147,7 @@ public class BucketAssignmentsTest {
}
@Test
- public void testGetAllHosts() {
+ void testGetAllHosts() {
// host array is null
BucketAssignments asgn = new BucketAssignments();
assertEquals("[]", getSortedHosts(asgn).toString());
@@ -183,7 +184,7 @@ public class BucketAssignmentsTest {
}
@Test
- public void testGetAssignedHost() {
+ void testGetAssignedHost() {
// host array is null
BucketAssignments asgn = new BucketAssignments();
assertNull(asgn.getAssignedHost(3));
@@ -218,7 +219,7 @@ public class BucketAssignmentsTest {
}
@Test
- public void testSize() {
+ void testSize() {
// host array is null
BucketAssignments asgn = new BucketAssignments();
assertEquals(0, asgn.size());
@@ -238,7 +239,7 @@ public class BucketAssignmentsTest {
}
@Test
- public void testCheckValidity() throws Exception {
+ void testCheckValidity() throws Exception {
// host array is null
BucketAssignments asgn = new BucketAssignments();
expectException(asgn);
@@ -277,7 +278,7 @@ public class BucketAssignmentsTest {
}
@Test
- public void testHashCode() {
+ void testHashCode() {
// with null assignments
BucketAssignments asgn = new BucketAssignments();
asgn.hashCode();
@@ -303,10 +304,10 @@ public class BucketAssignmentsTest {
}
@Test
- public void testEquals() {
+ void testEquals() {
// null object
BucketAssignments asgn = new BucketAssignments();
- assertNotEquals(asgn, null);
+ assertNotEquals(null, asgn);
// same object
asgn = new BucketAssignments();
@@ -314,7 +315,7 @@ public class BucketAssignmentsTest {
// different class of object
asgn = new BucketAssignments();
- assertNotEquals(asgn, "not an assignment object");
+ assertNotEquals("not an assignment object", asgn);
assertNotEquals(asgn, new BucketAssignments(new String[] {"abc"}));
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/HeartbeatTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/HeartbeatTest.java
index d1a82f4f..142ebbca 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/HeartbeatTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/HeartbeatTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,7 +21,7 @@
package org.onap.policy.drools.pooling.message;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class HeartbeatTest extends SupportBasicMessageTester<Heartbeat> {
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/IdentificationTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/IdentificationTest.java
index 06336b3e..dced372d 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/IdentificationTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/IdentificationTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,16 +21,16 @@
package org.onap.policy.drools.pooling.message;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class IdentificationTest extends SupportMessageWithAssignmentsTester<Identification> {
+class IdentificationTest extends SupportMessageWithAssignmentsTester<Identification> {
public IdentificationTest() {
super(Identification.class);
}
- @Before
+ @BeforeEach
public void setUp() {
setNullAssignments(false);
}
@@ -42,7 +43,7 @@ public class IdentificationTest extends SupportMessageWithAssignmentsTester<Iden
* @throws Exception if an error occurs
*/
@Test
- public final void testJsonEncodeDecode_WithNullAssignments() throws Exception {
+ final void testJsonEncodeDecode_WithNullAssignments() throws Exception {
setNullAssignments(true);
testJsonEncodeDecode();
}
@@ -55,7 +56,7 @@ public class IdentificationTest extends SupportMessageWithAssignmentsTester<Iden
* @throws Exception if an error occurs
*/
@Test
- public void testCheckValidity_NullAssignments() throws Exception {
+ void testCheckValidity_NullAssignments() throws Exception {
// null assignments are OK
Identification msg = makeValidMessage();
msg.setAssignments(null);
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/LeaderTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/LeaderTest.java
index eefd45d4..15d9d338 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/LeaderTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/LeaderTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,16 +21,16 @@
package org.onap.policy.drools.pooling.message;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class LeaderTest extends SupportMessageWithAssignmentsTester<Leader> {
+class LeaderTest extends SupportMessageWithAssignmentsTester<Leader> {
public LeaderTest() {
super(Leader.class);
}
- @Before
+ @BeforeEach
public void setUp() {
setNullAssignments(false);
}
@@ -38,17 +39,16 @@ public class LeaderTest extends SupportMessageWithAssignmentsTester<Leader> {
* The superclass will already invoke testCheckValidity_InvalidFields() to
* verify that things work with a fully populated message. This verifies
* that it also works if the assignments are null.
- *
- * @throws Exception if an error occurs
+ *
*/
@Test
- public void testCheckValidity_InvalidFields_NullAssignments() throws Exception {
+ void testCheckValidity_InvalidFields_NullAssignments() {
// null assignments are invalid
expectCheckValidityFailure(msg -> msg.setAssignments(null));
}
@Test
- public void testCheckValidity_SourceIsNotLeader() throws Exception {
+ void testCheckValidity_SourceIsNotLeader() {
Leader ldr = makeValidMessage();
ldr.setSource("xyz");
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java
index db8cd9f9..cf2cb695 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/MessageTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,19 +21,19 @@
package org.onap.policy.drools.pooling.message;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class MessageTest extends SupportBasicMessageTester<Message> {
+class MessageTest extends SupportBasicMessageTester<Message> {
public MessageTest() {
super(Message.class);
}
@Test
- public void testGetSource_testSetSource() {
+ void testGetSource_testSetSource() {
Message msg = new Message();
msg.setSource("hello");
@@ -45,7 +46,7 @@ public class MessageTest extends SupportBasicMessageTester<Message> {
}
@Test
- public void testGetChannel_testSetChannel() {
+ void testGetChannel_testSetChannel() {
Message msg = new Message();
msg.setChannel("hello");
@@ -58,7 +59,7 @@ public class MessageTest extends SupportBasicMessageTester<Message> {
}
@Test
- public void testCheckValidity_InvalidFields() {
+ void testCheckValidity_InvalidFields() {
// null or empty source
expectCheckValidityFailure_NullOrEmpty((msg, value) -> msg.setSource(value));
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/OfflineTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/OfflineTest.java
index 906733e9..29a7fad1 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/OfflineTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/OfflineTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/QueryTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/QueryTest.java
index 933dddfd..737bcc19 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/QueryTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/QueryTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.java
index 86247835..2fe905a9 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/SupportBasicMessageTester.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.
@@ -20,11 +21,11 @@
package org.onap.policy.drools.pooling.message;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.PoolingFeatureException;
import org.onap.policy.drools.pooling.Serializer;
@@ -188,7 +189,7 @@ public abstract class SupportBasicMessageTester<T extends Message> {
/**
* Makes a message that will pass the validity check. Note: this should use
* the non-default constructor, and the source and channel should be set to
- * {@link VALID_HOST} and {@link VALID_CHANNEL}, respectively.
+ * VALID_HOST and VALID_CHANNEL, respectively.
*
* @return a valid Message
*/
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportMessageWithAssignmentsTester.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/SupportMessageWithAssignmentsTester.java
index bf245feb..3814553f 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/message/SupportMessageWithAssignmentsTester.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/message/SupportMessageWithAssignmentsTester.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,16 +21,20 @@
package org.onap.policy.drools.pooling.message;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.Test;
+import lombok.Getter;
+import lombok.Setter;
+import org.junit.jupiter.api.Test;
/**
* Superclass used to test subclasses of {@link MessageWithAssignments}.
*
* @param <T> type of {@link MessageWithAssignments} subclass that this tests
*/
+@Setter
+@Getter
public abstract class SupportMessageWithAssignmentsTester<T extends MessageWithAssignments>
extends SupportBasicMessageTester<T> {
// values set by makeValidMessage()
@@ -51,23 +56,8 @@ public abstract class SupportMessageWithAssignmentsTester<T extends MessageWithA
super(subclazz);
}
- /**
- * Indicates whether or not {@code null} assignments should be used for the
- * remaining tests.
- *
- * @param nullAssignments {@code true} to use {@code null} assignments,
- * {@code false} otherwise
- */
- public void setNullAssignments(boolean nullAssignments) {
- this.nullAssignments = nullAssignments;
- }
-
- public boolean isNullAssignments() {
- return nullAssignments;
- }
-
@Test
- public void testCheckValidity_InvalidFields() throws Exception {
+ public void testCheckValidity_InvalidFields() {
// null source (i.e., superclass field)
expectCheckValidityFailure(msg -> msg.setSource(null));
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java
index 771f694e..ce9adb9f 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/ActiveStateTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 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,10 +21,10 @@
package org.onap.policy.drools.pooling.state;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
@@ -38,15 +38,15 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.message.BucketAssignments;
import org.onap.policy.drools.pooling.message.Heartbeat;
import org.onap.policy.drools.pooling.message.Leader;
import org.onap.policy.drools.pooling.message.Offline;
import org.onap.policy.drools.pooling.message.Query;
-public class ActiveStateTest extends SupportBasicStateTester {
+class ActiveStateTest extends SupportBasicStateTester {
private ActiveState state;
@@ -54,7 +54,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
* Setup.
*/
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
@@ -62,7 +62,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testStart() {
+ void testStart() {
state.start();
// ensure the timers were created
@@ -74,7 +74,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessHeartbeat_NullHost() {
+ void testProcessHeartbeat_NullHost() {
assertNull(state.process(new Heartbeat()));
assertFalse(state.isMyHeartbeatSeen());
@@ -85,7 +85,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessHeartbeat_MyHost() {
+ void testProcessHeartbeat_MyHost() {
assertNull(state.process(new Heartbeat(MY_HOST, 0L)));
assertTrue(state.isMyHeartbeatSeen());
@@ -96,7 +96,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessHeartbeat_Predecessor() {
+ void testProcessHeartbeat_Predecessor() {
assertNull(state.process(new Heartbeat(HOST2, 0L)));
assertFalse(state.isMyHeartbeatSeen());
@@ -107,7 +107,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessHeartbeat_OtherHost() {
+ void testProcessHeartbeat_OtherHost() {
assertNull(state.process(new Heartbeat(HOST3, 0L)));
assertFalse(state.isMyHeartbeatSeen());
@@ -118,19 +118,19 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessOffline_NullHost() {
+ void testProcessOffline_NullHost() {
// should be ignored
assertNull(state.process(new Offline()));
}
@Test
- public void testProcessOffline_UnassignedHost() {
+ void testProcessOffline_UnassignedHost() {
// HOST4 is not in the assignment list - should be ignored
assertNull(state.process(new Offline(HOST4)));
}
@Test
- public void testProcessOffline_IAmLeader() {
+ void testProcessOffline_IAmLeader() {
// configure the next state
State next = mock(State.class);
when(mgr.goActive()).thenReturn(next);
@@ -148,7 +148,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessOffline_PredecessorIsLeaderNowOffline() {
+ void testProcessOffline_PredecessorIsLeaderNowOffline() {
// configure the next state
State next = mock(State.class);
when(mgr.goActive()).thenReturn(next);
@@ -170,7 +170,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessOffline__PredecessorIsNotLeaderNowOffline() {
+ void testProcessOffline__PredecessorIsNotLeaderNowOffline() {
// I am not the leader, and neither is my predecessor
mgr.startDistributing(new BucketAssignments(new String[] {PREV_HOST, MY_HOST, PREV_HOST2}));
state = new ActiveState(mgr);
@@ -184,7 +184,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessOffline_OtherAssignedHostOffline() {
+ void testProcessOffline_OtherAssignedHostOffline() {
// I am not the leader
mgr.startDistributing(new BucketAssignments(new String[] {PREV_HOST, MY_HOST, HOST1}));
state = new ActiveState(mgr);
@@ -197,7 +197,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader_Invalid() {
+ void testProcessLeader_Invalid() {
Leader msg = new Leader(PREV_HOST, null);
// should stay in the same state, and not start distributing
@@ -212,7 +212,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader_BadLeader() {
+ void testProcessLeader_BadLeader() {
String[] arr = {HOST2, HOST1};
BucketAssignments asgn = new BucketAssignments(arr);
@@ -228,7 +228,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader_GoodLeader() {
+ void testProcessLeader_GoodLeader() {
String[] arr = {HOST2, PREV_HOST, MY_HOST};
BucketAssignments asgn = new BucketAssignments(arr);
@@ -244,7 +244,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testActiveState() {
+ void testActiveState() {
assertEquals(MY_HOST, state.getLeader());
assertEquals(ASGN3, state.getAssignments());
@@ -254,11 +254,11 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testDetmNeighbors() {
+ void testDetmNeighbors() {
// if only one host (i.e., itself)
mgr.startDistributing(new BucketAssignments(new String[] {MY_HOST, MY_HOST}));
state = new ActiveState(mgr);
- assertEquals(null, state.getSuccHost());
+ assertNull(state.getSuccHost());
assertEquals("", state.getPredHost());
// two hosts
@@ -281,7 +281,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testAddTimers_WithPredecessor() {
+ void testAddTimers_WithPredecessor() {
// invoke start() to add the timers
state.start();
@@ -306,7 +306,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testAddTimers_SansPredecessor() {
+ void testAddTimers_SansPredecessor() {
// only one host, thus no predecessor
mgr.startDistributing(new BucketAssignments(new String[] {MY_HOST, MY_HOST}));
state = new ActiveState(mgr);
@@ -330,7 +330,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testAddTimers_HeartbeatGenerator() {
+ void testAddTimers_HeartbeatGenerator() {
// only one host so we only have to look at one heart beat at a time
mgr.startDistributing(new BucketAssignments(new String[] {MY_HOST}));
state = new ActiveState(mgr);
@@ -354,7 +354,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testAddTimers_MyHeartbeatSeen() {
+ void testAddTimers_MyHeartbeatSeen() {
// invoke start() to add the timers
state.start();
@@ -374,7 +374,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testAddTimers_MyHeartbeatMissed() {
+ void testAddTimers_MyHeartbeatMissed() {
// invoke start() to add the timers
state.start();
@@ -396,7 +396,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testAddTimers_PredecessorHeartbeatSeen() {
+ void testAddTimers_PredecessorHeartbeatSeen() {
// invoke start() to add the timers
state.start();
@@ -416,7 +416,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testAddTimers_PredecessorHeartbeatMissed() {
+ void testAddTimers_PredecessorHeartbeatMissed() {
// invoke start() to add the timers
state.start();
@@ -433,7 +433,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testGenHeartbeat_OneHost() {
+ void testGenHeartbeat_OneHost() {
// only one host (i.e., itself)
mgr.startDistributing(new BucketAssignments(new String[] {MY_HOST}));
state = new ActiveState(mgr);
@@ -448,7 +448,7 @@ public class ActiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testGenHeartbeat_MultipleHosts() {
+ void testGenHeartbeat_MultipleHosts() {
state.start();
verify(mgr, times(2)).publish(any(), any());
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java
index 5cc88d3a..51e27738 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/IdleStateTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,15 +21,15 @@
package org.onap.policy.drools.pooling.state;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.message.BucketAssignments;
import org.onap.policy.drools.pooling.message.Heartbeat;
import org.onap.policy.drools.pooling.message.Identification;
@@ -36,14 +37,14 @@ import org.onap.policy.drools.pooling.message.Leader;
import org.onap.policy.drools.pooling.message.Offline;
import org.onap.policy.drools.pooling.message.Query;
-public class IdleStateTest extends SupportBasicStateTester {
+class IdleStateTest extends SupportBasicStateTester {
private IdleState state;
/**
* Setup.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
@@ -51,19 +52,19 @@ public class IdleStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessHeartbeat() {
+ void testProcessHeartbeat() {
assertNull(state.process(new Heartbeat(PREV_HOST, 0L)));
verifyNothingPublished();
}
@Test
- public void testProcessIdentification() {
+ void testProcessIdentification() {
assertNull(state.process(new Identification(PREV_HOST, null)));
verifyNothingPublished();
}
@Test
- public void testProcessLeader() {
+ void testProcessLeader() {
BucketAssignments asgn = new BucketAssignments(new String[] {HOST2, PREV_HOST, MY_HOST});
Leader msg = new Leader(PREV_HOST, asgn);
@@ -76,13 +77,13 @@ public class IdleStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessOffline() {
+ void testProcessOffline() {
assertNull(state.process(new Offline(PREV_HOST)));
verifyNothingPublished();
}
@Test
- public void testProcessQuery() {
+ void testProcessQuery() {
assertNull(state.process(new Query()));
verifyNothingPublished();
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java
index f8f70461..a5ee2d06 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/InactiveStateTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 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,8 +21,8 @@
package org.onap.policy.drools.pooling.state;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -30,14 +30,14 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.message.BucketAssignments;
import org.onap.policy.drools.pooling.message.Identification;
import org.onap.policy.drools.pooling.message.Leader;
import org.onap.policy.drools.pooling.message.Query;
-public class InactiveStateTest extends SupportBasicStateTester {
+class InactiveStateTest extends SupportBasicStateTester {
private InactiveState state;
@@ -46,7 +46,7 @@ public class InactiveStateTest extends SupportBasicStateTester {
*
*/
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
@@ -54,7 +54,7 @@ public class InactiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader() {
+ void testProcessLeader() {
State next = mock(State.class);
when(mgr.goActive()).thenReturn(next);
@@ -67,7 +67,7 @@ public class InactiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader_Invalid() {
+ void testProcessLeader_Invalid() {
Leader msg = new Leader(PREV_HOST, null);
// should stay in the same state, and not start distributing
@@ -78,7 +78,7 @@ public class InactiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessQuery() {
+ void testProcessQuery() {
State next = mock(State.class);
when(mgr.goQuery()).thenReturn(next);
@@ -90,12 +90,12 @@ public class InactiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testGoInatcive() {
+ void testGoInatcive() {
assertNull(state.goInactive());
}
@Test
- public void testStart() {
+ void testStart() {
state.start();
Pair<Long, StateTimerTask> timer = onceTasks.remove();
@@ -110,7 +110,7 @@ public class InactiveStateTest extends SupportBasicStateTester {
}
@Test
- public void testInactiveState() {
+ void testInactiveState() {
/*
* Prove the state is attached to the manager by invoking getHost(), which
* delegates to the manager.
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
index 02cbe491..dbac7619 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/ProcessingStateTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020-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.
@@ -20,11 +21,12 @@
package org.onap.policy.drools.pooling.state;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+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.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -32,8 +34,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.message.BucketAssignments;
import org.onap.policy.drools.pooling.message.Identification;
import org.onap.policy.drools.pooling.message.Leader;
@@ -41,7 +43,7 @@ import org.onap.policy.drools.pooling.message.Message;
import org.onap.policy.drools.pooling.message.Query;
import org.onap.policy.drools.pooling.state.ProcessingState.HostBucket;
-public class ProcessingStateTest extends SupportBasicStateTester {
+class ProcessingStateTest extends SupportBasicStateTester {
private ProcessingState state;
private HostBucket hostBucket;
@@ -49,7 +51,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
/**
* Setup.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
@@ -58,7 +60,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessQuery() {
+ void testProcessQuery() {
State next = mock(State.class);
when(mgr.goQuery()).thenReturn(next);
@@ -70,7 +72,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessingState() {
+ void testProcessingState() {
/*
* Null assignments should be OK.
*/
@@ -102,20 +104,20 @@ public class ProcessingStateTest extends SupportBasicStateTester {
assertEquals(ASGN3, state.getAssignments());
}
- @Test(expected = IllegalArgumentException.class)
- public void testProcessingState_NullLeader() {
+ @Test
+ void testProcessingState_NullLeader() {
when(mgr.getAssignments()).thenReturn(EMPTY_ASGN);
- state = new ProcessingState(mgr, null);
+ assertThrows(NullPointerException.class, () -> state = new ProcessingState(mgr, null));
}
- @Test(expected = IllegalArgumentException.class)
- public void testProcessingState_ZeroLengthHostArray() {
+ @Test
+ void testProcessingState_ZeroLengthHostArray() {
when(mgr.getAssignments()).thenReturn(new BucketAssignments(new String[] {}));
- state = new ProcessingState(mgr, LEADER);
+ assertThrows(IllegalArgumentException.class, () -> state = new ProcessingState(mgr, LEADER));
}
@Test
- public void testGetAssignments() {
+ void testGetAssignments() {
// assignments from constructor
assertEquals(ASGN3, state.getAssignments());
@@ -133,7 +135,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testSetAssignments() {
+ void testSetAssignments() {
state.setAssignments(null);
verify(mgr, never()).startDistributing(any());
@@ -142,7 +144,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testGetLeader() {
+ void testGetLeader() {
// check value from constructor
assertEquals(MY_HOST, state.getLeader());
@@ -154,18 +156,18 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testSetLeader() {
+ void testSetLeader() {
state.setLeader(MY_HOST);
assertEquals(MY_HOST, state.getLeader());
}
- @Test(expected = NullPointerException.class)
- public void testSetLeader_Null() {
- state.setLeader(null);
+ @Test
+ void testSetLeader_Null() {
+ assertThrows(NullPointerException.class, () -> state.setLeader(null));
}
@Test
- public void testIsLeader() {
+ void testIsLeader() {
state.setLeader(MY_HOST);
assertTrue(state.isLeader());
@@ -174,7 +176,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testBecomeLeader() {
+ void testBecomeLeader() {
State next = mock(State.class);
when(mgr.goActive()).thenReturn(next);
@@ -186,14 +188,15 @@ public class ProcessingStateTest extends SupportBasicStateTester {
verify(mgr).goActive();
}
- @Test(expected = IllegalArgumentException.class)
- public void testBecomeLeader_NotFirstAlive() {
+ @Test
+ void testBecomeLeader_NotFirstAlive() {
// alive list contains something before my host name
- state.becomeLeader(sortHosts(PREV_HOST, MY_HOST));
+ var sortedHosts = sortHosts(PREV_HOST, MY_HOST);
+ assertThrows(IllegalArgumentException.class, () -> state.becomeLeader(sortedHosts));
}
@Test
- public void testMakeLeader() throws Exception {
+ void testMakeLeader() throws Exception {
state.becomeLeader(sortHosts(MY_HOST, HOST2));
Leader msg = captureAdminMessage(Leader.class);
@@ -213,14 +216,14 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testMakeAssignments() throws Exception {
+ void testMakeAssignments() throws Exception {
state.becomeLeader(sortHosts(MY_HOST, HOST2));
captureAssignments().checkValidity();
}
@Test
- public void testMakeBucketArray_NullAssignments() {
+ void testMakeBucketArray_NullAssignments() {
when(mgr.getAssignments()).thenReturn(null);
state = new ProcessingState(mgr, MY_HOST);
state.becomeLeader(sortHosts(MY_HOST));
@@ -229,11 +232,11 @@ public class ProcessingStateTest extends SupportBasicStateTester {
assertEquals(BucketAssignments.MAX_BUCKETS, arr.length);
- assertTrue(Arrays.asList(arr).stream().allMatch(host -> MY_HOST.equals(host)));
+ assertTrue(Arrays.stream(arr).allMatch(MY_HOST::equals));
}
@Test
- public void testMakeBucketArray_ZeroAssignments() {
+ void testMakeBucketArray_ZeroAssignments() {
// bucket assignment with a zero-length array
state.setAssignments(new BucketAssignments(new String[0]));
@@ -243,11 +246,11 @@ public class ProcessingStateTest extends SupportBasicStateTester {
assertEquals(BucketAssignments.MAX_BUCKETS, arr.length);
- assertTrue(Arrays.asList(arr).stream().allMatch(host -> MY_HOST.equals(host)));
+ assertTrue(Arrays.stream(arr).allMatch(MY_HOST::equals));
}
@Test
- public void testMakeBucketArray() {
+ void testMakeBucketArray() {
/*
* All hosts are still alive, so it should have the exact same assignments as it
* had to start.
@@ -262,7 +265,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testRemoveExcessHosts() {
+ void testRemoveExcessHosts() {
/*
* All hosts are still alive, plus some others.
*/
@@ -274,7 +277,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testAddIndicesToHostBuckets() {
+ void testAddIndicesToHostBuckets() {
// some are null, some hosts are no longer alive
String[] asgn = {null, MY_HOST, HOST3, null, HOST4, HOST1, HOST2};
@@ -287,7 +290,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testAssignNullBuckets() {
+ void testAssignNullBuckets() {
/*
* Ensure buckets are assigned to the host with the fewest buckets.
*/
@@ -301,7 +304,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testRebalanceBuckets() {
+ void testRebalanceBuckets() {
/*
* Some are very lopsided.
*/
@@ -315,7 +318,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testHostBucketRemove_testHostBucketAdd_testHostBucketSize() {
+ void testHostBucketRemove_testHostBucketAdd_testHostBucketSize() {
assertEquals(0, hostBucket.size());
hostBucket.add(20);
@@ -344,7 +347,7 @@ public class ProcessingStateTest extends SupportBasicStateTester {
}
@Test
- public void testHostBucketCompareTo() {
+ void testHostBucketCompareTo() {
HostBucket hb1 = new HostBucket(PREV_HOST);
HostBucket hb2 = new HostBucket(MY_HOST);
@@ -381,13 +384,13 @@ public class ProcessingStateTest extends SupportBasicStateTester {
assertTrue(hb2.compareTo(hb1) > 0);
}
- @Test(expected = UnsupportedOperationException.class)
- public void testHostBucketHashCode() {
- hostBucket.hashCode();
+ @Test
+ void testHostBucketHashCode() {
+ assertThrows(UnsupportedOperationException.class, () -> hostBucket.hashCode());
}
- @Test(expected = UnsupportedOperationException.class)
- public void testHostBucketEquals() {
- hostBucket.equals(hostBucket);
+ @Test
+ void testHostBucketEquals() {
+ assertThrows(UnsupportedOperationException.class, () -> hostBucket.equals(hostBucket));
}
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java
index 70abb96a..aae6e056 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/QueryStateTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 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,10 +21,10 @@
package org.onap.policy.drools.pooling.state;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -33,14 +33,14 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.message.BucketAssignments;
import org.onap.policy.drools.pooling.message.Identification;
import org.onap.policy.drools.pooling.message.Leader;
import org.onap.policy.drools.pooling.message.Offline;
-public class QueryStateTest extends SupportBasicStateTester {
+class QueryStateTest extends SupportBasicStateTester {
private QueryState state;
@@ -48,7 +48,7 @@ public class QueryStateTest extends SupportBasicStateTester {
* Setup.
*/
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
@@ -56,12 +56,12 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testGoQuery() {
+ void testGoQuery() {
assertNull(state.goQuery());
}
@Test
- public void testStart() {
+ void testStart() {
state.start();
Pair<Long, StateTimerTask> timer = onceTasks.remove();
@@ -71,7 +71,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessIdentification_SameSource() {
+ void testProcessIdentification_SameSource() {
String[] arr = {HOST2, PREV_HOST, MY_HOST};
BucketAssignments asgn = new BucketAssignments(arr);
@@ -83,7 +83,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessIdentification_DiffSource() {
+ void testProcessIdentification_DiffSource() {
String[] arr = {HOST2, PREV_HOST, MY_HOST};
BucketAssignments asgn = new BucketAssignments(arr);
@@ -97,7 +97,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader_Invalid() {
+ void testProcessLeader_Invalid() {
Leader msg = new Leader(PREV_HOST, null);
// should stay in the same state, and not start distributing
@@ -112,12 +112,12 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader_SameLeader() {
+ void testProcessLeader_SameLeader() {
String[] arr = {HOST2, PREV_HOST, MY_HOST};
BucketAssignments asgn = new BucketAssignments(arr);
// identify a leader that's better than my host
- assertEquals(null, state.process(new Identification(PREV_HOST, asgn)));
+ assertNull(state.process(new Identification(PREV_HOST, asgn)));
// now send a Leader message for that leader
Leader msg = new Leader(PREV_HOST, asgn);
@@ -134,7 +134,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader_BetterLeaderWithAssignment() {
+ void testProcessLeader_BetterLeaderWithAssignment() {
String[] arr = {HOST2, PREV_HOST, MY_HOST};
BucketAssignments asgn = new BucketAssignments(arr);
Leader msg = new Leader(PREV_HOST, asgn);
@@ -149,7 +149,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader_BetterLeaderWithoutAssignment() {
+ void testProcessLeader_BetterLeaderWithoutAssignment() {
String[] arr = {HOST2, PREV_HOST, HOST1};
BucketAssignments asgn = new BucketAssignments(arr);
Leader msg = new Leader(PREV_HOST, asgn);
@@ -164,7 +164,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessLeader_NotABetterLeader() {
+ void testProcessLeader_NotABetterLeader() {
// no assignments yet
mgr.startDistributing(null);
state = new QueryState(mgr);
@@ -191,19 +191,19 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessOffline_NullHost() {
+ void testProcessOffline_NullHost() {
assertNull(state.process(new Offline()));
assertEquals(MY_HOST, state.getLeader());
}
@Test
- public void testProcessOffline_SameHost() {
+ void testProcessOffline_SameHost() {
assertNull(state.process(new Offline(MY_HOST)));
assertEquals(MY_HOST, state.getLeader());
}
@Test
- public void testProcessOffline_DiffHost() {
+ void testProcessOffline_DiffHost() {
BucketAssignments asgn = new BucketAssignments(new String[] {PREV_HOST, HOST1});
mgr.startDistributing(asgn);
state = new QueryState(mgr);
@@ -226,7 +226,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testQueryState() {
+ void testQueryState() {
/*
* Prove the state is attached to the manager by invoking getHost(), which
* delegates to the manager.
@@ -235,7 +235,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testAwaitIdentification_MissingSelfIdent() {
+ void testAwaitIdentification_MissingSelfIdent() {
state.start();
Pair<Long, StateTimerTask> timer = onceTasks.remove();
@@ -258,7 +258,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testAwaitIdentification_Leader() {
+ void testAwaitIdentification_Leader() {
state.start();
state.process(new Identification(MY_HOST, null));
@@ -279,7 +279,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testAwaitIdentification_HasAssignment() {
+ void testAwaitIdentification_HasAssignment() {
// not the leader, but has an assignment
BucketAssignments asgn = new BucketAssignments(new String[] {PREV_HOST, MY_HOST, HOST2});
mgr.startDistributing(asgn);
@@ -310,7 +310,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testAwaitIdentification_NoAssignment() {
+ void testAwaitIdentification_NoAssignment() {
// not the leader and no assignment
BucketAssignments asgn = new BucketAssignments(new String[] {HOST1, HOST2});
mgr.startDistributing(asgn);
@@ -338,7 +338,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testRecordInfo_NullSource() {
+ void testRecordInfo_NullSource() {
state.setAssignments(ASGN3);
state.setLeader(MY_HOST);
@@ -353,7 +353,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testRecordInfo_SourcePreceedsMyHost() {
+ void testRecordInfo_SourcePreceedsMyHost() {
state.setAssignments(ASGN3);
state.setLeader(MY_HOST);
@@ -368,7 +368,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testRecordInfo_SourceFollowsMyHost() {
+ void testRecordInfo_SourceFollowsMyHost() {
mgr.startDistributing(null);
state.setLeader(MY_HOST);
@@ -383,7 +383,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testRecordInfo_NewIsNull() {
+ void testRecordInfo_NewIsNull() {
state.setAssignments(ASGN3);
state.process(new Identification(HOST1, null));
@@ -391,7 +391,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testRecordInfo_NewIsEmpty() {
+ void testRecordInfo_NewIsEmpty() {
state.setAssignments(ASGN3);
state.process(new Identification(PREV_HOST, new BucketAssignments()));
@@ -399,7 +399,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testRecordInfo_OldIsNull() {
+ void testRecordInfo_OldIsNull() {
mgr.startDistributing(null);
BucketAssignments asgn = new BucketAssignments(new String[] {HOST1, HOST2});
@@ -409,7 +409,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testRecordInfo_OldIsEmpty() {
+ void testRecordInfo_OldIsEmpty() {
state.setAssignments(new BucketAssignments());
BucketAssignments asgn = new BucketAssignments(new String[] {HOST1, HOST2});
@@ -419,7 +419,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testRecordInfo_NewLeaderPreceedsOld() {
+ void testRecordInfo_NewLeaderPreceedsOld() {
state.setAssignments(ASGN3);
state.setLeader(MY_HOST);
@@ -430,7 +430,7 @@ public class QueryStateTest extends SupportBasicStateTester {
}
@Test
- public void testRecordInfo_NewLeaderSucceedsOld() {
+ void testRecordInfo_NewLeaderSucceedsOld() {
state.setAssignments(ASGN3);
state.setLeader(MY_HOST);
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java
index 3d64687f..1a85304f 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/StartStateTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 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,9 +21,9 @@
package org.onap.policy.drools.pooling.state;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -33,15 +33,15 @@ import static org.mockito.Mockito.when;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.message.Heartbeat;
import org.onap.policy.drools.pooling.message.Identification;
import org.onap.policy.drools.pooling.message.Leader;
import org.onap.policy.drools.pooling.message.Offline;
import org.onap.policy.drools.pooling.message.Query;
-public class StartStateTest extends SupportBasicStateTester {
+class StartStateTest extends SupportBasicStateTester {
private StartState state;
@@ -49,7 +49,7 @@ public class StartStateTest extends SupportBasicStateTester {
* Setup.
*/
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
@@ -57,7 +57,7 @@ public class StartStateTest extends SupportBasicStateTester {
}
@Test
- public void testStart() {
+ void testStart() {
state.start();
Pair<String, Heartbeat> msg = capturePublishedMessage(Heartbeat.class);
@@ -75,11 +75,11 @@ public class StartStateTest extends SupportBasicStateTester {
assertEquals(STD_INTER_HEARTBEAT_MS, generator.getMiddle().longValue());
// invoke the task - it should generate another heartbeat
- assertEquals(null, generator.getRight().fire());
+ assertNull(generator.getRight().fire());
verify(mgr, times(2)).publish(MY_HOST, msg.getRight());
// and again
- assertEquals(null, generator.getRight().fire());
+ assertNull(generator.getRight().fire());
verify(mgr, times(3)).publish(MY_HOST, msg.getRight());
@@ -100,7 +100,7 @@ public class StartStateTest extends SupportBasicStateTester {
}
@Test
- public void testStartStatePoolingManager() {
+ void testStartStatePoolingManager() {
/*
* Prove the state is attached to the manager by invoking getHost(), which
* delegates to the manager.
@@ -109,7 +109,7 @@ public class StartStateTest extends SupportBasicStateTester {
}
@Test
- public void testStartStateState() {
+ void testStartStateState() {
// create a new state from the current state
state = new StartState(mgr);
@@ -121,7 +121,7 @@ public class StartStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessHeartbeat() {
+ void testProcessHeartbeat() {
Heartbeat msg = new Heartbeat();
// no matching data in heart beat
@@ -153,27 +153,27 @@ public class StartStateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessIdentification() {
+ void testProcessIdentification() {
assertNull(state.process(new Identification(MY_HOST, null)));
}
@Test
- public void testProcessLeader() {
+ void testProcessLeader() {
assertNull(state.process(new Leader(MY_HOST, null)));
}
@Test
- public void testProcessOffline() {
+ void testProcessOffline() {
assertNull(state.process(new Offline(HOST1)));
}
@Test
- public void testProcessQuery() {
+ void testProcessQuery() {
assertNull(state.process(new Query()));
}
@Test
- public void testGetHbTimestampMs() {
+ void testGetHbTimestampMs() {
long tcurrent = System.currentTimeMillis();
assertTrue(new StartState(mgr).getHbTimestampMs() >= tcurrent);
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java
index 87868a76..cfae6f3c 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/StateTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -21,18 +22,18 @@
package org.onap.policy.drools.pooling.state;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.pooling.CancellableScheduledTask;
import org.onap.policy.drools.pooling.PoolingManager;
import org.onap.policy.drools.pooling.message.BucketAssignments;
@@ -42,14 +43,14 @@ import org.onap.policy.drools.pooling.message.Leader;
import org.onap.policy.drools.pooling.message.Offline;
import org.onap.policy.drools.pooling.message.Query;
-public class StateTest extends SupportBasicStateTester {
+class StateTest extends SupportBasicStateTester {
private State state;
/**
* Setup.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
@@ -57,7 +58,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testStatePoolingManager() {
+ void testStatePoolingManager() {
/*
* Prove the state is attached to the manager by invoking getHost(), which
* delegates to the manager.
@@ -66,7 +67,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testStateState() {
+ void testStateState() {
// allocate a new state, copying from the old state
state = new MyState(mgr);
@@ -78,7 +79,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testCancelTimers() {
+ void testCancelTimers() {
int delay = 100;
int initDelay = 200;
@@ -122,12 +123,12 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testStart() {
+ void testStart() {
assertThatCode(() -> state.start()).doesNotThrowAnyException();
}
@Test
- public void testGoStart() {
+ void testGoStart() {
State next = mock(State.class);
when(mgr.goStart()).thenReturn(next);
@@ -136,7 +137,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testGoQuery() {
+ void testGoQuery() {
State next = mock(State.class);
when(mgr.goQuery()).thenReturn(next);
@@ -145,7 +146,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testGoActive_WithAssignment() {
+ void testGoActive_WithAssignment() {
State act = mock(State.class);
State inact = mock(State.class);
@@ -161,7 +162,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testGoActive_WithoutAssignment() {
+ void testGoActive_WithoutAssignment() {
State act = mock(State.class);
State inact = mock(State.class);
@@ -177,7 +178,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testGoActive_NullAssignment() {
+ void testGoActive_NullAssignment() {
State act = mock(State.class);
State inact = mock(State.class);
@@ -190,7 +191,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testGoInactive() {
+ void testGoInactive() {
State next = mock(State.class);
when(mgr.goInactive()).thenReturn(next);
@@ -199,28 +200,28 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessHeartbeat() {
+ void testProcessHeartbeat() {
assertNull(state.process(new Heartbeat()));
}
@Test
- public void testProcessIdentification() {
+ void testProcessIdentification() {
assertNull(state.process(new Identification()));
}
@Test
- public void testProcessLeader() {
+ void testProcessLeader() {
String[] arr = {HOST2, HOST1};
BucketAssignments asgn = new BucketAssignments(arr);
Leader msg = new Leader(HOST1, asgn);
// should ignore it
- assertEquals(null, state.process(msg));
+ assertNull(state.process(msg));
verify(mgr).startDistributing(asgn);
}
@Test
- public void testProcessLeader_Invalid() {
+ void testProcessLeader_Invalid() {
Leader msg = new Leader(PREV_HOST, null);
// should stay in the same state, and not start distributing
@@ -231,24 +232,24 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testIsValidLeader_NullAssignment() {
+ void testIsValidLeader_NullAssignment() {
assertFalse(state.isValid(new Leader(PREV_HOST, null)));
}
@Test
- public void testIsValidLeader_NullSource() {
+ void testIsValidLeader_NullSource() {
String[] arr = {HOST2, PREV_HOST, MY_HOST};
BucketAssignments asgn = new BucketAssignments(arr);
assertFalse(state.isValid(new Leader(null, asgn)));
}
@Test
- public void testIsValidLeader_EmptyAssignment() {
+ void testIsValidLeader_EmptyAssignment() {
assertFalse(state.isValid(new Leader(PREV_HOST, new BucketAssignments())));
}
@Test
- public void testIsValidLeader_FromSelf() {
+ void testIsValidLeader_FromSelf() {
String[] arr = {HOST2, MY_HOST};
BucketAssignments asgn = new BucketAssignments(arr);
@@ -256,7 +257,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testIsValidLeader_WrongLeader() {
+ void testIsValidLeader_WrongLeader() {
String[] arr = {HOST2, HOST3};
BucketAssignments asgn = new BucketAssignments(arr);
@@ -264,7 +265,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testIsValidLeader() {
+ void testIsValidLeader() {
String[] arr = {HOST2, HOST1};
BucketAssignments asgn = new BucketAssignments(arr);
@@ -272,17 +273,17 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testProcessOffline() {
+ void testProcessOffline() {
assertNull(state.process(new Offline()));
}
@Test
- public void testProcessQuery() {
+ void testProcessQuery() {
assertNull(state.process(new Query()));
}
@Test
- public void testPublishIdentification() {
+ void testPublishIdentification() {
Identification msg = new Identification();
state.publish(msg);
@@ -290,7 +291,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testPublishLeader() {
+ void testPublishLeader() {
Leader msg = new Leader();
state.publish(msg);
@@ -298,7 +299,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testPublishOffline() {
+ void testPublishOffline() {
Offline msg = new Offline();
state.publish(msg);
@@ -306,7 +307,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testPublishQuery() {
+ void testPublishQuery() {
Query msg = new Query();
state.publish(msg);
@@ -314,7 +315,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testPublishStringHeartbeat() {
+ void testPublishStringHeartbeat() {
String chnl = "channelH";
Heartbeat msg = new Heartbeat();
@@ -324,7 +325,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testStartDistributing() {
+ void testStartDistributing() {
BucketAssignments asgn = new BucketAssignments();
state.startDistributing(asgn);
@@ -332,14 +333,14 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testStartDistributing_NullAssignments() {
+ void testStartDistributing_NullAssignments() {
state.startDistributing(null);
verify(mgr, never()).startDistributing(any());
}
@Test
- public void testSchedule() {
+ void testSchedule() {
int delay = 100;
StateTimerTask task = mock(StateTimerTask.class);
@@ -361,7 +362,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testScheduleWithFixedDelay() {
+ void testScheduleWithFixedDelay() {
int initdel = 100;
int delay = 200;
@@ -384,7 +385,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testMissedHeartbeat() {
+ void testMissedHeartbeat() {
State next = mock(State.class);
when(mgr.goStart()).thenReturn(next);
@@ -399,7 +400,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testInternalTopicFailed() {
+ void testInternalTopicFailed() {
State next = mock(State.class);
when(mgr.goInactive()).thenReturn(next);
@@ -414,7 +415,7 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testMakeHeartbeat() {
+ void testMakeHeartbeat() {
long timestamp = 30000L;
Heartbeat msg = state.makeHeartbeat(timestamp);
@@ -423,40 +424,40 @@ public class StateTest extends SupportBasicStateTester {
}
@Test
- public void testMakeIdentification() {
+ void testMakeIdentification() {
Identification ident = state.makeIdentification();
assertEquals(MY_HOST, ident.getSource());
assertEquals(ASGN3, ident.getAssignments());
}
@Test
- public void testMakeOffline() {
+ void testMakeOffline() {
Offline msg = state.makeOffline();
assertEquals(MY_HOST, msg.getSource());
}
@Test
- public void testMakeQuery() {
+ void testMakeQuery() {
Query msg = state.makeQuery();
assertEquals(MY_HOST, msg.getSource());
}
@Test
- public void testGetHost() {
+ void testGetHost() {
assertEquals(MY_HOST, state.getHost());
}
@Test
- public void testGetTopic() {
+ void testGetTopic() {
assertEquals(MY_TOPIC, state.getTopic());
}
/**
* State used for testing purposes, with abstract methods implemented.
*/
- private class MyState extends State {
+ private static class MyState extends State {
public MyState(PoolingManager mgr) {
super(mgr);
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/SupportBasicStateTester.java b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/SupportBasicStateTester.java
index 18d77ba7..8f2c9160 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/state/SupportBasicStateTester.java
+++ b/feature-pooling-messages/src/test/java/org/onap/policy/drools/pooling/state/SupportBasicStateTester.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 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 +21,7 @@
package org.onap.policy.drools.pooling.state;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
diff --git a/feature-pooling-dmaap/src/test/resources/logback-test.xml b/feature-pooling-messages/src/test/resources/logback-test.xml
index 45d8201d..45d8201d 100644
--- a/feature-pooling-dmaap/src/test/resources/logback-test.xml
+++ b/feature-pooling-messages/src/test/resources/logback-test.xml
diff --git a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionAdditionalTest.java b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionAdditionalTest.java
index 7a32e549..f567c593 100644
--- a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionAdditionalTest.java
+++ b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionAdditionalTest.java
@@ -3,6 +3,7 @@
* feature-test-transaction
* ================================================================================
* Copyright (C) 2017-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.
@@ -20,10 +21,10 @@
package org.onap.policy.drools.testtransaction;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+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.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
@@ -40,13 +41,13 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.core.PolicyContainer;
import org.onap.policy.drools.system.PolicyController;
-public class TestTransactionAdditionalTest {
+class TestTransactionAdditionalTest {
private static final int MAX_SLEEP_COUNT = 3;
private static final String EXPECTED = "expected exception";
@@ -56,7 +57,7 @@ public class TestTransactionAdditionalTest {
private static final String SESSION1 = "session-a";
private static final String SESSION2 = "session-b";
private static final List<String> sessions = Arrays.asList(SESSION1, SESSION2);
- private static final List<Object> facts = Arrays.asList(0L);
+ private static final List<Object> facts = List.of(0L);
private Thread theThread;
private PolicyController controller;
@@ -76,7 +77,7 @@ public class TestTransactionAdditionalTest {
/**
* Initialize objects for each test.
*/
- @Before
+ @BeforeEach
public void setUp() {
theThread = mock(Thread.class);
controller = mock(PolicyController.class);
@@ -118,12 +119,12 @@ public class TestTransactionAdditionalTest {
}
@Test
- public void testTestTransactionImpl() {
+ void testTestTransactionImpl() {
assertNotNull(TestTransactionConstants.getManager());
}
@Test
- public void testTestTransactionImplRegister_testTestTransactionImplUnregister() {
+ void testTestTransactionImplRegister_testTestTransactionImplUnregister() {
task = mock(TtControllerTask.class);
when(task.isAlive()).thenReturn(true);
name2task.put(CONTROLLER1, task);
@@ -162,7 +163,7 @@ public class TestTransactionAdditionalTest {
}
@Test
- public void testTestTransactionControllerTaskFactory() throws Exception {
+ void testTestTransactionControllerTaskFactory() throws Exception {
task = new TtControllerTask(controller) {
@Override
protected Thread makeThread(Runnable action) {
@@ -170,7 +171,7 @@ public class TestTransactionAdditionalTest {
}
@Override
- protected void joinThread(long waitTimeMs) throws InterruptedException {
+ protected void joinThread(long waitTimeMs) {
// do nothing
}
};
@@ -180,7 +181,7 @@ public class TestTransactionAdditionalTest {
}
@Test
- public void testTestTransactionControllerTask() {
+ void testTestTransactionControllerTask() {
assertEquals(task, theAction);
assertTrue(task.isAlive());
assertEquals(controller, task.getController());
@@ -190,17 +191,17 @@ public class TestTransactionAdditionalTest {
}
@Test
- public void testTestTransactionControllerTaskGetController() {
+ void testTestTransactionControllerTaskGetController() {
assertEquals(controller, task.getController());
}
@Test
- public void testTestTransactionControllerTaskGetThread() {
+ void testTestTransactionControllerTaskGetThread() {
assertEquals(theThread, task.getThread());
}
@Test
- public void testTestTransactionControllerTaskStop() throws Exception {
+ void testTestTransactionControllerTaskStop() {
task.stop();
assertFalse(task.isAlive());
verify(theThread).interrupt();
@@ -222,7 +223,7 @@ public class TestTransactionAdditionalTest {
}
@Test
- public void testTestTransactionControllerTaskRun() {
+ void testTestTransactionControllerTaskRun() {
task.run();
assertFalse(task.isAlive());
verify(theThread, never()).interrupt();
@@ -338,7 +339,7 @@ public class TestTransactionAdditionalTest {
}
@Test
- public void testTestTransactionControllerTaskInjectTxIntoSessions() {
+ void testTestTransactionControllerTaskInjectTxIntoSessions() {
task.run();
verify(container, times(MAX_SLEEP_COUNT * sessions.size())).insert(anyString(), any(EventObject.class));
@@ -356,7 +357,7 @@ public class TestTransactionAdditionalTest {
}
@Test
- public void testTestTransactionControllerTaskToString() {
+ void testTestTransactionControllerTaskToString() {
assertTrue(task.toString().startsWith("TTControllerTask ["));
}
diff --git a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionFeatureTest.java b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionFeatureTest.java
index 6bb09903..a7b213bb 100644
--- a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionFeatureTest.java
+++ b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionFeatureTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,21 +21,21 @@
package org.onap.policy.drools.testtransaction;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+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.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.system.PolicyController;
-public class TestTransactionFeatureTest {
+class TestTransactionFeatureTest {
private AtomicInteger regCount;
private AtomicInteger unregCount;
@@ -46,7 +47,7 @@ public class TestTransactionFeatureTest {
/**
* Initialize objects for each test.
*/
- @Before
+ @BeforeEach
public void setUp() {
regCount = new AtomicInteger(0);
unregCount = new AtomicInteger(0);
@@ -75,34 +76,34 @@ public class TestTransactionFeatureTest {
}
@Test
- public void testAfterStart() {
+ void testAfterStart() {
// try each combination of alive, locked, and brained
checkCombos(regCount, ctlr -> feat.afterStart(ctlr));
}
@Test
- public void testAfterLock() {
+ void testAfterLock() {
checkSimple(unregCount, ctlr -> feat.afterLock(ctlr));
}
@Test
- public void testAfterUnlock() {
+ void testAfterUnlock() {
// try each combination of alive, locked, and brained
checkCombos(regCount, ctlr -> feat.afterUnlock(ctlr));
}
@Test
- public void testBeforeStop() {
+ void testBeforeStop() {
checkSimple(unregCount, ctlr -> feat.beforeStop(ctlr));
}
@Test
- public void testGetSequenceNumber() {
+ void testGetSequenceNumber() {
assertEquals(1000, feat.getSequenceNumber());
}
@Test
- public void testGetTestTransMgr() {
+ void testGetTestTransMgr() {
assertNotNull(new TestTransactionFeature().getTestTransMgr());
}
diff --git a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java
index f8a8cc20..a1fd2738 100644
--- a/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java
+++ b/feature-test-transaction/src/test/java/org/onap/policy/drools/testtransaction/TestTransactionTest.java
@@ -3,6 +3,7 @@
* feature-test-transaction
* ================================================================================
* Copyright (C) 2017-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.
@@ -20,8 +21,9 @@
package org.onap.policy.drools.testtransaction;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.IOException;
import java.nio.file.Files;
@@ -31,8 +33,8 @@ import java.util.Properties;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.properties.DroolsPropertyConstants;
import org.onap.policy.drools.system.PolicyController;
@@ -52,15 +54,14 @@ public class TestTransactionTest {
TEST_CONTROLLER_NAME + "-controller.properties.bak";
/** logger. */
- private static Logger logger = LoggerFactory.getLogger(TestTransactionTest.class);
+ private static final Logger logger = LoggerFactory.getLogger(TestTransactionTest.class);
/**
* Start up.
*
- * @throws IOException exception
*/
- @BeforeClass
- public static void startUp() throws IOException {
+ @BeforeAll
+ public static void startUp() {
logger.info("enter");
cleanUpWorkingDir();
@@ -70,7 +71,7 @@ public class TestTransactionTest {
}
@Test
- public void testRegisterUnregister() throws InterruptedException {
+ void testRegisterUnregister() throws InterruptedException {
final Properties controllerProperties = new Properties();
controllerProperties.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
final PolicyController controller =
@@ -80,7 +81,7 @@ public class TestTransactionTest {
CountDownLatch latch = new CountDownLatch(1);
- // use our own impl so we can decrement the latch when run() completes
+ // use our own impl, so we can decrement the latch when run() completes
TtImpl impl = new TtImpl() {
@Override
protected TtControllerTask makeControllerTask(PolicyController controller) {
@@ -104,7 +105,7 @@ public class TestTransactionTest {
impl.unregister(controller);
Thread ttThread = getThread(latch, "tt-controller-task-" + TEST_CONTROLLER_NAME);
- assertEquals(null, ttThread);
+ assertNull(ttThread);
}
/**
diff --git a/packages/docker/src/main/docker/pdpd-entrypoint.sh b/packages/docker/src/main/docker/pdpd-entrypoint.sh
index 112d3cb4..2caca628 100644
--- a/packages/docker/src/main/docker/pdpd-entrypoint.sh
+++ b/packages/docker/src/main/docker/pdpd-entrypoint.sh
@@ -2,6 +2,7 @@
# ########################################################################
# Copyright 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.
@@ -117,13 +118,6 @@ function security {
cp -f "${POLICY_INSTALL_INIT}"/policy-truststore "${POLICY_HOME}"/etc/ssl
fi
fi
-
- if [ -f "${POLICY_INSTALL_INIT}"/aaf-cadi.keyfile ]; then
- if ! cmp -s "${POLICY_INSTALL_INIT}"/aaf-cadi.keyfile "${POLICY_HOME}"/config/aaf-cadi.keyfile; then
- echo "overriding aaf-cadi.keyfile"
- cp -f "${POLICY_INSTALL_INIT}"/aaf-cadi.keyfile "${POLICY_HOME}"/config/aaf-cadi.keyfile
- fi
- fi
}
function serverConfig {
diff --git a/packages/install/pom.xml b/packages/install/pom.xml
index 45f15b72..a79aa0ee 100644
--- a/packages/install/pom.xml
+++ b/packages/install/pom.xml
@@ -4,6 +4,7 @@
================================================================================
Copyright (C) 2017, 2022 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
+ 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.
@@ -40,6 +41,7 @@
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
@@ -93,7 +95,7 @@
</dependency>
<dependency>
<groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>feature-pooling-dmaap</artifactId>
+ <artifactId>feature-pooling-messages</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
diff --git a/packages/install/src/files/base.conf b/packages/install/src/files/base.conf
index 24d95a76..3b447647 100644
--- a/packages/install/src/files/base.conf
+++ b/packages/install/src/files/base.conf
@@ -4,7 +4,7 @@
# ================================================================================
# Copyright (C) 2017-2022 AT&T Intellectual Property. All rights reserved.
# Modifications Copyright (C) 2020 Bell Canada.
-# Modifications Copyright (C) 2022 Nordix Foundation.
+# 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.
@@ -87,13 +87,6 @@ JDBC_URL=
# add optional JDBC options for the connector to use
JDBC_OPTS=
-# AAF
-
-AAF=false
-AAF_NAMESPACE=org.onap.policy
-AAF_HOST=aaf-onap-test.osaaf.org
-CADI_KEYFILE=/opt/app/policy/config/aaf-cadi.keyfile
-
# Prometheus
PROMETHEUS=false
@@ -102,7 +95,7 @@ PROMETHEUS=false
HTTP_SERVER_HTTPS=false
-# PDP-D DMaaP configuration channel
+# PDP-D Message Broker configuration channel
PDPD_CONFIGURATION_TOPIC=PDPD-CONFIGURATION
PDPD_CONFIGURATION_API_KEY=
@@ -139,7 +132,7 @@ PDP_CLIENT_USERNAME=
PDP_CLIENT_PASSWORD=
PDP_ENVIRONMENT=
-# DCAE DMaaP
+# DCAE Message Broker
DCAE_TOPIC=
DCAE_SERVERS=
@@ -147,8 +140,8 @@ DCAE_CONSUMER_GROUP=
# Open DMaaP
-DMAAP_SERVERS=
-DMAAP_HTTPS=true
+# DMAAP_SERVERS=
+# DMAAP_HTTPS=true
# AAI
diff --git a/packages/install/src/files/feature-pooling-dmaap.conf b/packages/install/src/files/feature-pooling-messages.conf
index 0ef81951..0ef81951 100644
--- a/packages/install/src/files/feature-pooling-dmaap.conf
+++ b/packages/install/src/files/feature-pooling-messages.conf
diff --git a/policy-core/pom.xml b/policy-core/pom.xml
index a9f47311..0a743e86 100644
--- a/policy-core/pom.xml
+++ b/policy-core/pom.xml
@@ -61,10 +61,6 @@
-->
<exclusions>
<exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- <exclusion>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java
index 1eab676f..ec5ceb21 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicyContainer.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017-2021 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.
@@ -46,12 +47,12 @@ import org.slf4j.LoggerFactory;
*/
public class PolicyContainer implements Startable {
// get an instance of logger
- private static Logger logger = LoggerFactory.getLogger(PolicyContainer.class);
+ private static final Logger logger = LoggerFactory.getLogger(PolicyContainer.class);
// 'KieServices' singleton
private static KieServices kieServices = KieServices.Factory.get();
// set of all 'PolicyContainer' instances
- private static HashSet<PolicyContainer> containers = new HashSet<>();
+ private static final HashSet<PolicyContainer> containers = new HashSet<>();
// maps feature objects to per-PolicyContainer data
private ConcurrentHashMap<Object, Object> adjuncts = new ConcurrentHashMap<>();
@@ -65,7 +66,7 @@ public class PolicyContainer implements Startable {
private volatile boolean isStarted = false;
// maps session name into the associated 'PolicySession' instance
- private HashMap<String, PolicySession> sessions = new HashMap<>();
+ private final HashMap<String, PolicySession> sessions = new HashMap<>();
// if not null, this is a 'KieScanner' looking for updates
private KieScanner scanner = null;
@@ -171,7 +172,7 @@ public class PolicyContainer implements Startable {
}
}
if (exception != null) {
- // all of the 'newKieContainer' invocations failed -- throw the
+ // all the 'newKieContainer' invocations failed -- throw the
// most recent exception
throw exception;
}
@@ -263,7 +264,7 @@ public class PolicyContainer implements Startable {
PolicySession session = null;
KieSession kieSession = null;
- // loop through all of the features, and give each one
+ // loop through all the features, and give each one
// a chance to create the 'KieSession'
for (PolicySessionFeatureApi feature : PolicySessionFeatureApiConstants.getImpl().getList()) {
try {
@@ -432,7 +433,7 @@ public class PolicyContainer implements Startable {
/**
* Get policy sessions.
*
- * @return all of the 'PolicySession' instances
+ * @return all the 'PolicySession' instances
*/
public Collection<PolicySession> getPolicySessions() {
// KLUDGE WARNING: this is a temporary workaround -- if there are
@@ -703,7 +704,7 @@ public class PolicyContainer implements Startable {
var configDir = "config";
logger.info("PolicyContainer.main: configDir={}", configDir);
- // invoke 'globalInit' on all of the features
+ // invoke 'globalInit' on all the features
for (PolicySessionFeatureApi feature : PolicySessionFeatureApiConstants.getImpl().getList()) {
try {
feature.globalInit(args, configDir);
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java
index 1f8a61c6..0c10e984 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySession.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017-2021 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.
@@ -49,14 +50,12 @@ import org.slf4j.LoggerFactory;
* 2) Access to UEB
* 3) Logging of events
*/
-public class PolicySession
- implements AgendaEventListener, RuleRuntimeEventListener {
+public class PolicySession implements AgendaEventListener, RuleRuntimeEventListener {
// get an instance of logger
- private static Logger logger = LoggerFactory.getLogger(PolicySession.class);
+ private static final Logger logger = LoggerFactory.getLogger(PolicySession.class);
// supports 'getCurrentSession()' method
- private static ThreadLocal<PolicySession> policySess =
- new ThreadLocal<>();
+ private static ThreadLocal<PolicySession> policySess = new ThreadLocal<>();
// name of the 'PolicySession' and associated 'KieSession'
@Getter
@@ -115,7 +114,7 @@ public class PolicySession
return;
}
- // loop through all of the features, and give each one
+ // loop through all the features, and give each one
// a chance to create the 'ThreadModel'
for (PolicySessionFeatureApi feature :
PolicySessionFeatureApiConstants.getImpl().getList()) {
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java
index 0f4add77..4356d111 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/jmx/PdpJmx.java
@@ -3,6 +3,7 @@
* policy-core
* ================================================================================
* Copyright (C) 2017-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.
@@ -41,7 +42,7 @@ public class PdpJmx implements PdpJmxMBean {
return actions.longValue();
}
- public void updateOccured() {
+ public void updateOccurred() {
updates.incrementAndGet();
}
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java
index dbb20883..df0ac151 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysFailLock.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.
@@ -20,6 +21,7 @@
package org.onap.policy.drools.core.lock;
+import java.io.Serial;
import lombok.NoArgsConstructor;
/**
@@ -27,6 +29,7 @@ import lombok.NoArgsConstructor;
*/
@NoArgsConstructor
public class AlwaysFailLock extends LockImpl {
+ @Serial
private static final long serialVersionUID = 1L;
/**
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java
index 6b1e1494..ced6c4c9 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/AlwaysSuccessLock.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,12 +21,14 @@
package org.onap.policy.drools.core.lock;
+import java.io.Serial;
import lombok.NonNull;
/**
* Lock implementation whose operations always succeed.
*/
public class AlwaysSuccessLock extends LockImpl {
+ @Serial
private static final long serialVersionUID = 1L;
/**
diff --git a/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java b/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java
index 755e7a18..285a9a0a 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/util/FeatureEnabledChecker.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -25,7 +26,7 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
- * Checks whether or not a feature is enabled.
+ * Checks whether a feature is enabled.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class FeatureEnabledChecker {
@@ -40,6 +41,6 @@ public class FeatureEnabledChecker {
*/
public static boolean isFeatureEnabled(Properties props, String propName) {
String val = props.getProperty(propName);
- return (val != null && Boolean.valueOf(val));
+ return (Boolean.parseBoolean(val));
}
}
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/DroolsContainerTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/DroolsContainerTest.java
index 81ca3407..abed9727 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/DroolsContainerTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/DroolsContainerTest.java
@@ -3,6 +3,7 @@
* policy-core
* ================================================================================
* Copyright (C) 2017-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.
@@ -20,11 +21,11 @@
package org.onap.policy.drools.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -32,11 +33,13 @@ import static org.mockito.Mockito.when;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
+import java.util.Objects;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.drools.core.WorkingMemory;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.util.KieUtils;
/**
@@ -54,7 +57,7 @@ public class DroolsContainerTest {
* and 'PolicySession', and the updating of that container to a new
* version.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
KieUtils.installArtifact(
Paths.get("src/test/resources/drools-artifact-1.1/src/main/resources/META-INF/kmodule.xml").toFile(),
@@ -75,13 +78,13 @@ public class DroolsContainerTest {
* version.
*/
@Test
- public void createAndUpdate() throws Exception {
+ void createAndUpdate() throws Exception {
// make sure feature log starts out clean
PolicySessionFeatureApiMock.getLog();
// run 'globalInit', and verify expected feature hook fired
PolicyContainer.globalInit(new String[0]);
- assertEquals(Arrays.asList("globalInit"),
+ assertEquals(List.of("globalInit"),
PolicySessionFeatureApiMock.getLog());
// initial conditions -- there should be no containers
@@ -139,15 +142,15 @@ public class DroolsContainerTest {
session.getKieSession().insert(result);
// the Drools rules should add 3 + 8 + 2, and store 13 in a[0]
- assertEquals(13, result.poll(TIMEOUT_SEC, TimeUnit.SECONDS).intValue());
+ assertEquals(13, Objects.requireNonNull(result.poll(TIMEOUT_SEC, TimeUnit.SECONDS)).intValue());
// update the container to a new version --
// the rules will then multiply values rather than add them
assertEquals("[]",
- container.updateToVersion("17.2.0-SNAPSHOT").toString());
+ container.updateToVersion("17.2.0-SNAPSHOT"));
// verify expected feature hooks fired
- assertEquals(Arrays.asList("selectThreadModel"),
+ assertEquals(List.of("selectThreadModel"),
PolicySessionFeatureApiMock.getLog());
// verify new container attributes
@@ -169,7 +172,7 @@ public class DroolsContainerTest {
container.insert("session1", Arrays.asList(3, 8, 2));
container.insert("session1", result);
- assertEquals(48, result.poll(TIMEOUT_SEC, TimeUnit.SECONDS).intValue());
+ assertEquals(48, Objects.requireNonNull(result.poll(TIMEOUT_SEC, TimeUnit.SECONDS)).intValue());
/*
* verify that default KiePackages have been added by testing that
@@ -198,7 +201,7 @@ public class DroolsContainerTest {
assertFalse(container.isAlive());
// verify expected feature hooks fired
- assertEquals(Arrays.asList("disposeKieSession"),
+ assertEquals(List.of("disposeKieSession"),
PolicySessionFeatureApiMock.getLog());
}
@@ -213,7 +216,7 @@ public class DroolsContainerTest {
* test, also to increase code coverage.
*/
@Test
- public void versionList() throws Exception {
+ void versionList() throws Exception {
// make sure feature log starts out clean
PolicySessionFeatureApiMock.getLog();
@@ -222,7 +225,7 @@ public class DroolsContainerTest {
// run 'globalInit', and verify expected feature hook fired
PolicyContainer.globalInit(new String[0]);
- assertEquals(Arrays.asList("globalInit-exception"),
+ assertEquals(List.of("globalInit-exception"),
PolicySessionFeatureApiMock.getLog());
// initial conditions -- there should be no containers
@@ -317,7 +320,7 @@ public class DroolsContainerTest {
container.insertAll(result);
// the Drools rules should add 7 + 3 + 4, and store 14 in a[0]
- assertEquals(14, result.poll(TIMEOUT_SEC, TimeUnit.SECONDS).intValue());
+ assertEquals(14, Objects.requireNonNull(result.poll(TIMEOUT_SEC, TimeUnit.SECONDS)).intValue());
// exercise some more API methods
assertEquals(container.getClassLoader(),
@@ -328,7 +331,7 @@ public class DroolsContainerTest {
assertFalse(container.isAlive());
// verify expected feature hooks fired
- assertEquals(Arrays.asList("destroyKieSession-exception"),
+ assertEquals(List.of("destroyKieSession-exception"),
PolicySessionFeatureApiMock.getLog());
// clear exception trigger
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiMock.java b/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiMock.java
index fbd81391..d8257067 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiMock.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiMock.java
@@ -3,6 +3,7 @@
* policy-core
* ================================================================================
* 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.
@@ -21,6 +22,7 @@
package org.onap.policy.drools.core;
import java.util.ArrayList;
+import lombok.Setter;
import org.kie.api.runtime.KieSession;
/**
@@ -30,10 +32,11 @@ import org.kie.api.runtime.KieSession;
*/
public class PolicySessionFeatureApiMock implements PolicySessionFeatureApi {
// contains the log entries since the most recent 'getLog()' call
- private static ArrayList<String> log = new ArrayList<>();
+ private static final ArrayList<String> log = new ArrayList<>();
// if 'true', trigger an exception right after doing the log,
// to verify that exceptions are handled
+ @Setter
private static boolean exceptionTrigger = false;
/**
@@ -50,17 +53,6 @@ public class PolicySessionFeatureApiMock implements PolicySessionFeatureApi {
}
/**
- * This method controls whether these hooks trigger an exception after
- * being invoked.
- *
- * @param indicator if 'true', subsequent hook method calls will trigger
- * an exception; if 'false', no exception is triggered
- */
- public static void setExceptionTrigger(boolean indicator) {
- exceptionTrigger = indicator;
- }
-
- /**
* This method adds an entry to the log, and possibly triggers an exception.
*
* @param arg value to add to the log
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiTest.java
index 1d1ca0ff..9e5643f1 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionFeatureApiTest.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.
@@ -20,20 +21,15 @@
package org.onap.policy.drools.core;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class PolicySessionFeatureApiTest {
+class PolicySessionFeatureApiTest {
@Test
- public void test() {
- PolicySessionFeatureApi api = new PolicySessionFeatureApi() {
- @Override
- public int getSequenceNumber() {
- return 0;
- }
- };
+ void test() {
+ PolicySessionFeatureApi api = () -> 0;
// test default methods
api.globalInit(null, null);
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionTest.java
index e937bb30..6f07a34f 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/PolicySessionTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2020-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,22 +22,22 @@
package org.onap.policy.drools.core;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.concurrent.Semaphore;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.kie.api.event.rule.AgendaEventListener;
import org.kie.api.event.rule.RuleRuntimeEventListener;
import org.kie.api.runtime.KieSession;
import org.onap.policy.drools.core.PolicySession.ThreadModel;
-public class PolicySessionTest {
+class PolicySessionTest {
private static final String MY_NAME = "my-name";
private static final String CONTAINER = "my-container";
@@ -49,7 +50,7 @@ public class PolicySessionTest {
/**
* Initialize test objects.
*/
- @Before
+ @BeforeEach
public void setUp() {
container = mock(PolicyContainer.class);
kie = mock(KieSession.class);
@@ -60,7 +61,7 @@ public class PolicySessionTest {
}
@Test
- public void test_Simple() {
+ void test_Simple() {
// verify constructor operations
AgendaEventListener agenda = session;
verify(kie).addEventListener(agenda);
@@ -92,7 +93,7 @@ public class PolicySessionTest {
}
@Test
- public void testStartThread() {
+ void testStartThread() {
session.startThread();
// re-start
@@ -102,7 +103,7 @@ public class PolicySessionTest {
}
@Test
- public void testSetPolicySession_testGetCurrentSession_testRemovePolicySession() {
+ void testSetPolicySession_testGetCurrentSession_testRemovePolicySession() {
PolicySession sess2 = new PolicySession(MY_NAME + "-b", container, kie);
session.setPolicySession();
@@ -121,7 +122,7 @@ public class PolicySessionTest {
}
@Test
- public void testGetAdjunct_testSetAdjunct() {
+ void testGetAdjunct_testSetAdjunct() {
Object adjnm1 = "adjunct-a";
Object adjval1 = "value-a";
session.setAdjunct(adjnm1, adjval1);
@@ -136,7 +137,7 @@ public class PolicySessionTest {
}
@Test
- public void testThreadModel() {
+ void testThreadModel() {
ThreadModel model = new PolicySession.ThreadModel() {
@Override
public void stop() {
@@ -149,11 +150,11 @@ public class PolicySessionTest {
}
};
- assertThatCode(() -> model.updated()).doesNotThrowAnyException();
+ assertThatCode(model::updated).doesNotThrowAnyException();
}
@Test
- public void testDefaultThreadModelRun() throws Exception {
+ void testDefaultThreadModelRun() throws Exception {
testDefaultThreadModelRun_Ex(() -> {
throw new RuntimeException(EXPECTED);
});
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/jmx/PdpJmxTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/jmx/PdpJmxTest.java
index e585a4b6..6bd994be 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/jmx/PdpJmxTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/jmx/PdpJmxTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,45 +21,45 @@
package org.onap.policy.drools.core.jmx;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class PdpJmxTest {
+class PdpJmxTest {
private PdpJmx jmx;
- @Before
+ @BeforeEach
public void setUp() {
jmx = new PdpJmx();
}
@Test
- public void testGetInstance() {
+ void testGetInstance() {
jmx = PdpJmx.getInstance();
assertNotNull(jmx);
assertSame(jmx, PdpJmx.getInstance());
}
@Test
- public void testGetUpdates_testUpdateOccured() {
+ void testGetUpdates_testUpdateOccurred() {
assertEquals(0, jmx.getUpdates());
assertEquals(0, jmx.getRulesFired());
- jmx.updateOccured();
+ jmx.updateOccurred();
assertEquals(1, jmx.getUpdates());
assertEquals(0, jmx.getRulesFired());
- jmx.updateOccured();
+ jmx.updateOccurred();
assertEquals(2, jmx.getUpdates());
assertEquals(0, jmx.getRulesFired());
}
@Test
- public void testGetRulesFired_testRuleFired() {
+ void testGetRulesFired_testRuleFired() {
assertEquals(0, jmx.getUpdates());
assertEquals(0, jmx.getRulesFired());
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysFailLockTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysFailLockTest.java
index 178ef0af..51273d7d 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysFailLockTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysFailLockTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -21,33 +22,33 @@
package org.onap.policy.drools.core.lock;
import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class AlwaysFailLockTest extends AlwaysLockBaseTest<AlwaysFailLock> {
+class AlwaysFailLockTest extends AlwaysLockBaseTest<AlwaysFailLock> {
- @Before
+ @BeforeEach
public void setUp() {
callback = mock(LockCallback.class);
lock = new AlwaysFailLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback);
}
@Test
- public void testAlwaysFailLockNoArgs() {
+ void testAlwaysFailLockNoArgs() {
assertThatCode(AlwaysFailLock::new).doesNotThrowAnyException();
}
@Test
- public void testUnavailableLock() {
+ void testUnavailableLock() {
assertTrue(lock.isUnavailable());
}
@Test
- public void testFree() {
+ void testFree() {
assertFalse(lock.free());
assertTrue(lock.isUnavailable());
}
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysLockBaseTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysLockBaseTest.java
index b5f7a64c..347ff874 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysLockBaseTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysLockBaseTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,15 +21,15 @@
package org.onap.policy.drools.core.lock;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public abstract class AlwaysLockBaseTest<T extends LockImpl> {
protected static final String RESOURCE = "hello";
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysSuccessLockTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysSuccessLockTest.java
index 32889484..80f81f92 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysSuccessLockTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/lock/AlwaysSuccessLockTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -22,24 +23,24 @@ package org.onap.policy.drools.core.lock;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class AlwaysSuccessLockTest extends AlwaysLockBaseTest<AlwaysSuccessLock> {
+class AlwaysSuccessLockTest extends AlwaysLockBaseTest<AlwaysSuccessLock> {
- @Before
+ @BeforeEach
public void setUp() {
callback = mock(LockCallback.class);
lock = new AlwaysSuccessLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback);
}
@Test
- public void testAlwaysSuccessLockConstructors() {
+ void testAlwaysSuccessLockConstructors() {
assertThatCode(AlwaysSuccessLock::new).doesNotThrowAnyException();
assertThatCode(() -> new AlwaysSuccessLock(LockState.ACTIVE, RESOURCE, OWNER_KEY, HOLD_SEC, callback))
.doesNotThrowAnyException();
@@ -48,18 +49,18 @@ public class AlwaysSuccessLockTest extends AlwaysLockBaseTest<AlwaysSuccessLock>
}
@Test
- public void testActiveLock() {
+ void testActiveLock() {
assertTrue(lock.isActive());
}
@Test
- public void testFree() {
+ void testFree() {
assertTrue(lock.free());
assertTrue(lock.isActive());
}
@Test
- public void testExtend() {
+ void testExtend() {
LockCallback callback2 = mock(LockCallback.class);
lock.extend(HOLD_SEC2, callback2);
diff --git a/policy-core/src/test/java/org/onap/policy/drools/core/lock/LockImplTest.java b/policy-core/src/test/java/org/onap/policy/drools/core/lock/LockImplTest.java
index 56cd5090..f16d9c4e 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/core/lock/LockImplTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/core/lock/LockImplTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -24,12 +25,12 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -40,10 +41,10 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class LockImplTest {
+class LockImplTest {
private static final LockState STATE = LockState.WAITING;
private static final String RESOURCE = "hello";
private static final String OWNER_KEY = "world";
@@ -57,7 +58,7 @@ public class LockImplTest {
/**
* Populates {@link #lock}.
*/
- @Before
+ @BeforeEach
public void setUp() {
callback = mock(LockCallback.class);
@@ -65,7 +66,7 @@ public class LockImplTest {
}
@Test
- public void testSerializable() throws Exception {
+ void testSerializable() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
oos.writeObject(lock);
@@ -86,7 +87,7 @@ public class LockImplTest {
}
@Test
- public void testLockImplNoArgs() {
+ void testLockImplNoArgs() {
// use no-arg constructor
lock = new LockImpl();
assertEquals(LockState.UNAVAILABLE, lock.getState());
@@ -97,7 +98,7 @@ public class LockImplTest {
}
@Test
- public void testLockImpl_testGetters() {
+ void testLockImpl_testGetters() {
assertEquals(STATE, lock.getState());
assertEquals(RESOURCE, lock.getResourceId());
assertEquals(OWNER_KEY, lock.getOwnerKey());
@@ -118,7 +119,7 @@ public class LockImplTest {
}
@Test
- public void testFree() {
+ void testFree() {
assertTrue(lock.free());
assertTrue(lock.isUnavailable());
@@ -132,7 +133,7 @@ public class LockImplTest {
}
@Test
- public void testExtend() {
+ void testExtend() {
lock.setState(LockState.WAITING);
LockCallback callback2 = mock(LockCallback.class);
@@ -181,7 +182,7 @@ public class LockImplTest {
}
@Test
- public void testNotifyAvailable() {
+ void testNotifyAvailable() {
lock.notifyAvailable();
verify(callback).lockAvailable(any());
@@ -189,7 +190,7 @@ public class LockImplTest {
}
@Test
- public void testNotifyAvailable_Ex() {
+ void testNotifyAvailable_Ex() {
doThrow(new IllegalArgumentException(EXPECTED_EXCEPTION)).when(callback).lockAvailable(any());
doThrow(new IllegalArgumentException(EXPECTED_EXCEPTION)).when(callback).lockUnavailable(any());
@@ -198,7 +199,7 @@ public class LockImplTest {
}
@Test
- public void testNotifyUnavailable() {
+ void testNotifyUnavailable() {
lock.notifyUnavailable();
verify(callback, never()).lockAvailable(any());
@@ -206,7 +207,7 @@ public class LockImplTest {
}
@Test
- public void testNotifyUnavailable_Ex() {
+ void testNotifyUnavailable_Ex() {
doThrow(new IllegalArgumentException(EXPECTED_EXCEPTION)).when(callback).lockAvailable(any());
doThrow(new IllegalArgumentException(EXPECTED_EXCEPTION)).when(callback).lockUnavailable(any());
@@ -215,7 +216,7 @@ public class LockImplTest {
}
@Test
- public void testSetState_testIsActive_testIsWaiting_testIsUnavailable() {
+ void testSetState_testIsActive_testIsWaiting_testIsUnavailable() {
lock.setState(LockState.WAITING);
assertEquals(LockState.WAITING, lock.getState());
assertFalse(lock.isActive());
@@ -236,7 +237,7 @@ public class LockImplTest {
}
@Test
- public void testSetHoldSec() {
+ void testSetHoldSec() {
assertEquals(HOLD_SEC, lock.getHoldSec());
lock.setHoldSec(HOLD_SEC2);
@@ -244,7 +245,7 @@ public class LockImplTest {
}
@Test
- public void testSetCallback() {
+ void testSetCallback() {
assertSame(callback, lock.getCallback());
LockCallback callback2 = mock(LockCallback.class);
@@ -253,7 +254,7 @@ public class LockImplTest {
}
@Test
- public void testToString() {
+ void testToString() {
String text = lock.toString();
assertNotNull(text);
diff --git a/policy-core/src/test/java/org/onap/policy/drools/util/FeatureEnabledCheckerTest.java b/policy-core/src/test/java/org/onap/policy/drools/util/FeatureEnabledCheckerTest.java
index c118b897..454544a6 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/util/FeatureEnabledCheckerTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/util/FeatureEnabledCheckerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,18 +21,18 @@
package org.onap.policy.drools.util;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Properties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class FeatureEnabledCheckerTest {
+class FeatureEnabledCheckerTest {
private static final String PROP_NAME = "enable.it";
@Test
- public void test() {
+ void test() {
assertFalse(check(null));
assertTrue(check(true));
assertFalse(check(false));
diff --git a/policy-core/src/test/java/org/onap/policy/drools/util/KieUtilsTest.java b/policy-core/src/test/java/org/onap/policy/drools/util/KieUtilsTest.java
index 1622a2b9..7089fdad 100644
--- a/policy-core/src/test/java/org/onap/policy/drools/util/KieUtilsTest.java
+++ b/policy-core/src/test/java/org/onap/policy/drools/util/KieUtilsTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,9 +21,9 @@
package org.onap.policy.drools.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.io.IOException;
import java.net.URL;
@@ -32,8 +33,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.stream.Collectors;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.kie.api.builder.ReleaseId;
import org.kie.api.definition.KiePackage;
import org.kie.api.definition.rule.Rule;
@@ -51,7 +52,7 @@ public class KieUtilsTest {
/**
* Test class initialization.
*/
- @BeforeClass
+ @BeforeAll
public static void createArtifact() throws Exception {
ReleaseId releaseId =
KieUtils.installArtifact(
@@ -65,7 +66,7 @@ public class KieUtilsTest {
}
@Test
- public void testInstallArtifact() throws IOException {
+ void testInstallArtifact() throws IOException {
ReleaseId releaseId =
KieUtils.installArtifact(
Paths.get("src/test/resources/drools-artifact-1.1/src/main/resources/META-INF/kmodule.xml").toFile(),
@@ -77,7 +78,7 @@ public class KieUtilsTest {
}
@Test
- public void testInstallArtifactList() throws IOException {
+ void testInstallArtifactList() throws IOException {
ReleaseId releaseId =
KieUtils.installArtifact(
Paths.get("src/test/resources/drools-artifact-1.1/src/main/resources/META-INF/kmodule.xml").toFile(),
@@ -90,41 +91,41 @@ public class KieUtilsTest {
}
@Test
- public void getBases() {
+ void getBases() {
assertEquals(Collections.singletonList("rules"), KieUtils.getBases(container));
}
@Test
- public void getPackages() {
+ void getPackages() {
assertEquals(Arrays.asList("java.util", "java.util.concurrent", "org.onap.policy.drools.core.test"),
KieUtils.getPackages(container).stream().map(KiePackage::getName).collect(Collectors.toList()));
}
@Test
- public void getPackageNames() {
+ void getPackageNames() {
assertEquals(Arrays.asList("java.util", "java.util.concurrent", "org.onap.policy.drools.core.test"),
new ArrayList<>(KieUtils.getPackageNames(container)));
}
@Test
- public void getRules() {
+ void getRules() {
assertEquals(Arrays.asList("Initialization", "Add elements of an int list"),
KieUtils.getRules(container).stream().map(Rule::getName).collect(Collectors.toList()));
}
@Test
- public void getRuleNames() {
+ void getRuleNames() {
assertEquals(Arrays.asList("Initialization", "Add elements of an int list"),
- KieUtils.getRuleNames(container).stream().collect(Collectors.toList()));
+ new ArrayList<>(KieUtils.getRuleNames(container)));
}
@Test
- public void getFacts() {
+ void getFacts() {
assertEquals(0, KieUtils.getFacts(session).size());
}
@Test
- public void testResourceToPackages() {
+ void testResourceToPackages() {
// Some minimal logging -- it would be nice to verify the 'KieUtils' logger messages
StringBuffer log;
@@ -156,7 +157,7 @@ public class KieUtilsTest {
@Override
public Enumeration<URL> getResources(String name) throws IOException {
if ("BogusUrl".equals(name)) {
- return new Enumeration<URL>() {
+ return new Enumeration<>() {
@Override
public boolean hasMoreElements() {
return true;
diff --git a/policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/META-INF/kmodule.xml b/policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/META-INF/kmodule.xml
index 22319689..2ab03fcf 100644
--- a/policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/META-INF/kmodule.xml
+++ b/policy-core/src/test/resources/drools-artifact-1.1/src/main/resources/META-INF/kmodule.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="rules">
<ksession name="session1"/>
</kbase>
diff --git a/policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/META-INF/kmodule.xml b/policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/META-INF/kmodule.xml
index 22319689..2ab03fcf 100644
--- a/policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/META-INF/kmodule.xml
+++ b/policy-core/src/test/resources/drools-artifact-1.2/src/main/resources/META-INF/kmodule.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="rules">
<ksession name="session1"/>
</kbase>
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
index d7692fc0..3d1e8490 100644
--- a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DomainPolicyTypesTest.java
@@ -22,16 +22,16 @@
package org.onap.policy.drools.domain.models;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+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 com.worldturner.medeia.api.ValidationFailedException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -45,7 +45,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-public class DomainPolicyTypesTest {
+class DomainPolicyTypesTest {
// Policy Types
private static final String NATIVE_DROOLS_POLICY_TYPE = "onap.policies.native.drools.Artifact";
@@ -63,14 +63,14 @@ public class DomainPolicyTypesTest {
private DomainMaker domainMaker;
private StandardCoder nonValCoder;
- @Before
+ @BeforeEach
public void setUp() {
domainMaker = new DomainMaker();
nonValCoder = new StandardCoder();
}
@Test
- public void testToscaNativeDroolsPolicy() throws CoderException, IOException {
+ void testToscaNativeDroolsPolicy() throws CoderException, IOException {
String rawNativeDroolsPolicy =
getPolicyFromFileString();
ToscaPolicy toscaPolicy =
@@ -122,7 +122,7 @@ public class DomainPolicyTypesTest {
}
@Test
- public void testToscaControllerPolicy() throws CoderException {
+ void testToscaControllerPolicy() throws CoderException {
ToscaPolicy toscaPolicy =
getExamplesPolicy(EXAMPLE_CONTROLLER_DROOLS_POLICY_JSON, EXAMPLE_CONTROLLER_DROOLS_POLICY_NAME);
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java
index 98ddd4c8..99494d71 100644
--- a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/DroolsPolicyTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -29,26 +30,28 @@ import com.openpojo.validation.Validator;
import com.openpojo.validation.ValidatorBuilder;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
+import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class DroolsPolicyTest {
+class DroolsPolicyTest {
@Data
@SuperBuilder
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public static class DerivedDomainPolicy extends DroolsPolicy implements Serializable {
+ @Serial
private static final long serialVersionUID = -1027974819756498893L;
}
@Test
- public void testDerivedClass() {
+ void testDerivedClass() {
/* validate model pojos */
Validator validator = ValidatorBuilder.create()
.with(new SetterTester(), new GetterTester()).build();
@@ -57,7 +60,7 @@ public class DroolsPolicyTest {
}
@Test
- public void testPackage() {
+ void testPackage() {
/* validate model pojos */
List<PojoClass> pojoClasses =
PojoClassFactory
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/artifact/ArtifactPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/artifact/ArtifactPolicyTest.java
index b4c71f0d..16a91b67 100644
--- a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/artifact/ArtifactPolicyTest.java
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/artifact/ArtifactPolicyTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 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.
@@ -20,15 +21,15 @@
package org.onap.policy.drools.domain.models.artifact;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.domain.models.Metadata;
-public class ArtifactPolicyTest {
+class ArtifactPolicyTest {
@Test
- public void testBuildDomainPolicyNativeArtifact() {
+ void testBuildDomainPolicyNativeArtifact() {
/* manually create a native drools policy */
// @formatter:off
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerPolicyTest.java
index d24a8f70..05e85b84 100644
--- a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerPolicyTest.java
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/controller/ControllerPolicyTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -20,16 +21,16 @@
package org.onap.policy.drools.domain.models.controller;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.ArrayList;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.domain.models.Metadata;
-public class ControllerPolicyTest {
+class ControllerPolicyTest {
@Test
- public void testBuildDomainPolicyController() {
+ void testBuildDomainPolicyController() {
/* manually create a controller policy */
// @formatter:off
diff --git a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java
index 91e8acc1..8168e75a 100644
--- a/policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java
+++ b/policy-domains/src/test/java/org/onap/policy/drools/domain/models/operational/OperationalPolicyTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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,12 +21,12 @@
package org.onap.policy.drools.domain.models.operational;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -36,7 +36,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-public class OperationalPolicyTest {
+class OperationalPolicyTest {
// Policy Types
private static final String OPERATIONAL_DROOLS_POLICY_TYPE = "onap.policies.controlloop.operational.common.Drools";
@@ -48,15 +48,15 @@ public class OperationalPolicyTest {
private DomainMaker domainMaker;
private StandardCoder nonValCoder;
- @Before
+ @BeforeEach
public void setUp() {
domainMaker = new DomainMaker();
nonValCoder = new StandardCoder();
}
@Test
- public void testToscaCompliantOperationalPolicyType() throws CoderException {
- String rawVcpeToscaPolicy = getExamplesPolicyString(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, OP_POLICY_NAME_VCPE);
+ void testToscaCompliantOperationalPolicyType() throws CoderException {
+ String rawVcpeToscaPolicy = getExamplesPolicyString();
// valid "known" policy type with implicit schema
ToscaConceptIdentifier operationalCompliantType =
@@ -66,7 +66,7 @@ public class OperationalPolicyTest {
}
@Test
- public void testOperationalCompliantModel() {
+ void testOperationalCompliantModel() {
// @formatter:off
OperationalPolicy policy =
OperationalPolicy.builder()
@@ -100,17 +100,15 @@ public class OperationalPolicyTest {
assertNotNull(policy);
}
- private String getJsonFromResource(String resourcePath) {
- return ResourceUtils.getResourceAsString(resourcePath);
- }
-
- private ToscaPolicy getExamplesPolicy(String resourcePath, String policyName) throws CoderException {
- String policyJson = getJsonFromResource(resourcePath);
+ private ToscaPolicy getExamplesPolicy() throws CoderException {
+ String policyJson = ResourceUtils
+ .getResourceAsString(OperationalPolicyTest.VCPE_OPERATIONAL_DROOLS_POLICY_JSON);
ToscaServiceTemplate serviceTemplate = new StandardCoder().decode(policyJson, ToscaServiceTemplate.class);
- return serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(policyName);
+ return serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).get(
+ OperationalPolicyTest.OP_POLICY_NAME_VCPE);
}
- private String getExamplesPolicyString(String resourcePath, String policyName) throws CoderException {
- return nonValCoder.encode(getExamplesPolicy(resourcePath, policyName));
+ private String getExamplesPolicyString() throws CoderException {
+ return nonValCoder.encode(getExamplesPolicy());
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java
index 0c732246..1965e22f 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 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.
@@ -60,6 +60,11 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
protected Map<String, DroolsController> droolsControllers = new HashMap<>();
/**
+ * Null Drools Controller.
+ */
+ protected NullDroolsController nullDroolsController = new NullDroolsController();
+
+ /**
* Constructs the object.
*/
public IndexedDroolsControllerFactory() {
@@ -259,12 +264,6 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
} else {
return PolicyEndPointProperties.PROPERTY_UEB_SINK_TOPICS + ".";
}
- } else if (commInfra == CommInfrastructure.DMAAP) {
- if (isSource) {
- return PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + ".";
- } else {
- return PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS + ".";
- }
} else if (commInfra == CommInfrastructure.NOOP) {
if (isSource) {
return PolicyEndPointProperties.PROPERTY_NOOP_SOURCE_TOPICS + ".";
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
index e93adec5..68a69159 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
@@ -119,8 +119,6 @@ public class MavenDroolsController implements DroolsController {
/**
* original Drools Model/Rules classloader hash.
- * -- GETTER --
- * Get model class loader hash.
*/
@Getter
protected int modelClassLoaderHash;
@@ -208,7 +206,7 @@ public class MavenDroolsController implements DroolsController {
logger.warn("{} UPGRADE results: {}", this, messages);
/*
- * If all sucessful (can load new container), now we can remove all coders from previous sessions
+ * If all successful (can load new container), now we can remove all coders from previous sessions
*/
this.removeCoders();
@@ -533,7 +531,7 @@ public class MavenDroolsController implements DroolsController {
this.recentSourceEvents.add(event);
}
- PdpJmx.getInstance().updateOccured();
+ PdpJmx.getInstance().updateOccurred();
// Broadcast
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
index f3a422e7..76836ba2 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
@@ -3,6 +3,7 @@
* policy-management
* ================================================================================
* Copyright (C) 2017-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.
@@ -56,7 +57,8 @@ public class PdpdConfiguration {
@GsonJsonProperty("controllers")
private List<ControllerConfiguration> controllers = new ArrayList<>();
- @GsonJsonIgnore private Map<String, Object> additionalProperties = new HashMap<>();
+ @GsonJsonIgnore
+ private final Map<String, Object> additionalProperties = new HashMap<>();
/**
* Constructor.
@@ -163,32 +165,30 @@ public class PdpdConfiguration {
}
protected boolean declaredProperty(String name, Object value) {
- switch (name) {
- case "requestID":
+ return switch (name) {
+ case "requestID" -> {
callSetRequestId(value);
- return true;
- case "entity":
+ yield true;
+ }
+ case "entity" -> {
callSetEntity(value);
- return true;
- case "controllers":
+ yield true;
+ }
+ case "controllers" -> {
callSetControllers(value);
- return true;
- default:
- return false;
- }
+ yield true;
+ }
+ default -> false;
+ };
}
protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
- switch (name) {
- case "requestID":
- return getRequestId();
- case "entity":
- return getEntity();
- case "controllers":
- return getControllers();
- default:
- return notFoundValue;
- }
+ return switch (name) {
+ case "requestID" -> getRequestId();
+ case "entity" -> getEntity();
+ case "controllers" -> getControllers();
+ default -> notFoundValue;
+ };
}
/**
@@ -273,7 +273,7 @@ public class PdpdConfiguration {
"property \"controllers\" is of type "
+ "\"java.util.List<org.onap.policy.drools.protocol.configuration.Controller>\", "
+ "but got "
- + value.getClass().toString());
+ + value.getClass());
}
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
index ad23ff3a..ecc6c083 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021,2023 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -1392,7 +1392,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@GET
- @Path("engine/topics/sources/{comm: ueb|dmaap|noop}")
+ @Path("engine/topics/sources/{comm: ueb|kafka|noop}")
public Response commSources(
@PathParam("comm") String comm) {
if (!checkValidNameInput(comm)) {
@@ -1408,9 +1408,6 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
case UEB:
sources.addAll(TopicEndpointManager.getManager().getUebTopicSources());
break;
- case DMAAP:
- sources.addAll(TopicEndpointManager.getManager().getDmaapTopicSources());
- break;
case NOOP:
sources.addAll(TopicEndpointManager.getManager().getNoopTopicSources());
break;
@@ -1430,7 +1427,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@GET
- @Path("engine/topics/sinks/{comm: ueb|dmaap|noop}")
+ @Path("engine/topics/sinks/{comm: ueb|kafka|noop}")
public Response commSinks(
@PathParam("comm") String comm) {
if (!checkValidNameInput(comm)) {
@@ -1446,9 +1443,6 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
case UEB:
sinks.addAll(TopicEndpointManager.getManager().getUebTopicSinks());
break;
- case DMAAP:
- sinks.addAll(TopicEndpointManager.getManager().getDmaapTopicSinks());
- break;
case NOOP:
sinks.addAll(TopicEndpointManager.getManager().getNoopTopicSinks());
break;
@@ -1468,7 +1462,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@GET
- @Path("engine/topics/sources/{comm: ueb|dmaap|noop}/{topic}")
+ @Path("engine/topics/sources/{comm: ueb|kafka|noop}/{topic}")
public Response sourceTopic(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1484,7 +1478,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@GET
- @Path("engine/topics/sinks/{comm: ueb|dmaap|noop}/{topic}")
+ @Path("engine/topics/sinks/{comm: ueb|kafka|noop}/{topic}")
public Response sinkTopic(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1500,7 +1494,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@GET
- @Path("engine/topics/sources/{comm: ueb|dmaap|noop}/{topic}/events")
+ @Path("engine/topics/sources/{comm: ueb|kafka|noop}/{topic}/events")
public Response sourceEvents(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1516,7 +1510,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@GET
- @Path("engine/topics/sinks/{comm: ueb|dmaap|noop}/{topic}/events")
+ @Path("engine/topics/sinks/{comm: ueb|kafka|noop}/{topic}/events")
public Response sinkEvents(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1532,7 +1526,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@GET
- @Path("engine/topics/sources/{comm: ueb|dmaap|noop}/{topic}/switches")
+ @Path("engine/topics/sources/{comm: ueb|kafka|noop}/{topic}/switches")
public Response commSourceTopicSwitches(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1544,7 +1538,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@GET
- @Path("engine/topics/sinks/{comm: ueb|dmaap|noop}/{topic}/switches")
+ @Path("engine/topics/sinks/{comm: ueb|kafka|noop}/{topic}/switches")
public Response commSinkTopicSwitches(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1556,7 +1550,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@PUT
- @Path("engine/topics/sources/{comm: ueb|dmaap|noop}/{topic}/switches/lock")
+ @Path("engine/topics/sources/{comm: ueb|kafka|noop}/{topic}/switches/lock")
public Response commSourceTopicLock(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1570,7 +1564,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@DELETE
- @Path("engine/topics/sources/{comm: ueb|dmaap|noop}/{topic}/switches/lock")
+ @Path("engine/topics/sources/{comm: ueb|kafka|noop}/{topic}/switches/lock")
public Response commSourceTopicUnlock(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1584,7 +1578,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@PUT
- @Path("engine/topics/sources/{comm: ueb|dmaap|noop}/{topic}/switches/activation")
+ @Path("engine/topics/sources/{comm: ueb|kafka|noop}/{topic}/switches/activation")
public Response commSourceTopicActivation(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1598,7 +1592,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@DELETE
- @Path("engine/topics/sources/{comm: ueb|dmaap|noop}/{topic}/switches/activation")
+ @Path("engine/topics/sources/{comm: ueb|kafka|noop}/{topic}/switches/activation")
public Response commSourceTopicDeactivation(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1612,7 +1606,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@PUT
- @Path("engine/topics/sinks/{comm: ueb|dmaap|noop}/{topic}/switches/lock")
+ @Path("engine/topics/sinks/{comm: ueb|kafka|noop}/{topic}/switches/lock")
public Response commSinkTopicLock(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1626,7 +1620,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@DELETE
- @Path("engine/topics/sinks/{comm: ueb|dmaap|noop}/{topic}/switches/lock")
+ @Path("engine/topics/sinks/{comm: ueb|kafka|noop}/{topic}/switches/lock")
public Response commSinkTopicUnlock(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1640,7 +1634,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@PUT
- @Path("engine/topics/sinks/{comm: ueb|dmaap|noop}/{topic}/switches/activation")
+ @Path("engine/topics/sinks/{comm: ueb|kafka|noop}/{topic}/switches/activation")
public Response commSinkTopicActivation(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1654,7 +1648,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@DELETE
- @Path("engine/topics/sinks/{comm: ueb|dmaap|noop}/{topic}/switches/activation")
+ @Path("engine/topics/sinks/{comm: ueb|kafka|noop}/{topic}/switches/activation")
public Response commSinkTopicDeactivation(
@PathParam("comm") String comm,
@PathParam("topic") String topic) {
@@ -1682,7 +1676,7 @@ public class RestManager implements SwaggerApi, DefaultApi, FeaturesApi, InputsA
*/
@Override
@PUT
- @Path("engine/topics/sources/{comm: ueb|dmaap|noop}/{topic}/events")
+ @Path("engine/topics/sources/{comm: ueb|kafka|noop}/{topic}/events")
@Consumes(MediaType.TEXT_PLAIN)
public Response commEventOffer(
@PathParam("comm") String comm,
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafBase.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafBase.java
deleted file mode 100644
index 67725955..00000000
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafBase.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2018-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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.server.restful.aaf;
-
-import org.onap.policy.common.endpoints.http.server.aaf.AafAuthFilter;
-import org.onap.policy.drools.system.PolicyEngineConstants;
-
-/**
- * AAF Base Class.
- */
-public abstract class AafBase extends AafAuthFilter {
- public static final String AAF_NODETYPE = "pdpd";
- public static final String AAF_ROOT_PERMISSION_PROPERTY = "aaf.root.permission";
- public static final String AAF_ROOT_PERMISSION =
- PolicyEngineConstants.getManager().getProperties().getProperty(
- AAF_ROOT_PERMISSION_PROPERTY, DEFAULT_NAMESPACE + "." + AAF_NODETYPE);
-}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafTelemetryAuthFilter.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafTelemetryAuthFilter.java
deleted file mode 100644
index 1f7ef8c3..00000000
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/aaf/AafTelemetryAuthFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2018 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.server.restful.aaf;
-
-import jakarta.servlet.http.HttpServletRequest;
-import org.onap.policy.common.utils.network.NetworkUtil;
-
-/**
- * AAF Telemetry Authorization.
- */
-public class AafTelemetryAuthFilter extends AafBase {
- private static final String RESOURCE_TYPE = AAF_ROOT_PERMISSION + "." + "telemetry";
-
- @Override
- protected String getPermissionType(HttpServletRequest request) {
- return RESOURCE_TYPE;
- }
-
- @Override
- protected String getPermissionInstance(HttpServletRequest request) {
- return NetworkUtil.getHostname();
- }
-}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
index 43ab5e47..0bc2318b 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2022 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.
@@ -85,7 +86,6 @@ import org.onap.policy.drools.protocol.coders.EventProtocolCoderConstants;
import org.onap.policy.drools.protocol.configuration.ControllerConfiguration;
import org.onap.policy.drools.protocol.configuration.PdpdConfiguration;
import org.onap.policy.drools.server.restful.RestManager;
-import org.onap.policy.drools.server.restful.aaf.AafTelemetryAuthFilter;
import org.onap.policy.drools.stats.PolicyStatsManager;
import org.onap.policy.drools.system.internal.SimpleLockManager;
import org.onap.policy.drools.utils.PropertyUtil;
@@ -408,11 +408,6 @@ class PolicyEngineManager implements PolicyEngine {
try {
this.httpServers = getServletFactory().build(properties);
- for (HttpServletServer server : this.httpServers) {
- if (server.isAaf()) {
- server.addFilterClass(null, AafTelemetryAuthFilter.class.getName());
- }
- }
} catch (final IllegalArgumentException e) {
logger.error("{}: add-http-servers failed", this, e);
}
diff --git a/policy-management/src/main/resources/openapi/openapi.yaml b/policy-management/src/main/resources/openapi/openapi.yaml
index a763150b..80a3ae63 100644
--- a/policy-management/src/main/resources/openapi/openapi.yaml
+++ b/policy-management/src/main/resources/openapi/openapi.yaml
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (C) 2023 Nordix Foundation
+# 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.
@@ -3207,8 +3207,6 @@ components:
properties:
prometheus:
type: boolean
- aaf:
- type: boolean
name:
type: string
port:
diff --git a/policy-management/src/main/resources/swagger/swagger.json b/policy-management/src/main/resources/swagger/swagger.json
index f26a1bfe..9fb709b9 100644
--- a/policy-management/src/main/resources/swagger/swagger.json
+++ b/policy-management/src/main/resources/swagger/swagger.json
@@ -4593,9 +4593,6 @@
"prometheus" : {
"type" : "boolean"
},
- "aaf" : {
- "type" : "boolean"
- },
"name" : {
"type" : "string"
},
diff --git a/policy-management/src/main/server-gen/bin/add-secured-participant b/policy-management/src/main/server-gen/bin/add-secured-participant
index edd92e10..3ddc120f 100644
--- a/policy-management/src/main/server-gen/bin/add-secured-participant
+++ b/policy-management/src/main/server-gen/bin/add-secured-participant
@@ -5,6 +5,7 @@
# policy-management
# ================================================================================
# Copyright (C) 2017-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.
@@ -72,7 +73,7 @@ until [ -z "$1" ]; do
done
if [ -z "${BUS_HOST}" ]; then
- echo "An UEB/DMAAP server must be provided."
+ echo "An UEB/KAFKA server must be provided."
echo
usage
exit 1
diff --git a/policy-management/src/main/server-gen/bin/create-api-key b/policy-management/src/main/server-gen/bin/create-api-key
index 7870265e..e57c1e92 100644
--- a/policy-management/src/main/server-gen/bin/create-api-key
+++ b/policy-management/src/main/server-gen/bin/create-api-key
@@ -5,6 +5,7 @@
# policy-management
# ================================================================================
# Copyright (C) 2017-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.
@@ -52,7 +53,7 @@ until [ -z "$1" ]; do
done
if [ -z "${BUS_HOST}" ]; then
- echo "An UEB/DMAAP server must be provided."
+ echo "An UEB/KAFKA server must be provided."
echo
usage
exit 1
diff --git a/policy-management/src/main/server-gen/bin/create-secured-topic b/policy-management/src/main/server-gen/bin/create-secured-topic
index f906bb55..2aed99ae 100644
--- a/policy-management/src/main/server-gen/bin/create-secured-topic
+++ b/policy-management/src/main/server-gen/bin/create-secured-topic
@@ -5,6 +5,7 @@
# policy-management
# ================================================================================
# Copyright (C) 2017-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.
@@ -71,7 +72,7 @@ until [ -z "$1" ]; do
done
if [ -z "${BUS_HOST}" ]; then
- echo "An UEB/DMAAP server must be provided."
+ echo "An UEB/KAFKA server must be provided."
echo
usage
exit 1
diff --git a/policy-management/src/main/server-gen/bin/pdpd-configuration b/policy-management/src/main/server-gen/bin/pdpd-configuration
index c3fb43b5..5182f3ad 100644
--- a/policy-management/src/main/server-gen/bin/pdpd-configuration
+++ b/policy-management/src/main/server-gen/bin/pdpd-configuration
@@ -4,6 +4,7 @@
# ONAP
# ================================================================================
# Copyright (C) 2017-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.
@@ -37,7 +38,7 @@ function usage() {
echo ""
}
-BUS_PORT=3904
+BUS_PORT=9092
REQUEST_ID="7f5474ca-16a9-42ac-abc0-d86f62296fbc"
TOPIC="PDPD-CONFIGURATION"
@@ -87,7 +88,7 @@ until [ -z "$1" ]; do
done
if [ -z "${BUS_HOST}" ]; then
- echo "An UEB/DMAAP server must be provided."
+ echo "An UEB/KAFKA server must be provided."
echo
usage
exit 1
diff --git a/policy-management/src/main/server/config/aaf-cadi.keyfile b/policy-management/src/main/server/config/aaf-cadi.keyfile
deleted file mode 100644
index 59d544f3..00000000
--- a/policy-management/src/main/server/config/aaf-cadi.keyfile
+++ /dev/null
@@ -1,27 +0,0 @@
-N3INM2bAlQ8cNODnjR3Fuvo5z4GeID0KnRYlELmt-oHCFxq_XYVyepBVR591CIbJI9prNd_LLuv7
-tQD8xX_ypcNA-jQsecTwtw4GxvpqkZPhq6Q8BWNQaCegtXGDVTQ8gG2biKiQ7v-2C6Qhx4zj62b6
-bRPS5j1bfxqcAZu7082V00oQjbn40T2zFcLwCuBChZfx5DXTW49bwtLbkCbGqJSzFcIJpbGQ8gLg
-ussIoL8VE2Vee7bPJmUAdT4x9B1wrMIuvKlUMppeq0Bj-6ZJgxhM9F0WT8eEBh6NFANdK3LUgZrk
-D3kY3LrK-MT9u1TOMx13nOU7vOaVjl7_rkp5Q65gFd9VYbnJBYvJcc7asOQMsrugiSiRIoXH0Fyy
--f9L3ROGae042J4M8qxcoOihMbcjVkEXqn6eRIFbDe0eIAlkSRYfaxg9v4tf8GbBjQcShBjzGaI2
-g6QxTA5G6Aa7p63aVRGv3ZODCHcbsbxnkyByXgmkON4cTk9vR0RbT6YYhT5t8xTU3rhqV3jeE0Bz
-KbU0c4188xTnhdq_bje2TuuLvtEvevdvDsbtAj7chQmWMOW7GMF3MnqdEpcw1NCoNRdN8wpAdE-5
-mkG-jlYHljSRh9qZK5wdEoO4IXgpFktdGj50XuzcskqqURNfDGHGb29fHznL1-ssdQK6EXcKN0AU
-nYyGLAie3VfFxWKj5dGODBs5RttvkX4PHyLcLD3kOrVgtQrz7d0PWWYCxDRqKT6qnJkLB1CUwghn
-XweEiDfoQmuUmwFEQNRDp0NGLnde5nsw7NYgLrv5VafGK8EyT4GeVhuu5Tnb6T-HalxCq2p5JaIA
-SG8zlDmRx_TykrhfQEJe7sr0pRcAMwgxEhwunG2oBiKnzdRx5jxMfqnVC8xGirumhmOQNterfnd5
-0pIsfvIuntyxRQ48yzIb2gb5kaSkfSzCaVnlqK-_jpj1T74qO86eaKVee4faQAbXDPYF2z5w06nD
-WS2dd54wBjGmkFNzi13ejTrAJeA6UzOd1CF_WSpc9XSJJPTPUGxmnfLjmGThErFBYuQxjhpH7vKN
-uZgokkIXX78rVcO3zpfa5kTYWjE8lk9y3WA7sGNtTWfG8bR3WLWNLPCnrzxtKZdhq2JsQYC0gwW7
-ZgJSXhgPoaC_RrtCn7haj1_601G_MkD-jcUEsO-4XOBVicsCgG8hn7B-SpgKspqv8gulbeKoORqa
-CkrtiFPlXEqdNuaBSHcQ0MWJ3tpXzWtIPM3ouEFOR32xVfptfz4sRPOkM_PNiVXxQtLOn_z3uC7K
-VVJCKZxVaavQ6QiZvRRANS9_GD3kDILX15EnbEvh-2DfycDrEo330vMwvNJP7i9eM5vo0YADe--G
-r5UDqctmFjl1ulc1yAQkDBGWGxT92x-hhLqCnCXcYPu_aeWssfDpRj573PHPaTiM0SYxJixjszRD
-6-AMC1DqugkjiGA5_enQORn-G_H4ZVtoQ_zebizEfIxKv5-8uRdyZDHGG3mDu6_nasEffry-UyVu
-STU3oJMycZ1qf5GR1evRJ7gxkrtPXHWKNnVgxfrBC72ON6wJnr7KaY-l9L44epIsk1pEmXm3YQu1
-N0NxiAwdus9OnCXQ7GgZPRXCpxjJPNs7EIKFrYjKJfdtSzT85ZrTpHQtjim2L1ZP9iIlq2QVKD1v
-bKSjCwjtb9ztjrV-Bw1BHcAApPcfpXHLhYkJ7iL1XUhxjXp_DGUkD7ZN9S5tuyrsMXz5hh6wMfcq
-NPR_XqHaS2ur-ONNrHuFFCmY7Ehc5FArFzb_Xn1JTpOQJTcy6_3r3u3B_euT8GmXHahtVN1Rv8RM
-kAD5m_UBx-nHoZDVDYZkfR9k4hF2Sz5rfrWs6Zrl0r8FBrVFtU1j2vOTvTGwrkO9yZvgIqOkX_eq
-TnGIpM4paHxEGTP8H8A3Y0ZpsvLttmh0rT_OwzBPa1Mof3RQKhyTzfbptxuUJyVxU0Ln-9f--5Mk
-wEFqhuSrgssI6b1iMqm97PqFQMYrWX3SV8l0V-PKxFxDM1bguHq4mOXEtmZBUtMBepwSsI96 \ No newline at end of file
diff --git a/policy-management/src/main/server/config/aaf-system.properties b/policy-management/src/main/server/config/aaf-system.properties
deleted file mode 100644
index 9e64017f..00000000
--- a/policy-management/src/main/server/config/aaf-system.properties
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# ============LICENSE_START=======================================================
-# ONAP
-# ================================================================================
-# Copyright (C) 2019, 2021 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.
-# ============LICENSE_END=========================================================
-#
-
-# AAF related system properties
-
-aaf_locate_url=https://${env:AAF_HOST}:8095
-aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/onap.org.osaaf.aaf.introspect:2.1/introspect
-aaf_oauth2_token_url=https://AAF_LOCATE_URL/onap.org.osaaf.aaf.token:2.1/token
-aaf_url=https://AAF_LOCATE_URL/onap.org.osaaf.aaf.service:2.1
-aaf_env=DEV
-
-cadi_protocols=TLSv1.1,TLSv1.2
-cadi_latitude=38.000
-cadi_longitude=-72.000
-cadi_loglevel=DEBUG
-
-cadi_x509_issuers=CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_7, OU=OSAAF, O=ONAP, C=US
-cadi_keyfile=${envd:CADI_KEYFILE:/opt/app/policy/config/aaf-cadi.keyfile}
-cadi_keystore=${envd:KEYSTORE:/opt/app/policy/etc/ssl/policy-keystore}
-cadi_keystore_password=${envd:KEYSTORE_PASSWD:Pol1cy_0nap}
-cadi_key_password=${envd:KEYSTORE_PASSWD:Pol1cy_0nap}
-cadi_alias=policy@policy.onap.org
-cadi_truststore=${envd:TRUSTSTORE:/opt/app/policy/etc/ssl/policy-truststore}
-cadi_truststore_password=${envd:TRUSTSTORE_PASSWD:Pol1cy_0nap}
-
-cm_url=https://AAF_LOCATE_URL/onap.org.osaaf.aaf.cm:2.1
diff --git a/policy-management/src/main/server/config/engine.properties b/policy-management/src/main/server/config/engine.properties
index e30682f4..aa368fe9 100644
--- a/policy-management/src/main/server/config/engine.properties
+++ b/policy-management/src/main/server/config/engine.properties
@@ -3,6 +3,7 @@
# ONAP
# ================================================================================
# Copyright (C) 2019, 2021-2022 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.
@@ -30,11 +31,7 @@ http.server.services.CONFIG.restPackages=org.onap.policy.drools.server.restful
http.server.services.CONFIG.managed=false
http.server.services.CONFIG.swagger=true
http.server.services.CONFIG.https=${envd:HTTP_SERVER_HTTPS:false}
-http.server.services.CONFIG.aaf=${envd:AAF:false}
http.server.services.CONFIG.prometheus=${envd:PROMETHEUS:true}
http.server.services.CONFIG.serialization.provider=org.onap.policy.common.gson.JacksonHandler,org.onap.policy.common.endpoints.http.server.YamlJacksonHandler
-aaf.namespace=${envd:AAF_NAMESPACE:false}
-aaf.root.permission=${envd:AAF_NAMESPACE:org.onap.policy}.pdpd
-
engine.cluster=${envd:CLUSTER_NAME}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java
index 03301470..93d5ee43 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/DroolsControllerFactoryTest.java
@@ -3,6 +3,7 @@
* policy-management
* ================================================================================
* 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.
@@ -20,16 +21,16 @@
package org.onap.policy.drools.controller;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.onap.policy.drools.properties.DroolsPropertyConstants.PROPERTY_CONTROLLER_TYPE;
import java.util.List;
import java.util.Properties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.controller.internal.NullDroolsController;
import org.onap.policy.drools.features.DroolsControllerFeatureApi;
import org.onap.policy.drools.properties.DroolsPropertyConstants;
@@ -43,7 +44,7 @@ public class DroolsControllerFactoryTest {
public static final String TEST_VERSION = "testVersion";
@Test
- public void testBuildNullController() {
+ void testBuildNullController() {
Properties droolsProps = new Properties();
DroolsController droolsController = DroolsControllerConstants.getFactory().build(droolsProps, null, null);
@@ -53,7 +54,7 @@ public class DroolsControllerFactoryTest {
}
@Test
- public void testGetNullController() {
+ void testGetNullController() {
DroolsController controller =
DroolsControllerConstants.getFactory().get(DroolsControllerConstants.NO_GROUP_ID,
DroolsControllerConstants.NO_ARTIFACT_ID, DroolsControllerConstants.NO_VERSION);
@@ -65,26 +66,26 @@ public class DroolsControllerFactoryTest {
}
@Test
- public void testInventory() {
+ void testInventory() {
List<DroolsController> controllers = DroolsControllerConstants.getFactory().inventory();
assertNotNull(controllers);
- for (int i = 0; i < controllers.size(); i++) {
- if (!isNullController(controllers.get(i)) && !isActualController(controllers.get(i))) {
+ for (DroolsController controller : controllers) {
+ if (!isNullController(controller) && !isActualController(controller)) {
fail("drools controller is not a null controller");
}
}
}
@Test
- public void testShutdown() {
+ void testShutdown() {
DroolsControllerFactory droolsFactory = new IndexedDroolsControllerFactory();
droolsFactory.shutdown();
assertTrue(droolsFactory.inventory().isEmpty());
}
@Test
- public void testDestroy() {
+ void testDestroy() {
DroolsControllerFactory droolsFactory = new IndexedDroolsControllerFactory();
droolsFactory.destroy();
assertTrue(droolsFactory.inventory().isEmpty());
@@ -107,7 +108,7 @@ public class DroolsControllerFactoryTest {
}
@Test
- public void testControllerType() {
+ void testControllerType() {
DroolsControllerFactory droolsFactory = new IndexedDroolsControllerFactory();
Properties props = new Properties();
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
index f91c437a..fdbfab8f 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 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.
@@ -24,13 +24,14 @@ package org.onap.policy.drools.controller.internal;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+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.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
@@ -41,9 +42,10 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.kie.api.KieBase;
import org.kie.api.definition.KiePackage;
import org.kie.api.definition.rule.Query;
@@ -54,7 +56,8 @@ import org.kie.api.runtime.rule.QueryResults;
import org.kie.api.runtime.rule.QueryResultsRow;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.utils.services.OrderedServiceImpl;
import org.onap.policy.drools.core.PolicyContainer;
@@ -69,8 +72,8 @@ import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomGsonCoder;
import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.PotentialCoderFilter;
-@RunWith(MockitoJUnitRunner.class)
-public class MavenDroolsController2Test {
+@ExtendWith(MockitoExtension.class)
+class MavenDroolsController2Test {
private static final int FACT1_OBJECT = 1000;
private static final int FACT3_OBJECT = 1001;
@@ -186,113 +189,121 @@ public class MavenDroolsController2Test {
private MavenDroolsController drools;
+ AutoCloseable autoCloseable;
+
/**
* Initializes objects, including the drools controller.
*/
- @Before
+ @BeforeEach
public void setUp() {
- when(droolsProviders.getList()).thenReturn(List.of(prov1, prov2));
+ autoCloseable = MockitoAnnotations.openMocks(this);
+ lenient().when(droolsProviders.getList()).thenReturn(List.of(prov1, prov2));
- when(coderMgr.isDecodingSupported(GROUP, ARTIFACT, TOPIC)).thenReturn(true);
- when(coderMgr.decode(GROUP, ARTIFACT, TOPIC, EVENT_TEXT)).thenReturn(EVENT);
+ lenient().when(coderMgr.isDecodingSupported(GROUP, ARTIFACT, TOPIC)).thenReturn(true);
+ lenient().when(coderMgr.decode(GROUP, ARTIFACT, TOPIC, EVENT_TEXT)).thenReturn(EVENT);
- when(kieSess.getFactCount()).thenReturn(FACT_COUNT);
- when(kieSess.getFactHandles()).thenReturn(List.of(fact1, fact2, factex, fact3));
- when(kieSess.getFactHandles(any())).thenReturn(List.of(fact1, fact3));
- when(kieSess.getKieBase()).thenReturn(kieBase);
- when(kieSess.getQueryResults(QUERY, PARM1, PARM2)).thenReturn(queryResults);
+ lenient().when(kieSess.getFactCount()).thenReturn(FACT_COUNT);
+ lenient().when(kieSess.getFactHandles()).thenReturn(List.of(fact1, fact2, factex, fact3));
+ lenient().when(kieSess.getFactHandles(any())).thenReturn(List.of(fact1, fact3));
+ lenient().when(kieSess.getKieBase()).thenReturn(kieBase);
+ lenient().when(kieSess.getQueryResults(QUERY, PARM1, PARM2)).thenReturn(queryResults);
- when(kieSess.getFactHandle(FACT3_OBJECT)).thenReturn(fact3);
+ lenient().when(kieSess.getFactHandle(FACT3_OBJECT)).thenReturn(fact3);
- when(kieSess.getObject(fact1)).thenReturn(FACT1_OBJECT);
- when(kieSess.getObject(fact2)).thenReturn("");
- when(kieSess.getObject(fact3)).thenReturn(FACT3_OBJECT);
- when(kieSess.getObject(factex)).thenThrow(RUNTIME_EX);
+ lenient().when(kieSess.getObject(fact1)).thenReturn(FACT1_OBJECT);
+ lenient().when(kieSess.getObject(fact2)).thenReturn("");
+ lenient().when(kieSess.getObject(fact3)).thenReturn(FACT3_OBJECT);
+ lenient().when(kieSess.getObject(factex)).thenThrow(RUNTIME_EX);
- when(kieBase.getKiePackages()).thenReturn(List.of(pkg1, pkg2));
+ lenient().when(kieBase.getKiePackages()).thenReturn(List.of(pkg1, pkg2));
- when(pkg1.getQueries()).thenReturn(List.of(query3));
- when(pkg2.getQueries()).thenReturn(List.of(query2, query1));
+ lenient().when(pkg1.getQueries()).thenReturn(List.of(query3));
+ lenient().when(pkg2.getQueries()).thenReturn(List.of(query2, query1));
- when(query1.getName()).thenReturn(QUERY);
- when(query2.getName()).thenReturn(QUERY2);
+ lenient().when(query1.getName()).thenReturn(QUERY);
+ lenient().when(query2.getName()).thenReturn(QUERY2);
- when(queryResults.iterator()).thenReturn(List.of(row1, row2).iterator());
+ lenient().when(queryResults.iterator()).thenReturn(List.of(row1, row2).iterator());
- when(row1.get(ENTITY)).thenReturn(FACT1_OBJECT);
- when(row2.get(ENTITY)).thenReturn(FACT3_OBJECT);
+ lenient().when(row1.get(ENTITY)).thenReturn(FACT1_OBJECT);
+ lenient().when(row2.get(ENTITY)).thenReturn(FACT3_OBJECT);
- when(row1.getFactHandle(ENTITY)).thenReturn(fact1);
- when(row2.getFactHandle(ENTITY)).thenReturn(fact3);
+ lenient().when(row1.getFactHandle(ENTITY)).thenReturn(fact1);
+ lenient().when(row2.getFactHandle(ENTITY)).thenReturn(fact3);
- when(sess1.getKieSession()).thenReturn(kieSess);
- when(sess2.getKieSession()).thenReturn(kieSess2);
+ lenient().when(sess1.getKieSession()).thenReturn(kieSess);
+ lenient().when(sess2.getKieSession()).thenReturn(kieSess2);
- when(sess1.getName()).thenReturn(SESSION1);
- when(sess2.getName()).thenReturn(SESSION2);
+ lenient().when(sess1.getName()).thenReturn(SESSION1);
+ lenient().when(sess2.getName()).thenReturn(SESSION2);
- when(sess1.getFullName()).thenReturn(FULL_SESSION1);
- when(sess2.getFullName()).thenReturn(FULL_SESSION2);
+ lenient().when(sess1.getFullName()).thenReturn(FULL_SESSION1);
+ lenient().when(sess2.getFullName()).thenReturn(FULL_SESSION2);
- when(container.getClassLoader()).thenReturn(CLASS_LOADER);
- when(container.getPolicySessions()).thenReturn(List.of(sess1, sess2));
- when(container.insertAll(EVENT)).thenReturn(true);
+ lenient().when(container.getClassLoader()).thenReturn(CLASS_LOADER);
+ lenient().when(container.getPolicySessions()).thenReturn(List.of(sess1, sess2));
+ lenient().when(container.insertAll(EVENT)).thenReturn(true);
- when(decoder1.getTopic()).thenReturn(TOPIC);
- when(decoder2.getTopic()).thenReturn(TOPIC2);
+ lenient().when(decoder1.getTopic()).thenReturn(TOPIC);
+ lenient().when(decoder2.getTopic()).thenReturn(TOPIC2);
- when(encoder1.getTopic()).thenReturn(TOPIC);
- when(encoder2.getTopic()).thenReturn(TOPIC2);
+ lenient().when(encoder1.getTopic()).thenReturn(TOPIC);
+ lenient().when(encoder2.getTopic()).thenReturn(TOPIC2);
decoders = List.of(decoder1, decoder2);
encoders = List.of(encoder1, encoder2);
- when(decoder1.getCustomGsonCoder()).thenReturn(gson1);
- when(encoder2.getCustomGsonCoder()).thenReturn(gson2);
+ lenient().when(decoder1.getCustomGsonCoder()).thenReturn(gson1);
+ lenient().when(encoder2.getCustomGsonCoder()).thenReturn(gson2);
- when(filter1a.getCodedClass()).thenReturn(Object.class.getName());
- when(filter1a.getFilter()).thenReturn(jsonFilter1a);
+ lenient().when(filter1a.getCodedClass()).thenReturn(Object.class.getName());
+ lenient().when(filter1a.getFilter()).thenReturn(jsonFilter1a);
- when(filter1b.getCodedClass()).thenReturn(String.class.getName());
- when(filter1b.getFilter()).thenReturn(jsonFilter1b);
+ lenient().when(filter1b.getCodedClass()).thenReturn(String.class.getName());
+ lenient().when(filter1b.getFilter()).thenReturn(jsonFilter1b);
- when(filter2.getCodedClass()).thenReturn(Integer.class.getName());
- when(filter2.getFilter()).thenReturn(jsonFilter2);
+ lenient().when(filter2.getCodedClass()).thenReturn(Integer.class.getName());
+ lenient().when(filter2.getFilter()).thenReturn(jsonFilter2);
- when(decoder1.getCoderFilters()).thenReturn(List.of(filter1a, filter1b));
- when(decoder2.getCoderFilters()).thenReturn(Collections.emptyList());
+ lenient().when(decoder1.getCoderFilters()).thenReturn(List.of(filter1a, filter1b));
+ lenient().when(decoder2.getCoderFilters()).thenReturn(Collections.emptyList());
- when(encoder1.getCoderFilters()).thenReturn(Collections.emptyList());
- when(encoder2.getCoderFilters()).thenReturn(List.of(filter2));
+ lenient().when(encoder1.getCoderFilters()).thenReturn(Collections.emptyList());
+ lenient().when(encoder2.getCoderFilters()).thenReturn(List.of(filter2));
- when(sink.getTopic()).thenReturn(TOPIC);
- when(sink.send(EVENT_TEXT)).thenReturn(true);
+ lenient().when(sink.getTopic()).thenReturn(TOPIC);
+ lenient().when(sink.send(EVENT_TEXT)).thenReturn(true);
drools = new MyDrools(GROUP, ARTIFACT, VERSION, null, null);
- when(coderMgr.encode(TOPIC, EVENT, drools)).thenReturn(EVENT_TEXT);
+ lenient().when(coderMgr.encode(TOPIC, EVENT, drools)).thenReturn(EVENT_TEXT);
+ }
+
+ @AfterEach
+ void closeMocks() throws Exception {
+ autoCloseable.close();
}
@Test
- public void testMavenDroolsController_InvalidArgs() {
+ void testMavenDroolsController_InvalidArgs() {
assertThatIllegalArgumentException().isThrownBy(() -> new MyDrools(null, ARTIFACT, VERSION, null, null))
- .withMessageContaining("group");
+ .withMessageContaining("group");
assertThatIllegalArgumentException().isThrownBy(() -> new MyDrools("", ARTIFACT, VERSION, null, null))
- .withMessageContaining("group");
+ .withMessageContaining("group");
assertThatIllegalArgumentException().isThrownBy(() -> new MyDrools(GROUP, null, VERSION, null, null))
- .withMessageContaining("artifact");
+ .withMessageContaining("artifact");
assertThatIllegalArgumentException().isThrownBy(() -> new MyDrools(GROUP, "", VERSION, null, null))
- .withMessageContaining("artifact");
+ .withMessageContaining("artifact");
assertThatIllegalArgumentException().isThrownBy(() -> new MyDrools(GROUP, ARTIFACT, null, null, null))
- .withMessageContaining("version");
+ .withMessageContaining("version");
assertThatIllegalArgumentException().isThrownBy(() -> new MyDrools(GROUP, ARTIFACT, "", null, null))
- .withMessageContaining("version");
+ .withMessageContaining("version");
}
@Test
- public void testUpdateToVersion() {
+ void testUpdateToVersion() {
// add coders
drools.updateToVersion(GROUP, ARTIFACT, VERSION2, decoders, encoders);
@@ -320,7 +331,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testUpdateToVersion_Unchanged() {
+ void testUpdateToVersion_Unchanged() {
drools.updateToVersion(GROUP, ARTIFACT, VERSION, decoders, encoders);
verify(coderMgr, never()).addDecoder(any());
@@ -328,53 +339,53 @@ public class MavenDroolsController2Test {
}
@Test
- public void testUpdateToVersion_InvalidArgs() {
+ void testUpdateToVersion_InvalidArgs() {
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.updateToVersion(null, ARTIFACT, VERSION, null, null))
- .withMessageContaining("group");
+ .isThrownBy(() -> drools.updateToVersion(null, ARTIFACT, VERSION, null, null))
+ .withMessageContaining("group");
assertThatIllegalArgumentException().isThrownBy(() -> drools.updateToVersion("", ARTIFACT, VERSION, null, null))
- .withMessageContaining("group");
+ .withMessageContaining("group");
assertThatIllegalArgumentException().isThrownBy(() -> drools.updateToVersion(GROUP, null, VERSION, null, null))
- .withMessageContaining("artifact");
+ .withMessageContaining("artifact");
assertThatIllegalArgumentException().isThrownBy(() -> drools.updateToVersion(GROUP, "", VERSION, null, null))
- .withMessageContaining("artifact");
+ .withMessageContaining("artifact");
assertThatIllegalArgumentException().isThrownBy(() -> drools.updateToVersion(GROUP, ARTIFACT, null, null, null))
- .withMessageContaining("version");
+ .withMessageContaining("version");
assertThatIllegalArgumentException().isThrownBy(() -> drools.updateToVersion(GROUP, ARTIFACT, "", null, null))
- .withMessageContaining("version");
+ .withMessageContaining("version");
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.updateToVersion("no-group-id", ARTIFACT, VERSION, null, null))
- .withMessageContaining("BRAINLESS");
+ .isThrownBy(() -> drools.updateToVersion("no-group-id", ARTIFACT, VERSION, null, null))
+ .withMessageContaining("BRAINLESS");
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.updateToVersion(GROUP, "no-artifact-id", VERSION, null, null))
- .withMessageContaining("BRAINLESS");
+ .isThrownBy(() -> drools.updateToVersion(GROUP, "no-artifact-id", VERSION, null, null))
+ .withMessageContaining("BRAINLESS");
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.updateToVersion(GROUP, ARTIFACT, "no-version", null, null))
- .withMessageContaining("BRAINLESS");
+ .isThrownBy(() -> drools.updateToVersion(GROUP, ARTIFACT, "no-version", null, null))
+ .withMessageContaining("BRAINLESS");
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.updateToVersion(GROUP2, ARTIFACT, VERSION, null, null))
- .withMessageContaining("coordinates must be identical");
+ .isThrownBy(() -> drools.updateToVersion(GROUP2, ARTIFACT, VERSION, null, null))
+ .withMessageContaining("coordinates must be identical");
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.updateToVersion(GROUP, ARTIFACT2, VERSION, null, null))
- .withMessageContaining("coordinates must be identical");
+ .isThrownBy(() -> drools.updateToVersion(GROUP, ARTIFACT2, VERSION, null, null))
+ .withMessageContaining("coordinates must be identical");
}
@Test
- public void testInitCoders_NullCoders() {
+ void testInitCoders_NullCoders() {
// already constructed with null coders
verify(coderMgr, never()).addDecoder(any());
verify(coderMgr, never()).addEncoder(any());
}
@Test
- public void testInitCoders_NullOrEmptyFilters() {
+ void testInitCoders_NullOrEmptyFilters() {
when(decoder1.getCoderFilters()).thenReturn(Collections.emptyList());
when(decoder2.getCoderFilters()).thenReturn(null);
@@ -388,7 +399,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testInitCoders_GsonClass() {
+ void testInitCoders_GsonClass() {
when(gson1.getClassContainer()).thenReturn("");
when(gson2.getClassContainer()).thenReturn(Long.class.getName());
@@ -400,25 +411,25 @@ public class MavenDroolsController2Test {
}
@Test
- public void testInitCoders_InvalidGsonClass() {
+ void testInitCoders_InvalidGsonClass() {
when(gson1.getClassContainer()).thenReturn(UNKNOWN_CLASS);
assertThatIllegalArgumentException()
- .isThrownBy(() -> new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders))
- .withMessageContaining("cannot be retrieved");
+ .isThrownBy(() -> new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders))
+ .withMessageContaining("cannot be retrieved");
}
@Test
- public void testInitCoders_InvalidFilterClass() {
+ void testInitCoders_InvalidFilterClass() {
when(filter2.getCodedClass()).thenReturn(UNKNOWN_CLASS);
assertThatIllegalArgumentException()
- .isThrownBy(() -> new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders))
- .withMessageContaining("cannot be retrieved");
+ .isThrownBy(() -> new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders))
+ .withMessageContaining("cannot be retrieved");
}
@Test
- public void testInitCoders_Filters() {
+ void testInitCoders_Filters() {
drools = new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders);
@@ -458,7 +469,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOwnsCoder() {
+ void testOwnsCoder() {
int hc = CLASS_LOADER_HASHCODE;
// wrong hash code
@@ -478,7 +489,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testStart_testStop_testIsAlive() {
+ void testStart_testStop_testIsAlive() {
drools = new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders);
when(container.start()).thenReturn(true);
@@ -525,7 +536,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
drools = new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders);
// start it
@@ -546,7 +557,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testShutdown_Ex() {
+ void testShutdown_Ex() {
drools = new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders);
// start it
@@ -564,7 +575,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testHalt() {
+ void testHalt() {
drools = new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders);
// start it
@@ -584,7 +595,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testHalt_Ex() {
+ void testHalt_Ex() {
drools = new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders);
// start it
@@ -601,7 +612,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testRemoveCoders_Ex() {
+ void testRemoveCoders_Ex() {
drools = new MyDrools(GROUP, ARTIFACT, VERSION, decoders, encoders) {
@Override
protected void removeDecoders() {
@@ -618,7 +629,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferStringString() {
+ void testOfferStringString() {
drools.start();
assertTrue(drools.offer(TOPIC, EVENT_TEXT));
@@ -626,7 +637,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferStringString_NoDecode() {
+ void testOfferStringString_NoDecode() {
when(coderMgr.isDecodingSupported(GROUP, ARTIFACT, TOPIC)).thenReturn(false);
drools.start();
@@ -636,9 +647,9 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferStringString_DecodeUnsupported() {
+ void testOfferStringString_DecodeUnsupported() {
when(coderMgr.decode(GROUP, ARTIFACT, TOPIC, EVENT_TEXT))
- .thenThrow(new UnsupportedOperationException(EXPECTED_EXCEPTION));
+ .thenThrow(new UnsupportedOperationException(EXPECTED_EXCEPTION));
drools.start();
assertTrue(drools.offer(TOPIC, EVENT_TEXT));
@@ -647,7 +658,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferStringString_DecodeEx() {
+ void testOfferStringString_DecodeEx() {
when(coderMgr.decode(GROUP, ARTIFACT, TOPIC, EVENT_TEXT)).thenThrow(RUNTIME_EX);
drools.start();
@@ -657,7 +668,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferStringString_Ignored() {
+ void testOfferStringString_Ignored() {
drools.start();
drools.lock();
@@ -677,7 +688,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferT() {
+ void testOfferT() {
drools.start();
assertTrue(drools.offer(EVENT));
assertEquals(1, drools.getRecentSourceEvents().length);
@@ -692,7 +703,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferT_Ex() {
+ void testOfferT_Ex() {
when(prov1.beforeInsert(drools, EVENT)).thenThrow(RUNTIME_EX);
when(prov1.afterInsert(drools, EVENT, true)).thenThrow(RUNTIME_EX);
@@ -709,7 +720,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferT_NotInserted() {
+ void testOfferT_NotInserted() {
when(container.insertAll(EVENT)).thenReturn(false);
drools.start();
@@ -726,7 +737,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferT_BeforeInsertIntercept() {
+ void testOfferT_BeforeInsertIntercept() {
drools.start();
when(prov1.beforeInsert(drools, EVENT)).thenReturn(true);
@@ -744,7 +755,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferT_AfterInsertIntercept() {
+ void testOfferT_AfterInsertIntercept() {
drools.start();
when(prov1.afterInsert(drools, EVENT, true)).thenReturn(true);
@@ -764,7 +775,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testOfferT_Ignored() {
+ void testOfferT_Ignored() {
drools.start();
drools.lock();
@@ -784,7 +795,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testDeliver() {
+ void testDeliver() {
drools.start();
assertTrue(drools.deliver(sink, EVENT));
assertEquals(1, drools.getRecentSinkEvents().length);
@@ -800,14 +811,14 @@ public class MavenDroolsController2Test {
}
@Test
- public void testDeliver_InvalidArgs() {
+ void testDeliver_InvalidArgs() {
drools.start();
assertThatIllegalArgumentException().isThrownBy(() -> drools.deliver(null, EVENT))
- .withMessageContaining("sink");
+ .withMessageContaining("sink");
assertThatIllegalArgumentException().isThrownBy(() -> drools.deliver(sink, null))
- .withMessageContaining("event");
+ .withMessageContaining("event");
drools.lock();
assertThatIllegalStateException().isThrownBy(() -> drools.deliver(sink, EVENT)).withMessageContaining("locked");
@@ -815,14 +826,14 @@ public class MavenDroolsController2Test {
drools.stop();
assertThatIllegalStateException().isThrownBy(() -> drools.deliver(sink, EVENT))
- .withMessageContaining("stopped");
+ .withMessageContaining("stopped");
drools.start();
assertEquals(0, drools.getRecentSinkEvents().length);
}
@Test
- public void testDeliver_BeforeIntercept() {
+ void testDeliver_BeforeIntercept() {
when(prov1.beforeDeliver(drools, sink, EVENT)).thenReturn(true);
drools.start();
@@ -839,7 +850,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testDeliver_AfterIntercept() {
+ void testDeliver_AfterIntercept() {
when(prov1.afterDeliver(drools, sink, EVENT, EVENT_TEXT, true)).thenReturn(true);
drools.start();
@@ -859,7 +870,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testDeliver_InterceptEx() {
+ void testDeliver_InterceptEx() {
when(prov1.beforeDeliver(drools, sink, EVENT)).thenThrow(RUNTIME_EX);
when(prov1.afterDeliver(drools, sink, EVENT, EVENT_TEXT, true)).thenThrow(RUNTIME_EX);
@@ -874,7 +885,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testGetXxx() {
+ void testGetXxx() {
assertEquals(VERSION, drools.getVersion());
assertEquals(ARTIFACT, drools.getArtifactId());
assertEquals(GROUP, drools.getGroupId());
@@ -895,7 +906,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testLock_testUnlock_testIsLocked() {
+ void testLock_testUnlock_testIsLocked() {
assertFalse(drools.isLocked());
assertTrue(drools.lock());
@@ -913,7 +924,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testGetSessionNames_testGetCanonicalSessionNames() {
+ void testGetSessionNames_testGetCanonicalSessionNames() {
assertEquals("[session-A, session-B]", drools.getSessionNames(true).toString());
assertEquals("[full-A, full-B]", drools.getSessionNames(false).toString());
@@ -927,7 +938,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testGetBaseDomainNames() {
+ void testGetBaseDomainNames() {
KieContainer kiecont = mock(KieContainer.class);
when(kiecont.getKieBaseNames()).thenReturn(List.of("kieA", "kieB"));
when(container.getKieContainer()).thenReturn(kiecont);
@@ -936,12 +947,12 @@ public class MavenDroolsController2Test {
}
@Test
- public void testGetSession() {
+ void testGetSession() {
assertThatIllegalArgumentException().isThrownBy(() -> drools.getSession(null))
- .withMessageContaining("must be provided");
+ .withMessageContaining("must be provided");
assertThatIllegalArgumentException().isThrownBy(() -> drools.getSession(""))
- .withMessageContaining("must be provided");
+ .withMessageContaining("must be provided");
assertSame(sess1, drools.getSession(SESSION1));
assertSame(sess1, drools.getSession(FULL_SESSION1));
@@ -949,35 +960,35 @@ public class MavenDroolsController2Test {
assertSame(sess2, drools.getSession(SESSION2));
assertThatIllegalArgumentException().isThrownBy(() -> drools.getSession("unknown session"))
- .withMessageContaining("Invalid Session Name");
+ .withMessageContaining("Invalid Session Name");
}
@Test
- public void testFactClassNames() {
+ void testFactClassNames() {
// copy to a sorted map so the order remains unchanged
Map<String, Integer> map = new TreeMap<>(drools.factClassNames(SESSION1));
assertEquals("{java.lang.Integer=2, java.lang.String=1}", map.toString());
assertThatIllegalArgumentException().isThrownBy(() -> drools.factClassNames(null))
- .withMessageContaining("Invalid Session Name");
+ .withMessageContaining("Invalid Session Name");
assertThatIllegalArgumentException().isThrownBy(() -> drools.factClassNames(""))
- .withMessageContaining("Invalid Session Name");
+ .withMessageContaining("Invalid Session Name");
}
@Test
- public void testFactCount() {
+ void testFactCount() {
assertEquals(FACT_COUNT, drools.factCount(SESSION1));
assertThatIllegalArgumentException().isThrownBy(() -> drools.factCount(null))
- .withMessageContaining("Invalid Session Name");
+ .withMessageContaining("Invalid Session Name");
assertThatIllegalArgumentException().isThrownBy(() -> drools.factCount(""))
- .withMessageContaining("Invalid Session Name");
+ .withMessageContaining("Invalid Session Name");
}
@Test
- public void testFactsStringStringBoolean() {
+ void testFactsStringStringBoolean() {
assertEquals("[1000, 1001]", drools.facts(SESSION1, Integer.class.getName(), false).toString());
verify(kieSess, never()).delete(fact1);
verify(kieSess, never()).delete(fact2);
@@ -992,23 +1003,23 @@ public class MavenDroolsController2Test {
verify(kieSess, never()).delete(factex);
assertThatIllegalArgumentException().isThrownBy(() -> drools.facts(null, Integer.class.getName(), false))
- .withMessageContaining("Invalid Session Name");
+ .withMessageContaining("Invalid Session Name");
assertThatIllegalArgumentException().isThrownBy(() -> drools.facts("", Integer.class.getName(), false))
- .withMessageContaining("Invalid Session Name");
+ .withMessageContaining("Invalid Session Name");
assertThatIllegalArgumentException().isThrownBy(() -> drools.facts(SESSION1, null, false))
- .withMessageContaining("Invalid Class Name");
+ .withMessageContaining("Invalid Class Name");
assertThatIllegalArgumentException().isThrownBy(() -> drools.facts(SESSION1, "", false))
- .withMessageContaining("Invalid Class Name");
+ .withMessageContaining("Invalid Class Name");
assertThatIllegalArgumentException().isThrownBy(() -> drools.facts(SESSION1, UNKNOWN_CLASS, false))
- .withMessageContaining("classloader");
+ .withMessageContaining("classloader");
}
@Test
- public void testFactsStringStringBoolean_DeleteEx() {
+ void testFactsStringStringBoolean_DeleteEx() {
doThrow(RUNTIME_EX).when(kieSess).delete(fact1);
assertEquals("[1000, 1001]", drools.facts(SESSION1, Integer.class.getName(), true).toString());
@@ -1018,47 +1029,47 @@ public class MavenDroolsController2Test {
}
@Test
- public void testFactsStringClassOfT() {
+ void testFactsStringClassOfT() {
assertEquals("[1000, 1001]", drools.facts(SESSION1, Integer.class).toString());
}
@Test
- public void testFactQuery() {
+ void testFactQuery() {
assertEquals("[1000, 1001]", drools.factQuery(SESSION1, QUERY, ENTITY, false, PARM1, PARM2).toString());
verify(kieSess, never()).delete(fact1);
verify(kieSess, never()).delete(fact3);
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.factQuery(null, QUERY, ENTITY, false, PARM1, PARM2))
- .withMessageContaining("Invalid Session Name");
+ .isThrownBy(() -> drools.factQuery(null, QUERY, ENTITY, false, PARM1, PARM2))
+ .withMessageContaining("Invalid Session Name");
assertThatIllegalArgumentException().isThrownBy(() -> drools.factQuery("", QUERY, ENTITY, false, PARM1, PARM2))
- .withMessageContaining("Invalid Session Name");
+ .withMessageContaining("Invalid Session Name");
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.factQuery(SESSION1, null, ENTITY, false, PARM1, PARM2))
- .withMessageContaining("Invalid Query Name");
+ .isThrownBy(() -> drools.factQuery(SESSION1, null, ENTITY, false, PARM1, PARM2))
+ .withMessageContaining("Invalid Query Name");
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.factQuery(SESSION1, "", ENTITY, false, PARM1, PARM2))
- .withMessageContaining("Invalid Query Name");
+ .isThrownBy(() -> drools.factQuery(SESSION1, "", ENTITY, false, PARM1, PARM2))
+ .withMessageContaining("Invalid Query Name");
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.factQuery(SESSION1, QUERY, null, false, PARM1, PARM2))
- .withMessageContaining("Invalid Queried Entity");
+ .isThrownBy(() -> drools.factQuery(SESSION1, QUERY, null, false, PARM1, PARM2))
+ .withMessageContaining("Invalid Queried Entity");
assertThatIllegalArgumentException()
- .isThrownBy(() -> drools.factQuery(SESSION1, QUERY, "", false, PARM1, PARM2))
- .withMessageContaining("Invalid Queried Entity");
+ .isThrownBy(() -> drools.factQuery(SESSION1, QUERY, "", false, PARM1, PARM2))
+ .withMessageContaining("Invalid Queried Entity");
assertThatIllegalArgumentException().isThrownBy(
- () -> drools.factQuery(SESSION1, QUERY + "-unknown-query", ENTITY, false, PARM1, PARM2))
+ () -> drools.factQuery(SESSION1, QUERY + "-unknown-query", ENTITY, false, PARM1, PARM2))
.withMessageContaining("Invalid Query Name");
}
@Test
- public void testFactQuery_Delete() {
+ void testFactQuery_Delete() {
doThrow(RUNTIME_EX).when(kieSess).delete(fact1);
assertEquals("[1000, 1001]", drools.factQuery(SESSION1, QUERY, ENTITY, true, PARM1, PARM2).toString());
@@ -1068,7 +1079,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testDeleteStringT() {
+ void testDeleteStringT() {
assertTrue(drools.delete(SESSION1, FACT3_OBJECT));
verify(kieSess, never()).delete(fact1);
@@ -1087,14 +1098,14 @@ public class MavenDroolsController2Test {
}
@Test
- public void testDeleteT() {
+ void testDeleteT() {
assertTrue(drools.delete(FACT3_OBJECT));
verify(kieSess).delete(fact3);
}
@Test
- public void testDeleteStringClassOfT() {
+ void testDeleteStringClassOfT() {
assertTrue(drools.delete(SESSION1, Integer.class));
verify(kieSess).delete(fact1);
@@ -1102,7 +1113,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testDeleteStringClassOfT_Ex() {
+ void testDeleteStringClassOfT_Ex() {
doThrow(RUNTIME_EX).when(kieSess).delete(fact1);
assertFalse(drools.delete(SESSION1, Integer.class));
@@ -1112,7 +1123,7 @@ public class MavenDroolsController2Test {
}
@Test
- public void testDeleteClassOfT() {
+ void testDeleteClassOfT() {
assertTrue(drools.delete(Integer.class));
verify(kieSess).delete(fact1);
@@ -1120,17 +1131,17 @@ public class MavenDroolsController2Test {
}
@Test
- public void testFetchModelClass() {
+ void testFetchModelClass() {
assertSame(Long.class, drools.fetchModelClass(Long.class.getName()));
}
@Test
- public void testIsBrained() {
+ void testIsBrained() {
assertTrue(drools.isBrained());
}
@Test
- public void testToString() {
+ void testToString() {
assertNotNull(drools.toString());
}
@@ -1155,9 +1166,9 @@ public class MavenDroolsController2Test {
@Override
protected PolicyContainer makePolicyContainer(String groupId, String artifactId, String version) {
- when(container.getGroupId()).thenReturn(groupId);
- when(container.getArtifactId()).thenReturn(artifactId);
- when(container.getVersion()).thenReturn(version);
+ lenient().when(container.getGroupId()).thenReturn(groupId);
+ lenient().when(container.getArtifactId()).thenReturn(artifactId);
+ lenient().when(container.getVersion()).thenReturn(version);
return container;
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
index a2f41bc6..fbaf8433 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerTest.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.
@@ -20,14 +21,17 @@
package org.onap.policy.drools.controller.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.io.IOException;
import java.nio.file.Paths;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.kie.api.builder.ReleaseId;
import org.onap.policy.common.utils.gson.GsonTestUtils;
import org.onap.policy.drools.controller.DroolsController;
@@ -49,7 +53,7 @@ public class MavenDroolsControllerTest {
*
* @throws IOException throws an IO exception
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws IOException {
releaseId =
KieUtils.installArtifact(Paths.get(JUNIT_ECHO_KMODULE_PATH).toFile(),
@@ -58,7 +62,7 @@ public class MavenDroolsControllerTest {
Paths.get(JUNIT_ECHO_KMODULE_DRL_PATH).toFile());
}
- @Before
+ @BeforeEach
public void setUp() {
running = new CountDownLatch(1);
}
@@ -68,58 +72,58 @@ public class MavenDroolsControllerTest {
}
@Test
- public void stop() throws InterruptedException {
+ void stop() throws InterruptedException {
createDroolsController(10000L).stop();
}
@Test
- public void shutdown() throws InterruptedException {
+ void shutdown() throws InterruptedException {
createDroolsController(10000L).shutdown();
}
@Test
- public void testLock() throws InterruptedException {
+ void testLock() throws InterruptedException {
DroolsController controller = createDroolsController(30000L);
controller.lock();
- Assert.assertTrue(controller.isLocked());
+ assertTrue(controller.isLocked());
controller.unlock();
- Assert.assertFalse(controller.isLocked());
+ assertFalse(controller.isLocked());
controller.halt();
- Assert.assertFalse(controller.isAlive());
+ assertFalse(controller.isAlive());
new GsonTestUtils().compareGson(controller, MavenDroolsControllerTest.class);
}
@Test
- public void testFact() throws InterruptedException {
+ void testFact() throws InterruptedException {
DroolsController controller = createDroolsController(30000L);
Integer one = 1;
Integer two = 2;
- Assert.assertTrue(controller.offer(one));
- Assert.assertTrue(controller.exists(one));
- Assert.assertFalse(controller.exists(two));
+ assertTrue(controller.offer(one));
+ assertTrue(controller.exists(one));
+ assertFalse(controller.exists(two));
- Assert.assertTrue(controller.offer(two));
- Assert.assertTrue(controller.exists(one));
- Assert.assertTrue(controller.exists(two));
+ assertTrue(controller.offer(two));
+ assertTrue(controller.exists(one));
+ assertTrue(controller.exists(two));
Integer three = 3;
- Assert.assertFalse(controller.delete(three));
- Assert.assertTrue(controller.exists(one));
- Assert.assertTrue(controller.exists(two));
+ assertFalse(controller.delete(three));
+ assertTrue(controller.exists(one));
+ assertTrue(controller.exists(two));
- Assert.assertTrue(controller.delete(two));
- Assert.assertTrue(controller.exists(one));
- Assert.assertFalse(controller.exists(two));
+ assertTrue(controller.delete(two));
+ assertTrue(controller.exists(one));
+ assertFalse(controller.exists(two));
- Assert.assertTrue(controller.delete(one));
- Assert.assertFalse(controller.exists(one));
- Assert.assertFalse(controller.exists(two));
+ assertTrue(controller.delete(one));
+ assertFalse(controller.exists(one));
+ assertFalse(controller.exists(two));
}
private DroolsController createDroolsController(long courtesyStartTimeMs) throws InterruptedException {
@@ -130,31 +134,31 @@ public class MavenDroolsControllerTest {
DroolsController controller = new MavenDroolsController(releaseId.getGroupId(),
releaseId.getArtifactId(), releaseId.getVersion(), null, null);
- Assert.assertFalse(controller.isAlive());
- Assert.assertTrue(controller.isBrained());
+ assertFalse(controller.isAlive());
+ assertTrue(controller.isBrained());
controller.start();
- Assert.assertTrue(controller.isAlive());
- Assert.assertTrue(controller.isBrained());
+ assertTrue(controller.isAlive());
+ assertTrue(controller.isBrained());
- Assert.assertEquals(releaseId.getGroupId(), controller.getGroupId());
- Assert.assertEquals(releaseId.getArtifactId(), controller.getArtifactId());
- Assert.assertEquals(releaseId.getVersion(), controller.getVersion());
+ assertEquals(releaseId.getGroupId(), controller.getGroupId());
+ assertEquals(releaseId.getArtifactId(), controller.getArtifactId());
+ assertEquals(releaseId.getVersion(), controller.getVersion());
- Assert.assertEquals(releaseId.getGroupId(), controller.getContainer().getGroupId());
- Assert.assertEquals(releaseId.getArtifactId(), controller.getContainer().getArtifactId());
- Assert.assertEquals(releaseId.getVersion(), controller.getContainer().getVersion());
+ assertEquals(releaseId.getGroupId(), controller.getContainer().getGroupId());
+ assertEquals(releaseId.getArtifactId(), controller.getContainer().getArtifactId());
+ assertEquals(releaseId.getVersion(), controller.getContainer().getVersion());
/* allow full initialization from local maven repository */
- Assert.assertTrue(running.await(courtesyStartTimeMs, TimeUnit.MILLISECONDS));
+ assertTrue(running.await(courtesyStartTimeMs, TimeUnit.MILLISECONDS));
- Assert.assertEquals(1, controller.getSessionNames().size());
- Assert.assertEquals(JUNIT_ECHO_KSESSION, controller.getSessionNames().get(0));
- Assert.assertEquals(1, controller.getCanonicalSessionNames().size());
- Assert.assertTrue(controller.getCanonicalSessionNames().get(0).contains(JUNIT_ECHO_KSESSION));
+ assertEquals(1, controller.getSessionNames().size());
+ assertEquals(JUNIT_ECHO_KSESSION, controller.getSessionNames().get(0));
+ assertEquals(1, controller.getCanonicalSessionNames().size());
+ assertTrue(controller.getCanonicalSessionNames().get(0).contains(JUNIT_ECHO_KSESSION));
- Assert.assertEquals(JUNIT_ECHO_KBASE, String.join(",", controller.getBaseDomainNames()));
+ assertEquals(JUNIT_ECHO_KBASE, String.join(",", controller.getBaseDomainNames()));
return controller;
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.java
index b71403e7..38b38a8c 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsControllerUpgradesTest.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.
@@ -20,11 +21,12 @@
package org.onap.policy.drools.controller.internal;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
@@ -33,10 +35,10 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+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.kie.api.builder.ReleaseId;
import org.kie.api.event.rule.AfterMatchFiredEvent;
import org.kie.api.event.rule.AgendaEventListener;
@@ -93,15 +95,16 @@ public class MavenDroolsControllerUpgradesTest {
/**
* Test Class Initialization.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() throws IOException {
+ Path path = Paths.get(DROOLS_RESOURCES_DIR + "rules1" + DRL_EXT);
rulesDescriptor1 =
install("rules1",
- Stream.of(Paths.get(DROOLS_RESOURCES_DIR + "rules1" + DRL_EXT).toFile()).collect(Collectors.toList()));
+ Stream.of(path.toFile()).collect(Collectors.toList()));
rulesDescriptor2 =
install("rules2",
- Stream.of(Paths.get(DROOLS_RESOURCES_DIR + "rules1" + DRL_EXT).toFile(),
+ Stream.of(path.toFile(),
Paths.get(DROOLS_RESOURCES_DIR + "rules2" + DRL_EXT).toFile())
.collect(Collectors.toList()));
@@ -112,7 +115,7 @@ public class MavenDroolsControllerUpgradesTest {
/**
* Creates a controller before each test.
*/
- @Before
+ @BeforeEach
public void beforeTest() {
controller =
new MavenDroolsController(
@@ -123,7 +126,7 @@ public class MavenDroolsControllerUpgradesTest {
/**
* Shuts down the controller after each test.
*/
- @After
+ @AfterEach
public void afterTest() {
if (controller != null) {
controller.halt();
@@ -134,13 +137,13 @@ public class MavenDroolsControllerUpgradesTest {
* Upgrades test.
*/
@Test
- public void upgrades() throws InterruptedException {
+ void upgrades() throws InterruptedException {
assertTrue(controller.start());
logKieEvents();
assertTrue(running1a.await(30, TimeUnit.SECONDS));
summary();
- assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12"), 1);
+ assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12"));
controller.updateToVersion(
rulesDescriptor2.getGroupId(),
@@ -152,7 +155,7 @@ public class MavenDroolsControllerUpgradesTest {
assertTrue(running2b.await(30, TimeUnit.SECONDS));
assertTrue(running1b.await(30, TimeUnit.SECONDS));
summary();
- assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12", "SETUP.2", "VERSION.2"), 1);
+ assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12", "SETUP.2", "VERSION.2"));
controller.updateToVersion(
rulesDescriptor1.getGroupId(),
@@ -161,7 +164,7 @@ public class MavenDroolsControllerUpgradesTest {
null, null);
summary();
- assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12"), 1);
+ assertKie(Arrays.asList("run-drools-runnable", "SETUP.1", "VERSION.12"));
}
private void summary() {
@@ -176,11 +179,11 @@ public class MavenDroolsControllerUpgradesTest {
logger.info("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
- private void assertKie(List<String> expectedRuleNames, long expectedFactCount) {
+ private void assertKie(List<String> expectedRuleNames) {
assertEquals(Collections.singletonList("kbRules"),
KieUtils.getBases(controller.getContainer().getKieContainer()));
assertEquals(expectedRuleNames, KieUtils.getRuleNames(controller.getContainer().getKieContainer()));
- assertEquals(expectedFactCount, controller.factCount(controller.getSessionNames().get(0)));
+ assertEquals(1, controller.factCount(controller.getSessionNames().get(0)));
}
private void logKieEvents() {
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
index 010056bb..f61412d9 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -21,147 +22,158 @@
package org.onap.policy.drools.controller.internal;
import static org.assertj.core.api.Assertions.assertThatCode;
-
-import org.junit.Assert;
-import org.junit.Test;
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.gson.GsonTestUtils;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.controller.DroolsControllerConstants;
-public class NullDroolsControllerTest {
+class NullDroolsControllerTest {
@Test
- public void testStart() {
+ void testStart() {
DroolsController controller = new NullDroolsController();
controller.start();
- Assert.assertFalse(controller.isAlive());
+ assertFalse(controller.isAlive());
controller.stop();
- Assert.assertFalse(controller.isAlive());
+ assertFalse(controller.isAlive());
controller.shutdown();
- Assert.assertFalse(controller.isAlive());
+ assertFalse(controller.isAlive());
controller.halt();
- Assert.assertFalse(controller.isAlive());
+ assertFalse(controller.isAlive());
}
@Test
- public void testSerialize() {
+ void testSerialize() {
assertThatCode(() -> new GsonTestUtils().compareGson(new NullDroolsController(),
NullDroolsControllerTest.class)).doesNotThrowAnyException();
}
@Test
- public void testLock() {
+ void testLock() {
DroolsController controller = new NullDroolsController();
controller.lock();
- Assert.assertFalse(controller.isLocked());
+ assertFalse(controller.isLocked());
controller.unlock();
- Assert.assertFalse(controller.isLocked());
+ assertFalse(controller.isLocked());
}
@Test
- public void getGroupId() {
- Assert.assertEquals(DroolsControllerConstants.NO_GROUP_ID, new NullDroolsController().getGroupId());
+ void getGroupId() {
+ assertEquals(DroolsControllerConstants.NO_GROUP_ID, new NullDroolsController().getGroupId());
}
@Test
- public void getArtifactId() {
- Assert.assertEquals(DroolsControllerConstants.NO_ARTIFACT_ID, new NullDroolsController().getArtifactId());
+ void getArtifactId() {
+ assertEquals(DroolsControllerConstants.NO_ARTIFACT_ID, new NullDroolsController().getArtifactId());
}
@Test
- public void getVersion() {
- Assert.assertEquals(DroolsControllerConstants.NO_VERSION, new NullDroolsController().getVersion());
+ void getVersion() {
+ assertEquals(DroolsControllerConstants.NO_VERSION, new NullDroolsController().getVersion());
}
@Test
- public void getSessionNames() {
- Assert.assertTrue(new NullDroolsController().getSessionNames().isEmpty());
+ void getSessionNames() {
+ assertTrue(new NullDroolsController().getSessionNames().isEmpty());
}
@Test
- public void getCanonicalSessionNames() {
- Assert.assertTrue(new NullDroolsController().getCanonicalSessionNames().isEmpty());
+ void getCanonicalSessionNames() {
+ assertTrue(new NullDroolsController().getCanonicalSessionNames().isEmpty());
}
@Test
- public void offer() {
- Assert.assertFalse(new NullDroolsController().offer(null, null));
+ void offer() {
+ assertFalse(new NullDroolsController().offer(null, null));
}
- @Test(expected = IllegalStateException.class)
- public void deliver() {
- new NullDroolsController().deliver(null, null);
+ @Test
+ void deliver() {
+ var controller = new NullDroolsController();
+ assertThrows(IllegalStateException.class, () -> controller.deliver(null, null));
}
@Test
- public void getRecentSourceEvents() {
- Assert.assertEquals(0, new NullDroolsController().getRecentSourceEvents().length);
+ void getRecentSourceEvents() {
+ assertEquals(0, new NullDroolsController().getRecentSourceEvents().length);
}
@Test
- public void getRecentSinkEvents() {
- Assert.assertEquals(0, new NullDroolsController().getRecentSinkEvents().length);
+ void getRecentSinkEvents() {
+ assertEquals(0, new NullDroolsController().getRecentSinkEvents().length);
}
@Test
- public void getContainer() {
- Assert.assertNull(new NullDroolsController().getContainer());
+ void getContainer() {
+ assertNull(new NullDroolsController().getContainer());
}
@Test
- public void getDomains() {
- Assert.assertTrue(new NullDroolsController().getBaseDomainNames().isEmpty());
+ void getDomains() {
+ assertTrue(new NullDroolsController().getBaseDomainNames().isEmpty());
}
- @Test(expected = IllegalStateException.class)
- public void ownsCoder() {
- new NullDroolsController().ownsCoder(null, 0);
+ @Test
+ void ownsCoder() {
+ var controller = new NullDroolsController();
+ assertThrows(IllegalStateException.class, () -> controller.ownsCoder(null, 0));
}
- @Test(expected = IllegalArgumentException.class)
- public void fetchModelClass() {
- new NullDroolsController().fetchModelClass(this.getClass().getName());
+ @Test
+ void fetchModelClass() {
+ var controller = new NullDroolsController();
+ var className = this.getClass().getName();
+ assertThrows(IllegalArgumentException.class, () -> controller.fetchModelClass(className));
}
@Test
- public void isBrained() {
- Assert.assertFalse(new NullDroolsController().isBrained());
+ void isBrained() {
+ assertFalse(new NullDroolsController().isBrained());
}
@Test
- public void stringify() {
- Assert.assertNotNull(new NullDroolsController().toString());
+ void stringify() {
+ assertNotNull(new NullDroolsController().toString());
}
- @Test(expected = IllegalArgumentException.class)
- public void updateToVersion() {
- new NullDroolsController().updateToVersion(null, null, null, null, null);
+ @Test
+ void updateToVersion() {
+ var controller = new NullDroolsController();
+ assertThrows(IllegalArgumentException.class, () ->
+ controller.updateToVersion(null, null, null, null, null));
}
@Test
- public void factClassNames() {
- Assert.assertTrue(new NullDroolsController().factClassNames(null).isEmpty());
+ void factClassNames() {
+ assertTrue(new NullDroolsController().factClassNames(null).isEmpty());
}
@Test
- public void factCount() {
- Assert.assertEquals(0, new NullDroolsController().factCount(null));
+ void factCount() {
+ assertEquals(0, new NullDroolsController().factCount(null));
}
@Test
- public void facts() {
- Assert.assertTrue(new NullDroolsController().facts(null, null, true).isEmpty());
+ void facts() {
+ assertTrue(new NullDroolsController().facts(null, null, true).isEmpty());
}
@Test
- public void factQuery() {
- Assert.assertTrue(new NullDroolsController().factQuery(null, null, null, false).isEmpty());
+ void factQuery() {
+ assertTrue(new NullDroolsController().factQuery(null, null, null, false).isEmpty());
}
@Test
- public void exists() {
+ void exists() {
Object o1 = new Object();
- Assert.assertFalse(new NullDroolsController().exists("blah", o1));
- Assert.assertFalse(new NullDroolsController().exists(o1));
+ assertFalse(new NullDroolsController().exists("blah", o1));
+ assertFalse(new NullDroolsController().exists(o1));
}
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java b/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java
index 15a0b18f..b6a9ce52 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-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.
@@ -20,9 +21,9 @@
package org.onap.policy.drools.persistence;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -32,17 +33,17 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Properties;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
import org.onap.policy.drools.properties.DroolsPropertyConstants;
/**
* (File) System Persistence Tests.
*/
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@TestMethodOrder(MethodOrderer.MethodName.class)
public class SystemPersistenceTest {
/**
* sample configuration dir.
@@ -124,18 +125,18 @@ public class SystemPersistenceTest {
private static final String SYSTEM_PROPS = TEST_CONTROLLER_NAME;
private static final String SYSTEM_PROPS_FILE = SYSTEM_PROPS + "-system.properties";
- @BeforeClass
+ @BeforeAll
public static void setUp() throws IOException {
cleanUpWorkingDirs();
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws IOException {
cleanUpWorkingDirs();
}
@Test
- public void test1NonDefaultConfigDir() {
+ void test1NonDefaultConfigDir() {
SystemPersistenceConstants.getManager().setConfigurationDir(OTHER_CONFIG_DIR);
assertEquals(OTHER_CONFIG_DIR, SystemPersistenceConstants.getManager().getConfigurationPath().toString());
@@ -149,7 +150,7 @@ public class SystemPersistenceTest {
}
@Test
- public void test2Engine_Environment_System() throws IOException {
+ void test2Engine_Environment_System() throws IOException {
SystemPersistenceConstants.getManager().setConfigurationDir(OTHER_CONFIG_DIR);
final Path policyEnginePropsPath =
@@ -191,7 +192,7 @@ public class SystemPersistenceTest {
}
@Test
- public void test3Topic() {
+ void test3Topic() {
SystemPersistenceConstants.getManager().setConfigurationDir(null);
Path topicPath = Paths
@@ -221,7 +222,7 @@ public class SystemPersistenceTest {
}
@Test
- public void test4HttpServer() {
+ void test4HttpServer() {
SystemPersistenceConstants.getManager().setConfigurationDir(null);
Path httpServerPath = Paths
@@ -251,7 +252,7 @@ public class SystemPersistenceTest {
}
@Test
- public void test5HttpClient() {
+ void test5HttpClient() {
SystemPersistenceConstants.getManager().setConfigurationDir(null);
Path httpClientPath = Paths
@@ -281,7 +282,7 @@ public class SystemPersistenceTest {
}
@Test
- public void test6Controller() {
+ void test6Controller() {
SystemPersistenceConstants.getManager().setConfigurationDir(null);
Path controllerPath = Paths
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java
index b6168a2e..6d461eef 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -21,12 +22,12 @@
package org.onap.policy.drools.protocol.coders;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Properties;
import lombok.AllArgsConstructor;
import lombok.Getter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
@@ -34,7 +35,7 @@ import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
/**
* Tests Coders.
*/
-public class EventProtocolCoderTest {
+class EventProtocolCoderTest {
/**
* Coder Group.
@@ -66,7 +67,7 @@ public class EventProtocolCoderTest {
}
@Test
- public void test() {
+ void test() {
final Properties noopSinkProperties = new Properties();
noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java
index e0baeb6d..28b3e040 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilterTest.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.
@@ -20,13 +21,14 @@
package org.onap.policy.drools.protocol.coders;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class JsonProtocolFilterTest {
+class JsonProtocolFilterTest {
private static final String JSON =
"{\"requestID\":\"38adde30-cc22-11e8-a8d5-f2801f1b9fd1\",\"entity\":\"controller\","
@@ -38,7 +40,7 @@ public class JsonProtocolFilterTest {
* Tests getting the rule expression of the filter.
*/
@Test
- public void getRuleTest() {
+ void getRuleTest() {
assertEquals("$.test", new JsonProtocolFilter("$.test").getRule());
}
@@ -46,7 +48,7 @@ public class JsonProtocolFilterTest {
* Tests setting the rule expression of the filter.
*/
@Test
- public void setRuleTest() {
+ void setRuleTest() {
JsonProtocolFilter filter = new JsonProtocolFilter();
assertEquals(JsonProtocolFilter.MATCH_ANY, filter.getRule());
filter.setRule("$.test");
@@ -57,7 +59,7 @@ public class JsonProtocolFilterTest {
* Tests that the rule expression will be set to match anything if an empty string is passed.
*/
@Test
- public void setRuleEmptyTest() {
+ void setRuleEmptyTest() {
assertEquals(JsonProtocolFilter.MATCH_ANY, new JsonProtocolFilter("").getRule());
}
@@ -65,7 +67,7 @@ public class JsonProtocolFilterTest {
* Tests that the rule expression will be set to match anything if a null string is passed.
*/
@Test
- public void setRuleNullTest() {
+ void setRuleNullTest() {
assertEquals(JsonProtocolFilter.MATCH_ANY, new JsonProtocolFilter(null).getRule());
}
@@ -73,7 +75,7 @@ public class JsonProtocolFilterTest {
* Tests accepting a message if all filter rules pass.
*/
@Test
- public void acceptPassTest() {
+ void acceptPassTest() {
assertTrue(new JsonProtocolFilter(
"$.controllers[?(@.drools.version =~ /\\d\\.\\d\\.\\d/ && @.operation == 'update')]")
.accept(JSON));
@@ -83,7 +85,7 @@ public class JsonProtocolFilterTest {
* Tests accepting a message without having to filter if the rule is set to match anything.
*/
@Test
- public void acceptAnyTest() {
+ void acceptAnyTest() {
assertTrue(new JsonProtocolFilter(null).accept(JSON));
}
@@ -91,7 +93,7 @@ public class JsonProtocolFilterTest {
* Tests rejecting a message if one or more of the filter rules fail.
*/
@Test
- public void acceptFailTest() {
+ void acceptFailTest() {
assertFalse(
new JsonProtocolFilter("$.controllers[?(@.drools.version =~ /\\\\d\\\\.\\\\d\\\\.2/)]")
.accept(JSON));
@@ -101,7 +103,7 @@ public class JsonProtocolFilterTest {
* Tests finding field matches for a filter rule corresponding to a topic.
*/
@Test
- public void filterPassTest() {
+ void filterPassTest() {
assertEquals("38adde30-cc22-11e8-a8d5-f2801f1b9fd1", new JsonProtocolFilter("$.requestID").filter(JSON).get(0));
}
@@ -109,7 +111,7 @@ public class JsonProtocolFilterTest {
* Tests that an empty list is returned when no matches are found.
*/
@Test
- public void filterFailTest() {
+ void filterFailTest() {
assertTrue(new JsonProtocolFilter("$.test").filter(JSON).isEmpty());
}
@@ -117,7 +119,7 @@ public class JsonProtocolFilterTest {
* Tests static method for filtering a JSON string with an arbitrary expression.
*/
@Test
- public void staticFilterPassTest() {
+ void staticFilterPassTest() {
assertEquals("controller", JsonProtocolFilter.filter(JSON, "$.entity").get(0));
}
@@ -125,39 +127,39 @@ public class JsonProtocolFilterTest {
* Tests that an empty list is returned when the static filter() method does not find any matches.
*/
@Test
- public void staticFilterFailTest() {
+ void staticFilterFailTest() {
assertTrue(JsonProtocolFilter.filter(JSON, "$.test").isEmpty());
}
/**
* Tests that an exception is thrown if a null JSON string is passed.
*/
- @Test(expected = IllegalArgumentException.class)
- public void staticFilterNullJsonTest() {
- JsonProtocolFilter.filter(null, "[?($ =~ /.*/");
+ @Test
+ void staticFilterNullJsonTest() {
+ assertThrows(IllegalArgumentException.class, () -> JsonProtocolFilter.filter(null, "[?($ =~ /.*/"));
}
/**
* Tests that an exception is thrown if an empty JSON string is passed.
*/
- @Test(expected = IllegalArgumentException.class)
- public void staticFilterEmptyJsonTest() {
- JsonProtocolFilter.filter("", "[?($ =~ /.*/");
+ @Test
+ void staticFilterEmptyJsonTest() {
+ assertThrows(IllegalArgumentException.class, () -> JsonProtocolFilter.filter("", "[?($ =~ /.*/"));
}
/**
* Tests that an exception is thrown if a null expression string is passed.
*/
- @Test(expected = IllegalArgumentException.class)
- public void staticFilterNullExpressionTest() {
- JsonProtocolFilter.filter("{\"hello\":\"world\"}", null);
+ @Test
+ void staticFilterNullExpressionTest() {
+ assertThrows(IllegalArgumentException.class, () -> JsonProtocolFilter.filter("{\"hello\":\"world\"}", null));
}
/**
* Tests that an exception is thrown if an empty expression string is passed.
*/
- @Test(expected = IllegalArgumentException.class)
- public void staticFilterEmptyExpressionTest() {
- JsonProtocolFilter.filter("{\"hello\":\"world\"}", "");
+ @Test
+ void staticFilterEmptyExpressionTest() {
+ assertThrows(IllegalArgumentException.class, () -> JsonProtocolFilter.filter("{\"hello\":\"world\"}", ""));
}
} \ No newline at end of file
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
index 6d1ec3d3..659965f8 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-2021-2022 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,11 +22,11 @@
package org.onap.policy.drools.protocol.coders;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -35,10 +36,10 @@ import java.util.List;
import java.util.Properties;
import lombok.AllArgsConstructor;
import lombok.Getter;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+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.kie.api.builder.ReleaseId;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
@@ -73,7 +74,7 @@ public class ProtocolCoderToolsetTest {
/**
* Test Class Initialization.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpClass() throws IOException {
releaseId = KieUtils.installArtifact(Paths.get(MavenDroolsControllerTest.JUNIT_ECHO_KMODULE_PATH).toFile(),
Paths.get(MavenDroolsControllerTest.JUNIT_ECHO_KMODULE_POM_PATH).toFile(),
@@ -84,7 +85,7 @@ public class ProtocolCoderToolsetTest {
/**
* Test Set Up.
*/
- @Before
+ @BeforeEach
public void setUp() {
controller = createController();
}
@@ -92,7 +93,7 @@ public class ProtocolCoderToolsetTest {
/**
* Test Termination.
*/
- @After
+ @AfterEach
public void tearDown() {
if (controller != null) {
DroolsControllerConstants.getFactory().destroy(controller);
@@ -100,7 +101,7 @@ public class ProtocolCoderToolsetTest {
}
@Test
- public void testToolsets() {
+ void testToolsets() {
testGsonToolset(createFilterSet());
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
index 7248f11e..f251f9bf 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-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,16 +22,16 @@
package org.onap.policy.drools.protocol.configuration;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Properties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.gson.GsonTestUtils;
-public class ControllerConfigurationTest {
+class ControllerConfigurationTest {
private static final String NAME = "name";
private static final String OPERATION = "operation";
@@ -60,7 +61,7 @@ public class ControllerConfigurationTest {
* Test.
*/
@Test
- public void test() {
+ void test() {
Properties additionalProperties = new Properties();
additionalProperties.put(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
@@ -104,7 +105,7 @@ public class ControllerConfigurationTest {
}
@Test
- public void testSerialize() {
+ void testSerialize() {
ControllerConfiguration controllerConfig = new ControllerConfiguration(NAME, OPERATION, DROOLS_CONFIG);
controllerConfig.setAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
controllerConfig.setAdditionalProperty(ADDITIONAL_PROPERTY_KEY2, ADDITIONAL_PROPERTY_VALUE2);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
index 2d1ed7e2..e693d000 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-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,15 +22,15 @@
package org.onap.policy.drools.protocol.configuration;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+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.Properties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.gson.GsonTestUtils;
-public class DroolsConfigurationTest {
+class DroolsConfigurationTest {
private static final String ARTIFACT_ID_STRING = "artifactId";
private static final String GROUP_ID_STRING = "groupId";
private static final String VERSION_STRING = "version";
@@ -51,7 +52,7 @@ public class DroolsConfigurationTest {
private static final String ADDITIONAL_PROPERTY_VALUE2 = "world";
@Test
- public void test() {
+ void test() {
final Properties additionalProperties = new Properties();
additionalProperties.put(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
@@ -96,7 +97,7 @@ public class DroolsConfigurationTest {
}
@Test
- public void testSerialize() {
+ void testSerialize() {
final DroolsConfiguration droolsConfig = new DroolsConfiguration(ARTIFACT, GROUPID, VERSION);
droolsConfig.setAdditionalProperty(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
droolsConfig.setAdditionalProperty(ADDITIONAL_PROPERTY_KEY2, ADDITIONAL_PROPERTY_VALUE2);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
index a8a0a2ac..f8f542c8 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-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.
@@ -20,20 +21,19 @@
package org.onap.policy.drools.protocol.configuration;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.gson.GsonTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class PdpdConfigurationTest {
+class PdpdConfigurationTest {
private static final Logger logger = LoggerFactory.getLogger(PdpdConfigurationTest.class);
@@ -64,7 +64,7 @@ public class PdpdConfigurationTest {
private static final String OPERATION2 = "operation2";
@Test
- public void test() {
+ void test() {
//
// Empty constructor test
//
@@ -246,14 +246,14 @@ public class PdpdConfigurationTest {
}
@Test
- public void testConstructor() {
+ void testConstructor() {
PdpdConfiguration config = new PdpdConfiguration(REQUEST_ID, ENTITY, null);
assertEquals(REQUEST_ID, config.getRequestId());
assertEquals(ENTITY, config.getEntity());
}
@Test
- public void testSerialize() throws IOException {
+ void testSerialize() {
List<ControllerConfiguration> controllers = Arrays.asList(new ControllerConfiguration(NAME, OPERATION, null),
new ControllerConfiguration(NAME2, OPERATION2, null));
PdpdConfiguration pdpConfig = new PdpdConfiguration(REQUEST_ID, ENTITY, controllers);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
index ad0d1afc..65447d80 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/RestManagerTest.java
@@ -21,7 +21,7 @@
package org.onap.policy.drools.server.restful.test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.nio.file.Files;
@@ -44,11 +44,11 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.http.server.YamlJacksonHandler;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -60,7 +60,7 @@ import org.onap.policy.drools.system.PolicyEngineConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@TestMethodOrder(MethodOrderer.DisplayName.class)
public class RestManagerTest {
private static final int DEFAULT_TELEMETRY_PORT = 7887;
private static final String HOST = "localhost";
@@ -71,31 +71,19 @@ public class RestManagerTest {
private static final String FOO_CONTROLLER = "foo";
private static final String UEB_TOPIC = "ueb-topic-test";
- private static final String DMAAP_TOPIC = "dmaap-topic-test";
+ private static final String KAFKA_TOPIC = "kafka-topic-test";
private static final String NOOP_TOPIC = "noop_topic";
private static final String UEB_SOURCE_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_UEB_SOURCE_TOPICS + "."
+ UEB_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
private static final String UEB_SINK_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_UEB_SINK_TOPICS + "."
+ UEB_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
- private static final String DMAAP_SOURCE_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS
- + "." + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
- private static final String DMAAP_SINK_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS + "."
- + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
+ private static final String KAFKA_SOURCE_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_KAFKA_SOURCE_TOPICS
+ + "." + KAFKA_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
+ private static final String KAFKA_SINK_SERVER_PROPERTY = PolicyEndPointProperties.PROPERTY_KAFKA_SINK_TOPICS + "."
+ + KAFKA_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
private static final String UEB_SERVER = "localhost";
- private static final String DMAAP_SERVER = "localhost";
- private static final String DMAAP_MECHID = "blah";
- private static final String DMAAP_PASSWD = "blah";
-
- private static final String DMAAP_SOURCE_MECHID_KEY = PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "."
- + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_AAF_MECHID_SUFFIX;
- private static final String DMAAP_SOURCE_PASSWD_KEY = PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "."
- + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX;
-
- private static final String DMAAP_SINK_MECHID_KEY = PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS + "."
- + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_AAF_MECHID_SUFFIX;
- private static final String DMAAP_SINK_PASSWD_KEY = PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS + "."
- + DMAAP_TOPIC + PolicyEndPointProperties.PROPERTY_TOPIC_AAF_PASSWORD_SUFFIX;
+ private static final String KAFKA_SERVER = "localhost:9092";
private static final String FOO_CONTROLLER_FILE = FOO_CONTROLLER + "-controller.properties";
private static final String FOO_CONTROLLER_FILE_BAK = FOO_CONTROLLER_FILE + ".bak";
@@ -111,7 +99,7 @@ public class RestManagerTest {
*
* @throws IOException throws an IO exception
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() throws IOException, InterruptedException {
cleanUpWorkingDirs();
@@ -124,10 +112,6 @@ public class RestManagerTest {
+ PolicyEndPointProperties.PROPERTY_HTTP_PORT_SUFFIX, "" + DEFAULT_TELEMETRY_PORT);
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
- + PolicyEndPointProperties.PROPERTY_HTTP_FILTER_CLASSES_SUFFIX,
- TestAafTelemetryAuthFilter.class.getName());
- engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
- + PolicyEngineConstants.TELEMETRY_SERVER_DEFAULT_NAME
+ PolicyEndPointProperties.PROPERTY_HTTP_AUTH_USERNAME_SUFFIX,
TELEMETRY_USER);
engineProps.put(PolicyEndPointProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
@@ -142,16 +126,12 @@ public class RestManagerTest {
/* other properties */
engineProps.put(PolicyEndPointProperties.PROPERTY_UEB_SOURCE_TOPICS, UEB_TOPIC);
engineProps.put(PolicyEndPointProperties.PROPERTY_UEB_SINK_TOPICS, UEB_TOPIC);
- engineProps.put(PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS, DMAAP_TOPIC);
- engineProps.put(PolicyEndPointProperties.PROPERTY_DMAAP_SINK_TOPICS, DMAAP_TOPIC);
+ engineProps.put(PolicyEndPointProperties.PROPERTY_KAFKA_SOURCE_TOPICS, KAFKA_TOPIC);
+ engineProps.put(PolicyEndPointProperties.PROPERTY_KAFKA_SINK_TOPICS, KAFKA_TOPIC);
engineProps.put(UEB_SOURCE_SERVER_PROPERTY, UEB_SERVER);
engineProps.put(UEB_SINK_SERVER_PROPERTY, UEB_SERVER);
- engineProps.put(DMAAP_SOURCE_SERVER_PROPERTY, DMAAP_SERVER);
- engineProps.put(DMAAP_SINK_SERVER_PROPERTY, DMAAP_SERVER);
- engineProps.put(DMAAP_SOURCE_MECHID_KEY, DMAAP_MECHID);
- engineProps.put(DMAAP_SOURCE_PASSWD_KEY, DMAAP_PASSWD);
- engineProps.put(DMAAP_SINK_MECHID_KEY, DMAAP_MECHID);
- engineProps.put(DMAAP_SINK_PASSWD_KEY, DMAAP_PASSWD);
+ engineProps.put(KAFKA_SOURCE_SERVER_PROPERTY, KAFKA_SERVER);
+ engineProps.put(KAFKA_SINK_SERVER_PROPERTY, KAFKA_SERVER);
PolicyEngineConstants.getManager().configure(engineProps);
PolicyEngineConstants.getManager().start();
@@ -181,7 +161,7 @@ public class RestManagerTest {
*
* @throws IOException IO exception
*/
- @AfterClass
+ @AfterAll
public static void tearDown() throws IOException {
try {
client.close();
@@ -198,7 +178,7 @@ public class RestManagerTest {
@Test
- public void testPutDelete() throws IOException {
+ void testPutDelete() throws IOException {
putTest(HOST_URL + "/engine/switches/lock", 406);
deleteTest(HOST_URL + "/engine/switches/lock", 406);
@@ -218,24 +198,24 @@ public class RestManagerTest {
private void putDeleteTopicSwitches() throws IOException {
putDeleteSwitch("/engine/topics/sources/ueb/", UEB_TOPIC, "lock");
- putDeleteSwitch("/engine/topics/sources/dmaap/", DMAAP_TOPIC, "lock");
+ putDeleteSwitch("/engine/topics/sources/kafka/", KAFKA_TOPIC, "lock");
putDeleteSwitch("/engine/topics/sources/noop/", NOOP_TOPIC, "lock");
putDeleteSwitch("/engine/topics/sinks/ueb/", UEB_TOPIC, "lock");
- putDeleteSwitch("/engine/topics/sinks/dmaap/", DMAAP_TOPIC, "lock");
+ putDeleteSwitch("/engine/topics/sinks/kafka/", KAFKA_TOPIC, "lock");
putDeleteSwitch("/engine/topics/sinks/noop/", NOOP_TOPIC, "lock");
putDeleteSwitch("/engine/topics/sources/ueb/", UEB_TOPIC, "activation");
- putDeleteSwitch("/engine/topics/sources/dmaap/", DMAAP_TOPIC, "activation");
+ putDeleteSwitch("/engine/topics/sources/kafka/", KAFKA_TOPIC, "activation");
putDeleteSwitch("/engine/topics/sources/noop/", NOOP_TOPIC, "activation");
putDeleteSwitch("/engine/topics/sinks/ueb/", UEB_TOPIC, "activation");
- putDeleteSwitch("/engine/topics/sinks/dmaap/", DMAAP_TOPIC, "activation");
+ putDeleteSwitch("/engine/topics/sinks/kafka/", KAFKA_TOPIC, "activation");
putDeleteSwitch("/engine/topics/sinks/noop/", NOOP_TOPIC, "activation");
putSwitch("/engine/topics/sources/ueb/", UEB_TOPIC, "activation");
- putSwitch("/engine/topics/sources/dmaap/", DMAAP_TOPIC, "activation");
+ putSwitch("/engine/topics/sources/kafka/", KAFKA_TOPIC, "activation");
putSwitch("/engine/topics/sources/noop/", NOOP_TOPIC, "activation");
putSwitch("/engine/topics/sinks/ueb/", UEB_TOPIC, "activation");
- putSwitch("/engine/topics/sinks/dmaap/", DMAAP_TOPIC, "activation");
+ putSwitch("/engine/topics/sinks/kafka/", KAFKA_TOPIC, "activation");
putSwitch("/engine/topics/sinks/noop/", NOOP_TOPIC, "activation");
}
@@ -244,15 +224,15 @@ public class RestManagerTest {
"{x:y}", ContentType.TEXT_PLAIN);
putTest(HOST_URL + "/engine/topics/sources/noop/" + NOOP_TOPIC + "/events", 200,
"{x:y}", ContentType.TEXT_PLAIN);
- putTest(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events", 200,
+ putTest(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_TOPIC + "/events", 200,
"FOOOO", ContentType.TEXT_PLAIN);
putTest(HOST_URL + "/engine/topics/sources/ueb/fiznits/events", 406, "FOOOO", ContentType.TEXT_PLAIN);
- putTest(HOST_URL + "/engine/topics/sources/dmaap/fiznits/events", 406,
+ putTest(HOST_URL + "/engine/topics/sources/kafka/fiznits/events", 406,
"FOOOO", ContentType.TEXT_PLAIN);
putTest(HOST_URL + "/engine/topics/switches/lock", 200);
putTest(HOST_URL + "/engine/topics/sources/ueb/" + UEB_TOPIC + "/events",
406, "FOOOO", ContentType.TEXT_PLAIN);
- putTest(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events",
+ putTest(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_TOPIC + "/events",
406, "FOOOO", ContentType.TEXT_PLAIN);
deleteTest(HOST_URL + "/engine/topics/switches/lock", 200);
}
@@ -311,7 +291,7 @@ public class RestManagerTest {
}
@Test
- public void testPost() throws IOException {
+ void testPost() throws IOException {
postTest(HOST_URL + "/engine/inputs/configuration", 406,
Files.readString(Paths.get(PDP_CONFIGURATION_JSON)),
ContentType.APPLICATION_JSON);
@@ -338,7 +318,7 @@ public class RestManagerTest {
}
@Test
- public void testGetSwagger() throws IOException {
+ void testGetSwagger() throws IOException {
HttpGet httpGet;
CloseableHttpResponse response;
httpGet = new HttpGet(HOST_URL + "/engine/swagger");
@@ -349,7 +329,7 @@ public class RestManagerTest {
}
@Test
- public void testGet() throws IOException {
+ void testGet() throws IOException {
HttpGet httpGet;
CloseableHttpResponse response;
@@ -630,13 +610,13 @@ public class RestManagerTest {
/*
* GET: /engine/topics /engine/topics/switches /engine/topics/sources /engine/topics/sinks
- * /engine/topics/sinks/ueb /engine/topics/sources/ueb /engine/topics/sinks/dmaap
- * /engine/topics/sources/dmaap /engine/topics/sinks/ueb/topic
- * /engine/topics/sources/ueb/topic /engine/topics/sinks/dmaap/topic
- * /engine/topics/sources/dmaap/topic /engine/topics/sinks/ueb/topic/events
- * /engine/topics/sources/ueb/topic/events /engine/topics/sinks/dmaap/topic/events
- * /engine/topics/sources/dmaap/topic/events /engine/topics/sources/ueb/topic/switches
- * /engine/topics/sources/dmaap/topic/switches
+ * /engine/topics/sinks/ueb /engine/topics/sources/ueb /engine/topics/sinks/kafka
+ * /engine/topics/sources/kafka /engine/topics/sinks/ueb/topic
+ * /engine/topics/sources/ueb/topic /engine/topics/sinks/kafka/topic
+ * /engine/topics/sources/kafka/topic /engine/topics/sinks/ueb/topic/events
+ * /engine/topics/sources/ueb/topic/events /engine/topics/sinks/kafka/topic/events
+ * /engine/topics/sources/kafka/topic/events /engine/topics/sources/ueb/topic/switches
+ * /engine/topics/sources/kafka/topic/switches
*/
httpGet = new HttpGet(HOST_URL + "/engine/topics");
response = client.execute(httpGet);
@@ -674,13 +654,13 @@ public class RestManagerTest {
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(200, response.getStatusLine().getStatusCode());
@@ -722,25 +702,25 @@ public class RestManagerTest {
assertEquals(500, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC);
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_TOPIC);
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/foobar");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/foobar");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(500, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/" + DMAAP_TOPIC);
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/" + KAFKA_TOPIC);
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/foobar");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/foobar");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(500, response.getStatusLine().getStatusCode());
@@ -794,25 +774,25 @@ public class RestManagerTest {
assertEquals(500, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/events");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_TOPIC + "/events");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/foobar/events");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/foobar/events");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(500, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/" + DMAAP_TOPIC + "/events");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/" + KAFKA_TOPIC + "/events");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/foobar/events");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/foobar/events");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(500, response.getStatusLine().getStatusCode());
@@ -848,7 +828,7 @@ public class RestManagerTest {
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/dmaap/" + DMAAP_TOPIC + "/switches");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sources/kafka/" + KAFKA_TOPIC + "/switches");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(200, response.getStatusLine().getStatusCode());
@@ -866,7 +846,7 @@ public class RestManagerTest {
assertEquals(200, response.getStatusLine().getStatusCode());
httpGet.releaseConnection();
- httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/dmaap/" + DMAAP_TOPIC + "/switches");
+ httpGet = new HttpGet(HOST_URL + "/engine/topics/sinks/kafka/" + KAFKA_TOPIC + "/switches");
response = client.execute(httpGet);
logger.info(httpGet.getRequestLine() + " response code: {}", response.getStatusLine().getStatusCode());
assertEquals(200, response.getStatusLine().getStatusCode());
diff --git a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/TestAafTelemetryAuthFilter.java b/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/TestAafTelemetryAuthFilter.java
deleted file mode 100644
index 6a9be8a2..00000000
--- a/policy-management/src/test/java/org/onap/policy/drools/server/restful/test/TestAafTelemetryAuthFilter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2018 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.server.restful.test;
-
-import jakarta.servlet.http.HttpServletRequest;
-import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.drools.server.restful.aaf.AafTelemetryAuthFilter;
-
-/**
- * Test AAF Telemetry Authorization Filter for Junits.
- */
-public class TestAafTelemetryAuthFilter extends AafTelemetryAuthFilter {
-
- @Override
- protected String getRole(HttpServletRequest request) {
- String expectedPerm = "org.onap.policy.pdpd.telemetry|"
- + NetworkUtil.getHostname() + "|"
- + request.getMethod().toLowerCase();
- if (!expectedPerm.equals(super.getRole(request))) {
- throw new IllegalStateException("unexpected permission");
- } else {
- return "user";
- }
- }
-}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsManagerTest.java
index a12fb50a..118c4d7e 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsManagerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,15 +21,15 @@
package org.onap.policy.drools.stats;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.metrics.Metric;
-public class PolicyStatsManagerTest {
+class PolicyStatsManagerTest {
@Test
- public void testStat() {
+ void testStat() {
PolicyStatsManager stats = new PolicyStatsManager();
assertEquals(0, stats.getGroupStat().getPolicyExecutedCount());
diff --git a/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsTest.java b/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsTest.java
index 631e85b8..3f26e82e 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -21,15 +22,15 @@
package org.onap.policy.drools.stats;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.metrics.Metric;
-public class PolicyStatsTest {
+class PolicyStatsTest {
@Test
- public void testStat() {
+ void testStat() {
Metric trans1 = createTrans();
trans1.setSuccess(true);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyControllerFactoryTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyControllerFactoryTest.java
index 818f8fc1..615ffe2b 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyControllerFactoryTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyControllerFactoryTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -22,9 +23,9 @@ package org.onap.policy.drools.system;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -35,10 +36,11 @@ import static org.onap.policy.drools.properties.DroolsPropertyConstants.PROPERTY
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import java.util.Properties;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.gson.GsonTestUtils;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.controller.internal.NullDroolsController;
@@ -48,7 +50,7 @@ import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
import org.onap.policy.drools.system.internal.AggregatedPolicyController;
-public class PolicyControllerFactoryTest {
+class PolicyControllerFactoryTest {
private static final String POLICY_CONTROLLER_BUILDER_TAG = "PolicyControllerFactoryTest";
private static final String MY_NAME = "my-name-a";
@@ -79,7 +81,7 @@ public class PolicyControllerFactoryTest {
/**
* Initializes the object to be tested.
*/
- @Before
+ @BeforeEach
public void setUp() {
controller = mock(PolicyController.class);
controller2 = mock(PolicyController.class);
@@ -114,14 +116,14 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testFactory() {
+ void testFactory() {
// use a REAL object instead of an Impl
ipc = new IndexedPolicyControllerFactory();
assertNotNull(ipc.getProviders());
}
@Test
- public void testBuild() {
+ void testBuild() {
assertEquals(controller, ipc.build(MY_NAME, properties));
// re-build - should not create another one
@@ -134,14 +136,14 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testSerialize() {
+ void testSerialize() {
assertEquals(controller, ipc.build(MY_NAME, properties));
new GsonTestUtils().compareGson(ipc, PolicyControllerFactoryTest.class);
}
@Test
- public void testPatchStringDroolsConfiguration() {
+ void testPatchStringDroolsConfiguration() {
// unknown controller
assertThatIllegalArgumentException().isThrownBy(() -> ipc.patch(MY_NAME, config));
@@ -173,7 +175,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testPatchPolicyControllerDroolsConfiguration() {
+ void testPatchPolicyControllerDroolsConfiguration() {
ipc.patch(controller, config);
verify(controller).updateDrools(config);
@@ -194,7 +196,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testShutdownString() {
+ void testShutdownString() {
// null name
String nullName = null;
assertThatIllegalArgumentException().isThrownBy(() -> ipc.shutdown(nullName));
@@ -213,7 +215,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testShutdownPolicyController() {
+ void testShutdownPolicyController() {
ipc.build(MY_NAME, properties);
ipc.shutdown(controller);
@@ -225,7 +227,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
ipc.build(MY_NAME, properties);
ipc.build(MY_NAME2, properties);
@@ -240,7 +242,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testUnmanage() {
+ void testUnmanage() {
ipc.build(MY_NAME, properties);
ipc.build(MY_NAME2, properties);
@@ -265,7 +267,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testDestroyString() {
+ void testDestroyString() {
// null name
String nullName = null;
assertThatIllegalArgumentException().isThrownBy(() -> ipc.destroy(nullName));
@@ -284,7 +286,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testDestroyPolicyController() {
+ void testDestroyPolicyController() {
ipc.build(MY_NAME, properties);
ipc.destroy(controller);
@@ -296,7 +298,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testDestroy() {
+ void testDestroy() {
ipc.build(MY_NAME, properties);
ipc.build(MY_NAME2, properties);
@@ -311,7 +313,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testGetString() {
+ void testGetString() {
// unknown name
assertThatIllegalArgumentException().isThrownBy(() -> ipc.get(MY_NAME));
@@ -330,7 +332,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testGetStringString_testToKey() {
+ void testGetStringString_testToKey() {
// unknown controller
assertThatIllegalArgumentException().isThrownBy(() -> ipc.get(GROUP1, ARTIFACT1));
@@ -357,7 +359,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testGetDroolsController() {
+ void testGetDroolsController() {
// unknown controller
assertThatIllegalStateException().isThrownBy(() -> ipc.get(drools));
@@ -376,27 +378,27 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testInventory() {
+ void testInventory() {
ipc.build(MY_NAME, properties);
ipc.build(MY_NAME2, properties);
List<PolicyController> lst = ipc.inventory();
- Collections.sort(lst, (left, right) -> left.getName().compareTo(right.getName()));
+ lst.sort(Comparator.comparing(PolicyController::getName));
assertEquals(Arrays.asList(controller, controller2), lst);
}
@Test
- public void testGetFeatures() {
+ void testGetFeatures() {
assertEquals(Arrays.asList(FEATURE1, FEATURE2), ipc.getFeatures());
}
@Test
- public void testGetFeatureProviders() {
+ void testGetFeatureProviders() {
assertEquals(providers, ipc.getFeatureProviders());
}
@Test
- public void testGetFeatureProvider() {
+ void testGetFeatureProvider() {
// null name
assertThatIllegalArgumentException().isThrownBy(() -> ipc.getFeatureProvider(null));
@@ -411,7 +413,7 @@ public class PolicyControllerFactoryTest {
}
@Test
- public void testControllerType() {
+ void testControllerType() {
PolicyControllerFactory factory = new IndexedPolicyControllerFactory();
Properties props = new Properties();
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyDroolsPdpRuntimeExceptionTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyDroolsPdpRuntimeExceptionTest.java
index 64595178..f4b26307 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyDroolsPdpRuntimeExceptionTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyDroolsPdpRuntimeExceptionTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 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.
@@ -22,15 +23,15 @@
package org.onap.policy.drools.system;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class PolicyDroolsPdpRuntimeExceptionTest {
+class PolicyDroolsPdpRuntimeExceptionTest {
@Test
- public void test() {
+ void test() {
assertEquals(2, new ExceptionsTester().test(PolicyDroolsPdpRuntimeException.class));
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
index 93c0f348..4006c9ed 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018-2022 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.
@@ -25,12 +25,13 @@ import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doThrow;
@@ -50,9 +51,9 @@ import java.util.Properties;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+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.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
@@ -80,7 +81,7 @@ import org.onap.policy.drools.system.internal.SimpleLockManager;
import org.onap.policy.drools.system.internal.SimpleLockProperties;
import org.onap.policy.models.pdp.enums.PdpResponseStatus;
-public class PolicyEngineManagerTest {
+class PolicyEngineManagerTest {
private static final String EXPECTED = "expected exception";
private static final String NOOP_STR = CommInfrastructure.NOOP.name();
@@ -158,7 +159,7 @@ public class PolicyEngineManagerTest {
*
* @throws Exception if an error occurs
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
CollectorRegistry.defaultRegistry.clear();
properties = new Properties();
@@ -324,13 +325,13 @@ public class PolicyEngineManagerTest {
mgr = new PolicyEngineManagerImpl();
}
- @After
+ @AfterEach
public void tearDown() {
CollectorRegistry.defaultRegistry.clear();
}
@Test
- public void testSerialize() {
+ void testSerialize() {
mgr.setHostName("foo");
mgr.setClusterName("bar");
mgr.configure(properties);
@@ -338,7 +339,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testFactory() {
+ void testFactory() {
mgr = new PolicyEngineManager();
assertNotNull(mgr.getEngineProviders());
@@ -353,7 +354,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testBoot() throws Exception {
+ void testBoot() throws Exception {
String[] args = {"boot-a", "boot-b"};
// arrange for first provider to throw exceptions
@@ -392,7 +393,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testSetEnvironment_testGetEnvironment_testGetEnvironmentProperty_setEnvironmentProperty() {
+ void testSetEnvironment_testGetEnvironment_testGetEnvironmentProperty_setEnvironmentProperty() {
Properties props1 = new Properties();
props1.put("prop1-a", "value1-a");
props1.put("prop1-b", "value1-b");
@@ -440,14 +441,14 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testDefaultTelemetryConfig() {
+ void testDefaultTelemetryConfig() {
Properties config = mgr.defaultTelemetryConfig();
assertNotNull(config);
assertFalse(config.isEmpty());
}
@Test
- public void testGetPdpName() {
+ void testGetPdpName() {
properties.setProperty(PolicyEngineManager.CLUSTER_NAME_PROP, "east1");
mgr.configure(properties);
@@ -480,7 +481,7 @@ public class PolicyEngineManagerTest {
* property.
*/
@Test
- public void testMakeExecutorServicePropertyProvided() {
+ void testMakeExecutorServicePropertyProvided() {
PolicyEngineManager mgrspy = spy(mgr);
properties.setProperty(PolicyEngineManager.EXECUTOR_THREAD_PROP, "3");
@@ -494,7 +495,7 @@ public class PolicyEngineManagerTest {
* property is provided.
*/
@Test
- public void testMakeExecutorServiceNoProperty() {
+ void testMakeExecutorServiceNoProperty() {
PolicyEngineManager mgrspy = spy(mgr);
mgrspy.configure(properties);
@@ -507,7 +508,7 @@ public class PolicyEngineManagerTest {
* property is invalid.
*/
@Test
- public void testMakeExecutorServiceInvalidProperty() {
+ void testMakeExecutorServiceInvalidProperty() {
PolicyEngineManager mgrspy = spy(mgr);
properties.setProperty(PolicyEngineManager.EXECUTOR_THREAD_PROP, "abc");
@@ -521,7 +522,7 @@ public class PolicyEngineManagerTest {
* manager.
*/
@Test
- public void testCreateLockManagerHaveProvider() {
+ void testCreateLockManagerHaveProvider() {
// first provider throws an exception
when(prov1.beforeCreateLockManager(any(), any())).thenThrow(new RuntimeException(EXPECTED));
@@ -533,7 +534,7 @@ public class PolicyEngineManagerTest {
* Tests createLockManager() when SimpleLockManager throws an exception.
*/
@Test
- public void testCreateLockManagerSimpleEx() {
+ void testCreateLockManagerSimpleEx() {
when(prov2.beforeCreateLockManager(any(), any())).thenReturn(null);
// invalid property for SimpleLockManager
@@ -541,22 +542,22 @@ public class PolicyEngineManagerTest {
mgr.configure(properties);
// should create a manager using default properties
- assertTrue(mgr.getLockManager() instanceof SimpleLockManager);
+ assertInstanceOf(SimpleLockManager.class, mgr.getLockManager());
}
/**
* Tests createLockManager() when SimpleLockManager is returned.
*/
@Test
- public void testCreateLockManagerSimple() {
+ void testCreateLockManagerSimple() {
when(prov2.beforeCreateLockManager(any(), any())).thenReturn(null);
mgr.configure(properties);
- assertTrue(mgr.getLockManager() instanceof SimpleLockManager);
+ assertInstanceOf(SimpleLockManager.class, mgr.getLockManager());
}
@Test
- public void testConfigureProperties() throws Exception {
+ void testConfigureProperties() throws Exception {
// arrange for first provider to throw exceptions
when(prov1.beforeConfigure(mgr, properties)).thenThrow(new RuntimeException(EXPECTED));
when(prov1.afterConfigure(mgr)).thenThrow(new RuntimeException(EXPECTED));
@@ -605,7 +606,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testConfigurePdpdConfiguration() throws Exception {
+ void testConfigurePdpdConfiguration() throws Exception {
mgr.configure(properties);
assertTrue(mgr.configure(pdpConfig));
@@ -630,7 +631,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testCreatePolicyController() throws Exception {
+ void testCreatePolicyController() throws Exception {
assertEquals(controller, mgr.createPolicyController(MY_NAME, properties));
verify(contProv1).beforeCreate(MY_NAME, properties);
@@ -698,7 +699,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testUpdatePolicyControllers() throws Exception {
+ void testUpdatePolicyControllers() throws Exception {
assertEquals(Arrays.asList(controller3, controller4), mgr.updatePolicyControllers(pdpConfig.getControllers()));
// controller3 was CREATE
@@ -730,7 +731,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testUpdatePolicyController() throws Exception {
+ void testUpdatePolicyController() throws Exception {
assertEquals(controller3, mgr.updatePolicyController(config3));
verify(engine).createPolicyController(CONTROLLER3, properties);
@@ -825,7 +826,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testStart() throws Throwable {
+ void testStart() throws Throwable {
// normal success case
testStart(true, () -> {
// arrange for first provider, server, source, and sink to throw exceptions
@@ -935,7 +936,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testStop() throws Throwable {
+ void testStop() throws Throwable {
// normal success case
testStop(true, () -> {
// arrange for first provider, server, source, and sink to throw exceptions
@@ -1043,7 +1044,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testShutdown() throws Throwable {
+ void testShutdown() throws Throwable {
// normal success case
testShutdown(() -> {
// arrange for first provider, source, and sink to throw exceptions
@@ -1112,7 +1113,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testShutdownThreadRun() throws Throwable {
+ void testShutdownThreadRun() throws Throwable {
// arrange for first server to throw exceptions
testShutdownThreadRun(() -> doThrow(new RuntimeException(EXPECTED)).when(server1).shutdown());
@@ -1148,7 +1149,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testIsAlive() {
+ void testIsAlive() {
mgr.configure(properties);
assertFalse(mgr.isAlive());
@@ -1160,7 +1161,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testLock() throws Throwable {
+ void testLock() throws Throwable {
// normal success case
testLock(true, () -> {
// arrange for first provider to throw exceptions
@@ -1237,7 +1238,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testUnlock() throws Throwable {
+ void testUnlock() throws Throwable {
// normal success case
testUnlock(true, () -> {
// arrange for first provider to throw exceptions
@@ -1314,7 +1315,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testIsLocked() {
+ void testIsLocked() {
mgr.configure(properties);
assertFalse(mgr.isLocked());
@@ -1326,31 +1327,31 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testRemovePolicyControllerString() {
+ void testRemovePolicyControllerString() {
mgr.removePolicyController(MY_NAME);
verify(controllerFactory).destroy(MY_NAME);
}
@Test
- public void testRemovePolicyControllerPolicyController() {
+ void testRemovePolicyControllerPolicyController() {
mgr.removePolicyController(controller);
verify(controllerFactory).destroy(controller);
}
@Test
- public void testGetPolicyControllers() {
+ void testGetPolicyControllers() {
assertEquals(controllers, mgr.getPolicyControllers());
}
@Test
- public void testGetPolicyControllerIds() {
+ void testGetPolicyControllerIds() {
assertEquals(Arrays.asList(CONTROLLER1, CONTROLLER2), mgr.getPolicyControllerIds());
}
@Test
- public void testGetProperties() {
+ void testGetProperties() {
properties.setProperty("prop-x", "value-x");
properties.setProperty("prop-y", "value-y");
@@ -1359,35 +1360,35 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testGetSources() {
+ void testGetSources() {
mgr.configure(properties);
assertEquals(sources, mgr.getSources());
}
@Test
- public void testGetSinks() {
+ void testGetSinks() {
mgr.configure(properties);
assertEquals(sinks, mgr.getSinks());
}
@Test
- public void testGetHttpServers() {
+ void testGetHttpServers() {
mgr.configure(properties);
assertEquals(servers, mgr.getHttpServers());
}
@Test
- public void testGetFeatures() {
+ void testGetFeatures() {
assertEquals(Arrays.asList(FEATURE1, FEATURE2), mgr.getFeatures());
}
@Test
- public void testGetFeatureProviders() {
+ void testGetFeatureProviders() {
assertEquals(providers, mgr.getFeatureProviders());
}
@Test
- public void testGetFeatureProvider() {
+ void testGetFeatureProvider() {
assertEquals(prov1, mgr.getFeatureProvider(FEATURE1));
assertEquals(prov2, mgr.getFeatureProvider(FEATURE2));
@@ -1402,7 +1403,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testTransaction() {
+ void testTransaction() {
mgr.metric(CONTROLLER1, POLICY, new Metric());
assertEquals(0, mgr.getStats().getGroupStat().getPolicyExecutedCount());
assertEquals(0, mgr.getStats().getSubgroupStats().size());
@@ -1434,7 +1435,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testOnTopicEvent() {
+ void testOnTopicEvent() {
mgr.onTopicEvent(CommInfrastructure.NOOP, MY_TOPIC, pdpConfigJson);
verify(controllerFactory).patch(controller3, drools3);
@@ -1448,7 +1449,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testDeliverStringObject() throws Exception {
+ void testDeliverStringObject() throws Exception {
mgr.configure(properties);
mgr.start();
@@ -1492,7 +1493,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testDeliverStringStringObject() {
+ void testDeliverStringStringObject() {
mgr.configure(properties);
mgr.start();
@@ -1523,7 +1524,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testDeliverCommInfrastructureStringObject() throws Exception {
+ void testDeliverCommInfrastructureStringObject() throws Exception {
mgr.configure(properties);
mgr.start();
@@ -1590,7 +1591,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testDeliverCommInfrastructureStringString() {
+ void testDeliverCommInfrastructureStringString() {
mgr.configure(properties);
// not started yet
@@ -1622,7 +1623,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testActivate() throws Throwable {
+ void testActivate() throws Throwable {
// normal success case
testActivate(() -> {
// arrange for first provider and controller to throw exceptions
@@ -1679,7 +1680,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testDeactivate() throws Throwable {
+ void testDeactivate() throws Throwable {
// normal success case
testDeactivate(() -> {
// arrange for first provider and controller to throw exceptions
@@ -1733,7 +1734,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testCreateLock() {
+ void testCreateLock() {
Lock lock = mock(Lock.class);
LockCallback callback = mock(LockCallback.class);
when(lockmgr.createLock(MY_RESOURCE, MY_OWNER, 10, callback, false)).thenReturn(lock);
@@ -1759,7 +1760,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testOpen() throws Throwable {
+ void testOpen() throws Throwable {
when(prov1.beforeOpen(mgr)).thenThrow(new RuntimeException(EXPECTED));
when(prov1.afterOpen(mgr)).thenThrow(new RuntimeException(EXPECTED));
@@ -1814,7 +1815,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testControllerConfig() throws Exception {
+ void testControllerConfig() throws Exception {
mgr.configure(properties);
assertTrue(mgr.configure(pdpConfig));
@@ -1845,7 +1846,7 @@ public class PolicyEngineManagerTest {
}
@Test
- public void testToString() {
+ void testToString() {
assertTrue(mgr.toString().startsWith("PolicyEngineManager("));
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
index 2054d91d..a6b8ac3f 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-2022 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,9 +22,9 @@
package org.onap.policy.drools.system;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+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.io.File;
import java.io.IOException;
@@ -32,11 +33,11 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicFactories;
@@ -55,8 +56,8 @@ import org.slf4j.LoggerFactory;
* PolicyEngine unit tests.
*/
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class PolicyEngineTest {
+@TestMethodOrder(MethodOrderer.DisplayName.class)
+class PolicyEngineTest {
/**
* Default Telemetry port for JUnits.
*/
@@ -132,9 +133,9 @@ public class PolicyEngineTest {
*
* @throws IOException throws IO exception
*/
- @BeforeClass
- public static void startUp() throws IOException {
- logger.info("enter");
+ @BeforeAll
+ static void startUp() throws IOException {
+ logger.info("startUp");
gson = new GsonTestUtils();
@@ -147,14 +148,8 @@ public class PolicyEngineTest {
}
}
- @AfterClass
- public static void tearDown() {
- logger.info("enter");
- cleanUpWorkingDir();
- }
-
@Test
- public void test100Configure() {
+ void test100Configure() {
var manager = (PolicyEngineManager) PolicyEngineConstants.getManager();
var engineProps = manager.defaultTelemetryConfig();
@@ -177,7 +172,7 @@ public class PolicyEngineTest {
}
@Test
- public void test200Start() {
+ void test200Start() {
logger.info("enter");
PolicyEngineConstants.getManager().start();
@@ -189,7 +184,7 @@ public class PolicyEngineTest {
}
@Test
- public void test300Lock() {
+ void test300Lock() {
logger.info("enter");
PolicyEngineConstants.getManager().lock();
@@ -201,7 +196,7 @@ public class PolicyEngineTest {
}
@Test
- public void test301Unlock() {
+ void test301Unlock() {
logger.info("enter");
PolicyEngineConstants.getManager().unlock();
@@ -213,7 +208,7 @@ public class PolicyEngineTest {
}
@Test
- public void test350TopicDeliver() {
+ void test350TopicDeliver() {
final Properties noopSinkProperties = new Properties();
noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, NOOP_TOPIC);
@@ -236,7 +231,7 @@ public class PolicyEngineTest {
}
@Test
- public void test400ControllerAdd() {
+ void test400ControllerAdd() {
logger.info("enter");
final Properties controllerProperties = new Properties();
@@ -251,7 +246,7 @@ public class PolicyEngineTest {
}
@Test
- public void test401ControllerVerify() {
+ void test401ControllerVerify() {
logger.info("enter");
final PolicyController testController = PolicyControllerConstants.getFactory().get(TEST_CONTROLLER_NAME);
@@ -266,7 +261,7 @@ public class PolicyEngineTest {
}
@Test
- public void test500Deactivate() {
+ void test500Deactivate() {
logger.info("enter");
PolicyEngineConstants.getManager().deactivate();
@@ -279,7 +274,7 @@ public class PolicyEngineTest {
}
@Test
- public void test501Activate() {
+ void test501Activate() {
logger.info("enter");
PolicyEngineConstants.getManager().activate();
@@ -292,7 +287,7 @@ public class PolicyEngineTest {
}
@Test
- public void test900ControllerRemove() {
+ void test900ControllerRemove() {
logger.info("enter");
PolicyEngineConstants.getManager().removePolicyController(TEST_CONTROLLER_NAME);
@@ -300,7 +295,7 @@ public class PolicyEngineTest {
}
@Test
- public void test901Stop() {
+ void test901Stop() {
logger.info("enter");
/* Shutdown managed resources */
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java
index a6aa9d9d..bc81a3cb 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -23,10 +24,11 @@ package org.onap.policy.drools.system.internal;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -39,8 +41,8 @@ import java.util.List;
import java.util.Properties;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
-import org.junit.Before;
-import org.junit.Test;
+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.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
@@ -53,7 +55,7 @@ import org.onap.policy.drools.persistence.SystemPersistence;
import org.onap.policy.drools.protocol.configuration.DroolsConfiguration;
import org.onap.policy.drools.system.GsonMgmtTestBuilder;
-public class AggregatedPolicyControllerTest {
+class AggregatedPolicyControllerTest {
private static final String AGG_NAME = "agg-name";
private static final String SINK_TOPIC1 = "sink-a";
@@ -93,7 +95,7 @@ public class AggregatedPolicyControllerTest {
/**
* Initializes the object to be tested.
*/
- @Before
+ @BeforeEach
public void setUp() {
properties = new Properties();
@@ -144,7 +146,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testFactory() {
+ void testFactory() {
apc = new AggregatedPolicyController(AGG_NAME, properties);
assertNotNull(apc.getDroolsFactory());
assertNotNull(apc.getEndpointManager());
@@ -153,32 +155,34 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testAggregatedPolicyController_() {
+ void testAggregatedPolicyController_() {
verify(persist).storeController(AGG_NAME, properties);
}
- @Test(expected = IllegalArgumentException.class)
- public void testInitDrools_Ex() {
+ @Test
+ void testInitDrools_Ex() {
+ assertThrows(IllegalArgumentException.class, () ->
new AggregatedPolicyControllerImpl(AGG_NAME, properties) {
@Override
protected DroolsControllerFactory getDroolsFactory() {
throw new RuntimeException(EXPECTED);
}
- };
+ });
}
- @Test(expected = IllegalArgumentException.class)
- public void testInitDrools_Error() {
+ @Test
+ void testInitDrools_Error() {
+ assertThrows(IllegalArgumentException.class, () ->
new AggregatedPolicyControllerImpl(AGG_NAME, properties) {
@Override
protected DroolsControllerFactory getDroolsFactory() {
throw new LinkageError(EXPECTED);
}
- };
+ });
}
@Test
- public void testUpdateDrools_ConfigVariations() {
+ void testUpdateDrools_ConfigVariations() {
// config should return same values as current controller
when(config.getArtifactId()).thenReturn(ARTIFACT1.toUpperCase());
@@ -233,7 +237,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testUpdateDrools_LockVariations() {
+ void testUpdateDrools_LockVariations() {
// not locked
apc.updateDrools(config);
verify(drools, never()).lock();
@@ -248,7 +252,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testUpdateDrools_AliveVariations() {
+ void testUpdateDrools_AliveVariations() {
// not started
apc.updateDrools(config);
verify(drools, never()).start();
@@ -263,19 +267,19 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testSerialize() {
+ void testSerialize() {
GsonTestUtils gson = new GsonMgmtTestBuilder().addDroolsControllerMock().addTopicSinkMock().addTopicSourceMock()
.build();
assertThatCode(() -> gson.compareGson(apc, AggregatedPolicyControllerTest.class)).doesNotThrowAnyException();
}
@Test
- public void testGetName() {
+ void testGetName() {
assertEquals(AGG_NAME, apc.getName());
}
@Test
- public void testStart() {
+ void testStart() {
// arrange for first provider to throw exceptions
when(prov1.beforeStart(any())).thenThrow(new RuntimeException(EXPECTED));
when(prov1.afterStart(any())).thenThrow(new RuntimeException(EXPECTED));
@@ -310,7 +314,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testStart_AlreadyStarted() {
+ void testStart_AlreadyStarted() {
apc.start();
// re-start it
@@ -329,7 +333,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testStart_Locked() {
+ void testStart_Locked() {
apc.lock();
// start it
@@ -347,7 +351,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testStop() {
+ void testStop() {
// arrange for first provider to throw exceptions
when(prov1.beforeStop(any())).thenThrow(new RuntimeException(EXPECTED));
when(prov1.afterStop(any())).thenThrow(new RuntimeException(EXPECTED));
@@ -387,7 +391,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testStop_AlreadyStopped() {
+ void testStop_AlreadyStopped() {
apc.start();
apc.stop();
@@ -404,7 +408,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
// arrange for first provider to throw exceptions
when(prov1.beforeShutdown(any())).thenThrow(new RuntimeException(EXPECTED));
when(prov1.afterShutdown(any())).thenThrow(new RuntimeException(EXPECTED));
@@ -444,7 +448,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testHalt() {
+ void testHalt() {
// arrange for first provider to throw exceptions
when(prov1.beforeHalt(any())).thenThrow(new RuntimeException(EXPECTED));
when(prov1.afterHalt(any())).thenThrow(new RuntimeException(EXPECTED));
@@ -485,7 +489,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testOnTopicEvent() {
+ void testOnTopicEvent() {
// arrange for first provider to throw exceptions
when(prov1.beforeOffer(apc, CommInfrastructure.NOOP, SOURCE_TOPIC1, MY_EVENT))
.thenThrow(new RuntimeException(EXPECTED));
@@ -522,7 +526,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testOnTopicEvent_Locked() {
+ void testOnTopicEvent_Locked() {
// start it
apc.start();
@@ -540,7 +544,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testOnTopicEvent_NotStarted() {
+ void testOnTopicEvent_NotStarted() {
// offer it
apc.onTopicEvent(CommInfrastructure.NOOP, SOURCE_TOPIC1, MY_EVENT);
@@ -554,7 +558,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testDeliver_testInitSinks() {
+ void testDeliver_testInitSinks() {
// arrange for first provider to throw exceptions
when(prov1.beforeDeliver(apc, CommInfrastructure.NOOP, SINK_TOPIC1, MY_EVENT))
.thenThrow(new RuntimeException(EXPECTED));
@@ -598,42 +602,43 @@ public class AggregatedPolicyControllerTest {
prov -> verify(prov).afterDeliver(apc, CommInfrastructure.NOOP, SINK_TOPIC1, MY_EVENT, true));
}
- @Test(expected = IllegalArgumentException.class)
- public void testDeliver_NullTopic() {
- validateDeliverFailure(null, MY_EVENT);
+ @Test
+ void testDeliver_NullTopic() {
+ assertThrows(IllegalArgumentException.class, () -> validateDeliverFailure(null, MY_EVENT));
}
- @Test(expected = IllegalArgumentException.class)
- public void testDeliver_EmptyTopic() {
- validateDeliverFailure("", MY_EVENT);
+ @Test
+ void testDeliver_EmptyTopic() {
+ assertThrows(IllegalArgumentException.class, () -> validateDeliverFailure("", MY_EVENT));
}
- @Test(expected = IllegalArgumentException.class)
- public void testDeliver_NullEvent() {
- validateDeliverFailure(SINK_TOPIC1, null);
+ @Test
+ void testDeliver_NullEvent() {
+ assertThrows(IllegalArgumentException.class, () -> validateDeliverFailure(SINK_TOPIC1, null));
}
- @Test(expected = IllegalStateException.class)
- public void testDeliver_NotStarted() {
+ @Test
+ void testDeliver_NotStarted() {
// do NOT start
- apc.deliver(CommInfrastructure.NOOP, SINK_TOPIC1, MY_EVENT);
+ assertThrows(IllegalStateException.class, () -> apc.deliver(CommInfrastructure.NOOP, SINK_TOPIC1, MY_EVENT));
}
- @Test(expected = IllegalStateException.class)
- public void testDeliver_Locked() {
+ @Test
+ void testDeliver_Locked() {
apc.start();
apc.lock();
- apc.deliver(CommInfrastructure.NOOP, SINK_TOPIC1, MY_EVENT);
+ assertThrows(IllegalStateException.class, () -> apc.deliver(CommInfrastructure.NOOP, SINK_TOPIC1, MY_EVENT));
}
- @Test(expected = IllegalArgumentException.class)
- public void testDeliver_UnknownTopic() {
+ @Test
+ void testDeliver_UnknownTopic() {
apc.start();
- apc.deliver(CommInfrastructure.NOOP, "unknown-topic", MY_EVENT);
+ assertThrows(IllegalArgumentException.class,
+ () -> apc.deliver(CommInfrastructure.NOOP, "unknown-topic", MY_EVENT));
}
@Test
- public void testIsAlive() {
+ void testIsAlive() {
assertFalse(apc.isAlive());
apc.start();
@@ -644,7 +649,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testLock() {
+ void testLock() {
// arrange for first provider to throw exceptions
when(prov1.beforeLock(any())).thenThrow(new RuntimeException(EXPECTED));
when(prov1.afterLock(any())).thenThrow(new RuntimeException(EXPECTED));
@@ -678,7 +683,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testLock_AlreadyLocked() {
+ void testLock_AlreadyLocked() {
apc.start();
apc.lock();
@@ -697,7 +702,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testUnlock() {
+ void testUnlock() {
// arrange for first provider to throw exceptions
when(prov1.beforeUnlock(any())).thenThrow(new RuntimeException(EXPECTED));
when(prov1.afterUnlock(any())).thenThrow(new RuntimeException(EXPECTED));
@@ -733,7 +738,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testUnlock_NotLocked() {
+ void testUnlock_NotLocked() {
apc.start();
// now unlock it
@@ -750,7 +755,7 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testIsLocked() {
+ void testIsLocked() {
assertFalse(apc.isLocked());
apc.lock();
@@ -761,27 +766,27 @@ public class AggregatedPolicyControllerTest {
}
@Test
- public void testGetTopicSources() {
+ void testGetTopicSources() {
assertEquals(sources, apc.getTopicSources());
}
@Test
- public void testGetTopicSinks() {
+ void testGetTopicSinks() {
assertEquals(sinks, apc.getTopicSinks());
}
@Test
- public void testGetDrools() {
+ void testGetDrools() {
assertEquals(drools, apc.getDrools());
}
@Test
- public void testGetProperties() {
+ void testGetProperties() {
assertEquals(properties, apc.getProperties());
}
@Test
- public void testToString() {
+ void testToString() {
assertTrue(apc.toString().startsWith("AggregatedPolicyController("));
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java
index 2ba7cde9..23511abd 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/FeatureLockImplTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 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.
@@ -24,12 +24,12 @@ package org.onap.policy.drools.system.internal;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -40,15 +40,18 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.Serial;
import java.util.concurrent.ScheduledExecutorService;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+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.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.drools.core.DroolsRunnable;
import org.onap.policy.drools.core.PolicySession;
import org.onap.policy.drools.core.lock.LockCallback;
@@ -56,8 +59,8 @@ import org.onap.policy.drools.core.lock.LockState;
import org.onap.policy.drools.system.PolicyEngineConstants;
import org.springframework.test.util.ReflectionTestUtils;
-@RunWith(MockitoJUnitRunner.class)
-public class FeatureLockImplTest {
+@ExtendWith(MockitoExtension.class)
+class FeatureLockImplTest {
private static final String POLICY_ENGINE_EXECUTOR_FIELD = "executorService";
private static final String OWNER_KEY = "my key";
private static final String RESOURCE = "my resource";
@@ -72,11 +75,13 @@ public class FeatureLockImplTest {
@Mock
private LockCallback callback;
+ AutoCloseable closeable;
+
/**
* Saves static fields and configures the location of the property files.
*/
- @BeforeClass
- public static void setUpBeforeClass() {
+ @BeforeAll
+ static void setUpBeforeClass() {
saveExec = (ScheduledExecutorService) ReflectionTestUtils.getField(PolicyEngineConstants.getManager(),
POLICY_ENGINE_EXECUTOR_FIELD);
}
@@ -84,8 +89,8 @@ public class FeatureLockImplTest {
/**
* Restores static fields.
*/
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
ReflectionTestUtils.setField(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, saveExec);
}
@@ -93,13 +98,19 @@ public class FeatureLockImplTest {
* Initializes the mocks and creates a feature that uses {@link #exsvc} to execute
* tasks.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
+ closeable = MockitoAnnotations.openMocks(this);
ReflectionTestUtils.setField(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, exsvc);
}
+ @AfterEach
+ void closeMocks() throws Exception {
+ closeable.close();
+ }
+
@Test
- public void testNoArgs() {
+ void testNoArgs() {
MyLock lock = new MyLock();
assertNull(lock.getResourceId());
assertNull(lock.getOwnerKey());
@@ -108,7 +119,7 @@ public class FeatureLockImplTest {
}
@Test
- public void testFeatureLockImpl() {
+ void testFeatureLockImpl() {
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
assertTrue(lock.isWaiting());
assertEquals(RESOURCE, lock.getResourceId());
@@ -118,7 +129,7 @@ public class FeatureLockImplTest {
}
@Test
- public void testSerializable() throws Exception {
+ void testSerializable() throws Exception {
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
lock = roundTrip(lock);
@@ -131,14 +142,14 @@ public class FeatureLockImplTest {
}
@Test
- public void testGrant() {
+ void testGrant() {
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
lock.grant();
assertTrue(lock.isActive());
assertEquals(1, lock.nupdates);
- invokeCallback(1);
+ invokeCallback();
verify(callback).lockAvailable(any());
verify(callback, never()).lockUnavailable(any());
}
@@ -147,7 +158,7 @@ public class FeatureLockImplTest {
* Tests grant() when the lock is already unavailable.
*/
@Test
- public void testGrantUnavailable() {
+ void testGrantUnavailable() {
MyLock lock = new MyLock(LockState.UNAVAILABLE, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
lock.setState(LockState.UNAVAILABLE);
lock.grant();
@@ -159,13 +170,13 @@ public class FeatureLockImplTest {
}
@Test
- public void testDeny() {
+ void testDeny() {
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
lock.deny("my reason");
assertTrue(lock.isUnavailable());
- invokeCallback(1);
+ invokeCallback();
verify(callback, never()).lockAvailable(any());
verify(callback).lockUnavailable(any());
}
@@ -174,10 +185,11 @@ public class FeatureLockImplTest {
* Tests doNotify() when a session exists.
*/
@Test
- public void testDoNotifySession() {
+ void testDoNotifySession() {
PolicySession session = mock(PolicySession.class);
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback) {
+ @Serial
private static final long serialVersionUID = 1L;
@Override
@@ -207,20 +219,20 @@ public class FeatureLockImplTest {
* Tests doNotify() when there is no session.
*/
@Test
- public void testDoNotifyNoSession() {
+ void testDoNotifyNoSession() {
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
lock.grant();
assertTrue(lock.isActive());
assertEquals(1, lock.nupdates);
- invokeCallback(1);
+ invokeCallback();
verify(callback).lockAvailable(any());
verify(callback, never()).lockUnavailable(any());
}
@Test
- public void testFreeAllowed() {
+ void testFreeAllowed() {
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
assertTrue(lock.freeAllowed());
}
@@ -229,7 +241,7 @@ public class FeatureLockImplTest {
* Tests freeAllowed() when the lock is unavailable.
*/
@Test
- public void testFreeAllowedUnavailable() {
+ void testFreeAllowedUnavailable() {
MyLock lock = new MyLock(LockState.UNAVAILABLE, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
assertFalse(lock.freeAllowed());
assertTrue(lock.isUnavailable());
@@ -241,7 +253,7 @@ public class FeatureLockImplTest {
* @throws Exception if an error occurs
*/
@Test
- public void testFreeAllowedSerialized() throws Exception {
+ void testFreeAllowedSerialized() throws Exception {
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
lock = roundTrip(lock);
@@ -254,7 +266,7 @@ public class FeatureLockImplTest {
* @throws Exception if an error occurs
*/
@Test
- public void testFreeAllowedNoFeature() throws Exception {
+ void testFreeAllowedNoFeature() throws Exception {
MyLock lock = new MyLockNoFeature(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
lock = roundTrip(lock);
@@ -263,7 +275,7 @@ public class FeatureLockImplTest {
}
@Test
- public void testExtendAllowed() {
+ void testExtendAllowed() {
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
LockCallback scallback = mock(LockCallback.class);
@@ -288,7 +300,7 @@ public class FeatureLockImplTest {
* Tests extendAllowed() when the lock is unavailable.
*/
@Test
- public void testExtendAllowedUnavailable() {
+ void testExtendAllowedUnavailable() {
MyLock lock = new MyLock(LockState.UNAVAILABLE, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
LockCallback scallback = mock(LockCallback.class);
@@ -297,7 +309,7 @@ public class FeatureLockImplTest {
assertEquals(HOLD_SEC2, lock.getHoldSec());
assertSame(scallback, lock.getCallback());
- invokeCallback(1);
+ invokeCallback();
verify(scallback, never()).lockAvailable(lock);
verify(scallback).lockUnavailable(lock);
}
@@ -308,7 +320,7 @@ public class FeatureLockImplTest {
* @throws Exception if an error occurs
*/
@Test
- public void testExtendAllowedSerialized() throws Exception {
+ void testExtendAllowedSerialized() throws Exception {
MyLock lock = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
lock = roundTrip(lock);
@@ -328,7 +340,7 @@ public class FeatureLockImplTest {
* @throws Exception if an error occurs
*/
@Test
- public void testExtendAllowedNoFeature() throws Exception {
+ void testExtendAllowedNoFeature() throws Exception {
MyLock lock = new MyLockNoFeature(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
lock = roundTrip(lock);
@@ -339,21 +351,21 @@ public class FeatureLockImplTest {
assertEquals(HOLD_SEC2, lock.getHoldSec());
assertSame(scallback, lock.getCallback());
- invokeCallback(1);
+ invokeCallback();
verify(scallback, never()).lockAvailable(lock);
verify(scallback).lockUnavailable(lock);
}
@Test
- public void testGetSession() {
+ void testGetSession() {
MyLockStdSession lock = new MyLockStdSession(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback);
// this should invoke the real policy session without throwing an exception
- assertThatCode(() -> lock.grant()).doesNotThrowAnyException();
+ assertThatCode(lock::grant).doesNotThrowAnyException();
}
@Test
- public void testToString() {
+ void testToString() {
String text = new MyLock(LockState.WAITING, RESOURCE, OWNER_KEY, HOLD_SEC, callback).toString();
assertNotNull(text);
assertThat(text).contains("LockImpl");
@@ -374,21 +386,18 @@ public class FeatureLockImplTest {
/**
* Invokes the last call-back in the work queue.
*
- * @param nexpected number of call-backs expected in the work queue
*/
- private void invokeCallback(int nexpected) {
+ private void invokeCallback() {
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
- verify(exsvc, times(nexpected)).execute(captor.capture());
-
- if (nexpected > 0) {
- captor.getAllValues().get(nexpected - 1).run();
- }
+ verify(exsvc, times(1)).execute(captor.capture());
+ captor.getAllValues().get(0).run();
}
/**
* Lock that inherits the normal getSession() method.
*/
public static class MyLockStdSession extends FeatureLockImpl {
+ @Serial
private static final long serialVersionUID = 1L;
protected int nupdates = 0;
@@ -424,6 +433,7 @@ public class FeatureLockImplTest {
}
public static class MyLock extends MyLockStdSession {
+ @Serial
private static final long serialVersionUID = 1L;
public MyLock() {
@@ -441,6 +451,7 @@ public class FeatureLockImplTest {
}
public static class MyLockNoFeature extends MyLock {
+ @Serial
private static final long serialVersionUID = 1L;
public MyLockNoFeature() {
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java
index 3617c445..74e1a9c1 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/LockManagerTest.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.
@@ -20,9 +21,10 @@
package org.onap.policy.drools.system.internal;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -31,10 +33,11 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.io.Serial;
import java.util.concurrent.ScheduledExecutorService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.onap.policy.drools.core.lock.AlwaysFailLock;
@@ -42,7 +45,7 @@ import org.onap.policy.drools.core.lock.Lock;
import org.onap.policy.drools.core.lock.LockCallback;
import org.onap.policy.drools.core.lock.LockState;
-public class LockManagerTest {
+class LockManagerTest {
private static final String OWNER_KEY = "my key";
private static final String RESOURCE = "my resource";
private static final String RESOURCE2 = "my resource #2";
@@ -56,12 +59,14 @@ public class LockManagerTest {
private MyManager mgr;
+ private AutoCloseable closeable;
+
/**
* Resets fields and creates {@link #mgr}.
*/
- @Before
+ @BeforeEach
public void setUp() {
- MockitoAnnotations.openMocks(this);
+ closeable = MockitoAnnotations.openMocks(this);
doAnswer(args -> {
args.getArgument(0, Runnable.class).run();
@@ -71,13 +76,13 @@ public class LockManagerTest {
mgr = new MyManager();
}
- @After
- public void tearDown() {
-
+ @AfterEach
+ public void tearDown() throws Exception {
+ closeable.close();
}
@Test
- public void testIsAlive() {
+ void testIsAlive() {
assertFalse(mgr.isAlive());
assertFalse(mgr.isLocked());
@@ -90,7 +95,7 @@ public class LockManagerTest {
}
@Test
- public void testStart() {
+ void testStart() {
assertTrue(mgr.start());
assertTrue(mgr.isAlive());
@@ -103,7 +108,7 @@ public class LockManagerTest {
}
@Test
- public void testStop() {
+ void testStop() {
assertFalse(mgr.stop());
mgr.start();
@@ -112,7 +117,7 @@ public class LockManagerTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
mgr.start();
mgr.shutdown();
assertFalse(mgr.isAlive());
@@ -122,7 +127,7 @@ public class LockManagerTest {
}
@Test
- public void testIsLocked() {
+ void testIsLocked() {
assertFalse(mgr.isLocked());
assertFalse(mgr.isAlive());
@@ -135,7 +140,7 @@ public class LockManagerTest {
}
@Test
- public void testLock() {
+ void testLock() {
assertTrue(mgr.lock());
assertTrue(mgr.isLocked());
@@ -148,7 +153,7 @@ public class LockManagerTest {
}
@Test
- public void testUnlock() {
+ void testUnlock() {
assertFalse(mgr.unlock());
mgr.lock();
@@ -157,7 +162,7 @@ public class LockManagerTest {
}
@Test
- public void testCreateLock() {
+ void testCreateLock() {
Lock lock = mgr.createLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
assertTrue(lock.isActive());
verify(callback).lockAvailable(lock);
@@ -182,12 +187,12 @@ public class LockManagerTest {
* Tests createLock() when the feature instance has changed.
*/
@Test
- public void testCreateLockInstanceChanged() {
+ void testCreateLockInstanceChanged() {
mgr = spy(mgr);
when(mgr.hasInstanceChanged()).thenReturn(true);
Lock lock = mgr.createLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
- assertTrue(lock instanceof AlwaysFailLock);
+ assertInstanceOf(AlwaysFailLock.class, lock);
assertTrue(lock.isUnavailable());
verify(callback, never()).lockAvailable(lock);
@@ -195,7 +200,7 @@ public class LockManagerTest {
}
@Test
- public void testGetResource2lock() {
+ void testGetResource2lock() {
assertNotNull(mgr.getResource2lock());
}
@@ -220,6 +225,7 @@ public class LockManagerTest {
}
private class MyLock extends FeatureLockImpl {
+ @Serial
private static final long serialVersionUID = 1L;
public MyLock(LockState waiting, String resourceId, String ownerKey, int holdSec, LockCallback callback) {
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerExceptionTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerExceptionTest.java
index 3e4e5762..fdf840b2 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerExceptionTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerExceptionTest.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,15 +21,15 @@
package org.onap.policy.drools.system.internal;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.test.ExceptionsTester;
-public class SimpleLockManagerExceptionTest extends ExceptionsTester {
+class SimpleLockManagerExceptionTest extends ExceptionsTester {
@Test
- public void test() {
+ void test() {
assertEquals(1, test(SimpleLockManagerException.class));
}
}
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java
index 4491a73b..3ee5583a 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/SimpleLockManagerTest.java
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 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.
@@ -25,12 +25,12 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyLong;
@@ -44,6 +44,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -53,15 +54,17 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterAll;
+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.junit.jupiter.api.extension.ExtendWith;
import org.kie.api.runtime.KieSession;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.common.utils.time.CurrentTime;
import org.onap.policy.common.utils.time.TestTime;
import org.onap.policy.drools.core.PolicySession;
@@ -72,8 +75,8 @@ import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.drools.system.internal.SimpleLockManager.SimpleLock;
import org.springframework.test.util.ReflectionTestUtils;
-@RunWith(MockitoJUnitRunner.class)
-public class SimpleLockManagerTest {
+@ExtendWith(MockitoExtension.class)
+class SimpleLockManagerTest {
private static final String POLICY_ENGINE_EXECUTOR_FIELD = "executorService";
private static final String TIME_FIELD = "currentTime";
private static final String OWNER_KEY = "my key";
@@ -91,7 +94,6 @@ public class SimpleLockManagerTest {
private static ScheduledExecutorService saveExec;
private static ScheduledExecutorService realExec;
- private PolicySession session;
private TestTime testTime;
private AtomicInteger nactive;
private AtomicInteger nsuccesses;
@@ -109,11 +111,13 @@ public class SimpleLockManagerTest {
@Mock
private LockCallback callback;
+ AutoCloseable closeable;
+
/**
* Saves static fields and configures the location of the property files.
*/
- @BeforeClass
- public static void setUpBeforeClass() {
+ @BeforeAll
+ static void setUpBeforeClass() {
saveTime = (CurrentTime) ReflectionTestUtils.getField(SimpleLockManager.class, TIME_FIELD);
saveExec = (ScheduledExecutorService) ReflectionTestUtils.getField(PolicyEngineConstants.getManager(),
POLICY_ENGINE_EXECUTOR_FIELD);
@@ -124,8 +128,8 @@ public class SimpleLockManagerTest {
/**
* Restores static fields.
*/
- @AfterClass
- public static void tearDownAfterClass() {
+ @AfterAll
+ static void tearDownAfterClass() {
ReflectionTestUtils.setField(SimpleLockManager.class, TIME_FIELD, saveTime);
ReflectionTestUtils.setField(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, saveExec);
@@ -136,10 +140,11 @@ public class SimpleLockManagerTest {
* Initializes the mocks and creates a feature that uses {@link #exsvc} to execute
* tasks.
*/
- @Before
- public void setUp() {
+ @BeforeEach
+ void setUp() {
+ closeable = MockitoAnnotations.openMocks(this);
// grant() and deny() calls will come through here and be immediately executed
- session = new PolicySession(null, null, kieSess) {
+ PolicySession session = new PolicySession(null, null, kieSess) {
@Override
public void insertDrools(Object object) {
((Runnable) object).run();
@@ -160,11 +165,16 @@ public class SimpleLockManagerTest {
feature.start();
}
+ @AfterEach
+ void closeMocks() throws Exception {
+ closeable.close();
+ }
+
/**
* Tests constructor() when properties are invalid.
*/
@Test
- public void testSimpleLockManagerInvalidProperties() {
+ void testSimpleLockManagerInvalidProperties() {
// use properties containing an invalid value
Properties props = new Properties();
props.setProperty(SimpleLockProperties.EXPIRE_CHECK_SEC, "abc");
@@ -173,7 +183,7 @@ public class SimpleLockManagerTest {
}
@Test
- public void testStart() {
+ void testStart() {
assertTrue(feature.isAlive());
verify(exsvc).scheduleWithFixedDelay(any(), anyLong(), anyLong(), any());
@@ -184,7 +194,7 @@ public class SimpleLockManagerTest {
}
@Test
- public void testStop() {
+ void testStop() {
assertTrue(feature.stop());
assertFalse(feature.isAlive());
verify(future).cancel(true);
@@ -196,16 +206,16 @@ public class SimpleLockManagerTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
feature.shutdown();
verify(future).cancel(true);
}
@Test
- public void testCreateLock() {
+ void testCreateLock() {
// this lock should be granted immediately
- SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
assertTrue(lock.isActive());
assertEquals(testTime.getMillis() + HOLD_MS, lock.getHoldUntilMs());
@@ -236,7 +246,7 @@ public class SimpleLockManagerTest {
* Tests createLock() when the feature is not the latest instance.
*/
@Test
- public void testCreateLockNotLatestInstance() {
+ void testCreateLockNotLatestInstance() {
SimpleLockManager.setLatestInstance(null);
Lock lock = feature.createLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
@@ -246,10 +256,10 @@ public class SimpleLockManagerTest {
}
@Test
- public void testCheckExpired() throws InterruptedException {
- final SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
- final SimpleLock lock2 = getLock(RESOURCE2, OWNER_KEY, HOLD_SEC, callback, false);
- final SimpleLock lock3 = getLock(RESOURCE3, OWNER_KEY, HOLD_SEC2, callback, false);
+ void testCheckExpired() throws InterruptedException {
+ final SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
+ final SimpleLock lock2 = getLock(RESOURCE2, HOLD_SEC, callback);
+ final SimpleLock lock3 = getLock(RESOURCE3, HOLD_SEC2, callback);
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(exsvc).scheduleWithFixedDelay(captor.capture(), anyLong(), anyLong(), any());
@@ -292,15 +302,15 @@ public class SimpleLockManagerTest {
* Tests checkExpired(), where the lock is removed from the map between invoking
* expired() and compute(). Should cause "null" to be returned by compute().
*
- * @throws InterruptedException if the test is interrupted
*/
@Test
- public void testCheckExpiredLockDeleted() throws InterruptedException {
+ void testCheckExpiredLockDeleted() {
feature = new MyLockingFeature() {
@Override
protected SimpleLock makeLock(LockState waiting, String resourceId, String ownerKey, int holdSec,
LockCallback callback) {
return new SimpleLock(waiting, resourceId, ownerKey, holdSec, callback, feature) {
+ @Serial
private static final long serialVersionUID = 1L;
@Override
@@ -343,7 +353,7 @@ public class SimpleLockManagerTest {
* @throws InterruptedException if the test is interrupted
*/
@Test
- public void testCheckExpiredLockReplaced() throws InterruptedException {
+ void testCheckExpiredLockReplaced() throws InterruptedException {
feature = new MyLockingFeature() {
private boolean madeLock = false;
@@ -357,6 +367,7 @@ public class SimpleLockManagerTest {
madeLock = true;
return new SimpleLock(waiting, resourceId, ownerKey, holdSec, callback, feature) {
+ @Serial
private static final long serialVersionUID = 1L;
@Override
@@ -388,7 +399,7 @@ public class SimpleLockManagerTest {
}
@Test
- public void testGetThreadPool() {
+ void testGetThreadPool() {
// use a real feature
feature = new SimpleLockManager(null, new Properties());
@@ -403,7 +414,7 @@ public class SimpleLockManagerTest {
}
@Test
- public void testSimpleLockNoArgs() {
+ void testSimpleLockNoArgs() {
SimpleLock lock = new SimpleLock();
assertNull(lock.getResourceId());
assertNull(lock.getOwnerKey());
@@ -414,8 +425,8 @@ public class SimpleLockManagerTest {
}
@Test
- public void testSimpleLockSimpleLock() {
- SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testSimpleLockSimpleLock() {
+ SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
assertEquals(RESOURCE, lock.getResourceId());
assertEquals(OWNER_KEY, lock.getOwnerKey());
assertSame(callback, lock.getCallback());
@@ -427,8 +438,8 @@ public class SimpleLockManagerTest {
}
@Test
- public void testSimpleLockSerializable() throws Exception {
- SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testSimpleLockSerializable() throws Exception {
+ SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
lock = roundTrip(lock);
assertTrue(lock.isActive());
@@ -440,8 +451,8 @@ public class SimpleLockManagerTest {
}
@Test
- public void testSimpleLockExpired() {
- SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testSimpleLockExpired() {
+ SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
lock.grant();
assertFalse(lock.expired(testTime.getMillis()));
@@ -450,11 +461,11 @@ public class SimpleLockManagerTest {
}
@Test
- public void testSimpleLockFree() {
- final SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testSimpleLockFree() {
+ final SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
// lock2 should be denied
- SimpleLock lock2 = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ SimpleLock lock2 = getLock(RESOURCE, HOLD_SEC, callback);
verify(callback, never()).lockAvailable(lock2);
verify(callback).lockUnavailable(lock2);
@@ -470,7 +481,7 @@ public class SimpleLockManagerTest {
assertEquals(LockState.UNAVAILABLE, lock.getState());
// should be able to get the lock now
- SimpleLock lock3 = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ SimpleLock lock3 = getLock(RESOURCE, HOLD_SEC, callback);
assertTrue(lock3.isActive());
verify(callback).lockAvailable(lock3);
@@ -483,8 +494,8 @@ public class SimpleLockManagerTest {
* @throws Exception if an error occurs
*/
@Test
- public void testSimpleLockFreeSerialized() throws Exception {
- SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testSimpleLockFreeSerialized() throws Exception {
+ SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
feature = new MyLockingFeature();
feature.start();
@@ -495,11 +506,11 @@ public class SimpleLockManagerTest {
}
@Test
- public void testSimpleLockExtend() {
- final SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testSimpleLockExtend() {
+ final SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
// lock2 should be denied
- SimpleLock lock2 = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ SimpleLock lock2 = getLock(RESOURCE, HOLD_SEC, callback);
verify(callback, never()).lockAvailable(lock2);
verify(callback).lockUnavailable(lock2);
@@ -529,8 +540,8 @@ public class SimpleLockManagerTest {
* @throws Exception if an error occurs
*/
@Test
- public void testSimpleLockExtendSerialized() throws Exception {
- SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testSimpleLockExtendSerialized() throws Exception {
+ SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
feature = new MyLockingFeature();
feature.start();
@@ -551,8 +562,8 @@ public class SimpleLockManagerTest {
* @throws Exception if an error occurs
*/
@Test
- public void testSimpleLockExtendNoFeature() throws Exception {
- SimpleLock lock = getLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false);
+ void testSimpleLockExtendNoFeature() throws Exception {
+ SimpleLock lock = getLock(RESOURCE, HOLD_SEC, callback);
SimpleLockManager.setLatestInstance(null);
@@ -567,7 +578,7 @@ public class SimpleLockManagerTest {
}
@Test
- public void testSimpleLockToString() {
+ void testSimpleLockToString() {
String text = feature.createLock(RESOURCE, OWNER_KEY, HOLD_SEC, callback, false).toString();
assertNotNull(text);
assertThat(text).contains("holdUntil").doesNotContain("ownerInfo").doesNotContain("callback");
@@ -580,7 +591,7 @@ public class SimpleLockManagerTest {
* the background threads to complete
*/
@Test
- public void testMultiThreaded() throws InterruptedException {
+ void testMultiThreaded() throws InterruptedException {
ReflectionTestUtils.setField(SimpleLockManager.class, TIME_FIELD, testTime);
ReflectionTestUtils.setField(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, realExec);
feature = new SimpleLockManager(null, new Properties());
@@ -607,9 +618,8 @@ public class SimpleLockManagerTest {
assertTrue(nsuccesses.get() > 0);
}
- private SimpleLock getLock(String resource, String ownerKey, int holdSec, LockCallback callback,
- boolean waitForLock) {
- return (SimpleLock) feature.createLock(resource, ownerKey, holdSec, callback, waitForLock);
+ private SimpleLock getLock(String resource, int holdSec, LockCallback callback) {
+ return (SimpleLock) feature.createLock(resource, SimpleLockManagerTest.OWNER_KEY, holdSec, callback, false);
}
private SimpleLock roundTrip(SimpleLock lock) throws Exception {
@@ -646,7 +656,7 @@ public class SimpleLockManagerTest {
}
/**
- * Thread used with the multi-threaded test. It repeatedly attempts to get a lock,
+ * Thread used with the multithreaded test. It repeatedly attempts to get a lock,
* extend it, and then unlock it.
*/
private class MyThread extends Thread {
diff --git a/policy-management/src/test/resources/echo.kmodule b/policy-management/src/test/resources/echo.kmodule
index 496f7098..9abadcb5 100644
--- a/policy-management/src/test/resources/echo.kmodule
+++ b/policy-management/src/test/resources/echo.kmodule
@@ -4,6 +4,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.
@@ -19,7 +20,7 @@
============LICENSE_END=========================================================
-->
-<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="onap.policies.test">
<ksession name="echo"/>
</kbase>
diff --git a/policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestAdd.json b/policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestAdd.json
index 576315ec..42fd3554 100644
--- a/policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestAdd.json
+++ b/policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestAdd.json
@@ -14,7 +14,6 @@
"sniHostCheck": false,
"user": null,
"alive": true,
- "aaf": false,
"prometheus": false
}
],
diff --git a/policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestConfig.json b/policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestConfig.json
index 69a10480..d7838e01 100644
--- a/policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestConfig.json
+++ b/policy-management/src/test/resources/org/onap/policy/drools/system/PolicyEngineTestConfig.json
@@ -11,7 +11,6 @@
"sniHostCheck": false,
"user": null,
"alive": false,
- "aaf": false,
"prometheus": false
}
],
diff --git a/policy-management/src/test/resources/rules.kmodule b/policy-management/src/test/resources/rules.kmodule
index 4f3f8745..f7752c82 100644
--- a/policy-management/src/test/resources/rules.kmodule
+++ b/policy-management/src/test/resources/rules.kmodule
@@ -4,6 +4,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.
@@ -19,7 +20,7 @@
============LICENSE_END=========================================================
-->
-<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="kbRules">
<ksession name="rules"/>
</kbase>
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java
index 8afc1e1e..5e77ee4b 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java
@@ -3,6 +3,7 @@
* policy-utils
* ================================================================================
* Copyright (C) 2017-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.
@@ -32,7 +33,7 @@ import org.slf4j.LoggerFactory;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ReflectionUtil {
- protected static final Logger logger = LoggerFactory.getLogger(ReflectionUtil.class);
+ private static final Logger logger = LoggerFactory.getLogger(ReflectionUtil.class);
/**
* returns (if exists) a class fetched from a given classloader.
@@ -75,11 +76,11 @@ public final class ReflectionUtil {
}
/**
- * Is it a sub class.
+ * Is it a subclass.
*
* @param parent superclass
* @param presumedSubclass subclass
- * @return true if it is a sub class
+ * @return true if it is a subclass
*/
public static boolean isSubclass(Class<?> parent, Class<?> presumedSubclass) {
return parent.isAssignableFrom(presumedSubclass);
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java
deleted file mode 100644
index 10788eb8..00000000
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2017-2019, 2021 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.utils.logging;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-/**
- * Loger Utils.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class LoggerUtil {
-
- /**
- * Logback configuration file system property.
- */
- public static final String LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY = "logback.configurationFile";
-
- /**
- * Logback default configuration file location.
- */
- public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "config/logback.xml";
-
-}
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/metrics/MetricTest.java b/policy-utils/src/test/java/org/onap/policy/drools/metrics/MetricTest.java
index 5a5965c4..924d1c95 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/metrics/MetricTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/metrics/MetricTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -22,10 +23,10 @@ package org.onap.policy.drools.metrics;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.impl.PojoClassFactory;
@@ -39,12 +40,12 @@ import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class MetricTest {
+class MetricTest {
@Test
- public void testPojo() {
+ void testPojo() {
PojoClass metric = PojoClassFactory.getPojoClass(Metric.class);
Validator val = ValidatorBuilder
.create()
@@ -57,7 +58,7 @@ public class MetricTest {
}
@Test
- public void testEndTimeSetter() {
+ void testEndTimeSetter() {
Metric metric = new Metric();
assertNull(metric.getEndTime());
@@ -66,7 +67,7 @@ public class MetricTest {
}
@Test
- public void testStartTimeSetter() {
+ void testStartTimeSetter() {
Metric metric = new Metric();
assertNull(metric.getStartTime());
@@ -75,7 +76,7 @@ public class MetricTest {
}
@Test
- public void testElapsedTimeSetter() {
+ void testElapsedTimeSetter() {
Metric metric = new Metric();
assertNull(metric.getElapsedTime());
@@ -96,7 +97,7 @@ public class MetricTest {
}
@Test
- public void testInvocationIdSetter() {
+ void testInvocationIdSetter() {
Metric metric = new Metric();
assertNull(metric.getInvocationId());
@@ -105,7 +106,7 @@ public class MetricTest {
}
@Test
- public void testServiceNameSetter() {
+ void testServiceNameSetter() {
Metric metric = new Metric();
assertNull(metric.getServiceName());
@@ -114,7 +115,7 @@ public class MetricTest {
}
@Test
- public void testInstanceUuidSetter() {
+ void testInstanceUuidSetter() {
Metric metric = new Metric();
assertNull(metric.getInstanceUuid());
@@ -123,7 +124,7 @@ public class MetricTest {
}
@Test
- public void testRequestIdSetter() {
+ void testRequestIdSetter() {
Metric metric = new Metric();
assertNull(metric.getRequestId());
@@ -132,7 +133,7 @@ public class MetricTest {
}
@Test
- public void testPartnerSetter() {
+ void testPartnerSetter() {
Metric metric = new Metric();
assertNull(metric.getPartner());
@@ -141,7 +142,7 @@ public class MetricTest {
}
@Test
- public void testServerNameSetter() {
+ void testServerNameSetter() {
Metric metric = new Metric();
assertNull(metric.getServerName());
@@ -150,7 +151,7 @@ public class MetricTest {
}
@Test
- public void testServerFqdnSetter() {
+ void testServerFqdnSetter() {
Metric metric = new Metric();
assertNull(metric.getServerFqdn());
@@ -159,7 +160,7 @@ public class MetricTest {
}
@Test
- public void testVirtualServerNameSetter() {
+ void testVirtualServerNameSetter() {
Metric metric = new Metric();
assertNull(metric.getVirtualServerName());
@@ -168,7 +169,7 @@ public class MetricTest {
}
@Test
- public void testEqualsToString() {
+ void testEqualsToString() {
Metric metric1 = new Metric();
Metric metric2 = new Metric();
@@ -185,7 +186,7 @@ public class MetricTest {
}
@Test
- public void testToTimestamp() {
+ void testToTimestamp() {
Instant now = Instant.now();
assertEquals(new SimpleDateFormat(Metric.DATE_FORMAT).format(Date.from(now)), Metric.toTimestamp(now));
}
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Metadata.java b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Metadata.java
index 0cad4ff0..e81bdd05 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Metadata.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Metadata.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -21,6 +22,7 @@
package org.onap.policy.drools.models.domains.a;
import com.google.gson.annotations.SerializedName;
+import java.io.Serial;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@@ -28,6 +30,7 @@ import lombok.Data;
@Data
@Builder
public class Metadata implements Serializable {
+ @Serial
private static final long serialVersionUID = 476541531265304644L;
@SerializedName("policy-id")
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Nested.java b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Nested.java
index eedadeff..1d46d59d 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Nested.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Nested.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -21,6 +22,7 @@
package org.onap.policy.drools.models.domains.a;
import com.google.gson.annotations.SerializedName;
+import java.io.Serial;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@@ -28,6 +30,7 @@ import lombok.Data;
@Data
@Builder
public class Nested implements Serializable {
+ @Serial
private static final long serialVersionUID = -1203143214137354429L;
@SerializedName("nested1")
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Properties.java b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Properties.java
index 3ba66ce9..e323e8ac 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Properties.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/models/domains/a/Properties.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -21,6 +22,7 @@
package org.onap.policy.drools.models.domains.a;
import com.google.gson.annotations.SerializedName;
+import java.io.Serial;
import java.io.Serializable;
import lombok.Builder;
import lombok.Data;
@@ -28,6 +30,7 @@ import lombok.Data;
@Data
@Builder
public class Properties implements Serializable {
+ @Serial
private static final long serialVersionUID = 8476625479607243095L;
@SerializedName("nested")
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java b/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java
index 2c883304..5563d5ea 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/policies/DomainMakerTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021, 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.
@@ -22,17 +22,17 @@
package org.onap.policy.drools.policies;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+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 com.worldturner.medeia.api.ValidationFailedException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.drools.models.domains.a.DomainAPolicy;
@@ -43,17 +43,17 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
-public class DomainMakerTest {
+class DomainMakerTest {
private DomainMaker domainMaker;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
domainMaker = new DomainMaker();
}
@Test
- public void testIsConformantString() throws IOException {
+ void testIsConformantString() throws IOException {
ToscaConceptIdentifier policyTypeId =
new ToscaConceptIdentifier("policy.type.A", "1.0.0");
String rawJsonPolicyType =
@@ -66,7 +66,7 @@ public class DomainMakerTest {
}
@Test
- public void testIsConformantToscaPolicy() throws IOException, CoderException {
+ void testIsConformantToscaPolicy() throws IOException, CoderException {
ToscaPolicy policy = getToscaPolicy("src/test/resources/policyA.json");
assertTrue(domainMaker.isConformant(policy));
@@ -75,7 +75,7 @@ public class DomainMakerTest {
}
@Test
- public void testIsDomainConformant() {
+ void testIsDomainConformant() {
ToscaConceptIdentifier policyTypeId =
new ToscaConceptIdentifier("policy.type.A", "1.0.0");
@@ -95,7 +95,7 @@ public class DomainMakerTest {
@Test
- public void testConformance() throws IOException, CoderException {
+ void testConformance() throws IOException, CoderException {
ToscaPolicy policy1 = getToscaPolicy("src/test/resources/policyA.json");
assertTrue(domainMaker.conformance(policy1));
@@ -116,7 +116,7 @@ public class DomainMakerTest {
}
@Test
- public void testRegisterValidator() throws IOException, CoderException {
+ void testRegisterValidator() throws IOException, CoderException {
ToscaConceptIdentifier policyTypeId =
new ToscaConceptIdentifier("policy.type.external", "9.9.9");
@@ -133,7 +133,7 @@ public class DomainMakerTest {
}
@Test
- public void testConvertToDomainPolicy() throws IOException, CoderException {
+ void testConvertToDomainPolicy() throws IOException, CoderException {
DomainAPolicy domainAPolicy =
domainMaker.convertTo(getToscaPolicy("src/test/resources/policyA.json"), DomainAPolicy.class);
assertDomainPolicy(domainAPolicy);
@@ -143,7 +143,7 @@ public class DomainMakerTest {
}
@Test
- public void testConvertToSchema() {
+ void testConvertToSchema() {
ToscaPolicyType type = new ToscaPolicyType();
assertThatThrownBy(() -> domainMaker
.convertToSchema(type))
@@ -151,7 +151,7 @@ public class DomainMakerTest {
}
@Test
- public void testIsRegistered() {
+ void testIsRegistered() {
ToscaConceptIdentifier policyTypeId1 =
new ToscaConceptIdentifier("policy.type.A", "1.0.0");
assertTrue(domainMaker.isRegistered(policyTypeId1));
@@ -189,7 +189,7 @@ public class DomainMakerTest {
assertEquals("policy.type.A", domainAPolicy.getType());
assertEquals("A", domainAPolicy.getMetadata().getPolicyId());
assertEquals("nested1", domainAPolicy.getProperties().getNested().getNested1());
- assertEquals(true, domainAPolicy.getProperties().getNested().isNested2());
+ assertTrue(domainAPolicy.getProperties().getNested().isNested2());
assertEquals(50, domainAPolicy.getProperties().getNested().getNested3());
}
}
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java b/policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java
index c19adea4..f2676e5d 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-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.
@@ -20,20 +21,22 @@
package org.onap.policy.drools.utils;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.logging.LoggerUtils;
import org.onap.policy.common.utils.security.CryptoUtils;
import org.slf4j.Logger;
@@ -84,7 +87,7 @@ public class PropertyUtilTest {
/**
* Test Setup -- Create a directory for temporary files.
*/
- @BeforeClass
+ @BeforeAll
public static void setup() {
logger.info("setup: creating a temporary directory");
@@ -96,15 +99,15 @@ public class PropertyUtilTest {
/**
* Test Cleanup -- Remove temporary files.
*/
- @AfterClass
+ @AfterAll
public static void teardown() {
logger.info("teardown: remove the temporary directory");
// the assumption is that we only have one level of temporary files
- for (File file : directory.listFiles()) {
- file.delete();
+ for (File file : Objects.requireNonNull(directory.listFiles())) {
+ assertTrue(file.delete());
}
- directory.delete();
+ assertTrue(directory.delete());
}
/**
@@ -153,7 +156,7 @@ public class PropertyUtilTest {
* Test the basic properties file interface.
*/
@Test
- public void testGetProperties() throws Exception {
+ void testGetProperties() throws Exception {
logger.info("testGetProperties: test the basic properties file interface");
// copy system properties
@@ -253,7 +256,7 @@ public class PropertyUtilTest {
* This tests the 'PropertyUtil.Listener' interface.
*/
@Test
- public void testListenerInterface() throws Exception {
+ void testListenerInterface() throws Exception {
logger.info("testListenerInterface: test receipt of dynamic updates");
// create initial property file
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/utils/ReferenceTest.java b/policy-utils/src/test/java/org/onap/policy/drools/utils/ReferenceTest.java
index 8afe4626..c8c08d9d 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/utils/ReferenceTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/utils/ReferenceTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* 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.
@@ -20,17 +21,17 @@
package org.onap.policy.drools.utils;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ReferenceTest {
+class ReferenceTest {
@Test
- public void testReference() {
+ void testReference() {
Reference<Integer> val = new Reference<>(null);
assertNull(val.get());
@@ -39,7 +40,7 @@ public class ReferenceTest {
}
@Test
- public void testGet_testSet() {
+ void testGet_testSet() {
Reference<Integer> val = new Reference<>(null);
assertNull(val.get());
@@ -51,7 +52,7 @@ public class ReferenceTest {
}
@Test
- public void testCompareAndSet() {
+ void testCompareAndSet() {
Reference<Integer> val = new Reference<>(null);
Integer valCompare = 100;
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/utils/ReflectionUtilTest.java b/policy-utils/src/test/java/org/onap/policy/drools/utils/ReflectionUtilTest.java
index b7feaf06..cd1aac43 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/utils/ReflectionUtilTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/utils/ReflectionUtilTest.java
@@ -3,6 +3,7 @@
* policy-utils
* ================================================================================
* Copyright (C) 2017-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.
@@ -20,26 +21,27 @@
package org.onap.policy.drools.utils;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ReflectionUtilTest {
+class ReflectionUtilTest {
public class ParentClass {
}
- public class ChildClass extends ParentClass{
+ class ChildClass extends ParentClass{
}
@Test
- public void testReflection() {
+ void testReflection() {
try {
@@ -61,25 +63,27 @@ public class ReflectionUtilTest {
}
}
- @Test(expected = IllegalArgumentException.class)
- public void testException1() {
- ReflectionUtil.fetchClass(null, "org.onap.policy.drools.utils.ReflectionUtil");
+ @Test
+ void testException1() {
+ assertThrows(IllegalArgumentException.class, () ->
+ ReflectionUtil.fetchClass(null, "org.onap.policy.drools.utils.ReflectionUtil"));
}
- @Test(expected = IllegalArgumentException.class)
- public void testException2() {
+ @Test
+ void testException2() {
Class<?> class1;
try {
class1 = Class.forName("org.onap.policy.drools.utils.ReflectionUtil");
ClassLoader classLoader = class1.getClassLoader();
- ReflectionUtil.fetchClass(classLoader, null);
+ assertThrows(IllegalArgumentException.class, () ->
+ ReflectionUtil.fetchClass(classLoader, null));
} catch (ClassNotFoundException e) {
fail();
}
}
@Test
- public void testException3() throws ClassNotFoundException {
+ void testException3() {
assertNull(ReflectionUtil.fetchClass(ClassLoader.getSystemClassLoader(), "foo.bar"));
}
}
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java
index 195a7add..524d46e4 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/LoggerUtilTest.java
@@ -3,6 +3,7 @@
* policy-utils
* ================================================================================
* 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.
@@ -20,18 +21,18 @@
package org.onap.policy.drools.utils.logging;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.logging.LoggerUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class LoggerUtilTest {
+class LoggerUtilTest {
@Test
- public void test() {
+ void test() {
Logger logger = LoggerFactory.getLogger(LoggerUtilTest.class);
diff --git a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java
index 213c1c6e..2beddcc3 100644
--- a/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java
+++ b/policy-utils/src/test/java/org/onap/policy/drools/utils/logging/MdcTransactionTest.java
@@ -3,6 +3,7 @@
* policy-utils
* ================================================================================
* 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.
@@ -19,20 +20,20 @@
package org.onap.policy.drools.utils.logging;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.time.Duration;
import java.time.Instant;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.MDC;
-public class MdcTransactionTest {
+class MdcTransactionTest {
@Test
- public void testResetSubTransaction() {
+ void testResetSubTransaction() {
MdcTransaction trans =
MdcTransaction.newTransaction(null, null).resetSubTransaction();
@@ -88,7 +89,7 @@ public class MdcTransactionTest {
private void assertNullKeys(String... nullKeys) {
for (String key: nullKeys) {
- assertNull(key, MDC.get(key));
+ assertNull(MDC.get(key));
}
}
@@ -126,7 +127,7 @@ public class MdcTransactionTest {
}
@Test
- public void testFlush() {
+ void testFlush() {
MdcTransaction trans =
MdcTransaction.newTransaction()
.setRequestId(null)
@@ -198,12 +199,12 @@ public class MdcTransactionTest {
}
private void assertKeyEquals(String expected, String transValue, String mdcKey) {
- assertEquals("trans." + expected, expected, transValue);
- assertEquals("mdc." + expected, expected, MDC.get(mdcKey));
+ assertEquals(expected, transValue, "trans." + expected);
+ assertEquals(expected, MDC.get(mdcKey), "mdc." + expected);
}
@Test
- public void testMetric() {
+ void testMetric() {
MdcTransaction trans =
MdcTransaction.newTransaction(null, null).metric();
@@ -211,7 +212,7 @@ public class MdcTransactionTest {
}
@Test
- public void testTransaction() {
+ void testTransaction() {
MdcTransaction trans =
MdcTransaction.newTransaction(null, null).transaction();
@@ -219,7 +220,7 @@ public class MdcTransactionTest {
}
@Test
- public void testSubTransaction() {
+ void testSubTransaction() {
MdcTransaction trans =
MdcTransaction.newTransaction(null, "partner");
diff --git a/pom.xml b/pom.xml
index 5a55e2e0..e2d29197 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
ONAP Policy Engine - Drools PDP
================================================================================
Copyright (C) 2017-2022 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2020, 2023 Nordix Foundation.
+ Modifications Copyright (C) 2020, 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.
@@ -48,7 +48,7 @@
<staging.path>content/repositories/staging/</staging.path>
<!-- Project common dependency versions -->
- <json.path.version>2.8.0</json.path.version>
+ <json.path.version>2.9.0</json.path.version>
<hibernate.commons.annotations.version>6.0.6.Final</hibernate.commons.annotations.version>
<xml.apis.version>1.4.01</xml.apis.version>
<policy.common.version>2.1.1-SNAPSHOT</policy.common.version>
@@ -61,7 +61,7 @@
<module>policy-domains</module>
<module>policy-management</module>
<module>feature-healthcheck</module>
- <module>feature-pooling-dmaap</module>
+ <module>feature-pooling-messages</module>
<module>feature-test-transaction</module>
<module>feature-distributed-locking</module>
<module>feature-lifecycle</module>
@@ -90,8 +90,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -100,6 +100,10 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>