summaryrefslogtreecommitdiffstats
path: root/model/policy-model
diff options
context:
space:
mode:
authorwaynedunican <wayne.dunican@est.tech>2020-07-09 13:03:28 +0100
committerwaynedunican <wayne.dunican@est.tech>2020-07-23 11:46:15 +0100
commit1e80f98e25442b4badf570fd6ca652c21e499e28 (patch)
treed180015f37854f69f5365111a3ec81ea8d0c302a /model/policy-model
parentd19067ce13765b7f98bcefb26b1bb469282c6624 (diff)
Remove try/catch blocks with assertj - apex-pdp
Removed try/catch blocks in apex-pdp and replaced with assertj assertions Part III Issue-ID: POLICY-2451 Change-Id: I1e6ede1c256c5bcf7899e1af130add71fdf1381c Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'model/policy-model')
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java29
1 files changed, 7 insertions, 22 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);