summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2023-08-10 16:58:48 +0100
committeradheli.tavares <adheli.tavares@est.tech>2023-09-22 16:01:00 +0100
commita3a032d5b902c3e125dccd2bc2b41f22861decc1 (patch)
tree481b0faa916f39da096fe5c935c630b1598f0f7d /core/src
parent097618956f681eee12a23d7d9dc4f4f22f5347cc (diff)
Java 17 Upgrade
Updated dependencies to latest versions Made Java 17 changes Moved apex dependencies versions to main apex pom Issue-ID: POLICY-4675 Change-Id: Ia5cd5670a1f024f5402cbd7371162ce3313930ef Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java5
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java10
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/StateExecutorTest.java7
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java7
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutorTest.java20
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java10
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java10
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxStateFacadeTest.java7
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java8
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContextTest.java7
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContextTest.java7
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContextTest.java7
-rw-r--r--core/src/test/java/org/onap/policy/apex/core/engine/executor/impl/ExceutorFactoryImplTest.java9
13 files changed, 60 insertions, 54 deletions
diff --git a/core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java b/core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java
index 9345abaaa..cea505854 100644
--- a/core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java
+++ b/core/src/main/java/org/onap/policy/apex/core/infrastructure/threading/ApplicationThreadFactory.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 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,11 @@ public class ApplicationThreadFactory implements ThreadFactory {
* @param stackSize the stack size
* @param threadPriority the thread priority
*/
+ @SuppressWarnings({
+ "deprecation", "removal"
+ })
public ApplicationThreadFactory(final String nameLocal, final long stackSize, final int threadPriority) {
+ @SuppressWarnings("removal")
final var s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
name = APPLICATION_NAME + nameLocal + HYPHEN + NEXT_POOL_NUMBER.getAndIncrement();
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java
index 3b682acd6..8d7df45cd 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/engine/impl/ApexEngineImplTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,9 +39,10 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
@@ -70,6 +71,7 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the engine implementation.
*/
+@RunWith(MockitoJUnitRunner.class)
public class ApexEngineImplTest {
private static final String ENGINE_ID = "Engine:0.0.1";
@@ -97,10 +99,8 @@ public class ApexEngineImplTest {
*/
@Before
public void initializeMocking() throws ApexException {
- MockitoAnnotations.initMocks(this);
-
Mockito.doThrow(new StateMachineException("mocked state machine exception",
- new IOException("nexted exception"))).when(smHandlerMock).execute(Mockito.anyObject());
+ new IOException("nexted exception"))).when(smHandlerMock).execute(Mockito.any());
}
/**
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateExecutorTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateExecutorTest.java
index f3e12cc1f..fc1b339d2 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateExecutorTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateExecutorTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 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,9 +26,10 @@ import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.event.EnEvent;
@@ -38,6 +39,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxState;
/**
* Test task executor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class StateExecutorTest {
@Mock
private ApexInternalContext internalContextMock;
@@ -56,7 +58,6 @@ public class StateExecutorTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Mockito.doReturn(new AxReferenceKey("Policy:0.0.1:PolName:State0")).when(axStateMock).getKey();
}
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java
index 8f6544497..e140291b4 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateFinalizerExecutorTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 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,9 +28,10 @@ import java.util.Map;
import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
@@ -43,6 +44,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxStateFinalizerLogic;
/**
* Test task executor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class StateFinalizerExecutorTest {
@Mock
private Executor<?, ?, ?, ?> parentMock;
@@ -64,7 +66,6 @@ public class StateFinalizerExecutorTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
AxState state = new AxState();
state.getStateOutputs().put("ValidOutput", null);
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutorTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutorTest.java
index 5d91bd2b3..14cc89ee8 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutorTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/StateMachineExecutorTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -35,9 +35,10 @@ import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.core.engine.ExecutorParameters;
@@ -65,6 +66,7 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test task executor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class StateMachineExecutorTest {
@Mock
private ApexInternalContext internalContextMock;
@@ -89,8 +91,6 @@ public class StateMachineExecutorTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
-
axPolicy.setKey(new AxArtifactKey("Policy:0.0.1"));
AxReferenceKey state0Key = new AxReferenceKey(axPolicy.getKey(), "state0");
@@ -169,16 +169,16 @@ public class StateMachineExecutorTest {
AxStateTaskReference str1 = new AxStateTaskReference(str1Key, AxStateTaskOutputType.LOGIC, sflKey);
state1.getTaskReferences().put(task1Key, str1);
- Mockito.doReturn(new DummyTaskExecutor(true)).when(executorFactoryMock).getTaskExecutor(Mockito.anyObject(),
- Mockito.anyObject(), Mockito.anyObject());
+ Mockito.doReturn(new DummyTaskExecutor(true)).when(executorFactoryMock).getTaskExecutor(Mockito.any(),
+ Mockito.any(), Mockito.any());
dummyTsle = new DummyTaskSelectExecutor(true);
- Mockito.doReturn(dummyTsle).when(executorFactoryMock).getTaskSelectionExecutor(Mockito.anyObject(),
- Mockito.anyObject(), Mockito.anyObject());
+ Mockito.doReturn(dummyTsle).when(executorFactoryMock).getTaskSelectionExecutor(Mockito.any(),
+ Mockito.any(), Mockito.any());
dummySfle = new DummyStateFinalizerExecutor(true);
- Mockito.doReturn(dummySfle).when(executorFactoryMock).getStateFinalizerExecutor(Mockito.anyObject(),
- Mockito.anyObject(), Mockito.anyObject());
+ Mockito.doReturn(dummySfle).when(executorFactoryMock).getStateFinalizerExecutor(Mockito.any(),
+ Mockito.any(), Mockito.any());
}
@After
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java
index 4160a9f19..1c4ffe4fc 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskExecutorTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -36,9 +36,10 @@ import java.util.Properties;
import java.util.TreeMap;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.TaskParameters;
@@ -57,6 +58,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter;
/**
* Test task excutor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class TaskExecutorTest {
@Mock
private AxTask axTaskMock;
@@ -96,7 +98,6 @@ public class TaskExecutorTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
AxArtifactKey task0Key = new AxArtifactKey("Task0:0.0.1");
Mockito.doReturn(task0Key).when(axTaskMock).getKey();
@@ -117,12 +118,9 @@ public class TaskExecutorTest {
AxArtifactKey schemaKey = new AxArtifactKey("Schema:0.0.1");
Mockito.doReturn(schemaKey).when(axInputFieldMock).getSchema();
Mockito.doReturn(schemaKey).when(axOptionalInputFieldMock).getSchema();
- Mockito.doReturn(schemaKey).when(axOutputFieldMock).getSchema();
- Mockito.doReturn(schemaKey).when(axOptionalOutputFieldMock).getSchema();
Mockito.doReturn(schemaKey).when(axMissingOutputFieldMock).getSchema();
Mockito.doReturn(true).when(axOptionalInputFieldMock).getOptional();
- Mockito.doReturn(true).when(axOptionalOutputFieldMock).getOptional();
Mockito.doReturn(false).when(axMissingOutputFieldMock).getOptional();
Mockito.doReturn(taskLogicMock).when(axTaskMock).getTaskLogic();
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java
index 613d1ae01..cf3c59fa9 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/TaskSelectExecutorTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 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,9 +29,10 @@ import java.util.Map;
import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.event.EnEvent;
@@ -45,6 +46,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTaskSelectionLogic;
/**
* Test task executor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class TaskSelectExecutorTest {
@Mock
private AxState axStateMock;
@@ -66,11 +68,9 @@ public class TaskSelectExecutorTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
AxReferenceKey state0Key = new AxReferenceKey("State0Parent:0.0.1:Parent:State0");
Mockito.doReturn(state0Key).when(axStateMock).getKey();
- Mockito.doReturn(state0Key.getId()).when(axStateMock).getId();
Map<AxArtifactKey, AxStateTaskReference> taskReferences = new LinkedHashMap<>();
taskReferences.put(new AxArtifactKey("Task0:0.0.0"), null);
@@ -79,8 +79,6 @@ public class TaskSelectExecutorTest {
Mockito.doReturn(new AxArtifactKey("Task1:0.0.0")).when(axStateMock).getDefaultTask();
Mockito.doReturn(taskSelectionLogicMock).when(axStateMock).getTaskSelectionLogic();
-
- Mockito.doReturn(new AxArtifactKey("Context:0.0.1")).when(internalContextMock).getKey();
}
@Test
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxStateFacadeTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxStateFacadeTest.java
index 68d478877..54013e943 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxStateFacadeTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxStateFacadeTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,9 +28,10 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
@@ -40,6 +42,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTasks;
/**
* Test the state facade.
*/
+@RunWith(MockitoJUnitRunner.class)
public class AxStateFacadeTest {
@Mock
private AxState axStateMock;
@@ -52,8 +55,6 @@ public class AxStateFacadeTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
-
AxReferenceKey stateKey = new AxReferenceKey("StateParent:0.0.1:ParentName:StateName");
Mockito.doReturn(stateKey).when(axStateMock).getKey();
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java
index 9da8ecfad..634b3b35c 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/AxTaskFacadeTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,9 +31,10 @@ import java.util.TreeMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -51,6 +52,7 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* Test the state facade.
*/
+@RunWith(MockitoJUnitRunner.class)
public class AxTaskFacadeTest {
@Mock
private AxTask axTaskMock;
@@ -80,8 +82,6 @@ public class AxTaskFacadeTest {
ModelService.registerModel(AxContextSchemas.class, schemas);
- MockitoAnnotations.initMocks(this);
-
AxArtifactKey task0Key = new AxArtifactKey("Task0:0.0.1");
Mockito.doReturn(task0Key).when(axTaskMock).getKey();
Mockito.doReturn(task0Key.getId()).when(axTaskMock).getId();
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContextTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContextTest.java
index c540f51ad..9c6aa2f07 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContextTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/StateFinalizerExecutionContextTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 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,9 +31,10 @@ import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.executor.StateFinalizerExecutor;
@@ -44,6 +45,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxState;
/**
* Test Task Execution Context.
*/
+@RunWith(MockitoJUnitRunner.class)
public class StateFinalizerExecutionContextTest {
@Mock
private StateFinalizerExecutor stateFinalizerExecutorMock;
@@ -62,7 +64,6 @@ public class StateFinalizerExecutionContextTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Set<AxArtifactKey> contextAlbumReferences = new LinkedHashSet<>();
contextAlbumReferences.add(new AxArtifactKey(("AlbumKey0:0.0.1")));
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContextTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContextTest.java
index 24c504822..7f813cc01 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContextTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskExecutionContextTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,9 +35,10 @@ import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.executor.TaskExecutor;
@@ -49,6 +50,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTaskParameter;
/**
* Test Task Execution Context.
*/
+@RunWith(MockitoJUnitRunner.class)
public class TaskExecutionContextTest {
@Mock
private TaskExecutor taskExecutorMock;
@@ -67,7 +69,6 @@ public class TaskExecutionContextTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Set<AxArtifactKey> contextAlbumReferences = new LinkedHashSet<>();
contextAlbumReferences.add(new AxArtifactKey(("AlbumKey0:0.0.1")));
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContextTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContextTest.java
index 5857e0513..84f4817e0 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContextTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/context/TaskSelectionExecutionContextTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 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,9 +31,10 @@ import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.event.EnEvent;
@@ -45,6 +46,7 @@ import org.onap.policy.apex.model.policymodel.concepts.AxState;
/**
* Test Task Execution Context.
*/
+@RunWith(MockitoJUnitRunner.class)
public class TaskSelectionExecutionContextTest {
@Mock
private TaskSelectExecutor taskSelectExecutorMock;
@@ -66,7 +68,6 @@ public class TaskSelectionExecutionContextTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Set<AxArtifactKey> contextAlbumReferences = new LinkedHashSet<>();
contextAlbumReferences.add(new AxArtifactKey(("AlbumKey0:0.0.1")));
diff --git a/core/src/test/java/org/onap/policy/apex/core/engine/executor/impl/ExceutorFactoryImplTest.java b/core/src/test/java/org/onap/policy/apex/core/engine/executor/impl/ExceutorFactoryImplTest.java
index 5957ff347..c8aa7eb08 100644
--- a/core/src/test/java/org/onap/policy/apex/core/engine/executor/impl/ExceutorFactoryImplTest.java
+++ b/core/src/test/java/org/onap/policy/apex/core/engine/executor/impl/ExceutorFactoryImplTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 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,9 +28,10 @@ import static org.junit.Assert.assertNull;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
@@ -47,6 +48,7 @@ import org.onap.policy.common.parameters.ParameterService;
* Test the executor factory implementation.
*
*/
+@RunWith(MockitoJUnitRunner.class)
public class ExceutorFactoryImplTest {
@Mock
private ApexInternalContext internalContextMock;
@@ -76,7 +78,6 @@ public class ExceutorFactoryImplTest {
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Mockito.doReturn(tslMock).when(stateMock).getTaskSelectionLogic();
Mockito.doReturn("Dummy").when(tslMock).getLogicFlavour();
@@ -163,8 +164,6 @@ public class ExceutorFactoryImplTest {
final ExecutorFactoryImpl factory = new ExecutorFactoryImpl();
- Mockito.doReturn(true).when(stateMock).checkSetTaskSelectionLogic();
-
assertThatThrownBy(() -> factory.getTaskExecutor(null, taskMock, internalContextMock))
.hasMessage("Executor plugin class not defined for \"Dummy\" executor of type "
+ "\"org.onap.policy.apex.core.engine.executor.TaskExecutor\"");