aboutsummaryrefslogtreecommitdiffstats
path: root/model/engine-model
diff options
context:
space:
mode:
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());