diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-08-31 12:22:01 +0100 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2023-08-31 11:51:58 +0000 |
commit | 2ddac68ffbd875f83463784ea75053434f0eed0d (patch) | |
tree | 5f7a6c3a6b151efdabcce7c00e0f3958399521ed /feature-lifecycle | |
parent | 16fba653605436e692410bff9d6a8bafaec27226 (diff) |
Fix unit tests in drools pdpjava-17
Issue-ID: POLICY-4815
Change-Id: I27270ec1fd31f73563c4b59308ee42d0787496c1
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'feature-lifecycle')
4 files changed, 14 insertions, 23 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java index 27d845b5..953f0b37 100644 --- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java +++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java @@ -37,7 +37,7 @@ public class LifecycleFeature * Lifecycle FSM. */ @Getter - public static final LifecycleFsm fsm = new LifecycleFsm(); + public static LifecycleFsm fsm = new LifecycleFsm(); @Override public int getSequenceNumber() { 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 4c1830b8..4e0b4bf7 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 @@ -135,14 +135,10 @@ public class ControllerSupport { * Change final marker in static field. */ public static <T> Field unsetFinalStaticAccess(Class<T> clazz, String fieldName) - throws NoSuchFieldException, IllegalAccessException { + throws NoSuchFieldException { Field field = clazz.getDeclaredField(fieldName); field.setAccessible(true); - Field modifiers = Field.class.getDeclaredField("modifiers"); - modifiers.setAccessible(true); - modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL); - return field; } 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 31fe3ebc..90c0d94c 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 @@ -163,7 +163,7 @@ public class LifecycleFsmUpdateTest { // checkstyle } - //ControllerSupport.setStaticField(LifecycleFeature.class, "fsm", savedFsm); + ControllerSupport.setStaticField(LifecycleFeature.class, "fsm", savedFsm); } /** @@ -177,7 +177,7 @@ public class LifecycleFsmUpdateTest { return new PseudoScheduledExecutorService(new TestTimeMulti()); } }; - //ControllerSupport.setStaticField(LifecycleFeature.class, "fsm", fsm); + ControllerSupport.setStaticField(LifecycleFeature.class, "fsm", fsm); fsm.setStatusTimerSeconds(15); assertTrue(fsm.start()); @@ -206,8 +206,7 @@ public class LifecycleFsmUpdateTest { unvalPolicy = getPolicyFromFile(EXAMPLE_OTHER_UNVAL_POLICY_JSON, EXAMPLE_OTHER_UNVAL_POLICY_NAME); } - - //TODO This test needs to be enabled in java-17 branch + @Test public void testUpdate() throws CoderException { verifyInitState(); @@ -365,7 +364,7 @@ public class LifecycleFsmUpdateTest { protected void deltaUpdate(List<ToscaPolicy> deploy, List<ToscaPolicy> undeploy, List<ToscaPolicy> active, long deployCount, long deploySuccess, long deployFail, long undeployCount, long undeploySuccess, long undeployFail) throws CoderException { - //assertTrue(fsm.update(getPdpUpdate(deploy, undeploy))); + assertTrue(fsm.update(getPdpUpdate(deploy, undeploy))); verifyDeploy(active, deployCount, deploySuccess, deployFail, undeployCount, undeploySuccess, undeployFail); } 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 9a756c74..29ef5a77 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 @@ -158,24 +158,20 @@ public class RestLifecycleManagerTest { */ @After public void tearDown() { - if (fsm != null) { - fsm.shutdown(); + fsm.shutdown(); - NoopTopicFactories.getSourceFactory().destroy(); - NoopTopicFactories.getSinkFactory().destroy(); + NoopTopicFactories.getSourceFactory().destroy(); + NoopTopicFactories.getSinkFactory().destroy(); - HttpClientFactoryInstance.getClientFactory().destroy(); - HttpServletServerFactoryInstance.getServerFactory().destroy(); + HttpClientFactoryInstance.getClientFactory().destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); - PolicyControllerConstants.getFactory().destroy(); - SystemPersistenceConstants.getManager().setConfigurationDir(null); - } + PolicyControllerConstants.getFactory().destroy(); + SystemPersistenceConstants.getManager().setConfigurationDir(null); } - - //TODO The below test needs to be enabled in java-17 branch - + @Test public void testMultiPolicyFlow() throws IOException, CoderException { /* group assignments */ |