aboutsummaryrefslogtreecommitdiffstats
path: root/applications
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-02-11 18:36:24 -0500
committerJim Hahn <jrh3@att.com>2021-02-11 18:38:49 -0500
commitb860345c386ffbedd1afd6332a5630a9458a5dec (patch)
tree25b74675cc3a13c6011de0c3277b786c2d906e24 /applications
parent91d9acd26c90365e940a3eabd5265bf913b83a1e (diff)
Fix sonars from dependency upgrade
The dependency upgrades in policy-parent caused some new sonars. In particular, initMocks() has been deprecated - replaced with calls to the Mockito Runner. Also removed unnecessary when() calls. Issue-ID: POLICY-2912 Change-Id: If386bd282635067a20045f2626af0cf5be49bc0e Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'applications')
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPipTest.java18
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java8
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequestTest.java8
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequestTest.java8
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPipTest.java8
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java8
6 files changed, 24 insertions, 34 deletions
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPipTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPipTest.java
index badc5f9c..e12a204e 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPipTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPipTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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.
@@ -21,8 +21,6 @@ package org.onap.policy.pdp.xacml.application.common.operationshistory;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import com.att.research.xacml.api.Attribute;
@@ -49,12 +47,14 @@ 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.guard.OperationsHistory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@RunWith(MockitoJUnitRunner.class)
public class CountRecentOperationsPipTest {
private static final Logger LOGGER = LoggerFactory.getLogger(CountRecentOperationsPipTest.class);
@@ -133,8 +133,6 @@ public class CountRecentOperationsPipTest {
*/
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
when(pipRequest.getIssuer()).thenReturn("urn:org:onap:xacml:guard:tw:1:hour");
pipEngine = new MyPip();
@@ -144,16 +142,8 @@ public class CountRecentOperationsPipTest {
properties.load(is);
}
- when(pipFinder.getMatchingAttributes(any(), eq(pipEngine))).thenReturn(resp1, resp2, resp3);
-
responses = new LinkedList<>(Arrays.asList(resp1, resp2, resp3));
attributes = new LinkedList<>(Arrays.asList(ACTOR, RECIPE, TARGET));
-
- when(resp1.getStatus()).thenReturn(okStatus);
- when(resp2.getStatus()).thenReturn(okStatus);
- when(resp3.getStatus()).thenReturn(okStatus);
-
- when(okStatus.isOk()).thenReturn(true);
}
@Test
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java
index dd961d8c..61d923c2 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePipTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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.
@@ -45,13 +45,15 @@ 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.guard.OperationsHistory;
import org.onap.policy.pdp.xacml.application.common.ToscaDictionary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@RunWith(MockitoJUnitRunner.class)
public class GetOperationOutcomePipTest {
private static final Logger LOGGER = LoggerFactory.getLogger(GetOperationOutcomePipTest.class);
private static final String TEST_PROPERTIES = "src/test/resources/test.properties";
@@ -119,8 +121,6 @@ public class GetOperationOutcomePipTest {
*/
@Before
public void setupEngine() throws Exception {
- MockitoAnnotations.initMocks(this);
-
when(pipRequest.getIssuer()).thenReturn("urn:org:onap:xacml:guard:tw:1:hour");
//
// Create instance
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequestTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequestTest.java
index 7d7d0e6b..be7e0cea 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequestTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyRequestTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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.
@@ -32,10 +32,12 @@ import java.util.Map;
import java.util.TreeMap;
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.models.decisions.concepts.DecisionRequest;
+@RunWith(MockitoJUnitRunner.class)
public class StdCombinedPolicyRequestTest {
private static final String ACTION = "my-action";
private static final String ONAP_NAME = "my-name";
@@ -56,8 +58,6 @@ public class StdCombinedPolicyRequestTest {
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
resources = new TreeMap<>();
when(decreq.getResource()).thenReturn(resources);
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequestTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequestTest.java
index f259c207..57ab227a 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequestTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchablePolicyRequestTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 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.
@@ -34,12 +34,14 @@ import java.util.Map;
import java.util.TreeMap;
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.models.decisions.concepts.DecisionRequest;
import org.onap.policy.pdp.xacml.application.common.ToscaDictionary;
import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
+@RunWith(MockitoJUnitRunner.class)
public class StdMatchablePolicyRequestTest {
private static final String ACTION = "my-action";
private static final String ONAP_NAME = "my-name";
@@ -62,8 +64,6 @@ public class StdMatchablePolicyRequestTest {
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
resources = new TreeMap<>();
when(decreq.getResource()).thenReturn(resources);
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPipTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPipTest.java
index a0f85730..82347474 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPipTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdOnapPipTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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.
@@ -48,10 +48,12 @@ import java.util.Iterator;
import java.util.Properties;
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.pdp.xacml.application.common.ToscaDictionary;
+@RunWith(MockitoJUnitRunner.class)
public class StdOnapPipTest {
private static final String EXPECTED_EXCEPTION = "expected exception";
private static final String MY_ID = "my-id";
@@ -81,8 +83,6 @@ public class StdOnapPipTest {
*/
@Before
public void setUp() throws PIPException {
- MockitoAnnotations.initMocks(this);
-
resp = new StdMutablePIPResponse();
when(request.getIssuer()).thenReturn(ISSUER);
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
index 0552ff30..7d5dd664 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-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.
@@ -53,8 +53,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.parameters.RestServerParameters;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
@@ -66,6 +67,7 @@ import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@RunWith(MockitoJUnitRunner.class)
public class StdXacmlApplicationServiceProviderTest {
private static final Logger logger = LoggerFactory.getLogger(StdXacmlApplicationServiceProviderTest.class);
@@ -131,8 +133,6 @@ public class StdXacmlApplicationServiceProviderTest {
*/
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
policy = new ToscaPolicy();
policy.setType(POLICY_TYPE);
policy.setName(POLICY_NAME);