summaryrefslogtreecommitdiffstats
path: root/testsuites/integration/integration-uservice-test/src/test
diff options
context:
space:
mode:
authorwaynedunican <wayne.dunican@est.tech>2020-07-07 17:51:42 +0100
committerwaynedunican <wayne.dunican@est.tech>2020-07-17 09:44:03 +0100
commit4752a9ede61f2df4e67ec18f6c53cdcd0c35885f (patch)
tree29374ab930d63747cd9fff119d598184930a056d /testsuites/integration/integration-uservice-test/src/test
parent28eced32d2acdf731f7782e14f37bf2ea8c98019 (diff)
Replace try/catch with assertj - apex-pdp
Replaced try/catch blocks in apex-pdp with assertj assertions. Part II of changes Issue-ID: POLICY-2451 Change-Id: I29823054fbeb6d1a287d1234859aaf2d4609ef6d Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'testsuites/integration/integration-uservice-test/src/test')
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java42
1 files changed, 12 insertions, 30 deletions
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
index 7ba309cc0..fdc60d765 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java
@@ -21,10 +21,10 @@
package org.onap.policy.apex.testsuites.integration.uservice.engine;
+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 static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -159,14 +159,9 @@ public class ApexServiceModelUpdateTest {
*/
@Test
public void testNoModelStart() {
- try {
- service.startAll();
- fail("Engine should not start with no model");
- } catch (final Exception e) {
- e.printStackTrace();
- assertEquals("start()<-Machine-1_process-1_engine-1-0:0.0.0,STOPPED, cannot start engine, "
- + "engine has not been initialized, its model is not loaded", e.getMessage());
- }
+ assertThatThrownBy(service::startAll)
+ .hasMessage("start()<-Machine-1_process-1_engine-1-0:0.0.0,STOPPED, cannot start engine, "
+ + "engine has not been initialized, its model is not loaded");
}
/**
@@ -227,16 +222,10 @@ public class ApexServiceModelUpdateTest {
final AxPolicyModel incoPolicyModel0 = new AxPolicyModel(apexSamplePolicyModel);
incoPolicyModel0.getKey().setName("INCOMPATIBLE");
- try {
- service.updateModel(parameters.getEngineKey(), incoPolicyModel0, false);
- fail("model update should fail on incompatible model without force being true");
- } catch (final Exception e) {
- System.err.println(e.getMessage());
- assertEquals("apex model update failed, supplied model with key \"INCOMPATIBLE:0.0.1\" is not a compatible "
- + "model update from the existing engine model " + "with key \"SamplePolicyModelJAVASCRIPT:0.0.1\"",
- e.getMessage());
- }
-
+ assertThatThrownBy(() -> service.updateModel(parameters.getEngineKey(), incoPolicyModel0, false))
+ .hasMessage("apex model update failed, supplied model with key \"INCOMPATIBLE:0.0.1\" is "
+ + "not a compatible model update from the existing engine model " + "with key "
+ + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"");
// Still on old model
sendEvents();
@@ -244,17 +233,10 @@ public class ApexServiceModelUpdateTest {
final AxPolicyModel incoPolicyModel1 = new AxPolicyModel(apexSamplePolicyModel);
incoPolicyModel1.getKey().setVersion("1.0.1");
- try {
- service.updateModel(parameters.getEngineKey(), incoPolicyModel1, false);
- fail("model update should fail on incompatible model without force being true");
- } catch (final Exception e) {
- System.err.println(e.getMessage());
- e.printStackTrace();
- assertEquals("apex model update failed, supplied model with key \"SamplePolicyModelJAVASCRIPT:1.0.1\" "
- + "is not a compatible model update from the existing engine model with key "
- + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> service.updateModel(parameters.getEngineKey(), incoPolicyModel1, false))
+ .hasMessage("apex model update failed, supplied model with key \"SamplePolicyModelJAVASCRIPT:"
+ + "1.0.1\" is not a compatible model update from the existing engine model with key "
+ + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"");
// Still on old model
sendEvents();