aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@est.tech>2020-02-07 16:27:26 +0000
committera.sreekumar <ajith.sreekumar@est.tech>2020-02-10 16:57:38 +0000
commit93a3e76cef9e3c39ce90b6c68f3d551ee489149b (patch)
tree524391e903a3b4a860d472de43560049c56e2e2b /main/src/test
parentce9d064bf511926f0f187d5b28ff018a492556cf (diff)
Cleanup the sonar issues in PAP
Change-Id: I0eccc6064eb0b49d84370104d1219074ec8bde71 Issue-ID: POLICY-2271 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java6
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java9
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java9
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java17
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java11
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java12
6 files changed, 39 insertions, 25 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java b/main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java
index 9509d03b..4733f91e 100644
--- a/main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/PapConstantsTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,14 +21,15 @@
package org.onap.policy.pap.main;
+import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.powermock.reflect.Whitebox;
public class PapConstantsTest {
@Test
- public void test() throws Exception {
+ public void test() {
// verify that constructor does not throw an exception
- Whitebox.invokeConstructor(PapConstants.class);
+ Assertions.assertThatCode(() -> Whitebox.invokeConstructor(PapConstants.class)).doesNotThrowAnyException();
}
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
index edc70103..3a35370b 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 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,8 +27,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -42,6 +43,7 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.ws.rs.core.Response.Status;
+import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -103,6 +105,7 @@ public class PdpModifyRequestMapTest extends CommonRequestBase {
* @throws Exception if an error occurs
*/
@Before
+ @Override
public void setUp() throws Exception {
super.setUp();
@@ -164,7 +167,7 @@ public class PdpModifyRequestMapTest extends CommonRequestBase {
@Test
public void testAddRequestPdpUpdatePdpStateChange_BothNull() {
// nulls should be ok
- map.addRequest(null, null);
+ Assertions.assertThatCode(() -> map.addRequest(null, null)).doesNotThrowAnyException();
}
@Test
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java
index 4b6c2d9a..efd380ec 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 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,12 +30,13 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.models.pdp.concepts.PdpMessage;
@@ -56,6 +58,7 @@ public class RequestImplTest extends CommonRequestBase {
* @throws Exception if an error occurs
*/
@Before
+ @Override
public void setUp() throws Exception {
super.setUp();
@@ -192,7 +195,7 @@ public class RequestImplTest extends CommonRequestBase {
@Test
public void testStopPublishingBoolean_NotPublishing() {
// should not throw an exception
- req.stopPublishing();
+ Assertions.assertThatCode(() -> req.stopPublishing()).doesNotThrowAnyException();
}
@Test
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java
index ddf24293..fc3bc626 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupCreateOrUpdateProvider.java
@@ -36,6 +36,7 @@ import java.util.Collections;
import java.util.List;
import java.util.TreeMap;
import javax.ws.rs.core.Response.Status;
+import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
@@ -67,8 +68,8 @@ public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
*
* @throws Exception if an error occurs
*/
- @Override
@Before
+ @Override
public void setUp() throws Exception {
super.setUp();
@@ -143,24 +144,24 @@ public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
}
@Test
- public void testValidateGroupOnly_NullState() throws PfModelException {
+ public void testValidateGroupOnly_NullState() {
PdpGroups groups = loadPdpGroups("createGroups.json");
groups.getGroups().get(0).setPdpGroupState(null);
- prov.createOrUpdateGroups(groups);
+ Assertions.assertThatCode(() -> prov.createOrUpdateGroups(groups)).doesNotThrowAnyException();
}
@Test
- public void testValidateGroupOnly_Active() throws PfModelException {
+ public void testValidateGroupOnly_Active() {
PdpGroups groups = loadPdpGroups("createGroups.json");
groups.getGroups().get(0).setPdpGroupState(PdpState.ACTIVE);
- prov.createOrUpdateGroups(groups);
+ Assertions.assertThatCode(() -> prov.createOrUpdateGroups(groups)).doesNotThrowAnyException();
}
@Test
- public void testValidateGroupOnly_Passive() throws PfModelException {
+ public void testValidateGroupOnly_Passive() {
PdpGroups groups = loadPdpGroups("createGroups.json");
groups.getGroups().get(0).setPdpGroupState(PdpState.PASSIVE);
- prov.createOrUpdateGroups(groups);
+ Assertions.assertThatCode(() -> prov.createOrUpdateGroups(groups)).doesNotThrowAnyException();
}
@Test
@@ -212,7 +213,7 @@ public class TestPdpGroupCreateOrUpdateProvider extends ProviderSuper {
assertGroupUpdateOnly(group);
- assertEquals(group.getDescription(), "my description");
+ assertEquals("my description", group.getDescription());
assertEquals(newgrp.toString(), group.toString());
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java
index ae356e83..250b9678 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeleteProvider.java
@@ -3,6 +3,7 @@
* ONAP PAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,8 +26,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -37,6 +38,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response.Status;
+import org.assertj.core.api.Assertions;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
@@ -81,6 +83,7 @@ public class TestPdpGroupDeleteProvider extends ProviderSuper {
* @throws Exception if an error occurs
*/
@Before
+ @Override
public void setUp() throws Exception {
super.setUp();
@@ -155,8 +158,8 @@ public class TestPdpGroupDeleteProvider extends ProviderSuper {
}
@Test
- public void testUndeploy_testUndeployPolicy() throws Exception {
- prov.undeploy(optIdent);
+ public void testUndeploy_testUndeployPolicy() {
+ Assertions.assertThatCode(() -> prov.undeploy(optIdent)).doesNotThrowAnyException();
}
/**
diff --git a/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java
index 2658b36c..1efa9e14 100644
--- a/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java
+++ b/main/src/test/java/org/onap/policy/pap/main/startstop/TestMain.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,6 +23,7 @@ package org.onap.policy.pap.main.startstop;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.After;
@@ -81,26 +82,27 @@ public class TestMain {
public void testMain_NoArguments() {
final String[] papConfigParameters = {};
main = new Main(papConfigParameters);
- assertTrue(main.getParameters() == null);
+ assertNull(main.getParameters());
}
@Test
public void testMain_InvalidArguments() {
final String[] papConfigParameters = {"parameters/PapConfigParameters.json"};
main = new Main(papConfigParameters);
- assertTrue(main.getParameters() == null);
+ assertNull(main.getParameters());
}
@Test
public void testMain_Help() {
final String[] papConfigParameters = {"-h"};
- Main.main(papConfigParameters);
+ main = new Main(papConfigParameters);
+ assertNull(main.getParameters());
}
@Test
public void testMain_InvalidParameters() {
final String[] papConfigParameters = {"-c", "parameters/PapConfigParameters_InvalidName.json"};
main = new Main(papConfigParameters);
- assertTrue(main.getParameters() == null);
+ assertNull(main.getParameters());
}
}