summaryrefslogtreecommitdiffstats
path: root/model/context-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/context-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/context-model')
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java12
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java13
2 files changed, 8 insertions, 17 deletions
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
index 0406543fb..74b000ff3 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
@@ -21,11 +21,11 @@
package org.onap.policy.apex.model.contextmodel.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;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -57,13 +57,9 @@ public class ContextAlbumsTest {
assertEquals("NewAlbumName:0.0.1", album.getKeys().get(0).getId());
album.setKey(albumKey);
- try {
- album.setScope("");
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("parameter \"scope\": value \"\", does not match regular expression \"[A-Za-z0-9\\-_]+\"",
- e.getMessage());
- }
+ assertThatThrownBy(() -> album.setScope(""))
+ .hasMessage("parameter \"scope\": value \"\", does not match regular expression "
+ + "\"[A-Za-z0-9\\-_]+\"");
album.setScope("NewAlbumScope");
assertEquals("NewAlbumScope", album.getScope());
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
index e5fc19a20..abe7c008f 100644
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
+++ b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
@@ -21,11 +21,11 @@
package org.onap.policy.apex.model.contextmodel.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;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -51,14 +51,9 @@ public class ContextSchemasTest {
assertEquals("NewSchemaName:0.0.1", schema.getKey().getId());
assertEquals("NewSchemaName:0.0.1", schema.getKeys().get(0).getId());
- try {
- schema.setSchemaFlavour("");
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("parameter \"schemaFlavour\": value \"\", "
- + "does not match regular expression \"[A-Za-z0-9\\-_]+\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> schema.setSchemaFlavour(""))
+ .hasMessage("parameter \"schemaFlavour\": value \"\", "
+ + "does not match regular expression \"[A-Za-z0-9\\-_]+\"");
schema.setSchemaFlavour("NewSchemaFlavour");
assertEquals("NewSchemaFlavour", schema.getSchemaFlavour());