summaryrefslogtreecommitdiffstats
path: root/controlloop/common/rules-test/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/rules-test/src/test')
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java11
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java25
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/HttpClientsTest.java9
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/ListenerTest.java10
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/RulesTest.java13
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/SimulatorsTest.java10
-rw-r--r--controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/TopicsTest.java8
7 files changed, 29 insertions, 57 deletions
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java
index 4a1cef0d9..a2b4d328e 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/BaseTestTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -42,8 +42,9 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.appc.CommonHeader;
import org.onap.policy.appc.Request;
import org.onap.policy.appclcm.AppcLcmBody;
@@ -63,6 +64,7 @@ import org.onap.policy.sdnr.PciMessage;
import org.onap.policy.sdnr.PciRequest;
import org.powermock.reflect.Whitebox;
+@RunWith(MockitoJUnitRunner.class)
public class BaseTestTest {
private static final String POLICY_NAME = "my-policy-name";
@@ -126,11 +128,6 @@ public class BaseTestTest {
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- when(policy.getIdentifier()).thenReturn(policyIdent);
- when(policyIdent.getName()).thenReturn(POLICY_NAME);
-
when(topics.createListener(eq(BaseTest.POLICY_CL_MGT_TOPIC), eq(VirtualControlLoopNotification.class),
any(StandardCoder.class))).thenReturn(policyClMgt);
when(topics.createListener(eq(BaseTest.APPC_LCM_READ_TOPIC), eq(AppcLcmDmaapWrapper.class),
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java
index 0aca1b2b8..82b9ed6cc 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/DroolsRuleTestTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,15 +40,15 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.appc.Request;
import org.onap.policy.appclcm.AppcLcmBody;
import org.onap.policy.appclcm.AppcLcmCommonHeader;
import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
import org.onap.policy.appclcm.AppcLcmInput;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.common.utils.coder.StandardCoderInstantAsMillis;
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.drools.controller.DroolsController;
@@ -58,6 +58,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.sdnr.PciMessage;
import org.powermock.reflect.Whitebox;
+@RunWith(MockitoJUnitRunner.class)
public class DroolsRuleTestTest {
private static final String CONTROLLER_NAME = "my-controller-name";
@@ -128,29 +129,13 @@ public class DroolsRuleTestTest {
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- when(policy.getIdentifier()).thenReturn(policyIdent);
- when(policyIdent.getName()).thenReturn(POLICY_NAME);
-
- when(drools.factCount(CONTROLLER_NAME)).thenReturn(0L);
- when(controller.getDrools()).thenReturn(drools);
-
- when(rules.getControllerName()).thenReturn(CONTROLLER_NAME);
when(rules.getController()).thenReturn(controller);
- when(rules.setupPolicyFromFile(any())).thenAnswer(args -> {
- when(drools.factCount(CONTROLLER_NAME)).thenReturn(2L);
- return policy;
- });
+ when(rules.setupPolicyFromFile(any())).thenReturn(policy);
when(topics.createListener(DroolsRuleTest.POLICY_CL_MGT_TOPIC,
VirtualControlLoopNotification.class, controller)).thenReturn(policyClMgt);
when(topics.createListener(eq(DroolsRuleTest.APPC_LCM_READ_TOPIC), eq(AppcLcmDmaapWrapper.class),
any(StandardCoder.class))).thenReturn(appcLcmRead);
- when(topics.createListener(eq(DroolsRuleTest.APPC_CL_TOPIC), eq(Request.class),
- any(StandardCoderInstantAsMillis.class))).thenReturn(appcClSink);
- when(topics.createListener(eq(DroolsRuleTest.SDNR_CL_TOPIC), eq(PciMessage.class),
- any(StandardCoder.class))).thenReturn(sdnrClSink);
Function<String, Rules> ruleMaker = this::makeRules;
Supplier<HttpClients> httpClientMaker = this::makeHttpClients;
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/HttpClientsTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/HttpClientsTest.java
index 5db835343..dac10df34 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/HttpClientsTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/HttpClientsTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,15 +29,16 @@ import java.util.Properties;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
-import org.onap.policy.controlloop.common.rules.test.HttpClients;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
+@RunWith(MockitoJUnitRunner.class)
public class HttpClientsTest {
private static final String CLIENT_NAME = "MY-CLIENT";
@@ -57,8 +58,6 @@ public class HttpClientsTest {
@Test
public void test() throws HttpClientConfigException {
- MockitoAnnotations.initMocks(this);
-
HttpClientFactoryInstance.getClientFactory().destroy();
HttpClients clients = new HttpClients();
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/ListenerTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/ListenerTest.java
index 07ccc405b..7a7add5a7 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/ListenerTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/ListenerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,16 +37,16 @@ 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.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
-import org.onap.policy.controlloop.common.rules.test.Listener;
-import org.onap.policy.controlloop.common.rules.test.TopicException;
+@RunWith(MockitoJUnitRunner.class)
public class ListenerTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String MY_TOPIC = "my-topic";
@@ -87,8 +87,6 @@ public class ListenerTest {
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
when(mgr.getNoopTopicSink(MY_TOPIC)).thenReturn(sink);
listener = new Listener<>(MY_TOPIC, msg -> msg + MSG_SUFFIX) {
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/RulesTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/RulesTest.java
index 11f7d4103..a4767dfd9 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/RulesTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/RulesTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,6 +46,7 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.kie.api.definition.rule.Rule;
import org.kie.api.event.rule.AfterMatchFiredEvent;
import org.kie.api.event.rule.AgendaEventListener;
@@ -59,7 +60,7 @@ import org.kie.api.event.rule.RuleRuntimeEventListener;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.Match;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.test.log.logback.ExtractAppender;
import org.onap.policy.controlloop.ControlLoopEvent;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
@@ -72,6 +73,7 @@ import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.LoggerFactory;
+@RunWith(MockitoJUnitRunner.class)
public class RulesTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String CONTROLLER_NAME = "rulesTest";
@@ -135,8 +137,6 @@ public class RulesTest {
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
facts = new LinkedList<>();
ruleListeners = new LinkedList<>();
agendaListeners = new LinkedList<>();
@@ -193,11 +193,6 @@ public class RulesTest {
return null;
}).when(kieSession).addEventListener(any(AgendaEventListener.class));
- doAnswer(args -> {
- agendaListeners.remove(args.getArgument(0));
- return null;
- }).when(kieSession).removeEventListener(any(AgendaEventListener.class));
-
rules = new MyRules();
rules.configure(RESOURCE_DIR);
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/SimulatorsTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/SimulatorsTest.java
index 8a87c4f26..3a98c0078 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/SimulatorsTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/SimulatorsTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,13 +30,13 @@ import static org.mockito.Mockito.verify;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.controlloop.common.rules.test.SimulatorException;
-import org.onap.policy.controlloop.common.rules.test.Simulators;
import org.onap.policy.controlloop.common.rules.test.Simulators.SimulatorBuilder;
+@RunWith(MockitoJUnitRunner.class)
public class SimulatorsTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
@@ -54,8 +54,6 @@ public class SimulatorsTest {
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
simulators = new Simulators();
}
diff --git a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/TopicsTest.java b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/TopicsTest.java
index 6ed8c3828..409c3d472 100644
--- a/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/TopicsTest.java
+++ b/controlloop/common/rules-test/src/test/java/org/onap/policy/controlloop/common/rules/test/TopicsTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,8 +37,9 @@ 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.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
@@ -52,6 +53,7 @@ import org.onap.policy.drools.protocol.coders.EventProtocolCoder;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+@RunWith(MockitoJUnitRunner.class)
public class TopicsTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String MY_SOURCE_TOPIC = "my-source-topic";
@@ -104,8 +106,6 @@ public class TopicsTest {
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
policy = new ToscaPolicy();
policy.setName(POLICY_NAME);
policy.setVersion("1.0.0");