aboutsummaryrefslogtreecommitdiffstats
path: root/applications/common
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/common
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/common')
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java14
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java4
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdBaseTranslatorTest.java6
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java2
4 files changed, 13 insertions, 13 deletions
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java
index fbfde1a4..d3aba91f 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java
@@ -207,12 +207,12 @@ public class XacmlPolicyUtilsTest {
@Test
public void testUncommonConditions() throws IOException {
- File fileTemp = policyFolder.newFile();
+ Path fileTemp = policyFolder.newFile().toPath();
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() ->
- XacmlPolicyUtils.writePolicyFile(fileTemp.toPath(), new String("not a policy"))
+ XacmlPolicyUtils.writePolicyFile(fileTemp, "not a policy")
);
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() ->
- XacmlPolicyUtils.constructUniquePolicyFilename(new String("not a policy"),
+ XacmlPolicyUtils.constructUniquePolicyFilename("not a policy",
policyFolder.getRoot().toPath())
);
}
@@ -313,7 +313,7 @@ public class XacmlPolicyUtilsTest {
// Copy to this folder
//
File copyFolder = policyFolder.newFolder("copy");
- assertThat(copyFolder.exists()).isTrue();
+ assertThat(copyFolder).exists();
//
// Mock up a properties object
//
@@ -332,10 +332,10 @@ public class XacmlPolicyUtilsTest {
File propertiesFile = XacmlPolicyUtils.copyXacmlPropertiesContents(
fileProperties.toAbsolutePath().toString(), mockProperties, myCreator);
- assertThat(propertiesFile.canRead()).isTrue();
+ assertThat(propertiesFile).canRead();
assertThat(Path.of(copyFolder.getAbsolutePath(),
- rootPath.getFileName().toString()).toFile().canRead()).isTrue();
+ rootPath.getFileName().toString()).toFile()).canRead();
assertThat(Path.of(copyFolder.getAbsolutePath(),
- path1.getFileName().toString()).toFile().canRead()).isTrue();
+ path1.getFileName().toString()).toFile()).canRead();
}
}
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java
index cd28bddc..9b489a67 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java
@@ -187,10 +187,10 @@ public class MatchablePolicyTypeTest implements MatchableCallback {
schema.setType("string");
property.setEntrySchema(schema);
MatchablePropertyTypeMap mapValue = new MatchablePropertyTypeMap(property);
- assertThat(mapValue.validate(new String("foo"))).hasSize(0);
+ assertThat(mapValue.validate("foo")).isEmpty();
MatchablePropertyTypeList listValue = new MatchablePropertyTypeList(property);
- assertThat(listValue.validate(new String("foo"))).hasSize(0);
+ assertThat(listValue.validate("foo")).isEmpty();
}
@Test
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 8e692583..b8a1d18a 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
@@ -162,7 +162,7 @@ public class StdBaseTranslatorTest {
assertThat(rule.getObligationExpressions().getObligationExpression().size()).isEqualTo(1);
assertThat(rule.getObligationExpressions().getObligationExpression().get(0)
- .getAttributeAssignmentExpression().size()).isEqualTo(0);
+ .getAttributeAssignmentExpression()).isEmpty();
//
// Should not throw an exception
@@ -184,7 +184,7 @@ public class StdBaseTranslatorTest {
assertNotNull(decision);
assertThat(decision.getPolicies()).isNotNull();
- assertThat(decision.getPolicies().size()).isEqualTo(0);
+ assertThat(decision.getPolicies()).isEmpty();
}
@Test
@@ -218,7 +218,7 @@ public class StdBaseTranslatorTest {
assertNotNull(decision);
assertThat(decision.getPolicies()).isNotNull();
- assertThat(decision.getPolicies().size()).isEqualTo(0);
+ assertThat(decision.getPolicies()).isEmpty();
Obligation badObligation = TestUtilsCommon.createXacmlObligation(
ToscaDictionary.ID_OBLIGATION_REST_BODY.stringValue(),
diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java
index 42c13d9e..9f0e0ac9 100644
--- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java
+++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslatorTest.java
@@ -116,7 +116,7 @@ public class StdCombinedPolicyResultsTranslatorTest {
assertNotNull(decision);
assertThat(decision.getPolicies()).isNotNull();
- assertThat(decision.getPolicies().size()).isEqualTo(1);
+ assertThat(decision.getPolicies()).hasSize(1);
}
@Test