Fix issues in pap for new sonar rules 56/109656/2
authorJim Hahn <jrh3@att.com>
Mon, 29 Jun 2020 15:53:42 +0000 (11:53 -0400)
committerJim Hahn <jrh3@att.com>
Mon, 29 Jun 2020 16:41:54 +0000 (12:41 -0400)
Addressed issues reported due to updates to the sonar rules:
- invoke only one method in a junit lambda

Issue-ID: POLICY-2679
Change-Id: I422856527b191a45b30a78bb8520f679ca2e7896
Signed-off-by: Jim Hahn <jrh3@att.com>
main/src/test/java/org/onap/policy/pap/main/comm/PdpTrackerTest.java
main/src/test/java/org/onap/policy/pap/main/rest/TestPdpGroupDeployProvider.java
main/src/test/java/org/onap/policy/pap/main/rest/TestProviderBase.java

index 19684a7..2b1e8f1 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP PAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -115,22 +115,22 @@ public class PdpTrackerTest {
 
     @Test
     public void testPdpTracker_MissingRequestMap() throws Exception {
-        assertThatThrownBy(() -> builder.requestMap(null).build()).isInstanceOf(NullPointerException.class);
+        assertThatThrownBy(() -> builder.requestMap(null)).isInstanceOf(NullPointerException.class);
     }
 
     @Test
     public void testPdpTracker_MissingModifyLock() throws Exception {
-        assertThatThrownBy(() -> builder.modifyLock(null).build()).isInstanceOf(NullPointerException.class);
+        assertThatThrownBy(() -> builder.modifyLock(null)).isInstanceOf(NullPointerException.class);
     }
 
     @Test
     public void testPdpTracker_MissingTimers() throws Exception {
-        assertThatThrownBy(() -> builder.timers(null).build()).isInstanceOf(NullPointerException.class);
+        assertThatThrownBy(() -> builder.timers(null)).isInstanceOf(NullPointerException.class);
     }
 
     @Test
     public void testPdpTracker_MissingDaoFactory() throws Exception {
-        assertThatThrownBy(() -> builder.daoFactory(null).build()).isInstanceOf(NullPointerException.class);
+        assertThatThrownBy(() -> builder.daoFactory(null)).isInstanceOf(NullPointerException.class);
     }
 
     @Test
index daa0504..db320b5 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP PAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -594,7 +594,8 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
         // subgroup has a different version of the Policy
         when(dao.getFilteredPdpGroups(any())).thenReturn(loadGroups("upgradeGroupDao_DiffVers.json"));
 
-        assertThatThrownBy(() -> prov.deployPolicies(loadRequest())).isInstanceOf(PfModelRuntimeException.class)
+        PdpDeployPolicies req = loadRequest();
+        assertThatThrownBy(() -> prov.deployPolicies(req)).isInstanceOf(PfModelRuntimeException.class)
                         .hasMessageContaining("pdpTypeC").hasMessageContaining("different version already deployed");
 
         verify(dao, never()).createPdpGroups(any());
@@ -608,7 +609,8 @@ public class TestPdpGroupDeployProvider extends ProviderSuper {
         // subgroup has no PDPs
         when(dao.getFilteredPdpGroups(any())).thenReturn(loadGroups("upgradeGroup_NoPdpsDao.json"));
 
-        assertThatThrownBy(() -> prov.deployPolicies(loadRequest())).isInstanceOf(PfModelRuntimeException.class)
+        PdpDeployPolicies req = loadRequest();
+        assertThatThrownBy(() -> prov.deployPolicies(req)).isInstanceOf(PfModelRuntimeException.class)
                         .hasMessage("group " + GROUP1_NAME + " subgroup " + PDP1_TYPE + " has no active PDPs");
 
         verify(dao, never()).createPdpGroups(any());
index b6f56ba..818237d 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP PAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 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.
@@ -167,7 +167,8 @@ public class TestProviderBase extends ProviderSuper {
         PfModelException exc = new PfModelException(Status.CONFLICT, EXPECTED_EXCEPTION);
         when(dao.getFilteredPolicyList(any())).thenThrow(exc);
 
-        assertThatThrownBy(() -> prov.process(loadRequest(), this::handle)).isInstanceOf(PfModelRuntimeException.class)
+        ToscaPolicyIdentifierOptVersion req = loadRequest();
+        assertThatThrownBy(() -> prov.process(req, this::handle)).isInstanceOf(PfModelRuntimeException.class)
                         .hasCause(exc);
     }
 
@@ -175,7 +176,8 @@ public class TestProviderBase extends ProviderSuper {
     public void testGetPolicy_NotFound() throws Exception {
         when(dao.getFilteredPolicyList(any())).thenReturn(Collections.emptyList());
 
-        assertThatThrownBy(() -> prov.process(loadRequest(), this::handle)).isInstanceOf(PfModelRuntimeException.class)
+        ToscaPolicyIdentifierOptVersion req = loadRequest();
+        assertThatThrownBy(() -> prov.process(req, this::handle)).isInstanceOf(PfModelRuntimeException.class)
                         .hasMessage("cannot find policy: policyA 1.2.3")
                         .extracting(ex -> ((PfModelRuntimeException) ex).getErrorResponse().getResponseCode())
                         .isEqualTo(Status.NOT_FOUND);