aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtilsTest.java17
-rw-r--r--applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java15
-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
-rw-r--r--applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java11
-rw-r--r--applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java8
-rw-r--r--applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java2
-rw-r--r--applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java40
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java13
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java50
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java8
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlJsonMessageBodyHandler.java1
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlXmlMessageBodyHandler.java1
13 files changed, 79 insertions, 95 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..9ff81423 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,13 +207,14 @@ 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")
);
+
+ Path rootPath = policyFolder.getRoot().toPath();
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() ->
- XacmlPolicyUtils.constructUniquePolicyFilename(new String("not a policy"),
- policyFolder.getRoot().toPath())
+ XacmlPolicyUtils.constructUniquePolicyFilename("not a policy", rootPath)
);
}
@@ -313,7 +314,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 +333,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..508b96ea 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
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 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.
@@ -32,7 +33,6 @@ import com.att.research.xacml.api.XACML3;
import com.att.research.xacml.std.IdentifierImpl;
import com.att.research.xacml.util.XACMLPolicyWriter;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -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
@@ -230,12 +230,9 @@ public class MatchablePolicyTypeTest implements MatchableCallback {
//
// Dump it out so we can see what was created
//
- try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
- XACMLPolicyWriter.writePolicyFile(os, policy);
- LOGGER.info("{}", os);
- } catch (IOException e) {
- LOGGER.error("Failed to create byte array stream", e);
- }
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ XACMLPolicyWriter.writePolicyFile(os, policy);
+ LOGGER.info("{}", os);
//
// Sanity check - the example policy should have each possible match type plus
// an extra one for the list and an extra one for the map.
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
diff --git a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java
index bdb8a343..fd6711d4 100644
--- a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java
+++ b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java
@@ -172,7 +172,7 @@ public class MonitoringPdpApplicationTest {
LOGGER.info("Decision {}", decision);
assertThat(decision.getKey()).isNotNull();
- assertThat(decision.getKey().getPolicies()).hasSize(0);
+ assertThat(decision.getKey().getPolicies()).isEmpty();
//
// Test the branch for query params, and we have no policy anyway
//
@@ -181,7 +181,7 @@ public class MonitoringPdpApplicationTest {
LOGGER.info("Decision {}", decision);
assertThat(decision.getKey()).isNotNull();
- assertThat(decision.getKey().getPolicies()).hasSize(0);
+ assertThat(decision.getKey().getPolicies()).isEmpty();
//
// Test the branch for query params, and we have no policy anyway
//
@@ -190,7 +190,7 @@ public class MonitoringPdpApplicationTest {
LOGGER.info("Decision {}", decision);
assertThat(decision.getKey()).isNotNull();
- assertThat(decision.getKey().getPolicies()).hasSize(0);
+ assertThat(decision.getKey().getPolicies()).isEmpty();
}
@SuppressWarnings("unchecked")
@@ -244,8 +244,7 @@ public class MonitoringPdpApplicationTest {
assertThat(decision.getKey()).isNotNull();
assertThat(decision.getKey().getPolicies()).hasSize(1);
jsonPolicy = (Map<String, Object>) decision.getKey().getPolicies().get("onap.scaleout.tca");
- assertThat(jsonPolicy).isNotNull();
- assertThat(jsonPolicy).doesNotContainKey("properties");
+ assertThat(jsonPolicy).isNotNull().doesNotContainKey("properties");
//
// Don't Ask for abbreviated results
//
@@ -290,7 +289,7 @@ public class MonitoringPdpApplicationTest {
LOGGER.info("Decision {}", decision.getKey());
assertThat(decision.getKey()).isNotNull();
- assertThat(decision.getKey().getPolicies()).hasSize(0);
+ assertThat(decision.getKey().getPolicies()).isEmpty();
}
}
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 0077d0b9..85b182cd 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
@@ -176,7 +176,7 @@ public class NamingPdpApplicationTest {
LOGGER.info("Decision {}", decision.getKey());
assertThat(decision.getKey()).isNotNull();
- assertThat(decision.getKey().getPolicies().size()).isEqualTo(0);
+ assertThat(decision.getKey().getPolicies()).isEmpty();
}
@Test
@@ -194,7 +194,7 @@ public class NamingPdpApplicationTest {
// There is no default policy
//
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(0);
+ assertThat(response.getPolicies()).isEmpty();
//
// Ask for VNF
//
@@ -204,7 +204,7 @@ public class NamingPdpApplicationTest {
//
response = makeDecision();
assertThat(response).isNotNull();
- assertThat(response.getPolicies().size()).isEqualTo(1);
+ assertThat(response.getPolicies()).hasSize(1);
//
// Validate it
//
@@ -227,7 +227,7 @@ public class NamingPdpApplicationTest {
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");
diff --git a/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java b/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java
index a11c1b14..f434e80f 100644
--- a/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java
+++ b/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java
@@ -220,7 +220,7 @@ public class NativePdpApplicationTest {
assertThat(response).isNotNull();
Decision decision = response.getResults().iterator().next().getDecision();
assertThat(decision).isNotNull();
- assertThat(decision.toString()).isEqualTo(expected);
+ assertThat(decision).hasToString(expected);
LOGGER.info("Xacml response we received {}", DOMResponse.toString(response));
}
} \ No newline at end of file
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..862f75a6 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
@@ -3,7 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2019-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.
@@ -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
//
@@ -469,17 +468,12 @@ public class OptimizationPdpApplicationTest {
//
// Serialize it into a class
//
- ToscaServiceTemplate serviceTemplate;
- try {
- serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class);
- } catch (CoderException e) {
- throw new XacmlApplicationException("Failed to decode policy from resource file", e);
- }
+ JpaToscaServiceTemplate jtst = new JpaToscaServiceTemplate();
+ ToscaServiceTemplate serviceTemplate = yamlCoder.decode(policyYaml, ToscaServiceTemplate.class);
+ jtst.fromAuthorative(serviceTemplate);
//
// Make sure all the fields are setup properly
//
- JpaToscaServiceTemplate jtst = new JpaToscaServiceTemplate();
- jtst.fromAuthorative(serviceTemplate);
ToscaServiceTemplate completedJtst = jtst.toAuthorative();
//
// Get the policies
@@ -516,7 +510,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");
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java
index a59fee32..52dbff4a 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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,6 +21,7 @@
package org.onap.policy.pdpx.main.parameters;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -185,13 +187,12 @@ public class TestXacmlPdpParameterHandler {
}
@Test
- public void testXacmlPdpInvalidOption() throws PolicyXacmlPdpException {
+ public void testXacmlPdpInvalidOption() {
final String[] xacmlPdpConfigParameters = {"-d"};
final XacmlPdpCommandLineArguments arguments = new XacmlPdpCommandLineArguments();
- try {
- arguments.parse(xacmlPdpConfigParameters);
- } catch (final Exception exp) {
- assertTrue(exp.getMessage().startsWith("invalid command line arguments specified"));
- }
+ assertThatThrownBy(() ->
+ arguments.parse(xacmlPdpConfigParameters)
+ ).isInstanceOf(PolicyXacmlPdpException.class)
+ .hasMessageContaining("invalid command line arguments specified");
}
}
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
index 6d2a6fa9..c9910349 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 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.
@@ -24,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
@@ -158,39 +158,33 @@ public class TestAbbreviateDecisionResults {
* should have been removed from the response.
*/
@Test
- public void testAbbreviateDecisionResult() {
+ public void testAbbreviateDecisionResult() throws HttpClientConfigException {
LOGGER.info("Running testAbbreviateDecisionResult");
- try {
- // Create DecisionRequest
- DecisionRequest request = new DecisionRequest();
- request.setOnapName("DCAE");
- request.setOnapComponent("PolicyHandler");
- request.setOnapInstance("622431a4-9dea-4eae-b443-3b2164639c64");
- request.setAction("configure");
- Map<String, Object> resource = new HashMap<String, Object>();
- resource.put("policy-id", "onap.scaleout.tca");
- request.setResource(resource);
-
- // Query decision API
- DecisionResponse response = getDecision(request);
- LOGGER.info("Decision Response {}", response);
+ // Create DecisionRequest
+ DecisionRequest request = new DecisionRequest();
+ request.setOnapName("DCAE");
+ request.setOnapComponent("PolicyHandler");
+ request.setOnapInstance("622431a4-9dea-4eae-b443-3b2164639c64");
+ request.setAction("configure");
+ Map<String, Object> resource = new HashMap<String, Object>();
+ resource.put("policy-id", "onap.scaleout.tca");
+ request.setResource(resource);
- assertFalse(response.getPolicies().isEmpty());
+ // Query decision API
+ DecisionResponse response = getDecision(request);
+ LOGGER.info("Decision Response {}", response);
- @SuppressWarnings("unchecked")
- Map<String, Object> policy = (Map<String, Object>) response.getPolicies().get("onap.scaleout.tca");
- assertTrue(policy.containsKey("type"));
- assertFalse(policy.containsKey("properties"));
- assertFalse(policy.containsKey("name"));
- assertFalse(policy.containsKey("version"));
- assertTrue(policy.containsKey("metadata"));
+ assertFalse(response.getPolicies().isEmpty());
- } catch (Exception e) {
- LOGGER.error("Exception {}", e);
- fail("testAbbreviateDecisionResult failed due to: " + e.getLocalizedMessage());
- }
+ @SuppressWarnings("unchecked")
+ Map<String, Object> policy = (Map<String, Object>) response.getPolicies().get("onap.scaleout.tca");
+ assertTrue(policy.containsKey("type"));
+ assertFalse(policy.containsKey("properties"));
+ assertFalse(policy.containsKey("name"));
+ assertFalse(policy.containsKey("version"));
+ assertTrue(policy.containsKey("metadata"));
}
private static Main startXacmlPdpService(File params) throws PolicyXacmlPdpException {
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java
index 243c9eab..2a85579c 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java
@@ -95,7 +95,7 @@ public class XacmlPdpApplicationManagerTest {
// We need at least 1 policies
//
assertThat(completedJtst).isNotNull();
- assertThat(completedJtst.getToscaTopologyTemplate().getPolicies().size()).isGreaterThan(0);
+ assertThat(completedJtst.getToscaTopologyTemplate().getPolicies().size()).isPositive();
//
// Copy test directory over of the application directories
//
@@ -141,7 +141,7 @@ public class XacmlPdpApplicationManagerTest {
// Test the basics from the startup
//
assertThat(manager).isNotNull();
- assertThat(manager.getPolicyCount()).isEqualTo(0);
+ assertThat(manager.getPolicyCount()).isZero();
assertThat(manager.getPolicyTypeCount()).isEqualTo(19);
assertThat(manager.getToscaPolicies()).isEmpty();
assertThat(manager.getToscaPolicyIdentifiers()).isEmpty();
@@ -172,11 +172,11 @@ public class XacmlPdpApplicationManagerTest {
final ToscaPolicy policyFinal = policy;
assertThatCode(() -> {
manager.removeUndeployedPolicy(policyFinal);
- assertThat(manager.getPolicyCount()).isEqualTo(0);
+ assertThat(manager.getPolicyCount()).isZero();
manager.loadDeployedPolicy(policyFinal);
assertThat(manager.getPolicyCount()).isEqualTo(1);
manager.removeUndeployedPolicy(policyFinal);
- assertThat(manager.getPolicyCount()).isEqualTo(0);
+ assertThat(manager.getPolicyCount()).isZero();
}).doesNotThrowAnyException();
//
// try loading something unsupported
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlJsonMessageBodyHandler.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlJsonMessageBodyHandler.java
index 0b77650c..1dbbff9d 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlJsonMessageBodyHandler.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlJsonMessageBodyHandler.java
@@ -22,7 +22,6 @@ package org.onap.policy.pdpx.main.rest.serialization;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import com.att.research.xacml.api.Request;
import com.att.research.xacml.api.RequestAttributes;
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlXmlMessageBodyHandler.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlXmlMessageBodyHandler.java
index ba2bd780..f2e4f4f6 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlXmlMessageBodyHandler.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/serialization/TestXacmlXmlMessageBodyHandler.java
@@ -22,7 +22,6 @@ package org.onap.policy.pdpx.main.rest.serialization;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import com.att.research.xacml.api.Request;
import com.att.research.xacml.api.RequestAttributes;