aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/BatchDeployerTest.java4
-rw-r--r--core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/EngineServiceFacadeTest.java3
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java33
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java79
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java145
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/DaoMiscTest.java22
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java37
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java69
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java143
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java58
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java141
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java9
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTester.java104
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java33
-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
-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
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java31
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java27
-rw-r--r--model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java22
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java29
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java10
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java11
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java25
-rw-r--r--model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java6
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java14
-rw-r--r--model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java3
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java5
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java12
-rw-r--r--plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java6
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java2
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java7
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java7
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java10
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java5
-rw-r--r--testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java19
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceModelUpdateTest.java6
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java6
39 files changed, 438 insertions, 769 deletions
diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/BatchDeployerTest.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/BatchDeployerTest.java
index ab44f900d..7e17cacdc 100644
--- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/BatchDeployerTest.java
+++ b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/BatchDeployerTest.java
@@ -78,7 +78,7 @@ public class BatchDeployerTest {
assertThatThrownBy(deployer::init).hasMessage("model deployment failed on parameters localhost 12345");
// Wait until the connection to the server closes following the bad connection
// attempt
- Awaitility.await().atLeast(Duration.ofMillis(100));
+ Awaitility.await().atLeast(Duration.ofMillis(500));
// We are testing towards a dummy client, make it return a successful initiation
dummyDeploymentClient.setInitSuccessful(true);
@@ -105,7 +105,7 @@ public class BatchDeployerTest {
.hasMessage("model deployment failed on parameters localhost 12345");
// Wait until the connection to the server closes following the bad connection
// attempt
- Awaitility.await().atLeast(Duration.ofMillis(100));
+ Awaitility.await().atLeast(Duration.ofMillis(500));
dummyDeploymentClient.setInitSuccessful(true);
diff --git a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/EngineServiceFacadeTest.java b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/EngineServiceFacadeTest.java
index 6e0826c3f..1740c7e55 100644
--- a/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/EngineServiceFacadeTest.java
+++ b/core/core-deployment/src/test/java/org/onap/policy/apex/core/deployment/EngineServiceFacadeTest.java
@@ -27,6 +27,8 @@ import static org.junit.Assert.assertNull;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.time.Duration;
+import org.awaitility.Awaitility;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -54,6 +56,7 @@ public class EngineServiceFacadeTest {
.hasMessage("could not deploy apex model, deployer is not initialized");
// Second init should work
+ Awaitility.await().atLeast(Duration.ofMillis(1000));
dummyDeploymentClient.setInitSuccessful(true);
facade.init();
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java
index 37d3a9dd5..44a9de49e 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java
@@ -1,29 +1,30 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.basicmodel.concepts;
+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.assertNull;
-import static org.junit.Assert.fail;
import java.util.NavigableMap;
import java.util.TreeMap;
@@ -41,17 +42,12 @@ public class AxConceptGetterImplTest {
AxConceptGetterImpl<AxArtifactKey> getter = new AxConceptGetterImpl<>(keyMap);
assertNotNull(getter);
-
+
AxArtifactKey keyA = new AxArtifactKey("A", "0.0.1");
assertNull(getter.get(keyA));
-
- try {
- getter.get((String) null);
- fail("test should throw an exception here");
- } catch (Exception getException) {
- assertEquals("conceptKeyName may not be null", getException.getMessage());
- }
+ assertThatThrownBy(() -> getter.get((String) null))
+ .hasMessage("conceptKeyName may not be null");
assertNull(getter.get("W"));
AxArtifactKey keyZ = new AxArtifactKey("Z", "0.0.1");
@@ -69,19 +65,14 @@ public class AxConceptGetterImplTest {
keyMap.remove(keyZ);
assertEquals(keyW002, getter.get("W"));
- try {
- getter.get((String) null, "0.0.1");
- fail("test should throw an exception here");
- } catch (Exception getException) {
- assertEquals("conceptKeyName may not be null", getException.getMessage());
- }
-
+ assertThatThrownBy(() -> getter.get((String) null, "0.0.1"))
+ .hasMessage("conceptKeyName may not be null");
assertEquals(keyW002, getter.get("W", "0.0.2"));
assertEquals(keyW002, getter.get("W", (String) null));
-
+
assertEquals(new TreeSet<AxArtifactKey>(keyMap.values()), getter.getAll(null));
assertEquals(new TreeSet<AxArtifactKey>(keyMap.values()), getter.getAll(null, null));
-
+
assertEquals(keyW001, getter.getAll("W", null).iterator().next());
assertEquals(keyW002, getter.getAll("W", "0.0.2").iterator().next());
assertEquals(0, getter.getAll("A", null).size());
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
index ff12fc5e8..fbbc4a793 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
@@ -21,12 +21,12 @@
package org.onap.policy.apex.model.basicmodel.concepts;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
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 java.lang.reflect.Field;
import org.junit.Test;
@@ -36,15 +36,9 @@ public class AxKeyTest {
@Test
public void testArtifactKey() {
- try {
- new AxArtifactKey("some bad key id");
- fail("This test should throw an exception");
- } catch (IllegalArgumentException e) {
- assertEquals("parameter \"id\": value \"some bad key id\", "
- + "does not match regular expression \"[A-Za-z0-9\\-_\\.]+:[0-9].[0-9].[0-9]\"",
- e.getMessage());
- }
-
+ assertThatThrownBy(() -> new AxArtifactKey("some bad key id"))
+ .hasMessage("parameter \"id\": value \"some bad key id\", "
+ + "does not match regular expression \"[A-Za-z0-9\\-_\\.]+:[0-9].[0-9].[0-9]\"");
AxArtifactKey someKey0 = new AxArtifactKey();
assertEquals(AxArtifactKey.getNullKey(), someKey0);
@@ -109,12 +103,8 @@ public class AxKeyTest {
assertEquals(0, someKey7.compareTo(someKey1));
assertEquals(-12, someKey7.compareTo(someKey0));
- try {
- someKey0.compareTo(null);
- } catch (IllegalArgumentException e) {
- assertEquals("comparison object may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> someKey0.compareTo(null))
+ .hasMessage("comparison object may not be null");
assertEquals(0, someKey0.compareTo(someKey0));
assertEquals(353602977, someKey0.compareTo(new AxReferenceKey()));
@@ -135,40 +125,33 @@ public class AxKeyTest {
@Test
- public void testValidation() {
+ public void testValidation() throws IllegalArgumentException, IllegalAccessException,
+ NoSuchFieldException, SecurityException {
AxArtifactKey testKey = new AxArtifactKey("TheKey", "0.0.1");
assertEquals("TheKey:0.0.1", testKey.getId());
- try {
- Field nameField = testKey.getClass().getDeclaredField("name");
- nameField.setAccessible(true);
- nameField.set(testKey, "Key Name");
- AxValidationResult validationResult = new AxValidationResult();
- testKey.validate(validationResult);
- nameField.set(testKey, "TheKey");
- nameField.setAccessible(false);
- assertEquals(
- "name invalid-parameter name with value Key Name "
- + "does not match regular expression [A-Za-z0-9\\-_\\.]+",
- validationResult.getMessageList().get(0).getMessage());
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
-
- try {
- Field versionField = testKey.getClass().getDeclaredField("version");
- versionField.setAccessible(true);
- versionField.set(testKey, "Key Version");
- AxValidationResult validationResult = new AxValidationResult();
- testKey.validate(validationResult);
- versionField.set(testKey, "0.0.1");
- versionField.setAccessible(false);
- assertEquals(
- "version invalid-parameter version with value Key Version "
- + "does not match regular expression [A-Za-z0-9.]+",
- validationResult.getMessageList().get(0).getMessage());
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
+ Field nameField = testKey.getClass().getDeclaredField("name");
+ nameField.setAccessible(true);
+ nameField.set(testKey, "Key Name");
+ AxValidationResult validationResult = new AxValidationResult();
+ testKey.validate(validationResult);
+ nameField.set(testKey, "TheKey");
+ nameField.setAccessible(false);
+ assertEquals(
+ "name invalid-parameter name with value Key Name "
+ + "does not match regular expression [A-Za-z0-9\\-_\\.]+",
+ validationResult.getMessageList().get(0).getMessage());
+
+ Field versionField = testKey.getClass().getDeclaredField("version");
+ versionField.setAccessible(true);
+ versionField.set(testKey, "Key Version");
+ AxValidationResult validationResultV = new AxValidationResult();
+ testKey.validate(validationResultV);
+ versionField.set(testKey, "0.0.1");
+ versionField.setAccessible(false);
+ assertEquals(
+ "version invalid-parameter version with value Key Version "
+ + "does not match regular expression [A-Za-z0-9.]+",
+ validationResultV.getMessageList().get(0).getMessage());
}
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java
index cca0b61ae..49a14dd3c 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java
@@ -21,12 +21,12 @@
package org.onap.policy.apex.model.basicmodel.concepts;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
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 java.lang.reflect.Field;
import org.junit.Test;
@@ -107,100 +107,71 @@ public class AxReferenceKeyTest {
assertNotNull(testReferenceKey.getKeys());
- try {
- testReferenceKey.equals(null);
- fail("test should throw an exception here");
- } catch (Exception iae) {
- assertEquals("comparison object may not be null", iae.getMessage());
- }
-
- try {
- testReferenceKey.copyTo(null);
- fail("test should throw an exception here");
- } catch (Exception iae) {
- assertEquals("target may not be null", iae.getMessage());
- }
-
- try {
- testReferenceKey.copyTo(new AxArtifactKey("Key", "0.0.1"));
- fail("test should throw an exception here");
- } catch (Exception iae) {
- assertEquals("org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey is not an instance of "
- + "org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey", iae.getMessage());
- }
-
+ assertThatThrownBy(() -> testReferenceKey.equals(null))
+ .hasMessage("comparison object may not be null");
+ assertThatThrownBy(() -> testReferenceKey.copyTo(null))
+ .hasMessage("target may not be null");
+ assertThatThrownBy(() -> testReferenceKey.copyTo(new AxArtifactKey("Key", "0.0.1")))
+ .hasMessage("org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey is not an instance of "
+ + "org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey");
AxReferenceKey targetRefKey = new AxReferenceKey();
assertEquals(testReferenceKey, testReferenceKey.copyTo(targetRefKey));
}
@Test
- public void testValidation() {
+ public void testValidation() throws IllegalArgumentException, IllegalAccessException,
+ NoSuchFieldException, SecurityException {
AxReferenceKey testReferenceKey = new AxReferenceKey();
testReferenceKey.setParentArtifactKey(new AxArtifactKey("PN", "0.0.1"));
assertEquals("PN:0.0.1", testReferenceKey.getParentArtifactKey().getId());
- try {
- Field parentNameField = testReferenceKey.getClass().getDeclaredField("parentKeyName");
- parentNameField.setAccessible(true);
- parentNameField.set(testReferenceKey, "Parent Name");
- AxValidationResult validationResult = new AxValidationResult();
- testReferenceKey.validate(validationResult);
- parentNameField.set(testReferenceKey, "ParentName");
- parentNameField.setAccessible(false);
- assertEquals(
- "parentKeyName invalid-parameter parentKeyName with value Parent Name "
- + "does not match regular expression [A-Za-z0-9\\-_\\.]+",
- validationResult.getMessageList().get(0).getMessage());
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
-
- try {
- Field parentVersionField = testReferenceKey.getClass().getDeclaredField("parentKeyVersion");
- parentVersionField.setAccessible(true);
- parentVersionField.set(testReferenceKey, "Parent Version");
- AxValidationResult validationResult = new AxValidationResult();
- testReferenceKey.validate(validationResult);
- parentVersionField.set(testReferenceKey, "0.0.1");
- parentVersionField.setAccessible(false);
- assertEquals(
- "parentKeyVersion invalid-parameter parentKeyVersion with value Parent Version "
- + "does not match regular expression [A-Za-z0-9.]+",
- validationResult.getMessageList().get(0).getMessage());
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
-
- try {
- Field parentLocalNameField = testReferenceKey.getClass().getDeclaredField("parentLocalName");
- parentLocalNameField.setAccessible(true);
- parentLocalNameField.set(testReferenceKey, "Parent Local Name");
- AxValidationResult validationResult = new AxValidationResult();
- testReferenceKey.validate(validationResult);
- parentLocalNameField.set(testReferenceKey, "ParentLocalName");
- parentLocalNameField.setAccessible(false);
- assertEquals(
- "parentLocalName invalid-parameter parentLocalName with value "
- + "Parent Local Name does not match regular expression [A-Za-z0-9\\-_\\.]+|^$",
- validationResult.getMessageList().get(0).getMessage());
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
-
- try {
- Field localNameField = testReferenceKey.getClass().getDeclaredField("localName");
- localNameField.setAccessible(true);
- localNameField.set(testReferenceKey, "Local Name");
- AxValidationResult validationResult = new AxValidationResult();
- testReferenceKey.validate(validationResult);
- localNameField.set(testReferenceKey, "LocalName");
- localNameField.setAccessible(false);
- assertEquals(
- "localName invalid-parameter localName with value Local Name "
- + "does not match regular expression [A-Za-z0-9\\-_\\.]+|^$",
- validationResult.getMessageList().get(0).getMessage());
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
+ Field parentNameField = testReferenceKey.getClass().getDeclaredField("parentKeyName");
+ parentNameField.setAccessible(true);
+ parentNameField.set(testReferenceKey, "Parent Name");
+ AxValidationResult validationResult = new AxValidationResult();
+ testReferenceKey.validate(validationResult);
+ parentNameField.set(testReferenceKey, "ParentName");
+ parentNameField.setAccessible(false);
+ assertEquals(
+ "parentKeyName invalid-parameter parentKeyName with value Parent Name "
+ + "does not match regular expression [A-Za-z0-9\\-_\\.]+",
+ validationResult.getMessageList().get(0).getMessage());
+
+ Field parentVersionField = testReferenceKey.getClass().getDeclaredField("parentKeyVersion");
+ parentVersionField.setAccessible(true);
+ parentVersionField.set(testReferenceKey, "Parent Version");
+ AxValidationResult validationResultPV = new AxValidationResult();
+ testReferenceKey.validate(validationResultPV);
+ parentVersionField.set(testReferenceKey, "0.0.1");
+ parentVersionField.setAccessible(false);
+ assertEquals(
+ "parentKeyVersion invalid-parameter parentKeyVersion with value Parent Version "
+ + "does not match regular expression [A-Za-z0-9.]+",
+ validationResultPV.getMessageList().get(0).getMessage());
+
+ Field parentLocalNameField = testReferenceKey.getClass().getDeclaredField("parentLocalName");
+ parentLocalNameField.setAccessible(true);
+ parentLocalNameField.set(testReferenceKey, "Parent Local Name");
+ AxValidationResult validationResultPL = new AxValidationResult();
+ testReferenceKey.validate(validationResultPL);
+ parentLocalNameField.set(testReferenceKey, "ParentLocalName");
+ parentLocalNameField.setAccessible(false);
+ assertEquals(
+ "parentLocalName invalid-parameter parentLocalName with value "
+ + "Parent Local Name does not match regular expression [A-Za-z0-9\\-_\\.]+|^$",
+ validationResultPL.getMessageList().get(0).getMessage());
+
+ Field localNameField = testReferenceKey.getClass().getDeclaredField("localName");
+ localNameField.setAccessible(true);
+ localNameField.set(testReferenceKey, "Local Name");
+ AxValidationResult validationResultLN = new AxValidationResult();
+ testReferenceKey.validate(validationResultLN);
+ localNameField.set(testReferenceKey, "LocalName");
+ localNameField.setAccessible(false);
+ assertEquals(
+ "localName invalid-parameter localName with value Local Name "
+ + "does not match regular expression [A-Za-z0-9\\-_\\.]+|^$",
+ validationResultLN.getMessageList().get(0).getMessage());
+
}
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/DaoMiscTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/DaoMiscTest.java
index 2b4cd5c30..6f9bef83d 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/DaoMiscTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/DaoMiscTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +21,9 @@
package org.onap.policy.apex.model.basicmodel.dao;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
import java.util.Properties;
import org.junit.Test;
@@ -47,21 +48,12 @@ public class DaoMiscTest {
final DaoParameters daoParameters = new DaoParameters();
daoParameters.setPluginClass("somewhere.over.the.rainbow");
- try {
- new ApexDaoFactory().createApexDao(daoParameters);
- fail("test shold throw an exception here");
- } catch (final Exception e) {
- assertEquals("Apex DAO class not found for DAO plugin \"somewhere.over.the.rainbow\"", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new ApexDaoFactory().createApexDao(daoParameters))
+ .hasMessage("Apex DAO class not found for DAO plugin \"somewhere.over.the.rainbow\"");
daoParameters.setPluginClass("java.lang.String");
- try {
- new ApexDaoFactory().createApexDao(daoParameters);
- fail("test shold throw an exception here");
- } catch (final Exception e) {
- assertEquals("Specified Apex DAO plugin class \"java.lang.String\" "
- + "does not implement the ApexDao interface", e.getMessage());
- }
+ assertThatThrownBy(() -> new ApexDaoFactory().createApexDao(daoParameters))
+ .hasMessage("Specified Apex DAO plugin class \"java.lang.String\" "
+ + "does not implement the ApexDao interface");
}
@Test
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
index 370a4114f..f9b949701 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java
@@ -21,11 +21,10 @@
package org.onap.policy.apex.model.basicmodel.dao;
+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.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
@@ -51,34 +50,16 @@ public class EntityTest {
apexDao = new ApexDaoFactory().createApexDao(daoParameters);
- try {
- apexDao.init(null);
- fail("Test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("Apex persistence unit parameter not set", e.getMessage());
- }
-
- try {
- apexDao.init(daoParameters);
- fail("Test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("Apex persistence unit parameter not set", e.getMessage());
- }
-
+ assertThatThrownBy(() -> apexDao.init(null))
+ .hasMessage("Apex persistence unit parameter not set");
+ assertThatThrownBy(() -> apexDao.init(daoParameters))
+ .hasMessage("Apex persistence unit parameter not set");
daoParameters.setPluginClass("somewhere.over.the.rainbow");
daoParameters.setPersistenceUnit("Dorothy");
- try {
- apexDao.init(daoParameters);
- fail("Test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("Creation of Apex persistence unit \"Dorothy\" failed", e.getMessage());
- }
- try {
- apexDao.create(new AxArtifactKey());
- fail("Test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("Apex DAO has not been initialized", e.getMessage());
- }
+ assertThatThrownBy(() -> apexDao.init(daoParameters))
+ .hasMessage("Creation of Apex persistence unit \"Dorothy\" failed");
+ assertThatThrownBy(() -> apexDao.create(new AxArtifactKey()))
+ .hasMessage("Apex DAO has not been initialized");
apexDao.close();
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
index d6ff31e50..331e57f47 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
@@ -1,27 +1,28 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.basicmodel.handling;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
@@ -40,27 +41,26 @@ public class ApexModelFileWriterTest {
File tempFile = File.createTempFile("ApexFileWriterTest", "test");
File tempDir = tempFile.getParentFile();
- tempFile.delete();
-
+
File jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/ApexFileWriterTest.json");
File xmlTempFile = new File(tempDir.getAbsolutePath() + "/ccc/ApexFileWriterTest.xml");
-
+
AxModel model = new DummyApexBasicModelCreator().getModel();
modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
modelFileWriter.apexModelWriteXmlFile(model, AxModel.class, xmlTempFile.getAbsolutePath());
-
+
jsonTempFile.delete();
xmlTempFile.delete();
new File(tempDir.getAbsolutePath() + "/aaa").delete();
new File(tempDir.getAbsolutePath() + "/ccc").delete();
-
+
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
xmlTempFile = new File(tempDir.getAbsolutePath() + "/ccc/ddd/ApexFileWriterTest.xml");
-
+
modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
modelFileWriter.apexModelWriteXmlFile(model, AxModel.class, xmlTempFile.getAbsolutePath());
-
+
jsonTempFile.delete();
xmlTempFile.delete();
@@ -68,28 +68,22 @@ public class ApexModelFileWriterTest {
new File(tempDir.getAbsolutePath() + "/aaa").delete();
new File(tempDir.getAbsolutePath() + "/ccc/ddd").delete();
new File(tempDir.getAbsolutePath() + "/ccc").delete();
-
+
File dirA = new File(tempDir.getAbsolutePath() + "/aaa");
//File dirB = new File(tempDir.getAbsolutePath() + "/aaa/bbb");
dirA.createNewFile();
//dirB.createNewFile();
-
+
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.xml");
+ final File jsonTempFile01 = jsonTempFile;
+ assertThatThrownBy(() -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class,
+ jsonTempFile01.getAbsolutePath()))
+ .hasMessageContaining("could not create directory");
- try {
- modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- fail("this test should throw an exception here");
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("could not create directory "));
- }
-
- try {
- modelFileWriter.apexModelWriteXmlFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- fail("this test should throw an exception here");
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("could not create directory "));
- }
+ assertThatThrownBy(() -> modelFileWriter.apexModelWriteXmlFile(model, AxModel.class,
+ jsonTempFile01.getAbsolutePath()))
+ .hasMessageContaining("could not create directory");
dirA.delete();
@@ -97,23 +91,18 @@ public class ApexModelFileWriterTest {
File fileB = new File(tempDir.getAbsolutePath() + "/aaa/bbb");
dirA.mkdir();
fileB.createNewFile();
-
+
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.xml");
- try {
- modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- fail("this test should throw an exception here");
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("error processing file "));
- }
-
- try {
- modelFileWriter.apexModelWriteXmlFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- fail("this test should throw an exception here");
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("error processing file "));
- }
+ File jsonTempFile02 = jsonTempFile;
+ assertThatThrownBy(() -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class,
+ jsonTempFile02.getAbsolutePath()))
+ .hasMessageContaining("error processing file");
+
+ assertThatThrownBy(() -> modelFileWriter.apexModelWriteXmlFile(model, AxModel.class,
+ jsonTempFile02.getAbsolutePath()))
+ .hasMessageContaining("error processing file");
fileB.delete();
dirA.delete();
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
index 7f2f813d8..92f6206bb 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
@@ -1,29 +1,30 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.basicmodel.handling;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -52,144 +53,100 @@ public class ApexModelReaderTest {
public void testModelReader() throws IOException, ApexException {
AxModel model = new DummyApexBasicModelCreator().getModel();
AxModel invalidModel = new DummyApexBasicModelCreator().getInvalidModel();
-
+
ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
modelWriter.setValidateFlag(true);
modelWriter.setJsonOutput(true);
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
modelWriter.write(model, baos);
-
+
ByteArrayOutputStream baosInvalid = new ByteArrayOutputStream();
modelWriter.setValidateFlag(false);
modelWriter.write(invalidModel, baosInvalid);
-
+
ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class, true);
-
+
modelReader.setValidateFlag(true);
assertTrue(modelReader.getValidateFlag());
-
+
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
AxModel readModel = modelReader.read(bais);
assertEquals(model, readModel);
-
+
ByteArrayInputStream baisInvalid = new ByteArrayInputStream(baosInvalid.toByteArray());
- try {
- modelReader.read(baisInvalid);
- fail("test should throw an exceptino here");
- } catch (Exception e) {
- assertTrue(e.getMessage().startsWith("Apex concept validation failed"));
- }
-
+ assertThatThrownBy(() -> modelReader.read(baisInvalid))
+ .hasMessageStartingWith("Apex concept validation failed");
modelReader.setValidateFlag(false);
assertFalse(modelReader.getValidateFlag());
-
+
ByteArrayInputStream bais2 = new ByteArrayInputStream(baos.toByteArray());
AxModel readModel2 = modelReader.read(bais2);
assertEquals(model, readModel2);
-
+
modelWriter.setJsonOutput(false);
-
+
ByteArrayOutputStream baosXml = new ByteArrayOutputStream();
modelWriter.write(model, baosXml);
-
+
ByteArrayInputStream baisXml = new ByteArrayInputStream(baosXml.toByteArray());
AxModel readModelXml = modelReader.read(baisXml);
assertEquals(model, readModelXml);
-
+
String dummyString = "SomeDummyText";
ByteArrayInputStream baisDummy = new ByteArrayInputStream(dummyString.getBytes());
- try {
- modelReader.read(baisDummy);
- fail("test should throw an exception here");
- } catch (Exception e) {
- assertEquals("format of input for Apex concept is neither JSON nor XML", e.getMessage());
- }
-
- try {
- ByteArrayInputStream nullBais = null;
- modelReader.read(nullBais);
- fail("test should throw an exception here");
- } catch (Exception e) {
- assertEquals("concept stream may not be null", e.getMessage());
- }
-
- try {
+ assertThatThrownBy(() -> modelReader.read(baisDummy))
+ .hasMessage("format of input for Apex concept is neither JSON nor XML");
+ ByteArrayInputStream nullBais = null;
+ assertThatThrownBy(() -> modelReader.read(nullBais))
+ .hasMessage("concept stream may not be null");
+
+ assertThatThrownBy(() -> {
FileInputStream fis = new FileInputStream(new File("somewhere/over/the/rainbow"));
modelReader.read(fis);
- fail("test should throw an exception here");
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("rainbow"));
- }
-
- File tempFile = File.createTempFile("Apex", "Dummy");
- try {
- BufferedReader br = new BufferedReader(new FileReader(tempFile));
- br.close();
- modelReader.read(br);
- fail("test should throw an exception here");
- } catch (Exception e) {
- assertEquals("Unable to read Apex concept ", e.getMessage());
- } finally {
- tempFile.delete();
- }
-
+ }).hasMessageContaining("rainbow");
+ final File tempFile = File.createTempFile("Apex", "Dummy");
+ BufferedReader br = new BufferedReader(new FileReader(tempFile));
+ br.close();
+ assertThatThrownBy(() -> modelReader.read(br))
+ .hasMessage("Unable to read Apex concept ");
+ tempFile.delete();
modelReader.setSchema(null);
-
- tempFile = File.createTempFile("Apex", "Dummy");
- try {
- modelReader.setSchema(tempFile.getCanonicalPath());
- fail("test should throw an exception here");
- } catch (Exception e) {
- assertEquals("Unable to load schema", e.getMessage());
- } finally {
- tempFile.delete();
- }
-
+
+ final File tempFileA = File.createTempFile("Apex", "Dummy");
+ assertThatThrownBy(() -> modelReader.setSchema(tempFileA.getCanonicalPath()))
+ .hasMessage("Unable to load schema");
+ tempFile.delete();
modelReader.setSchema("xml/example.xsd");
}
@Test
- public void testSetInputTypeError() throws ApexModelException {
+ public void testSetInputTypeError() throws ApexModelException,
+ NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
MockitoAnnotations.initMocks(this);
ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class, true);
- try {
- Field marshallerField = modelReader.getClass().getDeclaredField("unmarshaller");
- marshallerField.setAccessible(true);
- marshallerField.set(modelReader, unmarshallerMock);
- marshallerField.setAccessible(false);
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
+ Field marshallerField = modelReader.getClass().getDeclaredField("unmarshaller");
+ marshallerField.setAccessible(true);
+ marshallerField.set(modelReader, unmarshallerMock);
+ marshallerField.setAccessible(false);
- try {
+ assertThatThrownBy(() -> {
Mockito.doThrow(new JAXBException("Exception marshalling to JSON")).when(unmarshallerMock)
.unmarshal((StreamSource) Mockito.anyObject(), Mockito.anyObject());
modelReader.read("{Hello}");
- fail("Test should throw an exception here");
- } catch (Exception jaxbe) {
- assertEquals("Unable to unmarshal Apex concept ", jaxbe.getMessage());
- }
-
- try {
+ }).hasMessage("Unable to unmarshal Apex concept ");
+ assertThatThrownBy(() -> {
Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(unmarshallerMock)
.setProperty(Mockito.anyString(), Mockito.anyString());
modelReader.read("{Hello}");
- fail("Test should throw an exception here");
- } catch (Exception jaxbe) {
- assertEquals("JAXB error setting unmarshaller for JSON input", jaxbe.getMessage());
- }
-
- try {
+ }).hasMessage("JAXB error setting unmarshaller for JSON input");
+ assertThatThrownBy(() -> {
Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(unmarshallerMock)
.setProperty(Mockito.anyString(), Mockito.anyString());
modelReader.read("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- fail("Test should throw an exception here");
- } catch (Exception jaxbe) {
- assertEquals("JAXB error setting unmarshaller for XML input", jaxbe.getMessage());
- }
+ }).hasMessage("JAXB error setting unmarshaller for XML input");
}
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
index cad4e05f3..0b8d789ad 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
@@ -1,29 +1,29 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.basicmodel.handling;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.IOException;
import org.junit.Test;
@@ -37,53 +37,33 @@ public class ApexModelStringWriterTest {
public void testModelStringWriter() throws IOException, ApexException {
AxModel basicModel = new DummyApexBasicModelCreator().getModel();
assertNotNull(basicModel);
-
+
AxKeyInfo intKeyInfo = basicModel.getKeyInformation().get("IntegerKIKey");
AxKeyInfo floatKeyInfo = basicModel.getKeyInformation().get("FloatKIKey");
// Ensure marshalling is OK
ApexModelStringWriter<AxKeyInfo> stringWriter = new ApexModelStringWriter<AxKeyInfo>(true);
-
+
assertNotNull(stringWriter.writeJsonString(intKeyInfo, AxKeyInfo.class));
assertNotNull(stringWriter.writeJsonString(floatKeyInfo, AxKeyInfo.class));
-
+
assertNotNull(stringWriter.writeString(intKeyInfo, AxKeyInfo.class, true));
assertNotNull(stringWriter.writeString(floatKeyInfo, AxKeyInfo.class, true));
-
+
assertNotNull(stringWriter.writeString(intKeyInfo, AxKeyInfo.class, false));
assertNotNull(stringWriter.writeString(floatKeyInfo, AxKeyInfo.class, false));
-
+
assertNotNull(stringWriter.writeXmlString(intKeyInfo, AxKeyInfo.class));
assertNotNull(stringWriter.writeXmlString(floatKeyInfo, AxKeyInfo.class));
-
- try {
- stringWriter.writeString(null, AxKeyInfo.class, true);
- fail("test should thrown an exception here");
- } catch (Exception e) {
- assertEquals("concept may not be null", e.getMessage());
- }
-
- try {
- stringWriter.writeString(null, AxKeyInfo.class, false);
- fail("test should thrown an exception here");
- } catch (Exception e) {
- assertEquals("concept may not be null", e.getMessage());
- }
-
- try {
- stringWriter.writeJsonString(null, AxKeyInfo.class);
- fail("test should thrown an exception here");
- } catch (Exception e) {
- assertEquals("error writing JSON string", e.getMessage());
- }
-
- try {
- stringWriter.writeXmlString(null, AxKeyInfo.class);
- fail("test should thrown an exception here");
- } catch (Exception e) {
- assertEquals("error writing XML string", e.getMessage());
- }
-
+
+ assertThatThrownBy(() -> stringWriter.writeString(null, AxKeyInfo.class, true))
+ .hasMessage("concept may not be null");
+ assertThatThrownBy(() -> stringWriter.writeString(null, AxKeyInfo.class, false))
+ .hasMessage("concept may not be null");
+ assertThatThrownBy(() -> stringWriter.writeJsonString(null, AxKeyInfo.class))
+ .hasMessage("error writing JSON string");
+ assertThatThrownBy(() -> stringWriter.writeXmlString(null, AxKeyInfo.class))
+ .hasMessage("error writing XML string");
stringWriter.setValidateFlag(true);
assertTrue(stringWriter.isValidateFlag());
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
index 1b8461c4e..fbbe2467c 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
@@ -1,29 +1,30 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.basicmodel.handling;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -75,126 +76,84 @@ public class ApexModelWriterTest {
modelWriter.setValidateFlag(true);
model.getKeyInformation().getKeyInfoMap().clear();
- try {
- modelWriter.write(model, baos);
- fail("Test should throw an exception here");
- } catch (Exception e) {
- assertEquals("Apex concept xml (BasicModel:0.0.1) validation failed", e.getMessage().substring(0, 53));
- }
+ assertThatThrownBy(() -> modelWriter.write(model, baos))
+ .hasMessageContaining("Apex concept xml (BasicModel:0.0.1) validation failed");
model.getKeyInformation().generateKeyInfo(model);
- try {
- modelWriter.write(null, baos);
- fail("Test should throw an exception here");
- } catch (Exception e) {
- assertEquals("concept may not be null", e.getMessage());
- }
-
- try {
- ByteArrayOutputStream nullBaos = null;
- modelWriter.write(model, nullBaos);
- fail("Test should throw an exception here");
- } catch (Exception e) {
- assertEquals("concept stream may not be null", e.getMessage());
- }
+ assertThatThrownBy(() -> modelWriter.write(null, baos))
+ .hasMessage("concept may not be null");
+
+ ByteArrayOutputStream nullBaos = null;
+ assertThatThrownBy(() -> modelWriter.write(model, nullBaos))
+ .hasMessage("concept stream may not be null");
}
@Test
- public void testSetOutputTypeError() throws ApexModelException {
+ public void testSetOutputTypeError() throws ApexModelException, NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException, PropertyException {
MockitoAnnotations.initMocks(this);
ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
- try {
- Field marshallerField = modelWriter.getClass().getDeclaredField("marshaller");
- marshallerField.setAccessible(true);
- marshallerField.set(modelWriter, marshallerMock);
- marshallerField.setAccessible(false);
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
-
- try {
- Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(marshallerMock)
- .setProperty(Mockito.anyString(), Mockito.anyString());
- modelWriter.setJsonOutput(true);
- fail("Test should throw an exception here");
- } catch (Exception jaxbe) {
- assertEquals("JAXB error setting marshaller for JSON output", jaxbe.getMessage());
- }
-
- try {
- Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(marshallerMock)
- .setProperty(Mockito.anyString(), Mockito.anyString());
- modelWriter.setJsonOutput(false);
- fail("Test should throw an exception here");
- } catch (Exception jaxbe) {
- assertEquals("JAXB error setting marshaller for XML output", jaxbe.getMessage());
- }
+ Field marshallerField = modelWriter.getClass().getDeclaredField("marshaller");
+ marshallerField.setAccessible(true);
+ marshallerField.set(modelWriter, marshallerMock);
+ marshallerField.setAccessible(false);
+ Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(marshallerMock)
+ .setProperty(Mockito.anyString(), Mockito.anyString());
+ assertThatThrownBy(() -> modelWriter.setJsonOutput(true))
+ .hasMessage("JAXB error setting marshaller for JSON output");
+ Mockito.doThrow(new PropertyException("Exception setting JAXB property")).when(marshallerMock)
+ .setProperty(Mockito.anyString(), Mockito.anyString());
+ assertThatThrownBy(() -> modelWriter.setJsonOutput(false))
+ .hasMessage("JAXB error setting marshaller for XML output");
}
@Test
- public void testOutputJsonError() throws ApexModelException {
+ public void testOutputJsonError() throws ApexModelException, NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException, JAXBException {
MockitoAnnotations.initMocks(this);
ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
- try {
- Field marshallerField = modelWriter.getClass().getDeclaredField("marshaller");
- marshallerField.setAccessible(true);
- marshallerField.set(modelWriter, marshallerMock);
- marshallerField.setAccessible(false);
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
+ Field marshallerField = modelWriter.getClass().getDeclaredField("marshaller");
+ marshallerField.setAccessible(true);
+ marshallerField.set(modelWriter, marshallerMock);
+ marshallerField.setAccessible(false);
modelWriter.setValidateFlag(false);
modelWriter.setJsonOutput(true);
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- AxModel model = new DummyApexBasicModelCreator().getModel();
-
- Mockito.doThrow(new JAXBException("Exception marshalling to JSON")).when(marshallerMock)
- .marshal((AxModel) Mockito.anyObject(), (Writer) Mockito.anyObject());
-
- modelWriter.write(model, baos);
- fail("Test should throw an exception here");
- } catch (Exception jaxbe) {
- assertEquals("Unable to marshal Apex concept to JSON", jaxbe.getMessage());
- }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ AxModel model = new DummyApexBasicModelCreator().getModel();
+ Mockito.doThrow(new JAXBException("Exception marshalling to JSON")).when(marshallerMock)
+ .marshal((AxModel) Mockito.anyObject(), (Writer) Mockito.anyObject());
+ assertThatThrownBy(() -> modelWriter.write(model, baos)).hasMessage("Unable to marshal Apex concept to JSON");
}
@Test
- public void testOutputXmlError() throws ApexModelException {
+ public void testOutputXmlError() throws ApexModelException, NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException, JAXBException {
MockitoAnnotations.initMocks(this);
ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
modelWriter.setJsonOutput(false);
- try {
- Field marshallerField = modelWriter.getClass().getDeclaredField("marshaller");
- marshallerField.setAccessible(true);
- marshallerField.set(modelWriter, marshallerMock);
- marshallerField.setAccessible(false);
- } catch (Exception validationException) {
- fail("test should not throw an exception");
- }
+ Field marshallerField = modelWriter.getClass().getDeclaredField("marshaller");
+ marshallerField.setAccessible(true);
+ marshallerField.set(modelWriter, marshallerMock);
+ marshallerField.setAccessible(false);
modelWriter.setValidateFlag(false);
modelWriter.setJsonOutput(false);
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- AxModel model = new DummyApexBasicModelCreator().getModel();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ AxModel model = new DummyApexBasicModelCreator().getModel();
- Mockito.doThrow(new JAXBException("Exception marshalling to JSON")).when(marshallerMock)
- .marshal((AxModel) Mockito.anyObject(), (Document) Mockito.anyObject());
+ Mockito.doThrow(new JAXBException("Exception marshalling to JSON")).when(marshallerMock)
+ .marshal((AxModel) Mockito.anyObject(), (Document) Mockito.anyObject());
- modelWriter.write(model, baos);
- fail("Test should throw an exception here");
- } catch (Exception jaxbe) {
- assertEquals("Unable to marshal Apex concept to XML", jaxbe.getMessage());
- }
+ assertThatThrownBy(() -> modelWriter.write(model, baos))
+ .hasMessage("Unable to marshal Apex concept to XML");
}
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java
index 80e2e15b4..064a107e7 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTester.java
@@ -21,11 +21,11 @@
package org.onap.policy.apex.model.basicmodel.handling;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
@@ -52,11 +52,8 @@ public class SupportApexBasicModelTester {
@Test
public void testApexModelVaidateObservation() throws Exception {
- try {
- testApexModel.testApexModelVaidateObservation();
- } catch (final ApexException e) {
- assertEquals("model should have observations", e.getMessage());
- }
+ assertThatThrownBy(testApexModel::testApexModelVaidateObservation)
+ .hasMessage("model should have observations");
}
@Test
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTester.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTester.java
index 57df96089..2761d86da 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTester.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTester.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +21,7 @@
package org.onap.policy.apex.model.basicmodel.handling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
@@ -37,12 +36,8 @@ public class SupportBasicModelTester {
new DummyApexBasicModelCreator());
testApexModel.testApexModelValid();
- try {
- testApexModel.testApexModelVaidateObservation();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertEquals("model should have observations", e.getMessage());
- }
+ assertThatThrownBy(testApexModel::testApexModelVaidateObservation)
+ .hasMessage("model should have observations");
testApexModel.testApexModelVaidateWarning();
testApexModel.testApexModelVaidateInvalidModel();
testApexModel.testApexModelVaidateMalstructured();
@@ -60,13 +55,8 @@ public class SupportBasicModelTester {
testApexModel1.getModel().getKey().setVersion("0.0.2");
- try {
- testApexModel0.checkModelEquality(testApexModel0.getModel(), testApexModel1.getModel(),
- "Models are not equal");
- fail("test should throw an exception here");
- } catch (ApexException ae) {
- assertEquals("Models are not equal", ae.getMessage());
- }
+ assertThatThrownBy(() -> testApexModel0.checkModelEquality(testApexModel0.getModel(), testApexModel1.getModel(),
+ "Models are not equal")).hasMessage("Models are not equal");
}
@Test
@@ -75,30 +65,14 @@ public class SupportBasicModelTester {
new SupportApexModelCreator0());
testApexModel.testApexModelValid();
- try {
- testApexModel.testApexModelVaidateObservation();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertEquals("model should have observations", e.getMessage());
- }
- try {
- testApexModel.testApexModelVaidateWarning();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertEquals("model should have warnings", e.getMessage());
- }
- try {
- testApexModel.testApexModelVaidateInvalidModel();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertEquals("model should not be valid ***validation of model successful***", e.getMessage());
- }
- try {
- testApexModel.testApexModelVaidateMalstructured();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertEquals("model should not be valid ***validation of model successful***", e.getMessage());
- }
+ assertThatThrownBy(() -> testApexModel.testApexModelVaidateObservation())
+ .hasMessage("model should have observations");
+ assertThatThrownBy(() -> testApexModel.testApexModelVaidateWarning())
+ .hasMessage("model should have warnings");
+ assertThatThrownBy(() -> testApexModel.testApexModelVaidateInvalidModel())
+ .hasMessage("model should not be valid ***validation of model successful***");
+ assertThatThrownBy(() -> testApexModel.testApexModelVaidateMalstructured())
+ .hasMessage("model should not be valid ***validation of model successful***");
}
@Test
@@ -106,24 +80,12 @@ public class SupportBasicModelTester {
final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
new SupportApexModelCreator1());
- try {
- testApexModel.testApexModelValid();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertTrue(e.getMessage().startsWith("model is invalid"));
- }
- try {
- testApexModel.testApexModelVaidateObservation();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertTrue(e.getMessage().startsWith("model is invalid"));
- }
- try {
- testApexModel.testApexModelVaidateWarning();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertTrue(e.getMessage().startsWith("model is invalid"));
- }
+ assertThatThrownBy(() -> testApexModel.testApexModelValid())
+ .hasMessageStartingWith("model is invalid");
+ assertThatThrownBy(() -> testApexModel.testApexModelVaidateObservation())
+ .hasMessageStartingWith("model is invalid");
+ assertThatThrownBy(() -> testApexModel.testApexModelVaidateWarning())
+ .hasMessageStartingWith("model is invalid");
testApexModel.testApexModelVaidateInvalidModel();
testApexModel.testApexModelVaidateMalstructured();
}
@@ -135,12 +97,8 @@ public class SupportBasicModelTester {
testApexModel.testApexModelValid();
testApexModel.testApexModelVaidateObservation();
- try {
- testApexModel.testApexModelVaidateWarning();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertEquals("model should have warnings", e.getMessage());
- }
+ assertThatThrownBy(() -> testApexModel.testApexModelVaidateWarning())
+ .hasMessage("model should have warnings");
}
@Test
@@ -148,18 +106,10 @@ public class SupportBasicModelTester {
final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
new SupportApexModelCreator1());
- try {
- testApexModel.testApexModelWriteReadJson();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertTrue(e.getMessage().startsWith("error processing file"));
- }
-
- try {
- testApexModel.testApexModelWriteReadXml();
- fail("Test should throw an exception");
- } catch (final Exception e) {
- assertTrue(e.getMessage().startsWith("error processing file"));
- }
+ assertThatThrownBy(() -> testApexModel.testApexModelWriteReadJson())
+ .hasMessageStartingWith("error processing file");
+
+ assertThatThrownBy(() -> testApexModel.testApexModelWriteReadXml())
+ .hasMessageStartingWith("error processing file");
}
}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java
index 1ebfb6d71..746e10607 100644
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java
+++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +21,7 @@
package org.onap.policy.apex.model.basicmodel.service;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -36,13 +37,9 @@ public class ModelServiceTest {
ModelService.clear();
assertFalse(ModelService.existsModel(AxKeyInformation.class));
- try {
- ModelService.getModel(AxKeyInformation.class);
- } catch (final Exception e) {
- assertEquals("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
- + "not found in model service", e.getMessage());
- }
-
+ assertThatThrownBy(() -> ModelService.getModel(AxKeyInformation.class))
+ .hasMessage("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
+ + "not found in model service");
ModelService.registerModel(AxKeyInformation.class,
new DummyApexBasicModelCreator().getModel().getKeyInformation());
assertTrue(ModelService.existsModel(AxKeyInformation.class));
@@ -51,13 +48,9 @@ public class ModelServiceTest {
ModelService.deregisterModel(AxKeyInformation.class);
assertFalse(ModelService.existsModel(AxKeyInformation.class));
- try {
- ModelService.getModel(AxKeyInformation.class);
- } catch (final Exception e) {
- assertEquals("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
- + "not found in model service", e.getMessage());
- }
-
+ assertThatThrownBy(() -> ModelService.getModel(AxKeyInformation.class))
+ .hasMessage("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
+ + "not found in model service");
ModelService.registerModel(AxKeyInformation.class,
new DummyApexBasicModelCreator().getModel().getKeyInformation());
assertTrue(ModelService.existsModel(AxKeyInformation.class));
@@ -65,12 +58,8 @@ public class ModelServiceTest {
ModelService.clear();
assertFalse(ModelService.existsModel(AxKeyInformation.class));
- try {
- ModelService.getModel(AxKeyInformation.class);
- } catch (final Exception e) {
- assertEquals("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
- + "not found in model service", e.getMessage());
- }
-
+ assertThatThrownBy(() -> ModelService.getModel(AxKeyInformation.class))
+ .hasMessage("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
+ + "not found in model service");
}
}
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());
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());
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
index e7330ee47..02195e4db 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
@@ -1,4 +1,4 @@
-/*-
+/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
@@ -21,11 +21,10 @@
package org.onap.policy.apex.model.modelapi;
+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 java.io.File;
import java.io.IOException;
@@ -144,24 +143,13 @@ public class ApexModelApiTest {
@Test
public void testApexModelUrl() throws IOException {
- ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
-
+ final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
+ //ApexApiResult result = null;
+ assertThatThrownBy(() -> apexModel.readFromUrl(null))
+ .isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> apexModel.writeToUrl(null, true))
+ .isInstanceOf(IllegalArgumentException.class);
ApexApiResult result = null;
-
- try {
- result = apexModel.readFromUrl(null);
- fail("expecting an IllegalArgumentException");
- } catch (final Exception e) {
- assertTrue(e instanceof IllegalArgumentException);
- }
-
- try {
- result = apexModel.writeToUrl(null, true);
- fail("expecting an IllegalArgumentException");
- } catch (final Exception e) {
- assertTrue(e instanceof IllegalArgumentException);
- }
-
result = apexModel.readFromUrl("zooby/looby");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
@@ -174,9 +162,10 @@ public class ApexModelApiTest {
result = apexModel.writeToUrl("zooby://zooby/looby", false);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- apexModel = new ApexModelFactory().createApexModel(null, false);
+ final ApexModel apexModelJSon = new ApexModelFactory().createApexModel(null, false);
final File tempJsonModelFile = File.createTempFile("ApexModelTest", ".json");
+
result = apexModel.saveToFile(tempJsonModelFile.getCanonicalPath(), false);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
index ac8f26095..a5f258e4c 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
@@ -1,28 +1,29 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.modelapi;
+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.fail;
import java.util.Properties;
import java.util.UUID;
@@ -33,22 +34,12 @@ public class ModelFacadeTest {
@Test
public void testModelFacade() {
- try {
- new ModelFacade(null, null, false);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("apexModel may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new ModelFacade(null, null, false))
+ .hasMessage("apexModel may not be null");
final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
- try {
- new ModelFacade(apexModel, null, false);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("apexProperties may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new ModelFacade(apexModel, null, false))
+ .hasMessage("apexProperties may not be null");
final Properties modelProperties = new Properties();
final ModelFacade mf = new ModelFacade(apexModel, modelProperties, false);
diff --git a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
index a34b4f474..4a1c3276c 100644
--- a/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
+++ b/model/model-api/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
@@ -21,9 +21,9 @@
package org.onap.policy.apex.model.modelapi;
+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.fail;
import java.io.File;
import java.io.IOException;
@@ -35,29 +35,19 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
/**
* Test the model handler facade.
- *
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class ModelHandlerFacadeTest {
@Test
public void testModelHandlerFacade() throws IOException {
- try {
- new ModelHandlerFacade(null, null, false);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("apexModel may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new ModelHandlerFacade(null, null, false))
+ .hasMessage("apexModel may not be null");
final ApexModel apexModel = new ApexModelFactory().createApexModel(null, false);
- try {
- new ModelHandlerFacade(apexModel, null, false);
- fail("test should throw an exception here");
- } catch (final Exception e) {
- assertEquals("apexProperties may not be null", e.getMessage());
- }
-
+ assertThatThrownBy(() -> new ModelHandlerFacade(apexModel, null, false))
+ .hasMessage("apexProperties may not be null");
final Properties modelProperties = new Properties();
final ModelHandlerFacade mhf = new ModelHandlerFacade(apexModel, modelProperties, false);
assertNotNull(mhf);
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);
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
index a521272ae..3192079d7 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,6 @@
package org.onap.policy.apex.model.policymodel.handling;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
@@ -46,19 +46,19 @@ public class ApexPolicyModelTest {
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
- assertTrue(result.toString().equals(VALID_MODEL_STRING));
+ assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test
public void testApexModelVaidateObservation() throws Exception {
final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
- assertTrue(result.toString().equals(OBSERVATION_MODEL_STRING));
+ assertEquals(OBSERVATION_MODEL_STRING, result.toString());
}
@Test
public void testApexModelVaidateWarning() throws Exception {
final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertTrue(result.toString().equals(WARNING_MODEL_STRING));
+ assertEquals(WARNING_MODEL_STRING, result.toString());
}
@Test
@@ -70,7 +70,7 @@ public class ApexPolicyModelTest {
@Test
public void testModelVaidateMalstructured() throws Exception {
final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertTrue(result.toString().equals(INVALID_MODEL_MALSTRUCTURED_STRING));
+ assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
}
@Test
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
index 046f5af22..3ff85c898 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
@@ -1,27 +1,28 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.model.policymodel.handling;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@@ -34,7 +35,7 @@ public class PolicyAnalyserTest {
final PolicyAnalyser policyAnalyser = new PolicyAnalyser();
final PolicyAnalysisResult analysisResult = policyAnalyser.analyse(apexModel);
- assertTrue(analysisResult.toString().equals(EXPECTED_ANALYSIS_RESULT));
+ assertEquals(EXPECTED_ANALYSIS_RESULT, analysisResult.toString());
assertNotNull(analysisResult.getUsedContextAlbums());
assertNotNull(analysisResult.getUsedContextSchemas());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
index f9514ae5b..f148f7d2a 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.apex.model.policymodel.handling;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.UUID;
@@ -51,20 +50,20 @@ public class PolicyModelComparerTest {
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalVerboseKeys.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, false);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonIdenticalTerse.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
final AxKeyInfo leftOnlyKeyInfo = new AxKeyInfo(new AxArtifactKey("LeftOnlyKeyInfo", "0.0.1"),
UUID.fromString("ce9168c-e6df-414f-9646-6da464b6f000"), "Left only key info");
@@ -90,20 +89,20 @@ public class PolicyModelComparerTest {
resultString = policyModelComparer.asString(false, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentVerboseKeys.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, false);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseValues.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
resultString = policyModelComparer.asString(true, true);
checkString = TextFileUtils
.getTextFileAsString("src/test/resources/checkFiles/PolicyModelComparisonDifferentTerseKeys.txt");
- assertTrue(resultString.trim().replaceAll("[\\r?\\n]+", " ")
- .equals(checkString.trim().replaceAll("[\\r?\\n]+", " ")));
+ assertEquals(checkString.trim().replaceAll("[\\r?\\n]+", " "),
+ resultString.trim().replaceAll("[\\r?\\n]+", " "));
assertNotNull(policyModelComparer.getContextAlbumComparisonResult());
assertNotNull(policyModelComparer.getContextAlbumKeyDifference());
diff --git a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java
index f8fc99dd8..902206d51 100644
--- a/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java
+++ b/model/policy-model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java
@@ -22,8 +22,8 @@
package org.onap.policy.apex.model.policymodel.handling;
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 java.util.Set;
import java.util.TreeSet;
@@ -49,7 +49,7 @@ public class PolicyModelSplitterTest {
// not be in the split model
apexModel.getEvents().getEventMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
apexModel.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
- assertTrue(apexModel.equals(splitApexModel));
+ assertEquals(apexModel, splitApexModel);
final Set<AxArtifactKey> requiredMissingPolicySet = new TreeSet<AxArtifactKey>();
requiredPolicySet.add(new AxArtifactKey("MissingPolicy", "0.0.1"));
@@ -65,7 +65,7 @@ public class PolicyModelSplitterTest {
// not be in the split model
apexModel.getEvents().getEventMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
apexModel.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("outEvent1", "0.0.1"));
- assertTrue(apexModel.equals(splitApexModel));
+ assertEquals(apexModel, splitApexModel);
// There's only one policy so a split of this model on that policy should return the same
// model
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java
index 4cf91bd39..20780b271 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java
@@ -21,8 +21,8 @@
package org.onap.policy.apex.model.utilities;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.onap.policy.apex.model.utilities.comparison.KeyComparer;
@@ -40,14 +40,14 @@ public class KeyComparerTest {
KeyDifference<String> keyDifference = new KeyComparer<String>().compareKeys("Hello", "Goodbye");
assertFalse(keyDifference.isEqual());
- assertTrue("Hello".equals(keyDifference.getLeftKey().toString()));
- assertTrue("Goodbye".equals(keyDifference.getRightKey().toString()));
+ assertEquals("Hello", keyDifference.getLeftKey().toString());
+ assertEquals("Goodbye", keyDifference.getRightKey().toString());
- assertTrue("left key Hello and right key Goodbye differ\n".equals(keyDifference.asString(true)));
- assertTrue("left key Hello and right key Goodbye differ\n".equals(keyDifference.asString(false)));
+ assertEquals("left key Hello and right key Goodbye differ\n", keyDifference.asString(true));
+ assertEquals("left key Hello and right key Goodbye differ\n", keyDifference.asString(false));
KeyDifference<String> keyDifference2 = new KeyComparer<String>().compareKeys("Here", "Here");
- assertTrue("".equals(keyDifference2.asString(true)));
- assertTrue("left key Here equals right key Here\n".equals(keyDifference2.asString(false)));
+ assertEquals("", keyDifference2.asString(true));
+ assertEquals("left key Here equals right key Here\n", keyDifference2.asString(false));
}
}
diff --git a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java
index fb993b10f..b4e88e20d 100644
--- a/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java
+++ b/model/utilities/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.apex.model.utilities;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import java.util.TreeMap;
import org.junit.Test;
@@ -58,7 +57,7 @@ public class KeyedMapComparerTest {
KeyedMapDifference<String, String> kmComparedDiff =
new KeyedMapComparer<String, String>().compareMaps(leftMap, rightMap);
- assertTrue(kmComparedSame.getIdenticalValues().equals(leftMap));
+ assertEquals(leftMap, kmComparedSame.getIdenticalValues());
assertEquals(1, kmComparedDiff.getLeftOnly().size());
assertEquals(3, kmComparedDiff.getRightOnly().size());
assertEquals(2, kmComparedDiff.getDifferentValues().size());
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java
index 48fce1bee..bd4103f92 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-grpc/src/test/java/org/onap/policy/apex/plugins/event/carrier/grpc/ApexGrpcConsumerTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.apex.plugins.event.carrier.grpc;
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 org.assertj.core.api.Assertions;
import org.junit.Before;
@@ -80,8 +79,8 @@ public class ApexGrpcConsumerTest {
grpcConsumer.init(CONSUMER_NAME, consumerParameters, incomingEventReceiver);
PeeredReference peeredReference = grpcConsumer.getPeeredReference(EventHandlerPeeredMode.REQUESTOR);
assertNotNull(peeredReference);
- assertTrue(peeredReference.getPeeredConsumer().equals(grpcConsumer));
- assertTrue(peeredReference.getPeeredProducer().equals(grpcProducer));
+ assertEquals(grpcConsumer, peeredReference.getPeeredConsumer());
+ assertEquals(grpcProducer, peeredReference.getPeeredProducer());
}
private EventHandlerParameters populateConsumerParameters(boolean isConsumer, boolean isPeeredMode) {
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
index 28c198cd8..caa3bd06f 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-xml/src/test/java/org/onap/policy/apex/plugins/event/protocol/xml/XmlEventHandlerTest.java
@@ -21,7 +21,9 @@
package org.onap.policy.apex.plugins.event.protocol.xml;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Date;
@@ -62,14 +64,14 @@ public class XmlEventHandlerTest {
logger.debug(apexEvent.toString());
assertTrue(apexEvent.getName().equals("Event0000") || apexEvent.getName().equals("Event0100"));
- assertTrue(apexEvent.getVersion().equals("0.0.1"));
- assertTrue(apexEvent.getNameSpace().equals("org.onap.policy.apex.sample.events"));
- assertTrue(apexEvent.getSource().equals("test"));
- assertTrue(apexEvent.getTarget().equals("apex"));
+ assertEquals("0.0.1", apexEvent.getVersion());
+ assertEquals("org.onap.policy.apex.sample.events", apexEvent.getNameSpace());
+ assertEquals("test", apexEvent.getSource());
+ assertEquals("apex", apexEvent.getTarget());
assertTrue(apexEvent.get("TestSlogan").toString().startsWith("Test slogan for External Event"));
final Object testMatchCaseSelected = apexEvent.get("TestMatchCaseSelected");
- assertTrue(testMatchCaseSelected == null);
+ assertNull(testMatchCaseSelected);
}
} catch (final Exception e) {
e.printStackTrace();
diff --git a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java
index 5098e9301..4f3c68b0f 100644
--- a/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java
+++ b/plugins/plugins-persistence/plugins-persistence-jpa/plugins-persistence-jpa-eclipselink/src/test/java/org/onap/policy/apex/plugins/persistence/jpa/eclipselink/EclipselinkApexDaoTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +24,6 @@ package org.onap.policy.apex.plugins.persistence.jpa.eclipselink;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Collections;
@@ -85,7 +85,7 @@ public class EclipselinkApexDaoTest {
assertNull(eclipselinkApexDao.getArtifact(ReferenceKeyTestEntity.class, nullRefernceKey));
assertNotNull(eclipselinkApexDao.getAll(null));
- assertTrue(eclipselinkApexDao.getAll(null).equals(emptyList));
+ assertEquals(emptyList, eclipselinkApexDao.getAll(null));
assertNotNull(eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class));
}
@@ -233,7 +233,7 @@ public class EclipselinkApexDaoTest {
// test with null class with known key --> return an empty list
assertNotNull(eclipselinkApexDao.getAll(null, artiKey1));
- assertTrue(eclipselinkApexDao.getAll(null, artiKey1).equals(Collections.emptyList()));
+ assertEquals(Collections.emptyList(), eclipselinkApexDao.getAll(null, artiKey1));
// test with (not_null) ArtifactKeyTestEntity class
assertEquals(0, eclipselinkApexDao.getAll(ReferenceKeyTestEntity.class, artiKey0).size());
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java
index 0a34b1164..731baf5ef 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexMainTest.java
@@ -166,7 +166,7 @@ public class ApexMainTest {
apexMain.shutdown();
final String outString = outContent.toString();
assertTrue(outString.contains("I/O Parameters for id2:v2 has duplicates. So this policy is not executed"));
- assertTrue(apexMain.getApexParametersMap().size() == 1); // only id1:v1 is kept in the map, id2:v2 failed
+ assertEquals(1, apexMain.getApexParametersMap().size()); // only id1:v1 is kept in the map, id2:v2 failed
}
@Test
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
index 43d36f84d..927c1c3f3 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
@@ -22,6 +22,7 @@ package org.onap.policy.apex.services.onappf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.After;
@@ -81,14 +82,14 @@ public class TestApexStarterMain {
public void testApexStarter_NoArguments() {
final String[] apexStarterConfigParameters = {};
apexStarter = new ApexStarterMain(apexStarterConfigParameters);
- assertTrue(apexStarter.getParameters() == null);
+ assertNull(apexStarter.getParameters());
}
@Test
public void testApexStarter_InvalidArguments() {
final String[] apexStarterConfigParameters = { "src/test/resources/ApexStarterConfigParameters.json" };
apexStarter = new ApexStarterMain(apexStarterConfigParameters);
- assertTrue(apexStarter.getParameters() == null);
+ assertNull(apexStarter.getParameters());
}
@Test
@@ -102,6 +103,6 @@ public class TestApexStarterMain {
final String[] apexStarterConfigParameters =
{ "-c", "src/test/resources/ApexStarterConfigParameters_InvalidName.json" };
apexStarter = new ApexStarterMain(apexStarterConfigParameters);
- assertTrue(apexStarter.getParameters() == null);
+ assertNull(apexStarter.getParameters());
}
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java
index bf883d761..ba4b225d2 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/event/TestEventInstantiation.java
@@ -25,7 +25,6 @@ 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.assertNull;
-import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Date;
@@ -194,11 +193,11 @@ public class TestEventInstantiation {
final double temp2 = (double) event.get("TestTemperature");
assertNotNull(temp2);
- assertTrue(temp2 == 123.456789);
+ assertEquals(123.456789, temp2, 0);
final Double temp3 = (Double) event.get("TestTemperature");
assertNotNull(temp3);
- assertTrue(temp3 == 123.456789);
+ assertEquals(123.456789, temp3, 0);
final Date aDate = new Date(1433453067123L);
final Map<String, Object> eventDataList = new HashMap<String, Object>();
@@ -223,7 +222,7 @@ public class TestEventInstantiation {
final double temp4 = (double) event.get("TestTemperature");
assertNotNull(temp4);
- assertTrue(temp4 == 34.5445667);
+ assertEquals(34.5445667, temp4, 0);
logger.debug(event.toString());
}
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java
index aaf640bb4..dc5c06f85 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexModelExport.java
@@ -21,9 +21,9 @@
package org.onap.policy.apex.testsuites.integration.executor.handling;
-import static org.junit.Assert.assertFalse;
+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 java.util.ArrayList;
import java.util.List;
@@ -89,13 +89,13 @@ public class TestApexModelExport {
model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem00B", "0.0.1"));
model.getKeyInformation().getKeyInfoMap().remove(new AxArtifactKey("TestContextItem00C", "0.0.1"));
- assertTrue(model.equals(exportedModel0));
+ assertEquals(model, exportedModel0);
exportPolicyList.remove(0);
final AxPolicyModel exportedModel1 = PolicyModelSplitter.getSubPolicyModel(model, exportPolicyList);
- assertFalse(model.equals(exportedModel1));
- assertTrue(model.getPolicies().get("Policy1").equals(exportedModel1.getPolicies().get("Policy1")));
+ assertNotEquals(model, exportedModel1);
+ assertEquals(model.getPolicies().get("Policy1"), exportedModel1.getPolicies().get("Policy1"));
exportPolicyList.clear();
exportPolicyList.add(new AxArtifactKey("NonExistentPolicy", "0.0.1"));
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java
index 3f38a10dd..0561162c8 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestApexSamplePolicyModel.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +21,7 @@
package org.onap.policy.apex.testsuites.integration.executor.handling;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -58,7 +59,7 @@ public class TestApexSamplePolicyModel {
@Test
public void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
- assertTrue(result.toString().equals(VALID_MODEL_STRING));
+ assertEquals(VALID_MODEL_STRING, result.toString());
}
/**
diff --git a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java
index d2e35ecb2..0a4b9a7d5 100644
--- a/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java
+++ b/testsuites/integration/integration-executor-test/src/test/java/org/onap/policy/apex/testsuites/integration/executor/handling/TestContextUpdateDifferentModels.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ package org.onap.policy.apex.testsuites.integration.executor.handling;
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 java.io.IOException;
import org.junit.After;
@@ -67,12 +66,12 @@ public class TestContextUpdateDifferentModels {
@Before
public void beforeTest() {
schemaParameters = new SchemaParameters();
-
+
schemaParameters.setName(ContextParameterConstants.SCHEMA_GROUP_NAME);
schemaParameters.getSchemaHelperParameterMap().put("JAVA", new JavaSchemaHelperParameters());
ParameterService.register(schemaParameters);
-
+
contextParameters = new ContextParameters();
contextParameters.setName(ContextParameterConstants.MAIN_GROUP_NAME);
@@ -84,7 +83,7 @@ public class TestContextUpdateDifferentModels {
ParameterService.register(contextParameters.getDistributorParameters());
ParameterService.register(contextParameters.getLockManagerParameters());
ParameterService.register(contextParameters.getPersistorParameters());
-
+
engineParameters = new EngineParameters();
engineParameters.getExecutorParameterMap().put("MVEL", new MvelExecutorParameters());
ParameterService.register(engineParameters);
@@ -96,7 +95,7 @@ public class TestContextUpdateDifferentModels {
@After
public void afterTest() {
ParameterService.deregister(engineParameters);
-
+
ParameterService.deregister(contextParameters.getDistributorParameters());
ParameterService.deregister(contextParameters.getLockManagerParameters());
ParameterService.deregister(contextParameters.getPersistorParameters());
@@ -136,16 +135,16 @@ public class TestContextUpdateDifferentModels {
assertEquals(apexEngine.getInternalContext().getContextAlbums().size(),
apexModelSample.getAlbums().getAlbumsMap().size());
for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) {
- assertTrue(
- contextAlbum.getAlbumDefinition().equals(apexModelSample.getAlbums().get(contextAlbum.getKey())));
+ assertEquals(
+ contextAlbum.getAlbumDefinition(), apexModelSample.getAlbums().get(contextAlbum.getKey()));
}
apexEngine.updateModel(someSpuriousModel, false);
assertEquals(apexEngine.getInternalContext().getContextAlbums().size(),
someSpuriousModel.getAlbums().getAlbumsMap().size());
for (final ContextAlbum contextAlbum : apexEngine.getInternalContext().getContextAlbums().values()) {
- assertTrue(
- contextAlbum.getAlbumDefinition().equals(someSpuriousModel.getAlbums().get(contextAlbum.getKey())));
+ assertEquals(
+ contextAlbum.getAlbumDefinition(), someSpuriousModel.getAlbums().get(contextAlbum.getKey()));
}
apexEngine.clear();
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 fdc60d765..22303a69a 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
@@ -369,9 +369,9 @@ public class ApexServiceModelUpdateTest {
private void checkResult(final ApexEvent result) {
assertTrue(result.getName().startsWith("Event0004") || result.getName().startsWith("Event0104"));
- assertTrue(result.get("TestSlogan").equals("This is a test slogan"));
- assertTrue(result.get("TestMatchCase").equals((byte) 123));
- assertTrue(result.get("TestTemperature").equals(34.5445667));
+ assertEquals("This is a test slogan", result.get("TestSlogan"));
+ assertEquals((byte) 123, result.get("TestMatchCase"));
+ assertEquals(34.5445667, result.get("TestTemperature"));
assertTrue(((byte) result.get("TestMatchCaseSelected")) >= 0
&& ((byte) result.get("TestMatchCaseSelected") <= 3));
assertTrue(((byte) result.get("TestEstablishCaseSelected")) >= 0
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
index 72444cc7c..445c2df1f 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/engine/ApexServiceTest.java
@@ -499,9 +499,9 @@ public class ApexServiceTest {
private void checkResult(final ApexEvent result) {
assertTrue(result.getName().startsWith("Event0004") || result.getName().startsWith("Event0104"));
- assertTrue(result.get("TestSlogan").equals("This is a test slogan"));
- assertTrue(result.get("TestMatchCase").equals((byte) 123));
- assertTrue(result.get("TestTemperature").equals(34.5445667));
+ assertEquals("This is a test slogan", result.get("TestSlogan"));
+ assertEquals((byte) 123, result.get("TestMatchCase"));
+ assertEquals(34.5445667, result.get("TestTemperature"));
assertTrue(((byte) result.get("TestMatchCaseSelected")) >= 0
&& ((byte) result.get("TestMatchCaseSelected") <= 3));
assertTrue(((byte) result.get("TestEstablishCaseSelected")) >= 0