diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2023-10-04 15:38:04 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2023-10-04 15:42:27 +0100 |
commit | 336d94aa7cf3e23b5b62772504edb0d1daeb9520 (patch) | |
tree | 0c567dacc4b9521e273499f87a0b2d9c5be4a5dd /controlloop/common/eventmanager/src/test | |
parent | fc19178b956f4474ed14e810fd911ac60f3756d0 (diff) |
Java 17 and sonar fixes.
- change on maven.compiler to new resource property targeting
java 17 version
- sonar bugs on try-resource and some code smells
Issue-ID: POLICY-4677
Issue-ID: POLICY-4837
Change-Id: I50a2170db80619c2ac95131ab5c91a6f767a5c30
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'controlloop/common/eventmanager/src/test')
-rw-r--r-- | controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java index 95d4046ce..5caca45c3 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithStepsTest.java @@ -38,9 +38,11 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.io.Serial; import java.time.Instant; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.ForkJoinPool; @@ -60,9 +62,7 @@ import org.onap.policy.controlloop.actorserviceprovider.Operation; import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationResult; -import org.onap.policy.controlloop.actorserviceprovider.Operator; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; import org.onap.policy.controlloop.drl.legacy.ControlLoopParams; import org.onap.policy.drools.core.lock.LockCallback; import org.onap.policy.drools.core.lock.LockImpl; @@ -91,9 +91,7 @@ class ClEventManagerWithStepsTest { private final PolicyEngine engineMgr = mock(PolicyEngine.class); private final WorkingMemory workMem = mock(WorkingMemory.class); private final InternalFactHandle factHandle = mock(InternalFactHandle.class); - private final Operator policyOperator = mock(Operator.class); private final Operation policyOperation = mock(Operation.class); - private final Actor policyActor = mock(Actor.class); private final ExecutorService executor = mock(ExecutorService.class); private final EventManagerServices services = mock(EventManagerServices.class); private final ActorService actors = mock(ActorService.class); @@ -101,7 +99,6 @@ class ClEventManagerWithStepsTest { private final MyStep stepb = mock(MyStep.class); private List<LockImpl> locks; - private ToscaPolicy tosca; private ControlLoopParams params; private ClEventManagerWithSteps<MyStep> mgr; @@ -231,18 +228,18 @@ class ClEventManagerWithStepsTest { } @Test - public void testLoadNextPolicy() throws Exception { + void testLoadNextPolicy() throws Exception { loadPolicy(EVENT_MGR_MULTI_YAML); mgr = new MyManager(services, params, REQ_ID, workMem); // start and load step for first policy mgr.start(); - assertEquals("OperationA", mgr.getSteps().poll().getOperationName()); + assertEquals("OperationA", Objects.requireNonNull(mgr.getSteps().poll()).getOperationName()); assertNull(mgr.getFinalResult()); // indicate success and load next policy mgr.loadNextPolicy(OperationResult.SUCCESS); - assertEquals("OperationB", mgr.getSteps().poll().getOperationName()); + assertEquals("OperationB", Objects.requireNonNull(mgr.getSteps().poll()).getOperationName()); assertNull(mgr.getFinalResult()); // indicate failure - should go to final failure @@ -378,7 +375,7 @@ class ClEventManagerWithStepsTest { private void loadPolicy(String fileName) throws CoderException { var template = yamlCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class); - tosca = template.getToscaTopologyTemplate().getPolicies().get(0).values().iterator().next(); + ToscaPolicy tosca = template.getToscaTopologyTemplate().getPolicies().get(0).values().iterator().next(); params.setToscaPolicy(tosca); } @@ -404,6 +401,7 @@ class ClEventManagerWithStepsTest { private class MyManager extends ClEventManagerWithSteps<MyStep> { + @Serial private static final long serialVersionUID = 1L; public MyManager(EventManagerServices services, ControlLoopParams params, UUID requestId, WorkingMemory workMem) @@ -437,6 +435,7 @@ class ClEventManagerWithStepsTest { private static class RealManager extends ClEventManagerWithSteps<MyStep> { + @Serial private static final long serialVersionUID = 1L; public RealManager(EventManagerServices services, ControlLoopParams params, UUID requestId, |