aboutsummaryrefslogtreecommitdiffstats
path: root/model/policy-model
diff options
context:
space:
mode:
Diffstat (limited to 'model/policy-model')
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java29
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java10
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java11
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java25
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java6
5 files changed, 33 insertions, 48 deletions
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java
index 655df059a..7961d8e8e 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.apex.model.policymodel.concepts;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
@@ -103,21 +104,11 @@ public class LogicTest {
result = logic.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- try {
- logic.setLogicFlavour(null);
- fail("test shold throw an exception here");
- } catch (final Exception e) {
- assertEquals("parameter \"logicFlavour\" is null", e.getMessage());
- }
-
- try {
- logic.setLogicFlavour("");
- fail("test shold throw an exception here");
- } catch (final Exception e) {
- assertEquals("parameter \"logicFlavour\": value \"\", "
- + "does not match regular expression \"[A-Za-z0-9\\-_]+\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> logic.setLogicFlavour(null))
+ .hasMessageContaining("parameter \"logicFlavour\" is null");
+ assertThatThrownBy(() -> logic.setLogicFlavour(""))
+ .hasMessage("parameter \"logicFlavour\": value \"\", "
+ + "does not match regular expression \"[A-Za-z0-9\\-_]+\"");
logic.setLogicFlavour(AxLogic.LOGIC_FLAVOUR_UNDEFINED);
result = new AxValidationResult();
result = logic.validate(result);
@@ -128,13 +119,7 @@ public class LogicTest {
result = logic.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- try {
- logic.setLogic(null);
- fail("test shold throw an exception here");
- } catch (final Exception e) {
- assertEquals("logic may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> logic.setLogic(null)).hasMessage("logic may not be null");
logic.setLogic("");
result = new AxValidationResult();
result = logic.validate(result);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
index a521272ae..3192079d7 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. 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.
@@ -21,7 +22,6 @@
package org.onap.policy.apex.model.policymodel.handling;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
@@ -46,19 +46,19 @@ public class ApexPolicyModelTest {
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
- assertTrue(result.toString().equals(VALID_MODEL_STRING));
+ assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test
public void testApexModelVaidateObservation() throws Exception {
final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
- assertTrue(result.toString().equals(OBSERVATION_MODEL_STRING));
+ assertEquals(OBSERVATION_MODEL_STRING, result.toString());
}
@Test
public void testApexModelVaidateWarning() throws Exception {
final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertTrue(result.toString().equals(WARNING_MODEL_STRING));
+ assertEquals(WARNING_MODEL_STRING, result.toString());
}
@Test
@@ -70,7 +70,7 @@ public class ApexPolicyModelTest {
@Test
public void testModelVaidateMalstructured() throws Exception {
final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertTrue(result.toString().equals(INVALID_MODEL_MALSTRUCTURED_STRING));
+ assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
}
@Test
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
index 046f5af22..3ff85c898 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
@@ -1,27 +1,28 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.policymodel.handling;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@@ -34,7 +35,7 @@ public class PolicyAnalyserTest {
final PolicyAnalyser policyAnalyser = new PolicyAnalyser();
final PolicyAnalysisResult analysisResult = policyAnalyser.analyse(apexModel);
- assertTrue(analysisResult.toString().equals(EXPECTED_ANALYSIS_RESULT));
+ assertEquals(EXPECTED_ANALYSIS_RESULT, analysisResult.toString());
assertNotNull(analysisResult.getUsedContextAlbums());
assertNotNull(analysisResult.getUsedContextSchemas());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
index f9514ae5b..f148f7d2a 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.apex.model.policymodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.UUID;
@@ -51,20 +50,20 @@ public class PolicyModelComparerTest {
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, false);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
final AxKeyInfo leftOnlyKeyInfo = new AxKeyInfo(new AxArtifactKey("LeftOnlyKeyInfo", "0.0.1"),
UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f000"), "Left only key info");
@@ -90,20 +89,20 @@ public class PolicyModelComparerTest {
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, false);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
assertNotNull(policyModelComparer.getContextAlbumComparisonResult());
assertNotNull(policyModelComparer.getContextAlbumKeyDifference());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java
index f8fc99dd8..902206d51 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java
@@ -22,8 +22,8 @@
package org.onap.policy.apex.model.policymodel.handling;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.util.Set;
import java.util.TreeSet;
@@ -49,7 +49,7 @@ public class PolicyModelSplitterTest {
// not be in the split model
apexModel.getEvents().getEventMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
apexModel.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
- assertTrue(apexModel.equals(splitApexModel));
+ assertEquals(apexModel, splitApexModel);
final Set<AxArtifactKey> requiredMissingPolicySet = new TreeSet<AxArtifactKey>();
requiredPolicySet.add(new AxArtifactKey("MissingPolicy", "0.0.1"));
@@ -65,7 +65,7 @@ public class PolicyModelSplitterTest {
// not be in the split model
apexModel.getEvents().getEventMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
apexModel.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
- assertTrue(apexModel.equals(splitApexModel));
+ assertEquals(apexModel, splitApexModel);
// There's only one policy so a split of this model on that policy should return the same
// model