summaryrefslogtreecommitdiffstats
path: root/model/engine-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/engine-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/engine-model')
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java29
-rw-r--r--model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java10
2 files changed, 10 insertions, 29 deletions
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
index 6e4fbbf05..f3f2fb602 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
@@ -21,11 +21,11 @@
package org.onap.policy.apex.model.enginemodel.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;
@@ -63,13 +63,8 @@ public class EngineModelTest {
new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats);
model.register();
- try {
- model.setKey(null);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("key may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> model.setKey(null))
+ .hasMessage("key may not be null");
model.setKey(modelKey);
assertEquals("ModelName:0.0.1", model.getKey().getId());
assertEquals("ModelName:0.0.1", model.getKeys().get(0).getId());
@@ -80,13 +75,8 @@ public class EngineModelTest {
model.setTimestamp(-1);
assertTrue(model.getTimeStampString().matches("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}"));
- try {
- model.setState(null);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("state may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> model.setState(null))
+ .hasMessage("state may not be null");
for (final AxEngineState state : AxEngineState.values()) {
model.setState(state);
assertEquals(state, model.getState());
@@ -95,13 +85,8 @@ public class EngineModelTest {
model.setState(AxEngineState.READY);
assertEquals(AxEngineState.READY, model.getState());
- try {
- model.setStats(null);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("stats may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> model.setStats(null))
+ .hasMessage("stats may not be null");
model.setStats(stats);
assertEquals(stats, model.getStats());
diff --git a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
index 9f48d1da5..5cb1bd40e 100644
--- a/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
+++ b/model/engine-model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.apex.model.enginemodel.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;
@@ -49,13 +50,8 @@ public class EngineStatsTest {
final AxReferenceKey statsKey = new AxReferenceKey("EngineKey", "0.0.1", "EngineStats");
final AxEngineStats stats = new AxEngineStats(statsKey);
- try {
- stats.setKey(null);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("key may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> stats.setKey(null))
+ .hasMessage("key may not be null");
stats.setKey(statsKey);
assertEquals("EngineKey:0.0.1:NULL:EngineStats", stats.getKey().getId());
assertEquals("EngineKey:0.0.1:NULL:EngineStats", stats.getKeys().get(0).getId());