aboutsummaryrefslogtreecommitdiffstats
path: root/applications
diff options
context:
space:
mode:
authorisaac <isaac.adorno@att.com>2022-02-02 17:26:05 -0600
committerisaac <isaac.adorno@att.com>2022-02-08 09:59:22 -0600
commitd8ed7a991d54bd6e53a7c1fedee808ab78dfdf19 (patch)
tree6c6ea957730d55906133976409c3ee741af9f652 /applications
parentc2b84da690d862f084609da8e788d874e6792410 (diff)
Fixing sonar issues in xacml-pdp
Issue-ID: POLICY-3900 Signed-off-by: isaac <isaac.adorno@att.com> Change-Id: I29d22d1c6b690204270d87fff6ce42d9d00cef6a
Diffstat (limited to 'applications')
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java5
-rw-r--r--applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java4
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java18
-rw-r--r--applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java6
-rw-r--r--applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java4
-rw-r--r--applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java4
-rw-r--r--applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java4
7 files changed, 23 insertions, 22 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java
index 4febd212..d6c744cb 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 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.
@@ -27,6 +27,7 @@ import com.att.research.xacml.api.Identifier;
import com.att.research.xacml.api.Obligation;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import java.util.Collections;
import java.util.Map;
import lombok.AccessLevel;
import lombok.Getter;
@@ -103,7 +104,7 @@ public class OnapObligation {
@SuppressWarnings("unchecked")
public Map<String, Object> getPolicyContentAsMap() {
if (this.policyContent == null) {
- return null;
+ return Collections.emptyMap();
}
return gson.fromJson(this.policyContent, Map.class);
}
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
index 5bf9151e..2a4574eb 100644
--- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
+++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 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.
@@ -186,7 +186,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator {
// Sanity check that we got the attributes we care about. NOTE: This translator
// ensures that these are set when convertPolicy is called.
//
- if (! Strings.isNullOrEmpty(policyId) && policyContent != null) {
+ if (! Strings.isNullOrEmpty(policyId) && !policyContent.isEmpty()) {
decisionResponse.getPolicies().put(policyId, policyContent);
} else {
LOGGER.error("Missing obligation policyId {} or policyContent {}", policyId,
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java
index b8a1d18a..6e60fe75 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 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.
@@ -127,7 +127,7 @@ public class StdBaseTranslatorTest {
assertNull(translator.convertRequest(null));
assertThat(translator.generateAnyOfForPolicyType("foo.bar")).isNotNull();
- assertThat(translator.generateAnyOfForPolicyType("foo.bar").getAllOf().size()).isEqualTo(1);
+ assertThat(translator.generateAnyOfForPolicyType("foo.bar").getAllOf()).hasSize(1);
assertThat(translator.generateConditionForPolicyType("foo.bar")).isNotNull();
assertThat(translator.generateConditionForPolicyType("foo.bar").getExpression()).isNotNull();
@@ -139,28 +139,28 @@ public class StdBaseTranslatorTest {
translator.addObligation(policySet, "policy.id", policyJson, 0, "foo.bar");
- assertThat(policySet.getObligationExpressions().getObligationExpression().size()).isEqualTo(1);
+ assertThat(policySet.getObligationExpressions().getObligationExpression()).hasSize(1);
assertThat(policySet.getObligationExpressions().getObligationExpression().get(0)
- .getAttributeAssignmentExpression().size()).isEqualTo(4);
+ .getAttributeAssignmentExpression()).hasSize(4);
PolicyType policy = new PolicyType();
translator.addObligation(policy, null, policyJson, null, null);
- assertThat(policy.getObligationExpressions().getObligationExpression().size()).isEqualTo(1);
+ assertThat(policy.getObligationExpressions().getObligationExpression()).hasSize(1);
assertThat(policy.getObligationExpressions().getObligationExpression().get(0)
- .getAttributeAssignmentExpression().size()).isEqualTo(1);
+ .getAttributeAssignmentExpression()).hasSize(1);
RuleType rule = new RuleType();
translator.addObligation(rule, "policy.id", null, null, "foo.bar");
- assertThat(rule.getObligationExpressions().getObligationExpression().size()).isEqualTo(1);
+ assertThat(rule.getObligationExpressions().getObligationExpression()).hasSize(1);
assertThat(rule.getObligationExpressions().getObligationExpression().get(0)
- .getAttributeAssignmentExpression().size()).isEqualTo(2);
+ .getAttributeAssignmentExpression()).hasSize(2);
rule = new RuleType();
translator.addObligation(rule, null, null, null, null);
- assertThat(rule.getObligationExpressions().getObligationExpression().size()).isEqualTo(1);
+ assertThat(rule.getObligationExpressions().getObligationExpression()).hasSize(1);
assertThat(rule.getObligationExpressions().getObligationExpression().get(0)
.getAttributeAssignmentExpression()).isEmpty();
diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
index 29d9e7f3..5cdb6abf 100644
--- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
+++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -216,14 +216,14 @@ public class GuardPdpApplicationTest {
//
// Decisions
//
- assertThat(service.actionDecisionsSupported().size()).isEqualTo(1);
+ assertThat(service.actionDecisionsSupported()).hasSize(1);
assertThat(service.actionDecisionsSupported()).contains("guard");
//
// Ensure it has the supported policy types and
// can support the correct policy types.
//
assertThat(service.supportedPolicyTypes()).isNotEmpty();
- assertThat(service.supportedPolicyTypes().size()).isEqualTo(5);
+ assertThat(service.supportedPolicyTypes()).hasSize(5);
assertThat(service.canSupportPolicyType(
new ToscaConceptIdentifier("onap.policies.controlloop.guard.common.FrequencyLimiter", "1.0.0")))
.isTrue();
diff --git a/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java b/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java
index a855f3e2..b022bca1 100644
--- a/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java
+++ b/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -142,7 +142,7 @@ public class MatchPdpApplicationTest {
//
// Decisions
//
- assertThat(service.actionDecisionsSupported().size()).isEqualTo(1);
+ assertThat(service.actionDecisionsSupported()).hasSize(1);
assertThat(service.actionDecisionsSupported()).contains("match");
//
// Ensure it has the supported policy types and
diff --git a/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java b/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java
index 0c567e11..aa8fde41 100644
--- a/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java
+++ b/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -148,7 +148,7 @@ public class NamingPdpApplicationTest {
//
// Decisions
//
- assertThat(service.actionDecisionsSupported().size()).isEqualTo(1);
+ assertThat(service.actionDecisionsSupported()).hasSize(1);
assertThat(service.actionDecisionsSupported()).contains("naming");
//
// Ensure it has the supported policy types and
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 9c922941..f9fe8728 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -170,7 +170,7 @@ public class OptimizationPdpApplicationTest {
//
// Does it return the correct decisions
//
- assertThat(service.actionDecisionsSupported().size()).isEqualTo(1);
+ assertThat(service.actionDecisionsSupported()).hasSize(1);
assertThat(service.actionDecisionsSupported()).contains("optimize");
//
// Ensure it has the supported policy types and