summaryrefslogtreecommitdiffstats
path: root/applications/optimization/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-06-29 14:13:14 -0400
committerJim Hahn <jrh3@att.com>2020-06-29 14:58:33 -0400
commit05506483dff28c491522beeaaea0f6904077e3ed (patch)
tree9146aba8b5f48b693d02ac1846b98e617931bc93 /applications/optimization/src/test
parentf92147f681bac8292021028d88c913ff977dd594 (diff)
Fix issues in xacml-pdp for new sonar rules
Addressed issues reported due to updates to the sonar rules: - invoke only one method in a junit lambda - complete the assertion - use assertThat().exists(), canRead(), etc. Issue-ID: POLICY-2681 Change-Id: I2935f4d0295244ab3b11a57a3bc401c64b695fd1 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'applications/optimization/src/test')
-rw-r--r--applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java
index 8886af21..631a359c 100644
--- a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java
+++ b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java
@@ -208,7 +208,7 @@ public class OptimizationPdpApplicationTest {
LOGGER.info("Decision {}", decision.getKey());
assertThat(decision.getKey()).isNotNull();
- assertThat(decision.getKey().getPolicies().size()).isEqualTo(0);
+ assertThat(decision.getKey().getPolicies()).isEmpty();
}
/**
@@ -223,15 +223,14 @@ public class OptimizationPdpApplicationTest {
//
List<ToscaPolicy> loadedPolicies = TestUtils.loadPolicies("src/test/resources/test-optimization-policies.yaml",
service);
- assertThat(loadedPolicies).isNotNull();
- assertThat(loadedPolicies).hasSize(14);
+ assertThat(loadedPolicies).isNotNull().hasSize(14);
//
// Ask for a decision for available default policies
//
DecisionResponse response = makeDecision();
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(2);
+ assertThat(response.getPolicies()).hasSize(2);
//
// Validate it
//
@@ -255,10 +254,10 @@ public class OptimizationPdpApplicationTest {
DecisionResponse response = makeDecision();
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(1);
+ assertThat(response.getPolicies()).hasSize(1);
response.getPolicies().forEach((key, value) -> {
- assertThat(((Map<String, Object>) value).get("type"))
- .isEqualTo(("onap.policies.optimization.resource.HpaPolicy"));
+ assertThat(((Map<String, Object>) value)).containsEntry("type",
+ "onap.policies.optimization.resource.HpaPolicy");
});
//
// Validate it
@@ -285,7 +284,7 @@ public class OptimizationPdpApplicationTest {
//
DecisionResponse response = makeDecision();
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(2);
+ assertThat(response.getPolicies()).hasSize(2);
//
// Validate it
//
@@ -308,7 +307,7 @@ public class OptimizationPdpApplicationTest {
DecisionResponse response = makeDecision();
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(3);
+ assertThat(response.getPolicies()).hasSize(3);
//
// Validate it
//
@@ -331,7 +330,7 @@ public class OptimizationPdpApplicationTest {
DecisionResponse response = makeDecision();
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(6);
+ assertThat(response.getPolicies()).hasSize(6);
//
// Validate it
//
@@ -405,7 +404,7 @@ public class OptimizationPdpApplicationTest {
DecisionResponse response = makeDecision();
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(7);
+ assertThat(response.getPolicies()).hasSize(7);
//
// Validate it
//
@@ -428,7 +427,7 @@ public class OptimizationPdpApplicationTest {
DecisionResponse response = makeDecision();
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(1);
+ assertThat(response.getPolicies()).hasSize(1);
//
// Validate it
//
@@ -452,7 +451,7 @@ public class OptimizationPdpApplicationTest {
DecisionResponse response = makeDecision();
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(2);
+ assertThat(response.getPolicies()).hasSize(2);
//
// Validate it
//
@@ -516,7 +515,7 @@ public class OptimizationPdpApplicationTest {
LOGGER.info("Decision Returned Policy {}", entrySet.getKey());
assertThat(entrySet.getValue()).isInstanceOf(Map.class);
Map<String, Object> policyContents = (Map<String, Object>) entrySet.getValue();
- assertThat(policyContents.containsKey("properties")).isTrue();
+ assertThat(policyContents).containsKey("properties");
assertThat(policyContents.get("properties")).isInstanceOf(Map.class);
Map<String, Object> policyProperties = (Map<String, Object>) policyContents.get("properties");