diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2024-01-26 15:28:56 +0000 |
---|---|---|
committer | Adheli Tavares <adheli.tavares@est.tech> | 2024-02-09 10:31:15 +0000 |
commit | cc1d3d352771d1fa35d297e90663539e34b022f6 (patch) | |
tree | b1b00d678b0157742b91be1262fbf614a62063b1 /feature-lifecycle/src/test | |
parent | cce79248655f484e007769ba81b092148f940d27 (diff) |
Removing deprecated DMAAP library
Issue-ID: POLICY-4402
Change-Id: I4ce5b303cb3a775010683d3c7102b0bd065280ea
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'feature-lifecycle/src/test')
18 files changed, 221 insertions, 213 deletions
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", |