aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java9
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/ContextExceptionTest.java17
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java168
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/DummyContextAlbumImpl.java71
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java24
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java38
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperParametersTest.java19
-rw-r--r--context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java211
-rw-r--r--model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java50
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java23
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java49
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java16
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java114
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ExceptionsTest.java39
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ValidationTest.java79
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelExceptionTest.java17
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java41
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java35
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java13
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyAxModelWithReferences.java30
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java32
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java90
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java62
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java25
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java24
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java46
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java38
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java36
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java96
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ContextComparisonTest.java116
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModelCreator.java42
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java57
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java156
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java104
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java55
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/DummyTestApexEngineModelCreator.java33
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java38
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java77
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java62
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java257
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ApexApiResultTest.java44
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java170
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java152
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java15
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java10
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java11
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java11
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java32
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/modelapi/RealModelTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/ExceptionsTest.java22
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java14
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java103
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReaderTest.java10
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelMergerTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java21
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java10
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java16
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java12
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java10
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java5
-rw-r--r--model/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java15
-rw-r--r--model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_InvalidModel.txt7
-rw-r--r--model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_InvalidModelMalStructured.txt5
-rw-r--r--model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_ValidModel.txt5
-rw-r--r--model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_WarningModel.txt7
-rw-r--r--model/src/test/resources/contextmodel/handling/ApexContextModel_InvalidMalStructuredModel.txt7
-rw-r--r--model/src/test/resources/contextmodel/handling/ApexContextModel_InvalidModel.txt5
-rw-r--r--model/src/test/resources/contextmodel/handling/ApexContextModel_ObservationModel.txt4
-rw-r--r--model/src/test/resources/contextmodel/handling/ApexContextModel_WarningModel.txt4
-rw-r--r--model/src/test/resources/eventmodel/handling/ApexEventModelTest_InvalidModel.txt37
-rw-r--r--model/src/test/resources/eventmodel/handling/ApexEventModelTest_InvalidModelMalStructured.txt20
-rw-r--r--model/src/test/resources/eventmodel/handling/ApexEventModelTest_ObservationModel.txt9
-rw-r--r--model/src/test/resources/eventmodel/handling/ApexEventModelTest_WarningModel.txt12
-rw-r--r--model/src/test/resources/policymodel/handling/ApexPolicyModelTest_InvalidMalStructuredModel.txt16
-rw-r--r--model/src/test/resources/policymodel/handling/ApexPolicyModelTest_InvalidModel.txt5
-rw-r--r--model/src/test/resources/policymodel/handling/ApexPolicyModel_ObservationModel.txt4
-rw-r--r--model/src/test/resources/policymodel/handling/ApexPolicyModel_WarningModel.txt4
-rw-r--r--pom.xml22
93 files changed, 1801 insertions, 1786 deletions
diff --git a/context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java b/context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java
index 358b95327..f8ca251ba 100644
--- a/context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java
+++ b/context/context-management/src/main/java/org/onap/policy/apex/context/ContextAlbum.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -84,7 +85,7 @@ public interface ContextAlbum extends Map<String, Object> {
SchemaHelper getSchemaHelper();
/**
- * Place a read lock on a key in this album across the entire cluster.
+ * Place a read lock on a key on this album across the entire cluster.
*
* @param key The key to lock
* @throws ContextException on locking errors
@@ -92,7 +93,7 @@ public interface ContextAlbum extends Map<String, Object> {
void lockForReading(String key) throws ContextException;
/**
- * Place a write lock on a key in this album across the entire cluster.
+ * Place a write lock on a key on this album across the entire cluster.
*
* @param key The key to lock
* @throws ContextException on locking errors
@@ -100,7 +101,7 @@ public interface ContextAlbum extends Map<String, Object> {
void lockForWriting(String key) throws ContextException;
/**
- * Release the the read lock on a key in this album across the entire cluster.
+ * Release the read lock on a key on this album across the entire cluster.
*
* @param key The key to unlock
* @throws ContextException on locking errors
@@ -108,7 +109,7 @@ public interface ContextAlbum extends Map<String, Object> {
void unlockForReading(String key) throws ContextException;
/**
- * Release the the write lock on a key in this album across the entire cluster.
+ * Release the write lock on a key on this album across the entire cluster.
*
* @param key The key to unlock
* @throws ContextException on locking errors
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/ContextExceptionTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/ContextExceptionTest.java
index ff07b1e50..19f695cda 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/ContextExceptionTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/ContextExceptionTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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,25 +21,25 @@
package org.onap.policy.apex.context;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ContextExceptionTest {
+class ContextExceptionTest {
@Test
- public void testContextException() {
+ void testContextException() {
assertEquals("context exception message", new ContextException("context exception message").getMessage());
assertEquals("context exception message",
- new ContextException("context exception message", new IOException()).getMessage());
+ new ContextException("context exception message", new IOException()).getMessage());
}
@Test
- public void testContextRuntimeException() {
+ void testContextRuntimeException() {
assertEquals("context exception message",
- new ContextRuntimeException("context exception message").getMessage());
+ new ContextRuntimeException("context exception message").getMessage());
assertEquals("context exception message",
- new ContextRuntimeException("context exception message", new IOException()).getMessage());
+ new ContextRuntimeException("context exception message", new IOException()).getMessage());
}
}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
index 6ebb79f43..216e3686a 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/ContextAlbumImplTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,15 +22,17 @@
package org.onap.policy.apex.context.impl;
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.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
@@ -49,11 +51,11 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.common.parameters.ParameterService;
-public class ContextAlbumImplTest {
+class ContextAlbumImplTest {
/**
- * Set ups everything for the test.
+ * Set-ups everything for the test.
*/
- @BeforeClass
+ @BeforeAll
public static void prepareForTest() {
final ContextParameters contextParameters = new ContextParameters();
contextParameters.getLockManagerParameters()
@@ -79,7 +81,7 @@ public class ContextAlbumImplTest {
/**
* Clear down the test data.
*/
- @AfterClass
+ @AfterAll
public static void cleanUpAfterTest() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
@@ -90,7 +92,7 @@ public class ContextAlbumImplTest {
}
@Test
- public void testNullsOnConstructor() {
+ void testNullsOnConstructor() {
assertThatThrownBy(() -> new ContextAlbumImpl(null, null, null))
.hasMessage("Context album definition may not be null");
@@ -101,13 +103,13 @@ public class ContextAlbumImplTest {
.hasMessage("Album map may not be null");
assertThatThrownBy(() -> new ContextAlbumImpl(new AxContextAlbum(), new JvmLocalDistributor(),
- new LinkedHashMap<String, Object>()))
- .hasMessage("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas "
- + "not found in model service");
+ new LinkedHashMap<>()))
+ .hasMessage("Model for org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas "
+ + "not found in model service");
}
@Test
- public void testAlbumInterface() throws ContextException {
+ void testAlbumInterface() throws ContextException {
AxContextSchemas schemas = new AxContextSchemas();
AxContextSchema simpleStringSchema = new AxContextSchema(new AxArtifactKey("SimpleStringSchema", "0.0.1"),
"JAVA", "java.lang.String");
@@ -118,39 +120,25 @@ public class ContextAlbumImplTest {
true, AxArtifactKey.getNullKey());
assertThatThrownBy(
- () -> new ContextAlbumImpl(axContextAlbum, new JvmLocalDistributor(), new LinkedHashMap<String, Object>()))
- .hasMessageContaining("could not initiate schema management for context album AxContextAlbum");
+ () -> new ContextAlbumImpl(axContextAlbum, new JvmLocalDistributor(), new LinkedHashMap<>()))
+ .hasMessageContaining("could not initiate schema management for context album AxContextAlbum");
axContextAlbum.setItemSchema(simpleStringSchema.getKey());
Distributor distributor = new JvmLocalDistributor();
distributor.init(axContextAlbum.getKey());
- ContextAlbum album = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<String, Object>());
+ ContextAlbum album = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<>());
- assertEquals("TestContextAlbum", album.getName());
- assertEquals("TestContextAlbum:0.0.1", album.getKey().getId());
- assertEquals("TestContextAlbum:0.0.1", album.getAlbumDefinition().getId());
- assertEquals("SimpleStringSchema:0.0.1", album.getSchemaHelper().getSchema().getId());
+ assertGetValuesFromContextAlbum(album);
assertThatThrownBy(() -> album.containsKey(null))
.hasMessage("null values are illegal on method parameter \"key\"");
- assertEquals(false, album.containsKey("Key0"));
-
- assertThatThrownBy(() -> album.containsValue(null))
- .hasMessage("null values are illegal on method parameter \"value\"");
- assertEquals(false, album.containsValue("some value"));
-
- assertThatThrownBy(() -> album.get(null))
- .hasMessage("album \"TestContextAlbum:0.0.1\" null keys are illegal on keys for get()");
+ assertFalse(album.containsKey("Key0"));
- assertThatThrownBy(() -> album.put(null, null))
- .hasMessage("album \"TestContextAlbum:0.0.1\" null keys are illegal on keys for put()");
-
- assertThatThrownBy(() -> album.put("KeyNull", null))
- .hasMessage("album \"TestContextAlbum:0.0.1\" null values are illegal on key \"KeyNull\"" + " for put()");
+ assertUsingNullValues_RaiseExceptions(album);
AxContextAlbum axContextAlbumRo = new AxContextAlbum(new AxArtifactKey("TestContextAlbum", "0.0.1"), "Policy",
false, simpleStringSchema.getKey());
- ContextAlbum albumRo = new ContextAlbumImpl(axContextAlbumRo, distributor, new LinkedHashMap<String, Object>());
+ ContextAlbum albumRo = new ContextAlbumImpl(axContextAlbumRo, distributor, new LinkedHashMap<>());
assertThatThrownBy(() -> albumRo.put("KeyReadOnly", "A value for a Read Only Album"))
.hasMessage("album \"TestContextAlbum:0.0.1\" put() not allowed on read only albums "
@@ -173,52 +161,25 @@ public class ContextAlbumImplTest {
assertThatThrownBy(albumRo::clear)
.hasMessage("album \"TestContextAlbum:0.0.1\" clear() not allowed on read only albums");
- // The following locking tests pass because the locking protects access to Key0
- // across all
- // copies of the distributed album whether the key exists or not
- album.lockForReading("Key0");
- assertEquals(null, album.get("Key0"));
- album.unlockForReading("Key0");
- assertEquals(null, album.get("Key0"));
-
- album.lockForWriting("Key0");
- assertEquals(null, album.get("Key0"));
- album.unlockForWriting("Key0");
- assertEquals(null, album.get("Key0"));
-
- // Test write access, trivial test because Integration Test does
- // a full test of access locking over albums in different JVMs
- album.lockForWriting("Key0");
- assertEquals(null, album.get("Key0"));
- album.put("Key0", "value of Key0");
- assertEquals("value of Key0", album.get("Key0"));
- album.unlockForWriting("Key0");
- assertEquals("value of Key0", album.get("Key0"));
-
- // Test read access, trivial test because Integration Test does
- // a full test of access locking over albums in different JVMs
- album.lockForReading("Key0");
- assertEquals("value of Key0", album.get("Key0"));
- album.unlockForReading("Key0");
+ assertLockingUnlocking(album);
AxArtifactKey somePolicyKey = new AxArtifactKey("MyPolicy", "0.0.1");
AxReferenceKey somePolicyState = new AxReferenceKey(somePolicyKey, "SomeState");
- AxConcept[] userArtifactStack = { somePolicyKey, somePolicyState };
+ AxConcept[] userArtifactStack = {somePolicyKey, somePolicyState};
album.setUserArtifactStack(userArtifactStack);
assertEquals("MyPolicy:0.0.1", album.getUserArtifactStack()[0].getId());
assertEquals("MyPolicy:0.0.1:NULL:SomeState", album.getUserArtifactStack()[1].getId());
- assertEquals(true, album.keySet().contains("Key0"));
- assertEquals(true, album.values().contains("value of Key0"));
+ assertTrue(album.containsKey("Key0"));
+ assertTrue(album.containsValue("value of Key0"));
assertEquals(1, album.entrySet().size());
// The flush() operation fails because the distributor is not initialized with
- // the album which
- // is fine for unit test
+ // the album which is fine for unit test
assertThatThrownBy(album::flush).hasMessage("map flush failed, supplied map is null");
assertEquals(1, album.size());
- assertEquals(false, album.isEmpty());
+ assertFalse(album.isEmpty());
album.put("Key0", "New value of Key0");
assertEquals("New value of Key0", album.get("Key0"));
@@ -231,13 +192,64 @@ public class ContextAlbumImplTest {
assertEquals("New value of Key0", album.remove("Key0"));
album.clear();
- assertTrue(album.isEmpty());
ModelService.clear();
}
+ private static void assertUsingNullValues_RaiseExceptions(ContextAlbum album) {
+ assertThatThrownBy(() -> album.containsValue(null))
+ .hasMessage("null values are illegal on method parameter \"value\"");
+ assertFalse(album.containsValue("some value"));
+
+ assertThatThrownBy(() -> album.get(null))
+ .hasMessage("album \"TestContextAlbum:0.0.1\" null keys are illegal on keys for get()");
+
+ assertThatThrownBy(() -> album.put(null, null))
+ .hasMessage("album \"TestContextAlbum:0.0.1\" null keys are illegal on keys for put()");
+
+ assertThatThrownBy(() -> album.put("KeyNull", null))
+ .hasMessage("album \"TestContextAlbum:0.0.1\" null values are illegal on key \"KeyNull\"" + " for put()");
+ }
+
+ private static void assertGetValuesFromContextAlbum(ContextAlbum album) {
+ assertEquals("TestContextAlbum", album.getName());
+ assertEquals("TestContextAlbum:0.0.1", album.getKey().getId());
+ assertEquals("TestContextAlbum:0.0.1", album.getAlbumDefinition().getId());
+ assertEquals("SimpleStringSchema:0.0.1", album.getSchemaHelper().getSchema().getId());
+ }
+
+ private static void assertLockingUnlocking(ContextAlbum album) throws ContextException {
+ // The following locking tests pass because the locking protects access to Key0
+ // across all
+ // copies of the distributed album whether the key exists or not
+ album.lockForReading("Key0");
+ assertNull(album.get("Key0"));
+ album.unlockForReading("Key0");
+ assertNull(album.get("Key0"));
+
+ album.lockForWriting("Key0");
+ assertNull(album.get("Key0"));
+ album.unlockForWriting("Key0");
+ assertNull(album.get("Key0"));
+
+ // Test write access, trivial test because Integration Test does
+ // a full test of access locking over albums in different JVMs
+ album.lockForWriting("Key0");
+ assertNull(album.get("Key0"));
+ album.put("Key0", "value of Key0");
+ assertEquals("value of Key0", album.get("Key0"));
+ album.unlockForWriting("Key0");
+ assertEquals("value of Key0", album.get("Key0"));
+
+ // Test read access, trivial test because Integration Test does
+ // a full test of access locking over albums in different JVMs
+ album.lockForReading("Key0");
+ assertEquals("value of Key0", album.get("Key0"));
+ album.unlockForReading("Key0");
+ }
+
@Test
- public void testCompareToEqualsHash() throws ContextException {
+ void testCompareToEqualsHash() throws ContextException {
AxContextSchemas schemas = new AxContextSchemas();
AxContextSchema simpleIntSchema = new AxContextSchema(new AxArtifactKey("SimpleIntSchema", "0.0.1"), "JAVA",
"java.lang.Integer");
@@ -253,26 +265,22 @@ public class ContextAlbumImplTest {
axContextAlbum.setItemSchema(simpleIntSchema.getKey());
Distributor distributor = new JvmLocalDistributor();
distributor.init(axContextAlbum.getKey());
- ContextAlbumImpl album = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<String, Object>());
+ ContextAlbumImpl album = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<>());
assertNotEquals(0, album.hashCode());
- assertEquals(0, album.compareTo(album));
assertEquals(1, album.compareTo(null));
- assertEquals(album, album);
assertNotEquals(album, new DummyContextAlbumImpl());
- ContextAlbumImpl otherAlbum = new ContextAlbumImpl(axContextAlbum, distributor,
- new LinkedHashMap<String, Object>());
+ ContextAlbumImpl otherAlbum = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<>());
assertEquals(album, otherAlbum);
otherAlbum.put("Key", 123);
assertNotEquals(album, otherAlbum);
assertThatThrownBy(() -> {
- ContextAlbumImpl otherAlbumBad = new ContextAlbumImpl(axContextAlbum, distributor,
- new LinkedHashMap<String, Object>());
+ ContextAlbumImpl otherAlbumBad = new ContextAlbumImpl(axContextAlbum, distributor, new LinkedHashMap<>());
otherAlbumBad.put("Key", "BadValue");
}).hasMessage("Failed to set context value for key \"Key\" in album \"TestContextAlbum:0.0.1\": "
+ "TestContextAlbum:0.0.1: object \"BadValue\" of class \"java.lang.String\" "
@@ -281,7 +289,7 @@ public class ContextAlbumImplTest {
"Policy", true, AxArtifactKey.getNullKey());
otherAxContextAlbum.setItemSchema(simpleStringSchema.getKey());
- otherAlbum = new ContextAlbumImpl(otherAxContextAlbum, distributor, new LinkedHashMap<String, Object>());
+ otherAlbum = new ContextAlbumImpl(otherAxContextAlbum, distributor, new LinkedHashMap<>());
assertNotEquals(album, otherAlbum);
assertThatThrownBy(album::flush).hasMessage("map flush failed, supplied map is null");
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/DummyContextAlbumImpl.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/DummyContextAlbumImpl.java
index 20398eb1a..6f7cd9fcb 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/DummyContextAlbumImpl.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/DummyContextAlbumImpl.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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=========================================================
*/
@@ -33,7 +34,6 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
/**
* Dummy album implementation class.
- *
*/
public class DummyContextAlbumImpl implements ContextAlbum {
@@ -42,7 +42,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public void clear() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -50,7 +50,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public boolean containsKey(Object key) {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -58,7 +58,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public boolean containsValue(Object value) {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -66,7 +66,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public Set<Entry<String, Object>> entrySet() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -74,7 +74,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public Object get(Object key) {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -82,7 +82,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public boolean isEmpty() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -90,7 +90,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public Set<String> keySet() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -98,7 +98,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public Object put(String key, Object value) {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -106,8 +106,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public void putAll(Map<? extends String, ? extends Object> map) {
- throw new NotImplementedException("Not Implemeted on dummy class");
-
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -115,7 +114,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public Object remove(Object key) {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -123,7 +122,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public int size() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -131,7 +130,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public Collection<Object> values() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -139,7 +138,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public AxArtifactKey getKey() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -147,7 +146,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public String getName() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -155,7 +154,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public AxContextAlbum getAlbumDefinition() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -163,43 +162,39 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public SchemaHelper getSchemaHelper() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
* {@inheritDoc}.
*/
@Override
- public void lockForReading(String key) throws ContextException {
- throw new NotImplementedException("Not Implemeted on dummy class");
-
+ public void lockForReading(String key) {
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
* {@inheritDoc}.
*/
@Override
- public void lockForWriting(String key) throws ContextException {
- throw new NotImplementedException("Not Implemeted on dummy class");
-
+ public void lockForWriting(String key) {
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
* {@inheritDoc}.
*/
@Override
- public void unlockForReading(String key) throws ContextException {
- throw new NotImplementedException("Not Implemeted on dummy class");
-
+ public void unlockForReading(String key) {
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
* {@inheritDoc}.
*/
@Override
- public void unlockForWriting(String key) throws ContextException {
- throw new NotImplementedException("Not Implemeted on dummy class");
-
+ public void unlockForWriting(String key) {
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -207,7 +202,7 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public AxConcept[] getUserArtifactStack() {
- throw new NotImplementedException("Not Implemeted on dummy class");
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
@@ -215,17 +210,15 @@ public class DummyContextAlbumImpl implements ContextAlbum {
*/
@Override
public void setUserArtifactStack(AxConcept[] userArtifactStack) {
- throw new NotImplementedException("Not Implemeted on dummy class");
-
+ throw new NotImplementedException("Not Implemented on dummy class");
}
/**
* {@inheritDoc}.
*/
@Override
- public void flush() throws ContextException {
- throw new NotImplementedException("Not Implemeted on dummy class");
-
+ public void flush() {
+ throw new NotImplementedException("Not Implemented on dummy class");
}
}
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
index 663424411..501b76c0a 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/SchemaHelperFactoryTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,11 @@
package org.onap.policy.apex.context.impl.schema;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
@@ -36,16 +36,16 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
import org.onap.policy.common.parameters.ParameterService;
-public class SchemaHelperFactoryTest {
+class SchemaHelperFactoryTest {
private static AxContextSchema intSchema;
private static AxContextSchemas schemas;
private static AxContextSchema badSchema;
/**
- * Set ups schema for the test.
+ * Set-ups schema for the test.
*/
- @BeforeClass
- public static void setupSchema() {
+ @BeforeAll
+ static void setupSchema() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
@@ -53,13 +53,13 @@ public class SchemaHelperFactoryTest {
badSchema = new AxContextSchema(new AxArtifactKey("IntSchema", "0.0.1"), "JAVA", "java.lang.Bad");
}
- @AfterClass
- public static void clearParameters() {
+ @AfterAll
+ static void clearParameters() {
ParameterService.clear();
}
@Test
- public void testSchemaHelperFactory() {
+ void testSchemaHelperFactory() {
assertThatThrownBy(() -> new SchemaHelperFactory().createSchemaHelper(null, null))
.hasMessage("Parameter \"owningEntityKey\" may not be null");
AxArtifactKey ownerKey = new AxArtifactKey("Owner", "0.0.1");
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
index 620a78152..f4c8c3e2d 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperInstanceCreationTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,11 @@
package org.onap.policy.apex.context.impl.schema.java;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
@@ -40,17 +40,17 @@ import org.onap.policy.common.parameters.ParameterService;
/**
* JavaSchemaHelperInstanceCreationTest.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
- * @version
*/
-public class JavaSchemaHelperInstanceCreationTest {
+class JavaSchemaHelperInstanceCreationTest {
private final AxKey testKey = new AxArtifactKey("AvroTest", "0.0.1");
private AxContextSchemas schemas;
/**
- * Set ups everything for the test.
+ * Set-ups everything for the test.
*/
- @Before
+ @BeforeEach
public void initTest() {
schemas = new AxContextSchemas(new AxArtifactKey("AvroSchemas", "0.0.1"));
ModelService.registerModel(AxContextSchemas.class, schemas);
@@ -62,40 +62,40 @@ public class JavaSchemaHelperInstanceCreationTest {
ParameterService.register(schemaParameters);
}
- @AfterClass
+ @AfterAll
public static void cleanUpAfterTest() {
ParameterService.clear();
}
@Test
- public void testNullEncoding() {
+ void testNullEncoding() {
final AxContextSchema javaBooleanSchema =
- new AxContextSchema(new AxArtifactKey("Boolean", "0.0.1"), "Java", "java.lang.Boolean");
+ new AxContextSchema(new AxArtifactKey("Boolean", "0.0.1"), "Java", "java.lang.Boolean");
final AxContextSchema javaLongSchema =
- new AxContextSchema(new AxArtifactKey("Long", "0.0.1"), "Java", "java.lang.Long");
+ new AxContextSchema(new AxArtifactKey("Long", "0.0.1"), "Java", "java.lang.Long");
final AxContextSchema javaStringSchema =
- new AxContextSchema(new AxArtifactKey("String", "0.0.1"), "Java", "java.lang.String");
+ new AxContextSchema(new AxArtifactKey("String", "0.0.1"), "Java", "java.lang.String");
schemas.getSchemasMap().put(javaBooleanSchema.getKey(), javaBooleanSchema);
schemas.getSchemasMap().put(javaLongSchema.getKey(), javaLongSchema);
schemas.getSchemasMap().put(javaStringSchema.getKey(), javaStringSchema);
final SchemaHelper schemaHelper0 =
- new SchemaHelperFactory().createSchemaHelper(testKey, javaBooleanSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, javaBooleanSchema.getKey());
final SchemaHelper schemaHelper1 =
- new SchemaHelperFactory().createSchemaHelper(testKey, javaLongSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, javaLongSchema.getKey());
final SchemaHelper schemaHelper2 =
- new SchemaHelperFactory().createSchemaHelper(testKey, javaStringSchema.getKey());
+ new SchemaHelperFactory().createSchemaHelper(testKey, javaStringSchema.getKey());
assertThatThrownBy(schemaHelper0::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Boolean\""
- + " using the default constructor \"Boolean()\"");
+ + " using the default constructor \"Boolean()\"");
assertEquals(true, schemaHelper0.createNewInstance("true"));
assertThatThrownBy(schemaHelper1::createNewInstance)
.hasMessage("AvroTest:0.0.1: could not create an instance of class \"java.lang.Long\""
- + " using the default constructor \"Long()\"");
+ + " using the default constructor \"Long()\"");
assertEquals(65536L, schemaHelper1.createNewInstance("65536"));
assertEquals("", schemaHelper2.createNewInstance());
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperParametersTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperParametersTest.java
index 65b2ed6ff..418149e50 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperParametersTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperParametersTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 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,26 +22,26 @@
package org.onap.policy.apex.context.impl.schema.java;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.LinkedHashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test Java schema helper parameters.
*/
-public class JavaSchemaHelperParametersTest {
+class JavaSchemaHelperParametersTest {
@Test
- public void testJavaSchemaHelperParameters() {
+ void testJavaSchemaHelperParameters() {
JavaSchemaHelperParameters pars = new JavaSchemaHelperParameters();
assertEquals("org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelper",
- pars.getSchemaHelperPluginClass());
+ pars.getSchemaHelperPluginClass());
assertEquals(0, pars.getJsonAdapters().size());
@@ -84,7 +85,7 @@ public class JavaSchemaHelperParametersTest {
}
@Test
- public void testJavaSchemaHelperJsonAdapterParameters() {
+ void testJavaSchemaHelperJsonAdapterParameters() {
JavaSchemaHelperJsonAdapterParameters pars = new JavaSchemaHelperJsonAdapterParameters();
assertNull(pars.getName());
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
index d06ac7469..773b6d84c 100644
--- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
+++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,16 +22,17 @@
package org.onap.policy.apex.context.impl.schema.java;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import java.math.BigDecimal;
import java.time.Instant;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
@@ -39,11 +40,11 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
import org.onap.policy.common.parameters.ParameterService;
-public class JavaSchemaHelperTest {
+class JavaSchemaHelperTest {
/**
* Initialize JSON adapters.
*/
- @BeforeClass
+ @BeforeAll
public static void registerParameters() {
JavaSchemaHelperParameters javaSchemaHelperPars = new JavaSchemaHelperParameters();
@@ -59,13 +60,13 @@ public class JavaSchemaHelperTest {
ParameterService.register(schemaPars);
}
- @AfterClass
+ @AfterAll
public static void deregisterParameters() {
ParameterService.clear();
}
@Test
- public void testJavaSchemaHelperInit() {
+ void testJavaSchemaHelperInit() {
AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
@@ -73,23 +74,23 @@ public class JavaSchemaHelperTest {
assertThatThrownBy(() -> new JavaSchemaHelper().init(userKey, badJavaTypeSchema))
.hasMessage("UserKey:0.0.1: class/type java.lang.Rubbish for context schema"
- + " \"SchemaKey:0.0.1\" not found. Check the class path of the JVM");
+ + " \"SchemaKey:0.0.1\" not found. Check the class path of the JVM");
AxContextSchema builtInJavaTypeSchema = new AxContextSchema(schemaKey, "Java", "short");
assertThatThrownBy(() -> new JavaSchemaHelper().init(userKey, builtInJavaTypeSchema))
.hasMessage("UserKey:0.0.1: class/type short for context schema "
- + "\"SchemaKey:0.0.1\" not found. Primitive types are not supported."
- + " Use the appropriate Java boxing type instead.");
+ + "\"SchemaKey:0.0.1\" not found. Primitive types are not supported."
+ + " Use the appropriate Java boxing type instead.");
}
@Test
- public void testJavaSchemaHelperMethods() {
+ void testJavaSchemaHelperMethods() {
SchemaHelper intSchemaHelper = new JavaSchemaHelper();
assertEquals(AxArtifactKey.getNullKey(), intSchemaHelper.getUserKey());
- assertEquals(null, intSchemaHelper.getSchema());
- assertEquals(null, intSchemaHelper.getSchemaClass());
- assertEquals(null, intSchemaHelper.getSchemaObject());
+ assertNull(intSchemaHelper.getSchema());
+ assertNull(intSchemaHelper.getSchemaClass());
+ assertNull(intSchemaHelper.getSchemaObject());
assertThatThrownBy(intSchemaHelper::createNewInstance)
.hasMessage("NULL:0.0.0: could not create an instance, schema class for the schema is null");
@@ -105,27 +106,27 @@ public class JavaSchemaHelperTest {
assertEquals(userKey, intSchemaHelper.getUserKey());
assertEquals(intSchema, intSchemaHelper.getSchema());
assertEquals(Integer.class, intSchemaHelper.getSchemaClass());
- assertEquals(null, intSchemaHelper.getSchemaObject());
+ assertNull(intSchemaHelper.getSchemaObject());
assertThatThrownBy(intSchemaHelper::createNewInstance)
.hasMessage("UserKey:0.0.1: could not create an instance of class "
- + "\"java.lang.Integer\" using the default constructor \"Integer()\"");
+ + "\"java.lang.Integer\" using the default constructor \"Integer()\"");
assertThatThrownBy(() -> intSchemaHelper.createNewInstance(Float.parseFloat("1.23")))
.hasMessage("UserKey:0.0.1: the object \"1.23\" of type "
- + "\"java.lang.Float\" is not an instance of JsonObject and is not "
- + "assignable to \"java.lang.Integer\"");
+ + "\"java.lang.Float\" is not an instance of JsonObject and is not "
+ + "assignable to \"java.lang.Integer\"");
assertThatThrownBy(() -> intSchemaHelper.createNewInstance("hello"))
.hasMessage("UserKey:0.0.1: could not create an instance of class \"java.lang.Integer\" "
- + "using the string constructor \"Integer(String)\"");
+ + "using the string constructor \"Integer(String)\"");
JsonElement jsonIntElement = null;
- assertEquals(null, intSchemaHelper.createNewInstance(jsonIntElement));
+ assertNull(intSchemaHelper.createNewInstance(jsonIntElement));
jsonIntElement = JsonParser.parseString("123");
assertEquals(123, intSchemaHelper.createNewInstance(jsonIntElement));
assertEquals(123, intSchemaHelper.createNewInstance(Integer.parseInt("123")));
- assertEquals(null, intSchemaHelper.unmarshal(null));
+ assertNull(intSchemaHelper.unmarshal(null));
assertEquals(123, intSchemaHelper.unmarshal(Integer.parseInt("123")));
assertEquals(123, intSchemaHelper.unmarshal(Byte.parseByte("123")));
assertEquals(123, intSchemaHelper.unmarshal(Short.parseShort("123")));
@@ -135,7 +136,7 @@ public class JavaSchemaHelperTest {
}
@Test
- public void testJavaSchemaHelperUnmarshal() {
+ void testJavaSchemaHelperUnmarshal() {
AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
@@ -167,44 +168,53 @@ public class JavaSchemaHelperTest {
stringSchemaHelper.init(userKey, stringSchema);
AxContextSchema myBaseClassSchema = new AxContextSchema(schemaKey, "Java",
- "org.onap.policy.apex.context.impl.schema.java.SupportBaseClass");
+ "org.onap.policy.apex.context.impl.schema.java.SupportBaseClass");
SchemaHelper myBaseClassSchemaHelper = new JavaSchemaHelper();
myBaseClassSchemaHelper.init(userKey, myBaseClassSchema);
- assertEquals(null, byteSchemaHelper.unmarshal(null));
- assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal("123"));
- assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Integer.parseInt("123")));
- assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Byte.parseByte("123")));
- assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Short.parseShort("123")));
- assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Long.parseLong("123")));
- assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Float.parseFloat("123")));
- assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Double.parseDouble("123")));
- assertThatThrownBy(() -> byteSchemaHelper.unmarshal("one two three"))
- .hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Byte\"");
- assertEquals(null, shortSchemaHelper.unmarshal(null));
- assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal("123"));
- assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Integer.parseInt("123")));
- assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Byte.parseByte("123")));
- assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Short.parseShort("123")));
- assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Long.parseLong("123")));
- assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Float.parseFloat("123")));
- assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Double.parseDouble("123")));
- assertThatThrownBy(() -> shortSchemaHelper.unmarshal("one two three"))
+ assertByteUnmarshal(byteSchemaHelper);
+ assertShortUnmarshal(shortSchemaHelper);
+ assertIntUnmarshal(intSchemaHelper);
+ assertLongUnmarshal(longSchemaHelper);
+ assertFloatUnmarshal(floatSchemaHelper);
+ assertDoubleUnmarshal(doubleSchemaHelper);
+ assertEquals("123", stringSchemaHelper.unmarshal(123));
+
+ SupportSubClass subClassInstance = new SupportSubClass("123");
+ assertEquals(subClassInstance, myBaseClassSchemaHelper.unmarshal(subClassInstance));
+ }
+
+ private static void assertDoubleUnmarshal(SchemaHelper doubleSchemaHelper) {
+ assertNull(doubleSchemaHelper.unmarshal(null));
+ assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal("123"));
+ assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Integer.parseInt("123")));
+ assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Byte.parseByte("123")));
+ assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Short.parseShort("123")));
+ assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Long.parseLong("123")));
+ assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Float.parseFloat("123")));
+ assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Double.parseDouble("123")));
+ assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(BigDecimal.valueOf(123)));
+ assertThatThrownBy(() -> doubleSchemaHelper.unmarshal("one two three"))
.hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Short\"");
- assertEquals(null, intSchemaHelper.unmarshal(null));
- assertEquals(123, intSchemaHelper.unmarshal("123"));
- assertEquals(123, intSchemaHelper.unmarshal(Integer.parseInt("123")));
- assertEquals(123, intSchemaHelper.unmarshal(Byte.parseByte("123")));
- assertEquals(123, intSchemaHelper.unmarshal(Short.parseShort("123")));
- assertEquals(123, intSchemaHelper.unmarshal(Long.parseLong("123")));
- assertEquals(123, intSchemaHelper.unmarshal(Float.parseFloat("123")));
- assertEquals(123, intSchemaHelper.unmarshal(Double.parseDouble("123")));
- assertThatThrownBy(() -> intSchemaHelper.unmarshal("one two three"))
+ + "compatible with class \"java.lang.Double\"");
+ }
+
+ private static void assertFloatUnmarshal(SchemaHelper floatSchemaHelper) {
+ assertNull(floatSchemaHelper.unmarshal(null));
+ assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal("123"));
+ assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Integer.parseInt("123")));
+ assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Byte.parseByte("123")));
+ assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Short.parseShort("123")));
+ assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Long.parseLong("123")));
+ assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Float.parseFloat("123")));
+ assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Double.parseDouble("123")));
+ assertThatThrownBy(() -> floatSchemaHelper.unmarshal("one two three"))
.hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Integer\"");
- assertEquals(null, longSchemaHelper.unmarshal(null));
+ + "compatible with class \"java.lang.Float\"");
+ }
+
+ private static void assertLongUnmarshal(SchemaHelper longSchemaHelper) {
+ assertNull(longSchemaHelper.unmarshal(null));
assertEquals(123L, longSchemaHelper.unmarshal("123"));
assertEquals(123L, longSchemaHelper.unmarshal(Integer.parseInt("123")));
assertEquals(123L, longSchemaHelper.unmarshal(Byte.parseByte("123")));
@@ -214,38 +224,53 @@ public class JavaSchemaHelperTest {
assertEquals(123L, longSchemaHelper.unmarshal(Double.parseDouble("123")));
assertThatThrownBy(() -> longSchemaHelper.unmarshal("one two three"))
.hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Long\"");
- assertEquals(null, floatSchemaHelper.unmarshal(null));
- assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal("123"));
- assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Integer.parseInt("123")));
- assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Byte.parseByte("123")));
- assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Short.parseShort("123")));
- assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Long.parseLong("123")));
- assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Float.parseFloat("123")));
- assertEquals(Float.valueOf("123"), floatSchemaHelper.unmarshal(Double.parseDouble("123")));
- assertThatThrownBy(() -> floatSchemaHelper.unmarshal("one two three"))
+ + "compatible with class \"java.lang.Long\"");
+ }
+
+ private static void assertIntUnmarshal(SchemaHelper intSchemaHelper) {
+ assertNull(intSchemaHelper.unmarshal(null));
+ assertEquals(123, intSchemaHelper.unmarshal("123"));
+ assertEquals(123, intSchemaHelper.unmarshal(Integer.parseInt("123")));
+ assertEquals(123, intSchemaHelper.unmarshal(Byte.parseByte("123")));
+ assertEquals(123, intSchemaHelper.unmarshal(Short.parseShort("123")));
+ assertEquals(123, intSchemaHelper.unmarshal(Long.parseLong("123")));
+ assertEquals(123, intSchemaHelper.unmarshal(Float.parseFloat("123")));
+ assertEquals(123, intSchemaHelper.unmarshal(Double.parseDouble("123")));
+ assertThatThrownBy(() -> intSchemaHelper.unmarshal("one two three"))
.hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Float\"");
- assertEquals(null, doubleSchemaHelper.unmarshal(null));
- assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal("123"));
- assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Integer.parseInt("123")));
- assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Byte.parseByte("123")));
- assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Short.parseShort("123")));
- assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Long.parseLong("123")));
- assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Float.parseFloat("123")));
- assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(Double.parseDouble("123")));
- assertEquals(Double.valueOf("123"), doubleSchemaHelper.unmarshal(BigDecimal.valueOf(123)));
- assertThatThrownBy(() -> doubleSchemaHelper.unmarshal("one two three"))
+ + "compatible with class \"java.lang.Integer\"");
+ }
+
+ private static void assertShortUnmarshal(SchemaHelper shortSchemaHelper) {
+ assertNull(shortSchemaHelper.unmarshal(null));
+ assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal("123"));
+ assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Integer.parseInt("123")));
+ assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Byte.parseByte("123")));
+ assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Short.parseShort("123")));
+ assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Long.parseLong("123")));
+ assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Float.parseFloat("123")));
+ assertEquals(Short.valueOf("123"), shortSchemaHelper.unmarshal(Double.parseDouble("123")));
+ assertThatThrownBy(() -> shortSchemaHelper.unmarshal("one two three"))
.hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
- + "compatible with class \"java.lang.Double\"");
- assertEquals("123", stringSchemaHelper.unmarshal(123));
+ + "compatible with class \"java.lang.Short\"");
+ }
- SupportSubClass subClassInstance = new SupportSubClass("123");
- assertEquals(subClassInstance, myBaseClassSchemaHelper.unmarshal(subClassInstance));
+ private static void assertByteUnmarshal(SchemaHelper byteSchemaHelper) {
+ assertNull(byteSchemaHelper.unmarshal(null));
+ assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal("123"));
+ assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Integer.parseInt("123")));
+ assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Byte.parseByte("123")));
+ assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Short.parseShort("123")));
+ assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Long.parseLong("123")));
+ assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Float.parseFloat("123")));
+ assertEquals(Byte.valueOf("123"), byteSchemaHelper.unmarshal(Double.parseDouble("123")));
+ assertThatThrownBy(() -> byteSchemaHelper.unmarshal("one two three"))
+ .hasMessage("UserKey:0.0.1: object \"one two three\" of class \"java.lang.String\" not "
+ + "compatible with class \"java.lang.Byte\"");
}
@Test
- public void testJavaSchemaHelperMarshal() {
+ void testJavaSchemaHelperMarshal() {
AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
@@ -257,13 +282,13 @@ public class JavaSchemaHelperTest {
assertEquals("123", intSchemaHelper.marshal2String(123));
assertThatThrownBy(() -> intSchemaHelper.marshal2String(123.45))
.hasMessage("UserKey:0.0.1: object \"123.45\" of class \"java.lang.Double\" not "
- + "compatible with class \"java.lang.Integer\"");
+ + "compatible with class \"java.lang.Integer\"");
JsonPrimitive intJsonPrimitive = (JsonPrimitive) intSchemaHelper.marshal2Object(123);
assertEquals(123, intJsonPrimitive.getAsInt());
}
@Test
- public void testJavaSchemaHelperAdapters() {
+ void testJavaSchemaHelperAdapters() {
AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
@@ -275,22 +300,22 @@ public class JavaSchemaHelperTest {
assertEquals("\"Hello\"", stringSchemaHelper.marshal2String("Hello"));
assertThatThrownBy(() -> stringSchemaHelper.marshal2String(Instant.ofEpochMilli(1000)))
.hasMessage("UserKey:0.0.1: object \"1970-01-01T00:00:01Z\" of class \"java.time.Instant\" "
- + "not compatible with class \"java.lang.String\"");
+ + "not compatible with class \"java.lang.String\"");
JsonPrimitive stringJsonPrimitive = (JsonPrimitive) stringSchemaHelper.marshal2Object("Another String");
assertEquals("Another String", stringJsonPrimitive.getAsString());
}
@Test
- public void testJavaSchemaHelperBadAdapter() {
+ void testJavaSchemaHelperBadAdapter() {
AxArtifactKey schemaKey = new AxArtifactKey("SchemaKey", "0.0.1");
AxArtifactKey userKey = new AxArtifactKey("UserKey", "0.0.1");
SchemaParameters pars = ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
JavaSchemaHelperParameters javaShPars =
- (JavaSchemaHelperParameters) pars.getSchemaHelperParameterMap().get("Java");
+ (JavaSchemaHelperParameters) pars.getSchemaHelperParameterMap().get("Java");
javaShPars.getJsonAdapters().get("String")
- .setAdaptorClass("org.onap.policy.apex.context.impl.schema.java.SupportBadJsonAdapter");
+ .setAdaptorClass("org.onap.policy.apex.context.impl.schema.java.SupportBadJsonAdapter");
AxContextSchema stringSchema = new AxContextSchema(schemaKey, "Java", "java.lang.String");
SchemaHelper stringSchemaHelper = new JavaSchemaHelper();
@@ -298,16 +323,16 @@ public class JavaSchemaHelperTest {
assertThatThrownBy(() -> stringSchemaHelper.marshal2String("Hello"))
.hasMessage("UserKey:0.0.1: instantiation of adapter class "
- + "\"org.onap.policy.apex.context.impl.schema.java.SupportBadJsonAdapter\" to decode and encode "
- + "class \"java.lang.String\" failed: null");
+ + "\"org.onap.policy.apex.context.impl.schema.java.SupportBadJsonAdapter\" to decode and encode "
+ + "class \"java.lang.String\" failed: null");
}
@Test
- public void testJavaSchemaHelperDefaultAdapter() {
+ void testJavaSchemaHelperDefaultAdapter() {
SchemaParameters pars = ParameterService.get(ContextParameterConstants.SCHEMA_GROUP_NAME);
JavaSchemaHelperParameters javaShPars =
- (JavaSchemaHelperParameters) pars.getSchemaHelperParameterMap().get("Java");
+ (JavaSchemaHelperParameters) pars.getSchemaHelperParameterMap().get("Java");
pars.getSchemaHelperParameterMap().clear();
diff --git a/model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java b/model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
index 9dde47d05..198552bd2 100644
--- a/model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
+++ b/model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021-2022 Nordix Foundation.
+ * Modifications Copyright (C) 2021-2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,8 +38,8 @@ import org.slf4j.ext.XLoggerFactory;
* This class tests reading and writing of Apex models to file and to a database using JPA. It also tests validation of
* Apex models. This class is designed for use in unit tests in modules that define Apex models.
*
- * @author Liam Fallon (liam.fallon@ericsson.com)
* @param <M> the generic type
+ * @author Liam Fallon (liam.fallon@ericsson.com)
*/
public class TestApexModel<M extends AxModel> {
private static final String MODEL_IS_INVALID = "model is invalid ";
@@ -53,14 +53,14 @@ public class TestApexModel<M extends AxModel> {
private final Class<M> rootModelClass;
// The class that provides the model
- private TestApexModelCreator<M> modelCreator = null;
+ private final TestApexModelCreator<M> modelCreator;
/**
* Constructor, defines the subclass of {@link AxModel} that is being tested and the {@link TestApexModelCreator}
* object that is used to generate Apex models.
*
- * @param rootModelClass the Apex model class, a sub class of {@link AxModel}
- * @param modelCreator the @link TestApexModelCreator} that will generate Apex models of various types for testing
+ * @param rootModelClass the Apex model class, a subclass of {@link AxModel}
+ * @param modelCreator {@link TestApexModelCreator} that will generate Apex models of various types for testing
*/
public TestApexModel(final Class<M> rootModelClass, final TestApexModelCreator<M> modelCreator) {
this.rootModelClass = rootModelClass;
@@ -105,7 +105,7 @@ public class TestApexModel<M extends AxModel> {
final var fileModel = modelReader.read(apexModelUrl.openStream());
checkModelEquality(model, fileModel, TEST_MODEL_UNEQUAL_STR + jsonFile.getAbsolutePath());
} catch (final Exception e) {
- LOGGER.warn(ERROR_PROCESSING_FILE + jsonFile.getAbsolutePath(), e);
+ LOGGER.warn(ERROR_PROCESSING_FILE + "{}", jsonFile.getAbsolutePath(), e);
throw new ApexException(ERROR_PROCESSING_FILE + jsonFile.getAbsolutePath(), e);
}
@@ -128,18 +128,18 @@ public class TestApexModel<M extends AxModel> {
* @throws ApexException thrown on errors validating the Apex model
*/
public final AxValidationResult testApexModelValid() throws ApexException {
- LOGGER.debug("running testApexModelVaid . . .");
+ LOGGER.debug("running testApexModelValid . . .");
final var model = modelCreator.getModel();
final AxValidationResult result = model.validate(new AxValidationResult());
if (!result.isValid()) {
- String message = MODEL_IS_INVALID + result.toString();
+ String message = MODEL_IS_INVALID + result;
LOGGER.warn(message);
throw new ApexException(message);
}
- LOGGER.debug("ran testApexModelVaid");
+ LOGGER.debug("ran testApexModelValid");
return result;
}
@@ -149,19 +149,19 @@ public class TestApexModel<M extends AxModel> {
* @return the result of the validation
* @throws ApexException thrown on errors validating the Apex model
*/
- public final AxValidationResult testApexModelVaidateMalstructured() throws ApexException {
- LOGGER.debug("running testApexModelVaidateMalstructured . . .");
+ public final AxValidationResult testApexModelValidateMalstructured() throws ApexException {
+ LOGGER.debug("running testApexModelValidateMalstructured . . .");
final var model = modelCreator.getMalstructuredModel();
final AxValidationResult result = model.validate(new AxValidationResult());
if (result.isValid()) {
- String message = "model should not be valid " + result.toString();
+ String message = "model should not be valid " + result;
LOGGER.warn(message);
throw new ApexException(message);
}
- LOGGER.debug("ran testApexModelVaidateMalstructured");
+ LOGGER.debug("ran testApexModelValidateMalstructured");
return result;
}
@@ -171,8 +171,8 @@ public class TestApexModel<M extends AxModel> {
* @return the result of the validation
* @throws ApexException thrown on errors validating the Apex model
*/
- public final AxValidationResult testApexModelVaidateObservation() throws ApexException {
- LOGGER.debug("running testApexModelVaidateObservation . . .");
+ public final AxValidationResult testApexModelValidateObservation() throws ApexException {
+ LOGGER.debug("running testApexModelValidateObservation . . .");
final var model = modelCreator.getObservationModel();
final AxValidationResult result = model.validate(new AxValidationResult());
@@ -188,7 +188,7 @@ public class TestApexModel<M extends AxModel> {
throw new ApexException("model should have observations");
}
- LOGGER.debug("ran testApexModelVaidateObservation");
+ LOGGER.debug("ran testApexModelValidateObservation");
return result;
}
@@ -198,8 +198,8 @@ public class TestApexModel<M extends AxModel> {
* @return the result of the validation
* @throws ApexException thrown on errors validating the Apex model
*/
- public final AxValidationResult testApexModelVaidateWarning() throws ApexException {
- LOGGER.debug("running testApexModelVaidateWarning . . .");
+ public final AxValidationResult testApexModelValidateWarning() throws ApexException {
+ LOGGER.debug("running testApexModelValidateWarning . . .");
final var model = modelCreator.getWarningModel();
final AxValidationResult result = model.validate(new AxValidationResult());
@@ -215,7 +215,7 @@ public class TestApexModel<M extends AxModel> {
throw new ApexException("model should have warnings");
}
- LOGGER.debug("ran testApexModelVaidateWarning");
+ LOGGER.debug("ran testApexModelValidateWarning");
return result;
}
@@ -225,27 +225,27 @@ public class TestApexModel<M extends AxModel> {
* @return the result of the validation
* @throws ApexException thrown on errors validating the Apex model
*/
- public final AxValidationResult testApexModelVaidateInvalidModel() throws ApexException {
- LOGGER.debug("running testApexModelVaidateInvalidModel . . .");
+ public final AxValidationResult testApexModelValidateInvalidModel() throws ApexException {
+ LOGGER.debug("running testApexModelValidateInvalidModel . . .");
final var model = modelCreator.getInvalidModel();
final AxValidationResult result = model.validate(new AxValidationResult());
if (result.isValid()) {
- String message = "model should not be valid " + result.toString();
+ String message = "model should not be valid " + result;
LOGGER.warn(message);
throw new ApexException(message);
}
- LOGGER.debug("ran testApexModelVaidateInvalidModel");
+ LOGGER.debug("ran testApexModelValidateInvalidModel");
return result;
}
/**
* Check if two models are equal.
*
- * @param leftModel the left model
- * @param rightModel the right model
+ * @param leftModel the left model
+ * @param rightModel the right model
* @param errorMessage the error message to output on inequality
* @throws ApexException the exception to throw on inequality
*/
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java
index 44a9de49e..48db5299a 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,22 +22,22 @@
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import java.util.NavigableMap;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the AxConceptGetterImpl class.
*/
-public class AxConceptGetterImplTest {
+class AxConceptGetterImplTest {
@Test
- public void testAxConceptGetterImpl() {
+ void testAxConceptGetterImpl() {
NavigableMap<AxArtifactKey, AxArtifactKey> keyMap = new TreeMap<>();
AxConceptGetterImpl<AxArtifactKey> getter = new AxConceptGetterImpl<>(keyMap);
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
index 0c7edee28..2e6512527 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2022, 2024 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,26 +21,26 @@
package org.onap.policy.apex.model.basicmodel.concepts;
-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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class AxKeyInfoTest {
+class AxKeyInfoTest {
@Test
- public void testNullAxKeyInfo() {
+ void testNullAxKeyInfo() {
assertNotNull(new AxKeyInfo());
assertNotNull(new AxKeyInfo(new AxArtifactKey()));
assertNotNull(new AxKeyInfo(new AxArtifactKey(), UUID.randomUUID(), "Key description"));
}
@Test
- public void testAxKeyInfo() {
+ void testAxKeyInfo() {
AxKeyInfo testKeyInfo = new AxKeyInfo();
testKeyInfo.setKey((new AxArtifactKey("PN", "0.0.1")));
assertEquals("PN:0.0.1", testKeyInfo.getKey().getId());
@@ -72,14 +72,11 @@ public class AxKeyInfoTest {
assertEquals(testKeyInfo, new AxKeyInfo(key, uuid, "Some Other Description"));
assertEquals(testKeyInfo, new AxKeyInfo(key, uuid, "Key Description"));
- assertEquals(0, testKeyInfo.compareTo(testKeyInfo));
assertEquals(0, testKeyInfo.compareTo(clonedReferenceKey));
-
-
}
@Test
- public void testAxKeyValidation() {
+ void testAxKeyValidation() {
AxKeyInfo testKeyInfo = new AxKeyInfo();
testKeyInfo.setKey((new AxArtifactKey("PN", "0.0.1")));
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
index 010f4b8a3..b181c2d41 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,18 +22,18 @@
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Field;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility;
-public class AxKeyTest {
+class AxKeyTest {
private static AxArtifactKey someKey0;
private static AxArtifactKey someKey1;
@@ -46,8 +46,8 @@ public class AxKeyTest {
/**
* Sets data in Keys for the tests.
*/
- @Before
- public void setKeys() {
+ @BeforeEach
+ void setKeys() {
someKey0 = new AxArtifactKey();
someKey1 = new AxArtifactKey("name", "0.0.1");
someKey2 = new AxArtifactKey(someKey1);
@@ -67,10 +67,10 @@ public class AxKeyTest {
}
@Test
- public void testArtifactKey() {
+ void testArtifactKey() {
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]\"");
+ + "does not match regular expression \"[A-Za-z0-9\\-_\\.]+:[0-9].[0-9].[0-9]\"");
assertEquals(AxArtifactKey.getNullKey(), someKey0);
@@ -92,7 +92,6 @@ public class AxKeyTest {
assertThatThrownBy(() -> someKey0.compareTo(null))
.hasMessage("comparison object may not be null");
- assertEquals(0, someKey0.compareTo(someKey0));
assertEquals(353602977, someKey0.compareTo(new AxReferenceKey()));
assertNotNull(someKey0);
@@ -102,7 +101,7 @@ public class AxKeyTest {
}
@Test
- public void testAxCompatibility() {
+ void testAxCompatibility() {
setKeyValues();
assertEquals(Compatibility.DIFFERENT, someKey0.getCompatibility(new AxReferenceKey()));
@@ -122,27 +121,27 @@ public class AxKeyTest {
}
@Test
- public void testAxValidation() {
+ void testAxValidation() {
setKeyValues();
assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey0.validate(new AxValidationResult()).getValidationResult());
+ someKey0.validate(new AxValidationResult()).getValidationResult());
assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey1.validate(new AxValidationResult()).getValidationResult());
+ someKey1.validate(new AxValidationResult()).getValidationResult());
assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey2.validate(new AxValidationResult()).getValidationResult());
+ someKey2.validate(new AxValidationResult()).getValidationResult());
assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey3.validate(new AxValidationResult()).getValidationResult());
+ someKey3.validate(new AxValidationResult()).getValidationResult());
assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey4.validate(new AxValidationResult()).getValidationResult());
+ someKey4.validate(new AxValidationResult()).getValidationResult());
assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey5.validate(new AxValidationResult()).getValidationResult());
+ someKey5.validate(new AxValidationResult()).getValidationResult());
assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey6.validate(new AxValidationResult()).getValidationResult());
+ someKey6.validate(new AxValidationResult()).getValidationResult());
}
@Test
- public void testNullKey() {
+ void testNullKey() {
setKeyValues();
AxArtifactKey nullKey0 = AxArtifactKey.getNullKey();
@@ -157,7 +156,7 @@ public class AxKeyTest {
@Test
- public void testValidation() throws IllegalArgumentException, IllegalAccessException,
+ void testValidation() throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, SecurityException {
AxArtifactKey testKey = new AxArtifactKey("TheKey", "0.0.1");
assertEquals("TheKey:0.0.1", testKey.getId());
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java
index 5346b6b21..d2c82a89a 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 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,18 +21,18 @@
package org.onap.policy.apex.model.basicmodel.concepts;
-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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility;
-public class AxKeyUseTest {
+class AxKeyUseTest {
@Test
- public void test() {
+ void test() {
assertNotNull(new AxKeyUse());
assertNotNull(new AxKeyUse(new AxArtifactKey()));
assertNotNull(new AxKeyUse(new AxReferenceKey()));
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java
index 515587558..a39756ed6 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,58 +22,28 @@
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Field;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class AxReferenceKeyTest {
+class AxReferenceKeyTest {
@Test
- public void testAxReferenceKey() {
- assertNotNull(new AxReferenceKey());
- assertNotNull(new AxReferenceKey(new AxArtifactKey()));
- assertNotNull(new AxReferenceKey(new AxArtifactKey(), "LocalName"));
- assertNotNull(new AxReferenceKey(new AxReferenceKey()));
- assertNotNull(new AxReferenceKey(new AxReferenceKey(), "LocalName"));
- assertNotNull(new AxReferenceKey(new AxArtifactKey(), "ParentLocalName", "LocalName"));
- assertNotNull(new AxReferenceKey("ParentKeyName", "0.0.1", "LocalName"));
- assertNotNull(new AxReferenceKey("ParentKeyName", "0.0.1", "ParentLocalName", "LocalName"));
- assertNotNull(new AxReferenceKey("ParentKeyName:0.0.1:ParentLocalName:LocalName"));
+ void testAxReferenceKey() {
+ assertConstructor();
assertEquals(AxReferenceKey.getNullKey().getKey(), AxReferenceKey.getNullKey());
assertEquals("NULL:0.0.0:NULL:NULL", AxReferenceKey.getNullKey().getId());
AxReferenceKey testReferenceKey = new AxReferenceKey();
- testReferenceKey.setParentArtifactKey(new AxArtifactKey("PN", "0.0.1"));
- assertEquals("PN:0.0.1", testReferenceKey.getParentArtifactKey().getId());
-
- testReferenceKey.setParentReferenceKey(new AxReferenceKey("PN", "0.0.1", "LN"));
- assertEquals("PN:0.0.1:NULL:LN", testReferenceKey.getParentReferenceKey().getId());
-
- testReferenceKey.setParentKeyName("NPKN");
- assertEquals("NPKN", testReferenceKey.getParentKeyName());
-
- testReferenceKey.setParentKeyVersion("0.0.1");
- assertEquals("0.0.1", testReferenceKey.getParentKeyVersion());
-
- testReferenceKey.setParentLocalName("NPKLN");
- assertEquals("NPKLN", testReferenceKey.getParentLocalName());
+ assertSetValues(testReferenceKey);
- testReferenceKey.setLocalName("NLN");
- assertEquals("NLN", testReferenceKey.getLocalName());
-
- assertFalse(testReferenceKey.isCompatible(AxArtifactKey.getNullKey()));
- assertFalse(testReferenceKey.isCompatible(AxReferenceKey.getNullKey()));
- assertTrue(testReferenceKey.isCompatible(testReferenceKey));
-
- assertEquals(AxKey.Compatibility.DIFFERENT, testReferenceKey.getCompatibility(AxArtifactKey.getNullKey()));
- assertEquals(AxKey.Compatibility.DIFFERENT, testReferenceKey.getCompatibility(AxReferenceKey.getNullKey()));
- assertEquals(AxKey.Compatibility.IDENTICAL, testReferenceKey.getCompatibility(testReferenceKey));
+ assertCompatibility(testReferenceKey);
AxValidationResult result = new AxValidationResult();
result = testReferenceKey.validate(result);
@@ -96,6 +66,16 @@ public class AxReferenceKeyTest {
assertNotEquals(testReferenceKey, new AxReferenceKey("NPKN", "0.0.1", "NPLN", "LN"));
assertEquals(testReferenceKey, new AxReferenceKey("NPKN", "0.0.1", "NPKLN", "NLN"));
+ assertCompareTo(testReferenceKey, clonedReferenceKey);
+
+ assertNotNull(testReferenceKey.getKeys());
+
+ assertExceptions(testReferenceKey);
+ AxReferenceKey targetRefKey = new AxReferenceKey();
+ assertEquals(testReferenceKey, testReferenceKey.copyTo(targetRefKey));
+ }
+
+ private static void assertCompareTo(AxReferenceKey testReferenceKey, AxReferenceKey clonedReferenceKey) {
assertEquals(0, testReferenceKey.compareTo(testReferenceKey));
assertEquals(0, testReferenceKey.compareTo(clonedReferenceKey));
assertNotEquals(0, testReferenceKey.compareTo(new AxArtifactKey()));
@@ -104,9 +84,9 @@ public class AxReferenceKeyTest {
assertNotEquals(0, testReferenceKey.compareTo(new AxReferenceKey("NPKN", "0.0.1", "PLN", "LN")));
assertNotEquals(0, testReferenceKey.compareTo(new AxReferenceKey("NPKN", "0.0.1", "NPLN", "LN")));
assertEquals(0, testReferenceKey.compareTo(new AxReferenceKey("NPKN", "0.0.1", "NPKLN", "NLN")));
+ }
- assertNotNull(testReferenceKey.getKeys());
-
+ private static void assertExceptions(AxReferenceKey testReferenceKey) {
assertThatThrownBy(() -> testReferenceKey.equals(null))
.hasMessage("comparison object may not be null");
assertThatThrownBy(() -> testReferenceKey.copyTo(null))
@@ -114,12 +94,52 @@ public class AxReferenceKeyTest {
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));
+ }
+
+ private static void assertCompatibility(AxReferenceKey testReferenceKey) {
+ assertFalse(testReferenceKey.isCompatible(AxArtifactKey.getNullKey()));
+ assertFalse(testReferenceKey.isCompatible(AxReferenceKey.getNullKey()));
+ assertTrue(testReferenceKey.isCompatible(testReferenceKey));
+
+ assertEquals(AxKey.Compatibility.DIFFERENT, testReferenceKey.getCompatibility(AxArtifactKey.getNullKey()));
+ assertEquals(AxKey.Compatibility.DIFFERENT, testReferenceKey.getCompatibility(AxReferenceKey.getNullKey()));
+ assertEquals(AxKey.Compatibility.IDENTICAL, testReferenceKey.getCompatibility(testReferenceKey));
+ }
+
+ private static void assertSetValues(AxReferenceKey testReferenceKey) {
+ testReferenceKey.setParentArtifactKey(new AxArtifactKey("PN", "0.0.1"));
+ assertEquals("PN:0.0.1", testReferenceKey.getParentArtifactKey().getId());
+
+ testReferenceKey.setParentReferenceKey(new AxReferenceKey("PN", "0.0.1", "LN"));
+ assertEquals("PN:0.0.1:NULL:LN", testReferenceKey.getParentReferenceKey().getId());
+
+ testReferenceKey.setParentKeyName("NPKN");
+ assertEquals("NPKN", testReferenceKey.getParentKeyName());
+
+ testReferenceKey.setParentKeyVersion("0.0.1");
+ assertEquals("0.0.1", testReferenceKey.getParentKeyVersion());
+
+ testReferenceKey.setParentLocalName("NPKLN");
+ assertEquals("NPKLN", testReferenceKey.getParentLocalName());
+
+ testReferenceKey.setLocalName("NLN");
+ assertEquals("NLN", testReferenceKey.getLocalName());
+ }
+
+ private static void assertConstructor() {
+ assertNotNull(new AxReferenceKey());
+ assertNotNull(new AxReferenceKey(new AxArtifactKey()));
+ assertNotNull(new AxReferenceKey(new AxArtifactKey(), "LocalName"));
+ assertNotNull(new AxReferenceKey(new AxReferenceKey()));
+ assertNotNull(new AxReferenceKey(new AxReferenceKey(), "LocalName"));
+ assertNotNull(new AxReferenceKey(new AxArtifactKey(), "ParentLocalName", "LocalName"));
+ assertNotNull(new AxReferenceKey("ParentKeyName", "0.0.1", "LocalName"));
+ assertNotNull(new AxReferenceKey("ParentKeyName", "0.0.1", "ParentLocalName", "LocalName"));
+ assertNotNull(new AxReferenceKey("ParentKeyName:0.0.1:ParentLocalName:LocalName"));
}
@Test
- public void testValidation() throws IllegalArgumentException, IllegalAccessException,
+ void testValidation() throws IllegalArgumentException, IllegalAccessException,
NoSuchFieldException, SecurityException {
AxReferenceKey testReferenceKey = new AxReferenceKey();
testReferenceKey.setParentArtifactKey(new AxArtifactKey("PN", "0.0.1"));
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ExceptionsTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ExceptionsTest.java
index ff87bc2d0..921b406b0 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ExceptionsTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ExceptionsTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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,32 +21,24 @@
package org.onap.policy.apex.model.basicmodel.concepts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ExceptionsTest {
+class ExceptionsTest {
@Test
- public void test() {
- assertNotNull(new ApexException("Message"));
- assertNotNull(new ApexException("Message", new AxArtifactKey()));
- assertNotNull(new ApexException("Message", new IOException()));
- assertNotNull(new ApexException("Message", new IOException(), new AxArtifactKey()));
+ void test() {
+ assertConstructors();
AxArtifactKey key = new AxArtifactKey();
ApexException ae = new ApexException("Message", new IOException("IO exception message"), key);
assertEquals("Message\ncaused by: Message\ncaused by: IO exception message", ae.getCascadedMessage());
assertEquals(key, ae.getObject());
- assertNotNull(new ApexRuntimeException("Message"));
- assertNotNull(new ApexRuntimeException("Message", new AxArtifactKey()));
- assertNotNull(new ApexRuntimeException("Message", new IOException()));
- assertNotNull(new ApexRuntimeException("Message", new IOException(), new AxArtifactKey()));
-
AxArtifactKey rkey = new AxArtifactKey();
ApexRuntimeException re = new ApexRuntimeException("Runtime Message",
new IOException("IO runtime exception message"), rkey);
@@ -53,9 +46,6 @@ public class ExceptionsTest {
re.getCascadedMessage());
assertEquals(key, re.getObject());
- assertNotNull(new ApexConceptException("Message"));
- assertNotNull(new ApexConceptException("Message", new IOException()));
-
AxArtifactKey ckey = new AxArtifactKey();
ApexException ace = new ApexException("Concept Message", new IOException("IO concept exception message"), ckey);
assertEquals("Concept Message\ncaused by: Concept Message\ncaused by: IO concept exception message",
@@ -63,4 +53,19 @@ public class ExceptionsTest {
assertEquals(ckey, ace.getObject());
}
+ private static void assertConstructors() {
+ assertNotNull(new ApexException("Message"));
+ assertNotNull(new ApexException("Message", new AxArtifactKey()));
+ assertNotNull(new ApexException("Message", new IOException()));
+ assertNotNull(new ApexException("Message", new IOException(), new AxArtifactKey()));
+
+ assertNotNull(new ApexRuntimeException("Message"));
+ assertNotNull(new ApexRuntimeException("Message", new AxArtifactKey()));
+ assertNotNull(new ApexRuntimeException("Message", new IOException()));
+ assertNotNull(new ApexRuntimeException("Message", new IOException(), new AxArtifactKey()));
+
+ assertNotNull(new ApexConceptException("Message"));
+ assertNotNull(new ApexConceptException("Message", new IOException()));
+ }
+
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ValidationTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ValidationTest.java
index 21ae9b65c..c5ed19ff3 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ValidationTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ValidationTest.java
@@ -1,90 +1,93 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-public class ValidationTest {
+class ValidationTest {
@Test
- public void test() {
+ void testValid() {
AxValidationResult result = new AxValidationResult();
AxReferenceKey refKey = new AxReferenceKey("PK", "0.0.1", "PLN", "LN");
result = refKey.validate(result);
-
- assertNotNull(result);
- assertTrue(result.isOk());
- assertTrue(result.isValid());
- assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult());
- assertNotNull(result.getMessageList());
+ assertResultIsValid(result, ValidationResult.VALID);
AxValidationMessage vmess0 = new AxValidationMessage(AxArtifactKey.getNullKey(), AxArtifactKey.class,
- ValidationResult.VALID, "Some message");
+ ValidationResult.VALID, "Some message");
result.addValidationMessage(vmess0);
-
- assertTrue(result.isOk());
- assertTrue(result.isValid());
- assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult());
- assertNotNull(result.getMessageList());
- assertNotNull("hello", result.toString());
+ assertResultIsValid(result, ValidationResult.VALID);
AxValidationMessage vmess1 = new AxValidationMessage(AxArtifactKey.getNullKey(), AxArtifactKey.class,
- ValidationResult.OBSERVATION, "Some message");
+ ValidationResult.OBSERVATION, "Some message");
result.addValidationMessage(vmess1);
+ assertResultIsValid(result, ValidationResult.OBSERVATION);
+ }
- assertTrue(result.isOk());
- assertTrue(result.isValid());
- assertEquals(AxValidationResult.ValidationResult.OBSERVATION, result.getValidationResult());
- assertNotNull(result.getMessageList());
- assertNotNull("hello", result.toString());
-
+ @Test
+ void testWarning() {
+ AxValidationResult result = new AxValidationResult();
AxValidationMessage vmess2 = new AxValidationMessage(AxArtifactKey.getNullKey(), AxArtifactKey.class,
- ValidationResult.WARNING, "Some message");
+ ValidationResult.WARNING, "Some message");
result.addValidationMessage(vmess2);
assertFalse(result.isOk());
assertTrue(result.isValid());
assertEquals(AxValidationResult.ValidationResult.WARNING, result.getValidationResult());
assertNotNull(result.getMessageList());
- assertNotNull("hello", result.toString());
+ assertNotNull(result.toString());
+ }
+ @Test
+ void testInvalid() {
+ AxValidationResult result = new AxValidationResult();
AxValidationMessage vmess3 = new AxValidationMessage(AxArtifactKey.getNullKey(), AxArtifactKey.class,
- ValidationResult.INVALID, "Some message");
+ ValidationResult.INVALID, "Some message");
result.addValidationMessage(vmess3);
assertFalse(result.isOk());
assertFalse(result.isValid());
assertEquals(AxValidationResult.ValidationResult.INVALID, result.getValidationResult());
assertNotNull(result.getMessageList());
- assertNotNull("hello", result.toString());
+ assertNotNull(result.toString());
- assertEquals(AxValidationResult.ValidationResult.INVALID, result.getMessageList().get(3).getValidationResult());
- assertEquals("Some message", result.getMessageList().get(3).getMessage());
- assertEquals(AxArtifactKey.class.getName(), result.getMessageList().get(3).getObservedClass());
- assertEquals(AxArtifactKey.getNullKey(), result.getMessageList().get(3).getObservedKey());
+ var otherResult = result.getMessageList().get(0);
+ assertEquals(AxValidationResult.ValidationResult.INVALID, otherResult.getValidationResult());
+ assertEquals("Some message", otherResult.getMessage());
+ assertEquals(AxArtifactKey.class.getName(), otherResult.getObservedClass());
+ assertEquals(AxArtifactKey.getNullKey(), otherResult.getObservedKey());
+ }
+
+ private static void assertResultIsValid(AxValidationResult result, ValidationResult valid) {
+ assertNotNull(result);
+ assertTrue(result.isOk());
+ assertTrue(result.isValid());
+ assertEquals(valid, result.getValidationResult());
+ assertNotNull(result.getMessageList());
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelExceptionTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelExceptionTest.java
index 2571ea65b..badb57ac6 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelExceptionTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelExceptionTest.java
@@ -1,35 +1,36 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ApexModelExceptionTest {
+class ApexModelExceptionTest {
@Test
- public void test() {
+ void test() {
assertNotNull(new ApexModelException("Message"));
assertNotNull(new ApexModelException("Message", new IOException()));
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
index 0f8f956ab..12bbd99d3 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,18 +22,18 @@
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.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-public class ApexModelFileWriterTest {
+class ApexModelFileWriterTest {
@Test
- public void testModelFileWriter() throws IOException, ApexException {
+ void testModelFileWriter() throws IOException, ApexException {
ApexModelFileWriter<AxModel> modelFileWriter = new ApexModelFileWriter<>(true);
modelFileWriter.setValidate(true);
@@ -48,25 +48,20 @@ public class ApexModelFileWriterTest {
modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- jsonTempFile.delete();
- new File(tempDir.getAbsolutePath() + "/aaa").delete();
- new File(tempDir.getAbsolutePath() + "/ccc").delete();
+ assertFileDeleted(jsonTempFile);
+ assertFileDeleted(new File(tempDir.getAbsolutePath() + "/aaa"));
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- jsonTempFile.delete();
+ assertFileDeleted(jsonTempFile);
- new File(tempDir.getAbsolutePath() + "/aaa/bbb").delete();
- new File(tempDir.getAbsolutePath() + "/aaa").delete();
- new File(tempDir.getAbsolutePath() + "/ccc/ddd").delete();
- new File(tempDir.getAbsolutePath() + "/ccc").delete();
+ assertFileDeleted(new File(tempDir.getAbsolutePath() + "/aaa/bbb"));
+ assertFileDeleted(new File(tempDir.getAbsolutePath() + "/aaa"));
File dirA = new File(tempDir.getAbsolutePath() + "/aaa");
- // File dirB = new File(tempDir.getAbsolutePath() + "/aaa/bbb");
- dirA.createNewFile();
- // dirB.createNewFile();
+ assertTrue(dirA.createNewFile());
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
final File jsonTempFile01 = jsonTempFile;
@@ -74,12 +69,12 @@ public class ApexModelFileWriterTest {
() -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile01.getAbsolutePath()))
.hasMessageContaining("could not create directory");
- dirA.delete();
+ assertFileDeleted(dirA);
dirA = new File(tempDir.getAbsolutePath() + "/aaa");
File fileB = new File(tempDir.getAbsolutePath() + "/aaa/bbb");
- dirA.mkdir();
- fileB.createNewFile();
+ assertTrue(dirA.mkdir());
+ assertTrue(fileB.createNewFile());
jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
@@ -88,7 +83,11 @@ public class ApexModelFileWriterTest {
() -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile02.getAbsolutePath()))
.hasMessageContaining("error processing file");
- fileB.delete();
- dirA.delete();
+ assertFileDeleted(fileB);
+ assertFileDeleted(dirA);
+ }
+
+ private void assertFileDeleted(File file) {
+ assertTrue(file.delete());
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
index ae14702ef..4744731a7 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022-2023 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2022-2024 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,9 +23,9 @@
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -34,20 +34,21 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-@RunWith(MockitoJUnitRunner.class)
-public class ApexModelReaderTest {
+@ExtendWith(MockitoExtension.class)
+class ApexModelReaderTest {
+
@Test
- public void testModelReader() throws IOException, ApexException {
+ void testModelReader() throws IOException, ApexException {
AxModel model = new DummyApexBasicModelCreator().getModel();
AxModel invalidModel = new DummyApexBasicModelCreator().getInvalidModel();
- ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
+ ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<>(AxModel.class);
modelWriter.setValidate(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -57,7 +58,7 @@ public class ApexModelReaderTest {
modelWriter.setValidate(false);
modelWriter.write(invalidModel, baosInvalid);
- ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class, true);
+ ApexModelReader<AxModel> modelReader = new ApexModelReader<>(AxModel.class, true);
modelReader.setValidate(true);
assertTrue(modelReader.isValidate());
@@ -87,19 +88,17 @@ public class ApexModelReaderTest {
ByteArrayInputStream baisDummy = new ByteArrayInputStream(dummyString.getBytes());
assertThatThrownBy(() -> modelReader.read(baisDummy))
.hasMessageContaining("Unable to unmarshal Apex concept");
- ByteArrayInputStream nullBais = null;
- assertThatThrownBy(() -> modelReader.read(nullBais))
+ assertThatThrownBy(() -> modelReader.read((java.io.InputStream) null))
.hasMessage("concept stream may not be null");
assertThatThrownBy(() -> {
- FileInputStream fis = new FileInputStream(new File("somewhere/over/the/rainbow"));
+ FileInputStream fis = new FileInputStream("somewhere/over/the/rainbow");
modelReader.read(fis);
}).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();
+ assertThatThrownBy(() -> modelReader.read(br)).hasMessage("Unable to read Apex concept ");
+ assertTrue(tempFile.delete());
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
index c95106aa8..53fa1062e 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2022, 2024 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,20 +21,20 @@
package org.onap.policy.apex.model.basicmodel.handling;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-public class ApexModelSaverTest {
+class ApexModelSaverTest {
@Test
- public void testModelSaver() throws IOException, ApexException {
+ void testModelSaver() throws IOException, ApexException {
AxModel model = new DummyApexBasicModelCreator().getModel();
assertNotNull(model);
@@ -42,7 +42,7 @@ public class ApexModelSaverTest {
assertNotNull(tempPath);
ApexModelSaver<AxModel> modelSaver =
- new ApexModelSaver<AxModel>(AxModel.class, model, tempPath.toAbsolutePath().toString());
+ new ApexModelSaver<>(AxModel.class, model, tempPath.toAbsolutePath().toString());
assertNotNull(modelSaver);
modelSaver.apexModelWriteJson();
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
index 13e72d3e2..1c13d9d5b 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,19 +22,18 @@
package org.onap.policy.apex.model.basicmodel.handling;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-public class ApexModelStringWriterTest {
+class ApexModelStringWriterTest {
@Test
- public void testModelStringWriter() throws IOException, ApexException {
+ void testModelStringWriter() throws ApexException {
AxModel basicModel = new DummyApexBasicModelCreator().getModel();
assertNotNull(basicModel);
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
index 3d59652b7..55f4975d0 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022-2023 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2022-2024 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,21 +23,21 @@
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.jupiter.api.Assertions.assertTrue;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
@ExtendWith(MockitoExtension.class)
-public class ApexModelWriterTest {
+class ApexModelWriterTest {
+
@Test
- public void testModelWriter() throws IOException, ApexException {
- ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
+ void testModelWriter() throws ApexException {
+ ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<>(AxModel.class);
modelWriter.setValidate(true);
assertTrue(modelWriter.isValidate());
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyAxModelWithReferences.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyAxModelWithReferences.java
index 887755d03..7a1ab82f7 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyAxModelWithReferences.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyAxModelWithReferences.java
@@ -1,41 +1,47 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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 java.io.Serial;
import java.util.ArrayList;
import java.util.List;
+import lombok.Getter;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
+@Getter
public class DummyAxModelWithReferences extends AxModel {
+
+ @Serial
private static final long serialVersionUID = -8194956638511120008L;
- private List<AxKey> extrakeyList = new ArrayList<>();
-
+ private final List<AxKey> extrakeyList = new ArrayList<>();
+
public DummyAxModelWithReferences(final AxArtifactKey key) {
super(key);
}
-
+
@Override
public List<AxKey> getKeys() {
List<AxKey> keys = super.getKeys();
@@ -44,27 +50,23 @@ public class DummyAxModelWithReferences extends AxModel {
return keys;
}
- public List<AxKey> getExtrakeyList() {
- return extrakeyList;
- }
-
/**
* Set the reference key list.
*/
public void setReferenceKeyList() {
List<AxKey> keys = super.getKeys();
-
- for (AxKey key: keys) {
+
+ for (AxKey key : keys) {
AxArtifactKey akey = (AxArtifactKey) key;
AxReferenceKey keyRef = new AxReferenceKey(akey, akey.getName());
extrakeyList.add(keyRef);
}
}
-
+
public void addKey(final AxKey akey) {
extrakeyList.add(akey);
}
-
+
public void removeKey(final AxKey akey) {
extrakeyList.remove(akey);
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java
index 905a27f38..d75834547 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2024 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,15 +21,15 @@
package org.onap.policy.apex.model.basicmodel.handling;
-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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
@@ -42,16 +42,16 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
-public class SupportApexBasicModelConceptsTest {
+class SupportApexBasicModelConceptsTest {
TestApexModel<AxModel> testApexModel;
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxModel>(AxModel.class, new DummyApexBasicModelCreator());
+ @BeforeEach
+ void setup() {
+ testApexModel = new TestApexModel<>(AxModel.class, new DummyApexBasicModelCreator());
}
@Test
- public void testModelConcepts() {
+ void testModelConcepts() {
final AxModel model = testApexModel.getModel();
assertNotNull(model);
model.clean();
@@ -94,7 +94,7 @@ public class SupportApexBasicModelConceptsTest {
}
@Test
- public void testKeyInformation() {
+ void testKeyInformation() {
final AxModel model = testApexModel.getModel();
final AxKeyInformation keyI = model.getKeyInformation();
@@ -147,11 +147,11 @@ public class SupportApexBasicModelConceptsTest {
}
@Test
- public void testClonedKey() {
+ void testClonedKey() {
final AxModel model = testApexModel.getModel();
final AxKeyInformation keyI = model.getKeyInformation();
final AxKeyInformation clonedKeyI = new AxKeyInformation(keyI);
- AxValidationResult result = new AxValidationResult();
+ AxValidationResult result;
clonedKeyI.setKey(AxArtifactKey.getNullKey());
result = new AxValidationResult();
@@ -217,7 +217,7 @@ public class SupportApexBasicModelConceptsTest {
}
@Test
- public void testModelConceptsWithReferences() {
+ void testModelConceptsWithReferences() {
final DummyAxModelWithReferences mwr = new DummyApexBasicModelCreator().getModelWithReferences();
assertNotNull(mwr);
mwr.getKeyInformation().getKeyInfoMap().clear();
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
index 68f755886..8c1f756c1 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,95 +22,71 @@
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.jupiter.api.Assertions.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
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.test.TestApexModel;
+import org.onap.policy.common.utils.resources.ResourceUtils;
-public class SupportApexBasicModelTest {
- // As there are no real concepts in a basic model, this is as near to a valid model as we can get
- private static final String VALID_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n"
- + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n" + "********************************";
-
- private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n"
- + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n"
- + "AxArtifactKey:(name=Unref0,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n"
- + "AxArtifactKey:(name=Unref1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts"
- + ".AxModel:WARNING:key not found for key information entry\n" + "********************************";
+class SupportApexBasicModelTest {
- private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInfo:OBSERVATION:description is blank\n"
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInformation:INVALID:duplicate UUID found on keyInfoMap entry AxArtifactKey:"
- + "(name=KeyInfoMapKey,version=0.0.1):00000000-0000-0000-0000-000000000000\n"
- + "********************************";
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts."
- + "AxModel:INVALID:key information not found for key "
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)\n" + "********************************";
+ // As there are no real concepts in a basic model, this is as near to a valid model as we can get
+ private static final String VALID_MODEL_STRING = "basicmodel/handling/SupportApexBasicModelTest_ValidModel.txt";
+ private static final String WARNING_MODEL_STRING = "basicmodel/handling/SupportApexBasicModelTest_WarningModel.txt";
+ private static final String INVALID_MODEL_STRING = "basicmodel/handling/SupportApexBasicModelTest_InvalidModel.txt";
+ private static final String INVALID_MODEL_MALSTRUCTURED_STRING =
+ "basicmodel/handling/SupportApexBasicModelTest_InvalidModelMalStructured.txt";
TestApexModel<AxModel> testApexModel;
/**
* Set up the test.
- *
- * @throws Exception any exception thrown by the test
*/
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxModel>(AxModel.class, new DummyApexBasicModelCreator());
+ @BeforeEach
+ void setup() {
+ testApexModel = new TestApexModel<>(AxModel.class, new DummyApexBasicModelCreator());
}
@Test
- public void testModelValid() throws Exception {
+ void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
- assertEquals(VALID_MODEL_STRING, result.toString());
+ var expectedResult = ResourceUtils.getResourceAsString(VALID_MODEL_STRING);
+ assertEquals(expectedResult, result.toString());
}
@Test
- public void testApexModelVaidateObservation() throws Exception {
- assertThatThrownBy(testApexModel::testApexModelVaidateObservation)
+ void testApexModelValidateObservation() {
+ assertThatThrownBy(testApexModel::testApexModelValidateObservation)
.hasMessage("model should have observations");
}
@Test
- public void testApexModelVaidateWarning() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertEquals(WARNING_MODEL_STRING, result.toString());
+ void testApexModelValidateWarning() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateWarning();
+ var expectedResult = ResourceUtils.getResourceAsString(WARNING_MODEL_STRING);
+ assertEquals(expectedResult, result.toString());
}
@Test
- public void testModelVaidateInvalidModel() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertEquals(INVALID_MODEL_STRING, result.toString());
+ void testModelValidateInvalidModel() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel();
+ var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_STRING);
+ assertEquals(expectedResult, result.toString());
}
@Test
- public void testModelVaidateMalstructured() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
+ void testModelValidateMalstructured() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateMalstructured();
+ var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING);
+ assertEquals(expectedResult, result.toString());
}
@Test
- public void testModelWriteReadJson() throws Exception {
+ void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
index d55a9da29..17a7f451e 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2022 Nordix Foundation
+ * Modifications Copyright (C) 2020-2022, 2024 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,33 +23,33 @@ package org.onap.policy.apex.model.basicmodel.handling;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.Test;
+import org.junit.jupiter.api.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.test.TestApexModel;
-public class SupportBasicModelTest {
+class SupportBasicModelTest {
@Test
- public void testNormalModelCreator() throws ApexException {
- final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
+ void testNormalModelCreator() throws ApexException {
+ final TestApexModel<AxModel> testApexModel = new TestApexModel<>(AxModel.class,
new DummyApexBasicModelCreator());
testApexModel.testApexModelValid();
- assertThatThrownBy(testApexModel::testApexModelVaidateObservation)
+ assertThatThrownBy(testApexModel::testApexModelValidateObservation)
.hasMessage("model should have observations");
- testApexModel.testApexModelVaidateWarning();
- testApexModel.testApexModelVaidateInvalidModel();
- testApexModel.testApexModelVaidateMalstructured();
+ testApexModel.testApexModelValidateWarning();
+ testApexModel.testApexModelValidateInvalidModel();
+ testApexModel.testApexModelValidateMalstructured();
testApexModel.testApexModelWriteReadJson();
}
@Test
- public void testModelsUnequal() throws ApexException {
- final TestApexModel<AxModel> testApexModel0 = new TestApexModel<AxModel>(AxModel.class,
+ void testModelsUnequal() {
+ final TestApexModel<AxModel> testApexModel0 = new TestApexModel<>(AxModel.class,
new DummyApexBasicModelCreator());
- final TestApexModel<AxModel> testApexModel1 = new TestApexModel<AxModel>(AxModel.class,
+ final TestApexModel<AxModel> testApexModel1 = new TestApexModel<>(AxModel.class,
new DummyApexBasicModelCreator());
testApexModel1.getModel().getKey().setVersion("0.0.2");
@@ -59,53 +59,53 @@ public class SupportBasicModelTest {
}
@Test
- public void testModelCreator0() throws ApexException {
- final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
+ void testModelCreator0() throws ApexException {
+ final TestApexModel<AxModel> testApexModel = new TestApexModel<>(AxModel.class,
new SupportApexModelCreator0());
testApexModel.testApexModelValid();
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateObservation())
+ assertThatThrownBy(testApexModel::testApexModelValidateObservation)
.hasMessage("model should have observations");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateWarning())
+ assertThatThrownBy(testApexModel::testApexModelValidateWarning)
.hasMessage("model should have warnings");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateInvalidModel())
+ assertThatThrownBy(testApexModel::testApexModelValidateInvalidModel)
.hasMessage("model should not be valid ***validation of model successful***");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateMalstructured())
+ assertThatThrownBy(testApexModel::testApexModelValidateMalstructured)
.hasMessage("model should not be valid ***validation of model successful***");
}
@Test
- public void testModelCreator1() throws ApexException {
+ void testModelCreator1() throws ApexException {
final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
new SupportApexModelCreator1());
- assertThatThrownBy(() -> testApexModel.testApexModelValid())
+ assertThatThrownBy(testApexModel::testApexModelValid)
.hasMessageStartingWith("model is invalid");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateObservation())
+ assertThatThrownBy(testApexModel::testApexModelValidateObservation)
.hasMessageStartingWith("model is invalid");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateWarning())
+ assertThatThrownBy(testApexModel::testApexModelValidateWarning)
.hasMessageStartingWith("model is invalid");
- testApexModel.testApexModelVaidateInvalidModel();
- testApexModel.testApexModelVaidateMalstructured();
+ testApexModel.testApexModelValidateInvalidModel();
+ testApexModel.testApexModelValidateMalstructured();
}
@Test
- public void testModelCreator2() throws ApexException {
- final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
+ void testModelCreator2() throws ApexException {
+ final TestApexModel<AxModel> testApexModel = new TestApexModel<>(AxModel.class,
new SupportApexModelCreator2());
testApexModel.testApexModelValid();
- testApexModel.testApexModelVaidateObservation();
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateWarning())
+ testApexModel.testApexModelValidateObservation();
+ assertThatThrownBy(testApexModel::testApexModelValidateWarning)
.hasMessage("model should have warnings");
}
@Test
- public void testModelCreator1Json() throws ApexException {
- final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
+ void testModelCreator1Json() {
+ final TestApexModel<AxModel> testApexModel = new TestApexModel<>(AxModel.class,
new SupportApexModelCreator1());
- assertThatThrownBy(() -> testApexModel.testApexModelWriteReadJson())
+ assertThatThrownBy(testApexModel::testApexModelWriteReadJson)
.hasMessageStartingWith("error processing file");
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
index 1783fc00f..9d83ed84c 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2022, 2024 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,21 +21,22 @@
package org.onap.policy.apex.model.basicmodel.handling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-public class SupportConceptGetterTest {
+class SupportConceptGetterTest {
private static final AxKeyInfo intKI01 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey01", "0.0.1"),
UUID.randomUUID(), "IntegerKIKey01 description");
@@ -109,7 +110,7 @@ public class SupportConceptGetterTest {
UUID.randomUUID(), "IntegerKIKey93 description");
@Test
- public void testConceptGetterInteger() {
+ void testConceptGetterInteger() {
AxModel basicModel = setTestBasicModel();
assertNull(basicModel.getKeyInformation().get("NonExistantKey", "0.0.6"));
@@ -133,7 +134,7 @@ public class SupportConceptGetterTest {
}
@Test
- public void testConceptGetterFloat() {
+ void testConceptGetterFloat() {
AxModel basicModel = setTestBasicModel();
assertEquals(floatKI01, basicModel.getKeyInformation().get("FloatKIKey01"));
@@ -149,12 +150,12 @@ public class SupportConceptGetterTest {
}
@Test
- public void testMarshalling() throws IOException, ApexException {
+ void testMarshalling() throws IOException, ApexException {
AxModel basicModel = setTestBasicModel();
// Ensure marshalling and unmarshalling is OK
- ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class);
- ApexModelFileWriter<AxModel> modelWriter = new ApexModelFileWriter<AxModel>(true);
+ ApexModelReader<AxModel> modelReader = new ApexModelReader<>(AxModel.class);
+ ApexModelFileWriter<AxModel> modelWriter = new ApexModelFileWriter<>(true);
modelReader.setValidate(false);
modelWriter.setValidate(false);
@@ -168,7 +169,7 @@ public class SupportConceptGetterTest {
assertEquals(basicModel, readJsonModel);
assertEquals(intKI91, readJsonModel.getKeyInformation().get("IntegerKIKey91"));
assertNotNull(readJsonModel.getKeyInformation().get("FloatKIKey"));
- tempJsonFile.delete();
+ assertTrue(tempJsonFile.delete());
}
private AxModel setTestBasicModel() {
diff --git a/model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java b/model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java
index 746e10607..7c2aa9faf 100644
--- a/model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,26 +22,26 @@
package org.onap.policy.apex.model.basicmodel.service;
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;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
import org.onap.policy.apex.model.basicmodel.handling.DummyApexBasicModelCreator;
-public class ModelServiceTest {
+class ModelServiceTest {
@Test
- public void testModelService() {
+ void testModelService() {
ModelService.clear();
assertFalse(ModelService.existsModel(AxKeyInformation.class));
assertThatThrownBy(() -> ModelService.getModel(AxKeyInformation.class))
.hasMessage("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
- + "not found in model service");
+ + "not found in model service");
ModelService.registerModel(AxKeyInformation.class,
- new DummyApexBasicModelCreator().getModel().getKeyInformation());
+ new DummyApexBasicModelCreator().getModel().getKeyInformation());
assertTrue(ModelService.existsModel(AxKeyInformation.class));
assertNotNull(ModelService.getModel(AxKeyInformation.class));
@@ -50,9 +50,9 @@ public class ModelServiceTest {
assertFalse(ModelService.existsModel(AxKeyInformation.class));
assertThatThrownBy(() -> ModelService.getModel(AxKeyInformation.class))
.hasMessage("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
- + "not found in model service");
+ + "not found in model service");
ModelService.registerModel(AxKeyInformation.class,
- new DummyApexBasicModelCreator().getModel().getKeyInformation());
+ new DummyApexBasicModelCreator().getModel().getKeyInformation());
assertTrue(ModelService.existsModel(AxKeyInformation.class));
assertNotNull(ModelService.getModel(AxKeyInformation.class));
@@ -60,6 +60,6 @@ public class ModelServiceTest {
assertFalse(ModelService.existsModel(AxKeyInformation.class));
assertThatThrownBy(() -> ModelService.getModel(AxKeyInformation.class))
.hasMessage("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
- + "not found in model service");
+ + "not found in model service");
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java b/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
index 44161b329..ab1275c96 100644
--- a/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,11 +24,13 @@ package org.onap.policy.apex.model.contextmodel.concepts;
import static org.assertj.core.api.Assertions.assertThat;
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
@@ -38,17 +40,17 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ContextAlbumsTest {
+class ContextAlbumsTest {
@Test
- public void testNewAxContectAlbum() {
+ void testNewAxContextAlbum() {
assertNotNull(new AxContextAlbum());
assertNotNull(new AxContextAlbum(new AxArtifactKey()));
assertNotNull(new AxContextAlbum(new AxArtifactKey(), "AlbumScope", false, new AxArtifactKey()));
}
@Test
- public void testContextAlbums() {
+ void testContextAlbums() {
final AxArtifactKey albumKey = new AxArtifactKey("AlbumName", "0.0.1");
final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
@@ -63,14 +65,14 @@ public class ContextAlbumsTest {
assertThatThrownBy(() -> album.setScope(""))
.hasMessage("parameter \"scope\": value \"\", does not match regular expression "
- + "\"[A-Za-z0-9\\-_]+\"");
+ + "\"[A-Za-z0-9\\-_]+\"");
album.setScope("NewAlbumScope");
assertEquals("NewAlbumScope", album.getScope());
- assertEquals(false, album.isWritable());
+ assertFalse(album.isWritable());
album.setWritable(true);
- assertEquals(true, album.isWritable());
+ assertTrue(album.isWritable());
final AxArtifactKey newSchemaKey = new AxArtifactKey("NewAlbumSchemaName", "0.0.1");
album.setItemSchema(newSchemaKey);
@@ -91,7 +93,7 @@ public class ContextAlbumsTest {
}
@Test
- public void testAxvalidationAlbum() {
+ void testAxValidationAlbum() {
final AxContextAlbum album = setTestAlbum();
AxValidationResult result = new AxValidationResult();
result = album.validate(result);
@@ -132,7 +134,7 @@ public class ContextAlbumsTest {
}
@Test
- public void testEqualsAlbum() {
+ void testEqualsAlbum() {
final AxContextAlbum album = setTestAlbum();
final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
@@ -140,8 +142,8 @@ public class ContextAlbumsTest {
final AxContextAlbum clonedAlbum = new AxContextAlbum(album);
assertEquals("AxContextAlbum(key=AxArtifactKey:(name=NewAlbumName,version=0.0.1), "
- + "scope=NewAlbumScope, isWritable=true, itemSchema="
- + "AxArtifactKey:(name=AlbumSchemaName,version=0.0.1))", clonedAlbum.toString());
+ + "scope=NewAlbumScope, isWritable=true, itemSchema="
+ + "AxArtifactKey:(name=AlbumSchemaName,version=0.0.1))", clonedAlbum.toString());
assertNotEquals(0, album.hashCode());
// disabling sonar because this code tests the equals() method
@@ -160,17 +162,17 @@ public class ContextAlbumsTest {
assertNotEquals(0, album.compareTo(null));
assertNotEquals(0, album.compareTo(new AxArtifactKey()));
assertNotEquals(0, album.compareTo(
- new AxContextAlbum(new AxArtifactKey(), "Scope", false, AxArtifactKey.getNullKey())));
+ new AxContextAlbum(new AxArtifactKey(), "Scope", false, AxArtifactKey.getNullKey())));
assertNotEquals(0, album.compareTo(new AxContextAlbum(newKey, "Scope", false, AxArtifactKey.getNullKey())));
assertNotEquals(0, album
- .compareTo(new AxContextAlbum(newKey, "NewAlbumScope", false, AxArtifactKey.getNullKey())));
+ .compareTo(new AxContextAlbum(newKey, "NewAlbumScope", false, AxArtifactKey.getNullKey())));
assertNotEquals(0,
- album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, AxArtifactKey.getNullKey())));
+ album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, AxArtifactKey.getNullKey())));
assertEquals(0, album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, albumSchemaKey)));
}
@Test
- public void testMultipleAlbums() {
+ void testMultipleAlbums() {
final AxContextAlbums albums = new AxContextAlbums();
final AxContextAlbum album = setTestAlbum();
final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
@@ -212,7 +214,7 @@ public class ContextAlbumsTest {
}
@Test
- public void testClonedAlbums() {
+ void testClonedAlbums() {
final AxContextAlbums albums = new AxContextAlbums();
final AxContextAlbum album = setTestAlbum();
final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
@@ -222,7 +224,7 @@ public class ContextAlbumsTest {
final AxContextAlbums clonedAlbums = new AxContextAlbums(albums);
assertThat(clonedAlbums.toString()).startsWith(
- "AxContextAlbums(key=AxArtifactKey:(name=AlbumsKey,version=0.0.1)");
+ "AxContextAlbums(key=AxArtifactKey:(name=AlbumsKey,version=0.0.1)");
assertNotEquals(0, albums.hashCode());
@@ -243,6 +245,6 @@ public class ContextAlbumsTest {
assertEquals("NewAlbumName", albums.get("NewAlbumName").getKey().getName());
assertEquals("NewAlbumName", albums.get("NewAlbumName", "0.0.1").getKey().getName());
assertEquals(1, albums.getAll("NewAlbumName", "0.0.1").size());
- assertEquals(0, albums.getAll("NonExistantAlbumName").size());
+ assertEquals(0, albums.getAll("NonExistentAlbumName").size());
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java b/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java
index b148ef6be..14d80381d 100644
--- a/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,11 +23,11 @@
package org.onap.policy.apex.model.contextmodel.concepts;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
@@ -36,22 +36,22 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ContextModelTest {
+class ContextModelTest {
@Test
- public void test() {
+ void test() {
assertNotNull(new AxContextModel());
assertNotNull(new AxContextModel(new AxArtifactKey()));
assertNotNull(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation()));
assertNotNull(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation()));
+ new AxKeyInformation()));
final AxArtifactKey modelKey = new AxArtifactKey("ModelKey", "0.0.1");
final AxArtifactKey schemasKey = new AxArtifactKey("SchemasKey", "0.0.1");
final AxArtifactKey albumsKey = new AxArtifactKey("SchemasKey", "0.0.1");
final AxArtifactKey keyInfoKey = new AxArtifactKey("SchemasKey", "0.0.1");
final AxContextModel model = new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
- new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey));
+ new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey));
model.register();
model.clean();
@@ -68,28 +68,28 @@ public class ContextModelTest {
assertNotEquals(model, (Object) "Hello");
assertNotEquals(model, new AxContextModel(new AxArtifactKey()));
assertNotEquals(model, new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation()));
+ new AxKeyInformation()));
assertNotEquals(model, new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation()));
+ new AxKeyInformation()));
assertNotEquals(model, new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation(keyInfoKey)));
+ new AxKeyInformation(keyInfoKey)));
assertNotEquals(model, new AxContextModel(modelKey, new AxContextSchemas(schemasKey), new AxContextAlbums(),
- new AxKeyInformation(keyInfoKey)));
+ new AxKeyInformation(keyInfoKey)));
assertEquals(model, new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
- new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey)));
+ new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey)));
assertEquals(0, model.compareTo(model));
assertEquals(0, model.compareTo(clonedModel));
assertNotEquals(0, model.compareTo(new AxArtifactKey()));
assertNotEquals(0, model.compareTo(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(),
- new AxContextAlbums(), new AxKeyInformation())));
+ new AxContextAlbums(), new AxKeyInformation())));
assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation())));
+ new AxKeyInformation())));
assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation(keyInfoKey))));
+ new AxKeyInformation(keyInfoKey))));
assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
- new AxContextAlbums(), new AxKeyInformation(keyInfoKey))));
+ new AxContextAlbums(), new AxKeyInformation(keyInfoKey))));
assertEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
- new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey))));
+ new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey))));
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java b/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
index 52cca14bf..67edd953a 100644
--- a/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,11 +24,11 @@ package org.onap.policy.apex.model.contextmodel.concepts;
import static org.assertj.core.api.Assertions.assertThat;
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
@@ -36,19 +36,19 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
/**
* Context schema tests.
*/
-public class ContextSchemasTest {
+class ContextSchemasTest {
@Test
- public void testNewAxContextSchema() {
+ void testNewAxContextSchema() {
assertNotNull(new AxContextSchema());
assertNotNull(new AxContextSchema(new AxArtifactKey(), "SchemaFlavour", "SchemaDefinition"));
}
@Test
- public void testContextSchemas() {
+ void testContextSchemas() {
final AxContextSchema schema = new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour",
- "SchemaDefinition");
+ "SchemaDefinition");
assertNotNull(schema);
final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
@@ -58,7 +58,7 @@ public class ContextSchemasTest {
assertThatThrownBy(() -> schema.setSchemaFlavour(""))
.hasMessage("parameter \"schemaFlavour\": value \"\", "
- + "does not match regular expression \"[A-Za-z0-9\\-_]+\"");
+ + "does not match regular expression \"[A-Za-z0-9\\-_]+\"");
schema.setSchemaFlavour("NewSchemaFlavour");
assertEquals("NewSchemaFlavour", schema.getSchemaFlavour());
@@ -68,7 +68,7 @@ public class ContextSchemasTest {
private AxContextSchema setTestSchema() {
final AxContextSchema schema = new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour",
- "SchemaDefinition");
+ "SchemaDefinition");
final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
schema.setKey(newKey);
schema.setSchemaFlavour("NewSchemaFlavour");
@@ -78,7 +78,7 @@ public class ContextSchemasTest {
}
@Test
- public void testAxvalidationSchema() {
+ void testAxvalidationSchema() {
AxContextSchema schema = setTestSchema();
AxValidationResult result = new AxValidationResult();
result = schema.validate(result);
@@ -117,14 +117,14 @@ public class ContextSchemasTest {
}
@Test
- public void testEqualsSchema() {
+ void testEqualsSchema() {
AxContextSchema schema = setTestSchema();
schema.clean();
final AxContextSchema clonedSchema = new AxContextSchema(schema);
assertEquals("AxContextSchema(key=AxArtifactKey:(name=NewSchemaName,version=0.0.1), "
- + "schemaFlavour=NewSchemaFlavour, schemaDefinition=NewSchemaDefinition)",
- clonedSchema.toString());
+ + "schemaFlavour=NewSchemaFlavour, schemaDefinition=NewSchemaDefinition)",
+ clonedSchema.toString());
assertNotEquals(0, schema.hashCode());
@@ -151,7 +151,7 @@ public class ContextSchemasTest {
}
@Test
- public void testMultipleSchemas() {
+ void testMultipleSchemas() {
final AxContextSchemas schemas = new AxContextSchemas();
AxValidationResult result = new AxValidationResult();
result = schemas.validate(result);
@@ -193,7 +193,7 @@ public class ContextSchemasTest {
}
@Test
- public void testClonedSchemas() {
+ void testClonedSchemas() {
final AxContextSchemas schemas = new AxContextSchemas();
AxContextSchema schema = setTestSchema();
final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
@@ -203,7 +203,7 @@ public class ContextSchemasTest {
final AxContextSchemas clonedSchemas = new AxContextSchemas(schemas);
assertThat(clonedSchemas.toString())
- .startsWith("AxContextSchemas(key=AxArtifactKey:(name=SchemasKey,version=0.0.1),");
+ .startsWith("AxContextSchemas(key=AxArtifactKey:(name=SchemasKey,version=0.0.1),");
assertNotEquals(0, schemas.hashCode());
diff --git a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
index 998469bac..a9cb16914 100644
--- a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 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,104 +21,80 @@
package org.onap.policy.apex.model.contextmodel.handling;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
+import org.onap.policy.common.utils.resources.ResourceUtils;
/**
* Apex context model tests.
*
* @author liam
- *
*/
-public class ApexContextModelTest {
+class ApexContextModelTest {
private static final String VALID_MODEL_STRING = "***validation of model successful***";
- private static final String OBSERVATION_MODEL_STRING = "\n"
- + "***observations noted during validation of model***\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n"
- + "********************************";
-
- private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:"
- + "UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "********************************";
-
- private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=StringType,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema:INVALID:"
- + "no schemaDefinition specified, schemaDefinition may not be blank\n"
- + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:"
- + "scope is not defined\n" + "********************************";
-
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=ContextModel,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:WARNING:"
- + "key not found for key information entry\n" + "AxArtifactKey:(name=ContextSchemas,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:"
- + "key on schemas entry AxArtifactKey:(name=MapType,version=0.0.1) "
- + "does not equal entry key AxArtifactKey:(name=MapType,version=0.0.2)\n"
- + "AxArtifactKey:(name=contextAlbums,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:INVALID:"
- + "key on context album entry key AxArtifactKey:(name=contextAlbum1,version=0.0.1) "
- + "does not equal context album value key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
- + "********************************";
+ private static final String OBSERVATION_MODEL_STRING =
+ "contextmodel/handling/ApexContextModel_ObservationModel.txt";
+
+ private static final String WARNING_MODEL_STRING = "contextmodel/handling/ApexContextModel_WarningModel.txt";
+
+ private static final String INVALID_MODEL_STRING = "contextmodel/handling/ApexContextModel_InvalidModel.txt";
+
+ private static final String INVALID_MODEL_MALSTRUCTURED_STRING =
+ "contextmodel/handling/ApexContextModel_InvalidMalStructuredModel.txt";
TestApexModel<AxContextModel> testApexModel;
/**
* Set up tests.
- *
- * @throws Exception a testing exception
*/
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxContextModel>(AxContextModel.class, new TestApexContextModelCreator());
+ @BeforeEach
+ void setup() {
+ testApexModel = new TestApexModel<>(AxContextModel.class, new TestApexContextModelCreator());
}
@Test
- public void testModelValid() throws Exception {
+ void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test
- public void testApexModelVaidateObservation() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
- assertEquals(OBSERVATION_MODEL_STRING, result.toString());
+ void testApexModelValidateObservation() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateObservation();
+ var expectedResult = ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING);
+ assertEquals(expectedResult, result.toString());
}
@Test
- public void testApexModelVaidateWarning() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertEquals(WARNING_MODEL_STRING, result.toString());
+ void testApexModelValidateWarning() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateWarning();
+ var expectedResult = ResourceUtils.getResourceAsString(WARNING_MODEL_STRING);
+ assertEquals(expectedResult, result.toString());
}
@Test
- public void testModelVaidateInvalidModel() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertEquals(INVALID_MODEL_STRING, result.toString());
+ void testModelValidateInvalidModel() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel();
+ var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_STRING);
+ assertEquals(expectedResult, result.toString());
}
@Test
- public void testModelVaidateMalstructured() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
+ void testModelValidateMalstructured() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateMalstructured();
+ var expectedResult = ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING);
+ assertEquals(expectedResult, result.toString());
}
@Test
- public void testModelWriteReadJson() throws Exception {
+ void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ContextComparisonTest.java b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ContextComparisonTest.java
index 483bc3661..b898122ae 100644
--- a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ContextComparisonTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ContextComparisonTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 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,11 +21,11 @@
package org.onap.policy.apex.model.contextmodel.handling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
@@ -37,7 +37,7 @@ import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ContextComparisonTest {
+class ContextComparisonTest {
private AxContextModel emptyModel;
private AxContextModel fullModel;
private AxContextModel noGlobalContextModel;
@@ -47,8 +47,8 @@ public class ContextComparisonTest {
/**
* Set up tests.
*/
- @Before
- public void getContext() {
+ @BeforeEach
+ void getContext() {
final TestContextComparisonFactory factory = new TestContextComparisonFactory();
emptyModel = factory.getEmptyModel();
fullModel = factory.getFullModel();
@@ -58,131 +58,131 @@ public class ContextComparisonTest {
}
@Test
- public void testEmptyEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), emptyModel.getSchemas());
+ void testEmptyEmpty() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(emptyModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(emptyModel.getSchemas().getSchemasMap(), schemaResult.getIdenticalValues());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(emptyModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertEquals(emptyModel.getAlbums().getAlbumsMap(), albumResult.getIdenticalValues());
}
@Test
- public void testEmptyFull() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), fullModel.getSchemas());
+ void testEmptyFull() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(emptyModel.getSchemas(), fullModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(fullModel.getSchemas().getSchemasMap(), schemaResult.getRightOnly());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), fullModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(emptyModel.getAlbums(), fullModel.getAlbums());
assertNotNull(albumResult);
assertEquals(fullModel.getAlbums().getAlbumsMap(), albumResult.getRightOnly());
}
@Test
- public void testFullEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(fullModel.getSchemas(), emptyModel.getSchemas());
+ void testFullEmpty() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(fullModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(fullModel.getSchemas().getSchemasMap(), schemaResult.getLeftOnly());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(fullModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(fullModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertEquals(fullModel.getAlbums().getAlbumsMap(), albumResult.getLeftOnly());
}
@Test
- public void testEmptyNoGlobalContext() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), noGlobalContextModel.getSchemas());
+ void testEmptyNoGlobalContext() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(emptyModel.getSchemas(), noGlobalContextModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(noGlobalContextModel.getSchemas().getSchemasMap(), schemaResult.getRightOnly());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), noGlobalContextModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(emptyModel.getAlbums(), noGlobalContextModel.getAlbums());
assertNotNull(albumResult);
assertEquals(noGlobalContextModel.getAlbums().getAlbumsMap(), albumResult.getRightOnly());
}
@Test
- public void testNoGlobalContextEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(noGlobalContextModel.getSchemas(), emptyModel.getSchemas());
+ void testNoGlobalContextEmpty() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(noGlobalContextModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(noGlobalContextModel.getSchemas().getSchemasMap(), schemaResult.getLeftOnly());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(noGlobalContextModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(noGlobalContextModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertEquals(noGlobalContextModel.getAlbums().getAlbumsMap(), albumResult.getLeftOnly());
}
@Test
- public void testEmptyShell() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), shellModel.getSchemas());
+ void testEmptyShell() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(emptyModel.getSchemas(), shellModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(shellModel.getSchemas().getSchemasMap(), schemaResult.getRightOnly());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), shellModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(emptyModel.getAlbums(), shellModel.getAlbums());
assertNotNull(albumResult);
assertEquals(shellModel.getAlbums().getAlbumsMap(), albumResult.getRightOnly());
}
@Test
- public void testShellEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(shellModel.getSchemas(), emptyModel.getSchemas());
+ void testShellEmpty() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(shellModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(shellModel.getSchemas().getSchemasMap(), schemaResult.getLeftOnly());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(shellModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(shellModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertEquals(shellModel.getAlbums().getAlbumsMap(), albumResult.getLeftOnly());
}
@Test
- public void testEmptySingleEntry() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), singleEntryModel.getSchemas());
+ void testEmptySingleEntry() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(emptyModel.getSchemas(), singleEntryModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(singleEntryModel.getSchemas().getSchemasMap(), schemaResult.getRightOnly());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), singleEntryModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(emptyModel.getAlbums(), singleEntryModel.getAlbums());
assertNotNull(albumResult);
assertEquals(singleEntryModel.getAlbums().getAlbumsMap(), albumResult.getRightOnly());
}
@Test
- public void testSingleEntryEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(singleEntryModel.getSchemas(), emptyModel.getSchemas());
+ void testSingleEntryEmpty() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(singleEntryModel.getSchemas(), emptyModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(singleEntryModel.getSchemas().getSchemasMap(), schemaResult.getLeftOnly());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(singleEntryModel.getAlbums(), emptyModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(singleEntryModel.getAlbums(), emptyModel.getAlbums());
assertNotNull(albumResult);
assertEquals(singleEntryModel.getAlbums().getAlbumsMap(), albumResult.getLeftOnly());
}
@Test
- public void testFullFull() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(fullModel.getSchemas(), fullModel.getSchemas());
+ void testFullFull() {
+ final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult =
+ new ContextComparer().compare(fullModel.getSchemas(), fullModel.getSchemas());
assertNotNull(schemaResult);
assertEquals(fullModel.getSchemas().getSchemasMap(), schemaResult.getIdenticalValues());
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(fullModel.getAlbums(), fullModel.getAlbums());
+ final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult =
+ new ContextComparer().compare(fullModel.getAlbums(), fullModel.getAlbums());
assertNotNull(albumResult);
assertEquals(fullModel.getAlbums().getAlbumsMap(), albumResult.getIdenticalValues());
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModelCreator.java b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModelCreator.java
index 3fe7e3aa2..8d366981d 100644
--- a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModelCreator.java
+++ b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModelCreator.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,18 +37,18 @@ public class TestApexContextModelCreator implements TestApexModelCreator<AxConte
@Override
public AxContextModel getModel() {
final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
- "org.onap.policy.apex.concept.TestContextItem000");
+ "org.onap.policy.apex.concept.TestContextItem000");
final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
- "org.onap.policy.apex.concept.TestContextItem00A");
+ "org.onap.policy.apex.concept.TestContextItem00A");
final AxContextSchemas contextSchemas = new AxContextSchemas(new AxArtifactKey("ContextSchemas", "0.0.1"));
contextSchemas.getSchemasMap().put(schema0.getKey(), schema0);
contextSchemas.getSchemasMap().put(schema1.getKey(), schema1);
final AxContextAlbum contextAlbum0 =
- new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", true, schema0.getKey());
+ new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", true, schema0.getKey());
final AxContextAlbum contextAlbum1 =
- new AxContextAlbum(new AxArtifactKey("contextAlbum1", "0.0.1"), "GLOBAL", false, schema1.getKey());
+ new AxContextAlbum(new AxArtifactKey("contextAlbum1", "0.0.1"), "GLOBAL", false, schema1.getKey());
final AxContextAlbums axContext = new AxContextAlbums(new AxArtifactKey("contextAlbums", "0.0.1"));
axContext.getAlbumsMap().put(contextAlbum0.getKey(), contextAlbum0);
@@ -55,25 +56,25 @@ public class TestApexContextModelCreator implements TestApexModelCreator<AxConte
final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"),
- contextSchemas, axContext, keyInformation);
+ contextSchemas, axContext, keyInformation);
contextModel.setKeyInformation(keyInformation);
contextModel.getKeyInformation().getKeyInfoMap().put(schema0.getKey(), new AxKeyInfo(schema0.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000001"), "axContextSchema0"));
+ UUID.fromString("00000000-0000-0000-0000-000000000001"), "axContextSchema0"));
contextModel.getKeyInformation().getKeyInfoMap().put(schema1.getKey(), new AxKeyInfo(schema1.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000002"), "axContextSchema1"));
+ UUID.fromString("00000000-0000-0000-0000-000000000002"), "axContextSchema1"));
contextModel.getKeyInformation().getKeyInfoMap().put(contextSchemas.getKey(), new AxKeyInfo(
- contextSchemas.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000003"), "ContextSchemas"));
+ contextSchemas.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000003"), "ContextSchemas"));
contextModel.getKeyInformation().getKeyInfoMap().put(contextAlbum0.getKey(), new AxKeyInfo(
- contextAlbum0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000004"), "contextAlbum0"));
+ contextAlbum0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000004"), "contextAlbum0"));
contextModel.getKeyInformation().getKeyInfoMap().put(contextAlbum1.getKey(), new AxKeyInfo(
- contextAlbum1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000005"), "contextAlbum1"));
+ contextAlbum1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000005"), "contextAlbum1"));
contextModel.getKeyInformation().getKeyInfoMap().put(axContext.getKey(), new AxKeyInfo(axContext.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000006"), "axContext"));
+ UUID.fromString("00000000-0000-0000-0000-000000000006"), "axContext"));
contextModel.getKeyInformation().getKeyInfoMap().put(contextModel.getKey(), new AxKeyInfo(contextModel.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000007"), "contextModel"));
+ UUID.fromString("00000000-0000-0000-0000-000000000007"), "contextModel"));
contextModel.getKeyInformation().getKeyInfoMap().put(keyInformation.getKey(), new AxKeyInfo(
- keyInformation.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000008"), "keyInformation"));
+ keyInformation.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000008"), "keyInformation"));
return contextModel;
}
@@ -81,42 +82,33 @@ public class TestApexContextModelCreator implements TestApexModelCreator<AxConte
@Override
public AxContextModel getInvalidModel() {
final AxContextModel contextModel = getModel();
-
contextModel.getAlbums().get(new AxArtifactKey("contextAlbum0", "0.0.1")).setScope("UNDEFINED");
-
contextModel.getSchemas().get(new AxArtifactKey("StringType", "0.0.1")).setSchema("");
-
return contextModel;
}
@Override
public AxContextModel getMalstructuredModel() {
final AxContextModel contextModel = getModel();
-
contextModel.getAlbums().get(new AxArtifactKey("contextAlbum1", "0.0.1"))
- .setKey(new AxArtifactKey("contextAlbum1", "0.0.2"));;
+ .setKey(new AxArtifactKey("contextAlbum1", "0.0.2"));
contextModel.getSchemas().get(new AxArtifactKey("MapType", "0.0.1"))
- .setKey(new AxArtifactKey("MapType", "0.0.2"));;
-
+ .setKey(new AxArtifactKey("MapType", "0.0.2"));
return contextModel;
}
@Override
public AxContextModel getObservationModel() {
final AxContextModel contextModel = getModel();
-
contextModel.getKeyInformation().get("contextAlbum1", "0.0.1").setDescription("");
-
return contextModel;
}
@Override
public AxContextModel getWarningModel() {
final AxContextModel contextModel = getModel();
-
contextModel.getKeyInformation().get("contextAlbum1", "0.0.1")
- .setUuid(UUID.fromString("00000000-0000-0000-0000-000000000000"));
-
+ .setUuid(UUID.fromString("00000000-0000-0000-0000-000000000000"));
return contextModel;
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java
index f7c7a1345..d396848b6 100644
--- a/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java
+++ b/model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,27 +35,28 @@ public class TestContextComparisonFactory {
/**
* Get a full context model.
+ *
* @return the model
*/
public AxContextModel getFullModel() {
final AxContextSchema testContextSchema000 =
- new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema000");
+ new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
+ "org.onap.policy.apex.concept.TestContextSchema000");
final AxContextSchema testContextSchema00A =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00A", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00A");
+ new AxContextSchema(new AxArtifactKey("TestContextSchema00A", "0.0.1"), "JAVA",
+ "org.onap.policy.apex.concept.TestContextSchema00A");
final AxContextSchema testContextSchema00C =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00C");
+ new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
+ "org.onap.policy.apex.concept.TestContextSchema00C");
final AxContextAlbum externalContextAlbum = new AxContextAlbum(
- new AxArtifactKey("ExternalContextAlbum", "0.0.1"), "EXTERNAL", false, testContextSchema000.getKey());
+ new AxArtifactKey("ExternalContextAlbum", "0.0.1"), "EXTERNAL", false, testContextSchema000.getKey());
final AxContextAlbum globalContextAlbum = new AxContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"),
- "GLOBAL", true, testContextSchema00A.getKey());
+ "GLOBAL", true, testContextSchema00A.getKey());
final AxContextAlbum policy0ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy0ContextAlbum", "0.0.1"),
- "APPLICATION", true, testContextSchema00C.getKey());
+ "APPLICATION", true, testContextSchema00C.getKey());
final AxContextAlbum policy1ContextAlbum = new AxContextAlbum(
- new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema00C.getKey());
+ new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema00C.getKey());
final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
@@ -75,18 +77,19 @@ public class TestContextComparisonFactory {
/**
* Get a skeleton model.
+ *
* @return The model
*/
public AxContextModel getShellModel() {
final AxContextSchema testContextSchema000 =
- new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema000");
+ new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
+ "org.onap.policy.apex.concept.TestContextSchema000");
final AxContextSchema testContextSchema00A =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00A", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00A");
+ new AxContextSchema(new AxArtifactKey("TestContextSchema00A", "0.0.1"), "JAVA",
+ "org.onap.policy.apex.concept.TestContextSchema00A");
final AxContextSchema testContextSchema00C =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00C");
+ new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
+ "org.onap.policy.apex.concept.TestContextSchema00C");
final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
@@ -98,15 +101,16 @@ public class TestContextComparisonFactory {
/**
* Get a single entry model.
+ *
* @return The single entry model
*/
public AxContextModel getSingleEntryModel() {
final AxContextSchema testContextSchema000 =
- new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema000");
+ new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
+ "org.onap.policy.apex.concept.TestContextSchema000");
final AxContextAlbum policy1ContextAlbum = new AxContextAlbum(
- new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema000.getKey());
+ new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema000.getKey());
final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
@@ -118,22 +122,23 @@ public class TestContextComparisonFactory {
/**
* Get a model with no global entries.
+ *
* @return the model
*/
public AxContextModel getNoGlobalContextModel() {
final AxContextSchema testContextSchema000 =
- new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema000");
+ new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
+ "org.onap.policy.apex.concept.TestContextSchema000");
final AxContextSchema testContextSchema00C =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00C");
+ new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
+ "org.onap.policy.apex.concept.TestContextSchema00C");
final AxContextAlbum externalContextAlbum = new AxContextAlbum(
- new AxArtifactKey("ExternalContextAlbum", "0.0.1"), "EXTERNAL", false, testContextSchema000.getKey());
+ new AxArtifactKey("ExternalContextAlbum", "0.0.1"), "EXTERNAL", false, testContextSchema000.getKey());
final AxContextAlbum policy0ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy0ContextAlbum", "0.0.1"),
- "APPLICATION", true, testContextSchema00C.getKey());
+ "APPLICATION", true, testContextSchema00C.getKey());
final AxContextAlbum policy1ContextAlbum = new AxContextAlbum(
- new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema00C.getKey());
+ new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema00C.getKey());
final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
diff --git a/model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java b/model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
index c23687bb1..b9ee952c1 100644
--- a/model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,12 +24,12 @@ package org.onap.policy.apex.model.enginemodel.concepts;
import static org.assertj.core.api.Assertions.assertThat;
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
@@ -40,19 +40,13 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
/**
* Test engine models.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class EngineModelTest {
+class EngineModelTest {
@Test
- public void testEnginetModel() {
- assertNotNull(new AxEngineModel());
- assertNotNull(new AxEngineModel(new AxArtifactKey()));
- assertNotNull(new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation(),
- new AxContextAlbums()));
- assertNotNull(new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation(),
- new AxContextAlbums(), AxEngineState.UNDEFINED, new AxEngineStats()));
-
+ void testEngineModel() {
final AxArtifactKey modelKey = new AxArtifactKey("ModelName", "0.0.1");
final AxArtifactKey schemasKey = new AxArtifactKey("SchemasKey", "0.0.1");
final AxArtifactKey albumKey = new AxArtifactKey("AlbumKey", "0.0.1");
@@ -62,11 +56,10 @@ public class EngineModelTest {
otherStats.setAverageExecutionTime(100);
final AxEngineModel model = new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats);
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats);
model.register();
- assertThatThrownBy(() -> model.setKey(null))
- .hasMessage("key may not be null");
+ 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());
@@ -77,8 +70,7 @@ public class EngineModelTest {
model.setTimestamp(-1);
assertTrue(model.getTimeStampString().matches("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}"));
- assertThatThrownBy(() -> model.setState(null))
- .hasMessage("state may not be null");
+ assertThatThrownBy(() -> model.setState(null)).hasMessage("state may not be null");
for (final AxEngineState state : AxEngineState.values()) {
model.setState(state);
assertEquals(state, model.getState());
@@ -87,8 +79,7 @@ public class EngineModelTest {
model.setState(AxEngineState.READY);
assertEquals(AxEngineState.READY, model.getState());
- assertThatThrownBy(() -> model.setStats(null))
- .hasMessage("stats may not be null");
+ assertThatThrownBy(() -> model.setStats(null)).hasMessage("stats may not be null");
model.setStats(stats);
assertEquals(stats, model.getStats());
@@ -101,76 +92,101 @@ public class EngineModelTest {
assertNotEquals(0, model.hashCode());
// disabling sonar because this code tests the equals() method
- assertEquals(model, model); // NOSONAR
- assertEquals(model, clonedModel);
- assertNotEquals(model, (Object) "Hello");
- assertNotEquals(model, new AxEngineModel(new AxArtifactKey()));
- assertNotEquals(model, new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats));
- assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey),
- new AxContextAlbums(albumKey), AxEngineState.READY, stats));
- assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(),
- new AxContextAlbums(albumKey), AxEngineState.READY, stats));
- assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(), AxEngineState.READY, stats));
- assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.STOPPED, stats));
- assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, otherStats));
- model.setTimestamp(timestamp);
- assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats));
- model.setTimestamp(0);
- assertEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats));
+ assertEqualsEngineModel(model, clonedModel, schemasKey, keyInfoKey, albumKey, stats, modelKey, otherStats,
+ timestamp);
model.setTimestamp(-1);
assertEquals(0, model.compareTo(model));
assertEquals(0, model.compareTo(clonedModel));
- assertNotEquals(0, model.compareTo(new AxArtifactKey()));
- assertNotEquals(model, new AxEngineModel(new AxArtifactKey()));
- assertNotEquals(0, model.compareTo(new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
- assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
- assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
- assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(), AxEngineState.READY, stats)));
- assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.STOPPED, stats)));
- assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, otherStats)));
- model.setTimestamp(timestamp);
- assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
+ assertNotEqualsEngineModels(model, schemasKey, keyInfoKey, albumKey, stats, modelKey, otherStats, timestamp);
model.setTimestamp(0);
assertEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
- model.setTimestamp(timestamp);
- AxValidationResult result = new AxValidationResult();
- result = model.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
+ assertSetTimestampToEngineModel(model, timestamp);
- model.setTimestamp(-1);
+ assertSetStateToEngineModel(model);
+ }
+
+ private static void assertSetStateToEngineModel(AxEngineModel model) {
+ AxValidationResult result;
+ model.setState(AxEngineState.UNDEFINED);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
- model.setTimestamp(timestamp);
+ model.setState(AxEngineState.READY);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ }
+
+ private static void assertSetTimestampToEngineModel(AxEngineModel model, long timestamp) {
+ model.setTimestamp(timestamp);
+ AxValidationResult result = new AxValidationResult();
+ result = model.validate(result);
+ assertEquals(ValidationResult.VALID, result.getValidationResult());
- model.setState(AxEngineState.UNDEFINED);
+ model.setTimestamp(-1);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
- model.setState(AxEngineState.READY);
+ model.setTimestamp(timestamp);
result = new AxValidationResult();
result = model.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
}
+
+ private static void assertNotEqualsEngineModels(AxEngineModel model, AxArtifactKey schemasKey,
+ AxArtifactKey keyInfoKey, AxArtifactKey albumKey,
+ AxEngineStats stats, AxArtifactKey modelKey,
+ AxEngineStats otherStats, long timestamp) {
+ assertNotEquals(0, model.compareTo(new AxArtifactKey()));
+ assertNotEquals(model, new AxEngineModel(new AxArtifactKey()));
+ assertNotEquals(0, model.compareTo(new AxEngineModel(new AxArtifactKey(),
+ new AxContextSchemas(schemasKey), new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey),
+ AxEngineState.READY, stats)));
+ assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
+ assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
+ assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(), AxEngineState.READY, stats)));
+ assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.STOPPED, stats)));
+ assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, otherStats)));
+ model.setTimestamp(timestamp);
+ assertNotEquals(0, model.compareTo(new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats)));
+ }
+
+ private static void assertEqualsEngineModel(AxEngineModel model, AxEngineModel clonedModel,
+ AxArtifactKey schemasKey,
+ AxArtifactKey keyInfoKey, AxArtifactKey albumKey, AxEngineStats stats,
+ AxArtifactKey modelKey, AxEngineStats otherStats, long timestamp) {
+ assertEquals(model, model); // NOSONAR
+ assertEquals(model, clonedModel);
+ assertNotEquals(model, (Object) "Hello");
+ assertNotEquals(model, new AxEngineModel(new AxArtifactKey()));
+ assertNotEquals(model, new AxEngineModel(new AxArtifactKey(), new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey),
+ new AxContextAlbums(albumKey), AxEngineState.READY, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(),
+ new AxContextAlbums(albumKey), AxEngineState.READY, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(), AxEngineState.READY, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.STOPPED, stats));
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, otherStats));
+ model.setTimestamp(timestamp);
+ assertNotEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats));
+ model.setTimestamp(0);
+ assertEquals(model, new AxEngineModel(modelKey, new AxContextSchemas(schemasKey),
+ new AxKeyInformation(keyInfoKey), new AxContextAlbums(albumKey), AxEngineState.READY, stats));
+ }
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java b/model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
index 542c6e4c5..a9e61db62 100644
--- a/model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/enginemodel/concepts/EngineStatsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,14 +23,14 @@
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 static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import io.prometheus.client.CollectorRegistry;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -41,25 +41,61 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class EngineStatsTest {
+class EngineStatsTest {
private static final Object WAIT_LOCK = new Object();
private static final String ENGINE_KEY = "EngineKey";
private static final String ENGINE_VERSION = "0.0.1";
@Test
- public void testEngineStats() {
- assertNotNull(new AxEngineStats());
- assertNotNull(new AxEngineStats(new AxReferenceKey()));
-
+ void testEngineStats() {
final AxReferenceKey statsKey = new AxReferenceKey(ENGINE_KEY, ENGINE_VERSION, "EngineStats");
final AxEngineStats stats = new AxEngineStats(statsKey);
- assertThatThrownBy(() -> stats.setKey(null))
- .hasMessage("key may not be null");
+ 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());
+ assertSetValuesToStats(stats);
+
+ synchronized (WAIT_LOCK) {
+ try {
+ WAIT_LOCK.wait(10);
+ } catch (InterruptedException e) {
+ fail("test should not throw an exception");
+ }
+ }
+
+ stats.executionExit();
+ checkAvgExecTimeMetric(stats);
+ checkEventsCountMetric(stats);
+ checkLastExecTimeMetric(stats);
+ final double avExecutionTime = stats.getAverageExecutionTime();
+ assertTrue(avExecutionTime >= 2.0 && avExecutionTime < 10.0);
+ stats.engineStop();
+ checkEngineStartTimestampMetric(stats);
+
+ AxValidationResult result = new AxValidationResult();
+ result = stats.validate(result);
+ assertEquals(ValidationResult.VALID, result.getValidationResult());
+
+ stats.setKey(new AxReferenceKey());
+ result = new AxValidationResult();
+ result = stats.validate(result);
+ assertEquals(ValidationResult.INVALID, result.getValidationResult());
+
+ stats.setKey(statsKey);
+ result = new AxValidationResult();
+ result = stats.validate(result);
+ assertEquals(ValidationResult.VALID, result.getValidationResult());
+
+ stats.clean();
+ stats.reset();
+
+ assertCompareTo(stats, statsKey);
+ }
+
+ private void assertSetValuesToStats(AxEngineStats stats) {
stats.setAverageExecutionTime(123.45);
assertEquals(Double.valueOf(123.45), Double.valueOf(stats.getAverageExecutionTime()));
@@ -105,41 +141,9 @@ public class EngineStatsTest {
stats.executionEnter(new AxArtifactKey());
checkEventsCountMetric(stats);
checkEngineStartTimestampMetric(stats);
+ }
- synchronized (WAIT_LOCK) {
- try {
- WAIT_LOCK.wait(10);
- } catch (InterruptedException e) {
- fail("test should not throw an exception");
- }
- }
-
- stats.executionExit();
- checkAvgExecTimeMetric(stats);
- checkEventsCountMetric(stats);
- checkLastExecTimeMetric(stats);
- final double avExecutionTime = stats.getAverageExecutionTime();
- assertTrue(avExecutionTime >= 2.0 && avExecutionTime < 10.0);
- stats.engineStop();
- checkEngineStartTimestampMetric(stats);
-
- AxValidationResult result = new AxValidationResult();
- result = stats.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- stats.setKey(new AxReferenceKey());
- result = new AxValidationResult();
- result = stats.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- stats.setKey(statsKey);
- result = new AxValidationResult();
- result = stats.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- stats.clean();
- stats.reset();
-
+ private void assertCompareTo(AxEngineStats stats, AxReferenceKey statsKey) {
final AxEngineStats clonedStats = new AxEngineStats(stats);
assertEquals("AxEngineStats:(engineKey=AxReferenceKey:(parentKey", clonedStats.toString().substring(0, 50));
@@ -220,10 +224,10 @@ public class EngineStatsTest {
}
private void checkLastExecTimeMetric(AxEngineStats stats) {
- Double lastExecTimeMetric = CollectorRegistry.defaultRegistry
+ double lastExecTimeMetric = CollectorRegistry.defaultRegistry
.getSampleValue("pdpa_engine_last_execution_time_sum", new String[]{AxEngineStats.ENGINE_INSTANCE_ID},
new String[]{ENGINE_KEY + ":" + ENGINE_VERSION}) * 1000d;
- assertEquals(lastExecTimeMetric.longValue(), stats.getLastExecutionTime());
+ assertEquals(lastExecTimeMetric, stats.getLastExecutionTime());
}
private void checkEngineStartTimestampMetric(AxEngineStats stats) {
diff --git a/model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java b/model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
index e7fdd2d93..20b3087ef 100644
--- a/model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/ApexEngineModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 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,61 +21,66 @@
package org.onap.policy.apex.model.enginemodel.handling;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
-public class ApexEngineModelTest {
+class ApexEngineModelTest {
private static final String VALID_MODEL_STRING = "***validation of model successful***";
+ private static final String AX_ARTIFACT_KEY = "AxArtifactKey:(name=AnEngine,version=0.0.1)";
+ private static final String ENGINE_MODEL_CLASS = "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel";
- private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=AnEngine,version=0.0.1):"
- + "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel:INVALID:"
- + "AxEngineModel - state is UNDEFINED\n" + "********************************";
+ private static final String INVALID_MODEL_STRING =
+ "\n" + "***validation of model failed***\n"
+ + AX_ARTIFACT_KEY + ":"
+ + ENGINE_MODEL_CLASS + ":INVALID:"
+ + "AxEngineModel - state is UNDEFINED\n"
+ + "********************************";
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=AnEngine,version=0.0.1):"
- + "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel:INVALID:"
- + "AxEngineModel - timestamp is not set\n" + "AxArtifactKey:(name=AnEngine,version=0.0.1):"
- + "org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel:INVALID:"
- + "AxEngineModel - state is UNDEFINED\n" + "********************************";
+ private static final String INVALID_MODEL_MALSTRUCTURED_STRING =
+ "\n" + "***validation of model failed***\n"
+ + AX_ARTIFACT_KEY + ":"
+ + ENGINE_MODEL_CLASS + ":INVALID:"
+ + "AxEngineModel - timestamp is not set\n" + AX_ARTIFACT_KEY + ":"
+ + ENGINE_MODEL_CLASS + ":INVALID:"
+ + "AxEngineModel - state is UNDEFINED\n"
+ + "********************************";
TestApexModel<AxEngineModel> testApexModel;
/**
* Set up the test.
*
- * @throws Exception errors from test setup
*/
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxEngineModel>(AxEngineModel.class, new DummyTestApexEngineModelCreator());
+ @BeforeEach
+ void setup() {
+ testApexModel = new TestApexModel<>(AxEngineModel.class, new DummyTestApexEngineModelCreator());
}
@Test
- public void testModelValid() throws Exception {
+ void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test
- public void testModelVaidateInvalidModel() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
+ void testModelValidateInvalidModel() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel();
assertEquals(INVALID_MODEL_STRING, result.toString());
}
@Test
- public void testModelVaidateMalstructured() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
+ void testModelValidateMalstructured() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateMalstructured();
assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
}
@Test
- public void testModelWriteReadJson() throws Exception {
+ void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/DummyTestApexEngineModelCreator.java b/model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/DummyTestApexEngineModelCreator.java
index 9e7d99b72..99c2144e5 100644
--- a/model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/DummyTestApexEngineModelCreator.java
+++ b/model/src/test/java/org/onap/policy/apex/model/enginemodel/handling/DummyTestApexEngineModelCreator.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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=========================================================
*/
@@ -39,16 +40,16 @@ public class DummyTestApexEngineModelCreator implements TestApexModelCreator<AxE
@Override
public AxEngineModel getModel() {
final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
- "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
+ "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
- "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
+ "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
final AxContextSchemas schemas = new AxContextSchemas(new AxArtifactKey("ContextSchemas", "0.0.1"));
schemas.getSchemasMap().put(schema0.getKey(), schema0);
schemas.getSchemasMap().put(schema1.getKey(), schema1);
final AxContextAlbum album0 =
- new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", true, schema1.getKey());
+ new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", true, schema1.getKey());
final AxContextAlbums albums = new AxContextAlbums(new AxArtifactKey("context", "0.0.1"));
albums.getAlbumsMap().put(album0.getKey(), album0);
@@ -59,7 +60,7 @@ public class DummyTestApexEngineModelCreator implements TestApexModelCreator<AxE
engineModel.setTimestamp(System.currentTimeMillis());
engineModel.setState(AxEngineState.EXECUTING);
engineModel.setStats(new AxEngineStats(new AxReferenceKey(engineModel.getKey(), "EngineStats"),
- System.currentTimeMillis(), 100, 205, 200, 12345, 9876));
+ System.currentTimeMillis(), 100, 205, 200, 12345, 9876));
engineModel.getKeyInformation().generateKeyInfo(engineModel);
final AxValidationResult result = new AxValidationResult();
@@ -75,7 +76,7 @@ public class DummyTestApexEngineModelCreator implements TestApexModelCreator<AxE
engineModel.setTimestamp(System.currentTimeMillis());
engineModel.setState(AxEngineState.UNDEFINED);
engineModel.setStats(new AxEngineStats(new AxReferenceKey(engineModel.getKey(), "EngineStats"),
- System.currentTimeMillis(), 100, 205, 200, 12345, 9876));
+ System.currentTimeMillis(), 100, 205, 200, 12345, 9876));
engineModel.getKeyInformation().generateKeyInfo(engineModel);
return engineModel;
@@ -98,14 +99,14 @@ public class DummyTestApexEngineModelCreator implements TestApexModelCreator<AxE
final AxEngineModel engineModel = getModel();
final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
- "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
+ "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
- "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
+ "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
engineModel.getKeyInformation().getKeyInfoMap().put(schema0.getKey(),
- new AxKeyInfo(schema0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000001"), ""));
+ new AxKeyInfo(schema0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000001"), ""));
engineModel.getKeyInformation().getKeyInfoMap().put(schema1.getKey(),
- new AxKeyInfo(schema1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000002"), ""));
+ new AxKeyInfo(schema1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000002"), ""));
return engineModel;
}
@@ -115,14 +116,14 @@ public class DummyTestApexEngineModelCreator implements TestApexModelCreator<AxE
final AxEngineModel engineModel = getModel();
final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
- "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
+ "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem000");
final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
- "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
+ "org.onap.policy.apex.model.enginemodel.concepts.TestContextItem00A");
engineModel.getKeyInformation().getKeyInfoMap().put(schema0.getKey(),
- new AxKeyInfo(schema0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000000"), ""));
+ new AxKeyInfo(schema0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000000"), ""));
engineModel.getKeyInformation().getKeyInfoMap().put(schema1.getKey(),
- new AxKeyInfo(schema1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000001"), ""));
+ new AxKeyInfo(schema1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000001"), ""));
return engineModel;
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java b/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java
index cdc5fecf6..4113247fd 100644
--- a/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 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,34 +21,30 @@
package org.onap.policy.apex.model.eventmodel.concepts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
/**
* Test event models.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class EventModelTest {
+class EventModelTest {
@Test
- public void testEventModel() {
- assertNotNull(new AxEventModel());
- assertNotNull(new AxEventModel(new AxArtifactKey()));
- assertNotNull(
- new AxEventModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation(), new AxEvents()));
-
+ void testEventModel() {
final AxArtifactKey modelKey = new AxArtifactKey("ModelKey", "0.0.1");
final AxArtifactKey schemasKey = new AxArtifactKey("SchemasKey", "0.0.1");
final AxArtifactKey eventsKey = new AxArtifactKey("EventsKey", "0.0.1");
final AxArtifactKey keyInfoKey = new AxArtifactKey("SchemasKey", "0.0.1");
final AxEventModel model = new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey));
model.register();
model.clean();
@@ -64,24 +60,24 @@ public class EventModelTest {
assertNotEquals(model, (Object) "Hello");
assertNotEquals(model, new AxEventModel(new AxArtifactKey()));
assertNotEquals(model, new AxEventModel(modelKey, new AxContextSchemas(), new AxKeyInformation(keyInfoKey),
- new AxEvents(eventsKey)));
+ new AxEvents(eventsKey)));
assertNotEquals(model, new AxEventModel(modelKey, new AxContextSchemas(schemasKey), new AxKeyInformation(),
- new AxEvents(eventsKey)));
+ new AxEvents(eventsKey)));
assertNotEquals(model, new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents()));
+ new AxKeyInformation(keyInfoKey), new AxEvents()));
assertEquals(model, new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey)));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey)));
assertEquals(0, model.compareTo(model));
assertEquals(0, model.compareTo(clonedModel));
assertNotEquals(0, model.compareTo(new AxArtifactKey()));
assertNotEquals(0, model.compareTo(new AxEventModel(modelKey, new AxContextSchemas(),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey))));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey))));
assertNotEquals(0, model.compareTo(new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(), new AxEvents(eventsKey))));
+ new AxKeyInformation(), new AxEvents(eventsKey))));
assertNotEquals(0, model.compareTo(new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents())));
+ new AxKeyInformation(keyInfoKey), new AxEvents())));
assertEquals(0, model.compareTo(new AxEventModel(modelKey, new AxContextSchemas(schemasKey),
- new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey))));
+ new AxKeyInformation(keyInfoKey), new AxEvents(eventsKey))));
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java b/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
index 7062fcb3c..760a8375c 100644
--- a/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/EventsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,14 +22,14 @@
package org.onap.policy.apex.model.eventmodel.concepts;
-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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
@@ -42,20 +42,13 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class EventsTest {
+class EventsTest {
@Test
- public void testEvents() {
+ void testEvents() {
final TreeMap<String, AxField> parameterMap = new TreeMap<>();
final TreeMap<String, AxField> parameterMapEmpty = new TreeMap<>();
- assertNotNull(new AxEvent());
- assertNotNull(new AxEvent(new AxArtifactKey()));
- assertNotNull(new AxEvent(new AxArtifactKey(), "namespace"));
- assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target"));
- assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target"));
- assertNotNull(new AxEvent(new AxArtifactKey(), "namespace", "source", "target", parameterMap, ""));
-
final AxEvent event = new AxEvent();
final AxArtifactKey eventKey = new AxArtifactKey("EventName", "0.0.1");
@@ -97,12 +90,36 @@ public class EventsTest {
assertEquals("EventName:0.0.1", event.getKey().getId());
assertEquals("EventName:0.0.1", event.getKeys().get(0).getId());
- assertTrue("Field0", event.getFields().contains(eventField));
- assertTrue(event.hasFields(new TreeSet<AxField>(parameterMap.values())));
+ assertTrue(event.getFields().contains(eventField));
+ assertTrue(event.hasFields(new TreeSet<>(parameterMap.values())));
+
+ assertValidationResults_SingleEvent(event, eventKey, eventField, eventFieldBadParent);
+
+ event.clean();
+ event.buildReferences();
+ assertNotEquals(AxKey.NULL_KEY_NAME,
+ event.getParameterMap().values().iterator().next().getKey().getParentKeyName());
+
+ assertCompareTo(event, parameterMap, eventKey, parameterMapEmpty);
+
+ assertNotNull(event.getKeys());
+
+ final AxEvents events = new AxEvents();
+ assertValidationResult_GroupEvents(events, eventKey, event);
+
+ events.clean();
+ event.buildReferences();
+ assertNotEquals(AxKey.NULL_KEY_NAME,
+ event.getParameterMap().values().iterator().next().getKey().getParentKeyName());
+
+ assertCompareToSpecificEvents(events, event, eventKey);
+ }
+ private static void assertValidationResults_SingleEvent(AxEvent event, AxArtifactKey eventKey, AxField eventField,
+ AxField eventFieldBadParent) {
AxValidationResult result = new AxValidationResult();
result = event.validate(result);
- assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult());
+ assertEquals(ValidationResult.VALID, result.getValidationResult());
event.setKey(AxArtifactKey.getNullKey());
result = new AxValidationResult();
@@ -189,12 +206,10 @@ public class EventsTest {
result = event.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
event.setToscaPolicyState(AxToscaPolicyProcessingStatus.ENTRY.name());
+ }
- event.clean();
- event.buildReferences();
- assertNotEquals(AxKey.NULL_KEY_NAME,
- event.getParameterMap().values().iterator().next().getKey().getParentKeyName());
-
+ private static void assertCompareTo(AxEvent event, TreeMap<String, AxField> parameterMap,
+ AxArtifactKey eventKey, TreeMap<String, AxField> parameterMapEmpty) {
final AxEvent clonedEvent = new AxEvent(event);
assertEquals("AxEvent:(key=AxArtifactKey:(name=EventName,version=0.0.1),nameSpace=namespace",
clonedEvent.toString().substring(0, 77));
@@ -237,10 +252,10 @@ public class EventsTest {
AxToscaPolicyProcessingStatus.ENTRY.name())));
assertEquals(0, event.compareTo(new AxEvent(eventKey, "namespace", "source", "target", parameterMap,
AxToscaPolicyProcessingStatus.ENTRY.name())));
+ }
- assertNotNull(event.getKeys());
-
- final AxEvents events = new AxEvents();
+ private static void assertValidationResult_GroupEvents(AxEvents events, AxArtifactKey eventKey, AxEvent event) {
+ AxValidationResult result;
result = new AxValidationResult();
result = events.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
@@ -287,18 +302,16 @@ public class EventsTest {
result = new AxValidationResult();
result = events.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ }
- events.clean();
- event.buildReferences();
- assertNotEquals(AxKey.NULL_KEY_NAME,
- event.getParameterMap().values().iterator().next().getKey().getParentKeyName());
-
+ private static void assertCompareToSpecificEvents(AxEvents events, AxEvent event, AxArtifactKey eventKey) {
final AxEvents clonedEvents = new AxEvents(events);
assertEquals("AxEvents:(key=AxArtifactKey:(name=EventsKey,version=0.0.1),e",
clonedEvents.toString().substring(0, 60));
assertNotEquals(0, events.hashCode());
+ Object helloObj = "Hello";
assertEquals(events, clonedEvents);
assertNotNull(events);
assertNotEquals(event, helloObj);
@@ -318,6 +331,6 @@ public class EventsTest {
assertEquals("EventName", events.get("EventName").getKey().getName());
assertEquals("EventName", events.get("EventName", "0.0.1").getKey().getName());
assertEquals(1, events.getAll("EventName", "0.0.1").size());
- assertEquals(0, events.getAll("NonExistantEventsName").size());
+ assertEquals(0, events.getAll("NonExistentEventsName").size());
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java b/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java
index 6ec46dbd5..85b3a48e3 100644
--- a/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/eventmodel/concepts/FieldTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 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,11 +21,13 @@
package org.onap.policy.apex.model.eventmodel.concepts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -36,32 +38,10 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class FieldTest {
+class FieldTest {
@Test
- public void testField() {
- assertNotNull(new AxField());
- assertNotNull(new AxField(new AxReferenceKey()));
- assertNotNull(new AxField(new AxReferenceKey(), new AxArtifactKey()));
- assertNotNull(new AxField(new AxReferenceKey(), new AxArtifactKey(), false));
- assertNotNull(new AxField("LocalName", new AxArtifactKey(), false));
- assertNotNull(new AxField("LocalName", new AxArtifactKey()));
- assertNotNull(new AxField("LocalName", new AxArtifactKey(), false));
-
- assertNotNull(new AxInputField());
- assertNotNull(new AxInputField(new AxReferenceKey()));
- assertNotNull(new AxInputField(new AxReferenceKey(), new AxArtifactKey()));
- assertNotNull(new AxInputField(new AxReferenceKey(), new AxArtifactKey(), true));
- assertNotNull(new AxInputField("LocalName", new AxArtifactKey()));
- assertNotNull(new AxInputField(new AxInputField()));
-
- assertNotNull(new AxOutputField());
- assertNotNull(new AxOutputField(new AxReferenceKey()));
- assertNotNull(new AxOutputField(new AxReferenceKey(), new AxArtifactKey()));
- assertNotNull(new AxOutputField(new AxReferenceKey(), new AxArtifactKey(), false));
- assertNotNull(new AxOutputField("LocalName", new AxArtifactKey()));
- assertNotNull(new AxOutputField(new AxOutputField()));
-
+ void testField() {
final AxField field = new AxField();
final AxReferenceKey fieldKey = new AxReferenceKey("FieldName", "0.0.1", "PLN", "LN");
@@ -73,13 +53,21 @@ public class FieldTest {
field.setSchema(schemaKey);
assertEquals("SchemaName:0.0.1", field.getSchema().getId());
- assertEquals(false, field.getOptional());
+ assertFalse(field.getOptional());
field.setOptional(true);
- assertEquals(true, field.getOptional());
+ assertTrue(field.getOptional());
+
+ assertValidationResult(field, fieldKey, schemaKey);
+
+ field.clean();
+
+ assertCompareTo(field, fieldKey, schemaKey);
+ }
+ private static void assertValidationResult(AxField field, AxReferenceKey fieldKey, AxArtifactKey schemaKey) {
AxValidationResult result = new AxValidationResult();
result = field.validate(result);
- assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult());
+ assertEquals(ValidationResult.VALID, result.getValidationResult());
field.setKey(AxReferenceKey.getNullKey());
result = new AxValidationResult();
@@ -100,13 +88,13 @@ public class FieldTest {
result = new AxValidationResult();
result = field.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ }
- field.clean();
-
+ private static void assertCompareTo(AxField field, AxReferenceKey fieldKey, AxArtifactKey schemaKey) {
final AxField clonedField = new AxField(field);
assertEquals("AxField:(key=AxReferenceKey:(parentKeyName=FieldName,parentKeyVersion=0.0.1,"
- + "parentLocalName=PLN,localName=LN),fieldSchemaKey="
- + "AxArtifactKey:(name=SchemaName,version=0.0.1),optional=true)", clonedField.toString());
+ + "parentLocalName=PLN,localName=LN),fieldSchemaKey="
+ + "AxArtifactKey:(name=SchemaName,version=0.0.1),optional=true)", clonedField.toString());
assertNotEquals(0, field.hashCode());
// disabling sonar because this code tests the equals() method
@@ -124,7 +112,7 @@ public class FieldTest {
assertNotEquals(0, field.compareTo(new AxArtifactKey()));
assertNotEquals(0, field.compareTo(null));
assertNotEquals(0,
- field.compareTo(new AxField(AxReferenceKey.getNullKey(), AxArtifactKey.getNullKey(), false)));
+ field.compareTo(new AxField(AxReferenceKey.getNullKey(), AxArtifactKey.getNullKey(), false)));
assertNotEquals(0, field.compareTo(new AxField(fieldKey, AxArtifactKey.getNullKey(), false)));
assertNotEquals(0, field.compareTo(new AxField(fieldKey, schemaKey, false)));
assertEquals(0, field.compareTo(new AxField(fieldKey, schemaKey, true)));
diff --git a/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java b/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
index 21b97c454..df1857c82 100644
--- a/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/eventmodel/handling/ApexEventModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 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,259 +21,76 @@
package org.onap.policy.apex.model.eventmodel.handling;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
-import org.junit.Before;
-import org.junit.Test;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.eventmodel.concepts.AxEventModel;
+import org.onap.policy.common.utils.resources.ResourceUtils;
-public class ApexEventModelTest {
+class ApexEventModelTest {
private static final String VALID_MODEL_STRING = "***validation of model successful***";
- private static final String OBSERVATION_MODEL_STRING = "\n"
- + "***observations noted during validation of model***\n"
- + "AxArtifactKey:(name=event0,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event0,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "AxArtifactKey:(name=event2,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event2,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "********************************";
-
- private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=event0,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:WARNING:nameSpace on event is blank\n"
- + "AxArtifactKey:(name=event0,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event0,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:WARNING:nameSpace on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "AxArtifactKey:(name=event2,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:WARNING:nameSpace on event is blank\n"
- + "AxArtifactKey:(name=event2,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event2,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "********************************";
-
- private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):"
- + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:"
- + "keyInfoMap may not be empty\n" + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=smallEventModel,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=Schemas,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=BigIntType,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=BooleanType,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=IntType,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=MapType,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=SetType,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=StringType,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=smallEventMap,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=event0,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par0)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par2)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par3)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par4)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par5)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par6)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=event1,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "duplicate key AxArtifactKey:(name=event1,version=0.0.1) found\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=event1,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "duplicate key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,"
- + "localName=theOnlyPar) found\n" + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar)\n"
- + "AxArtifactKey:(name=event0,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event0,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:INVALID:"
- + "parent key on parameter field AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,"
- + "parentLocalName=NULL,localName=theOnlyPar) does not equal event key\n"
- + "AxArtifactKey:(name=smallEventMap,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvents:INVALID:"
- + "key on event entry key AxArtifactKey:(name=event2,version=0.0.1) does not equal event value key "
- + "AxArtifactKey:(name=event1,version=0.0.1)\n" + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:INVALID:"
- + "parent key on parameter field AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,"
- + "parentLocalName=NULL,localName=theOnlyPar) does not equal event key\n"
- + "********************************";
-
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):"
- + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:"
- + "keyInfoMap may not be empty\n" + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=smallEventModel,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=Schemas,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=SetType,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=smallEventMap,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=event1,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "duplicate key AxArtifactKey:(name=event1,version=0.0.1) found\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=event1,version=0.0.1)\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "duplicate key AxReferenceKey:(parentKeyName=event1,parentKeyVersion=0.0.1,"
- + "parentLocalName=NULL,localName=theOnlyPar) found\n"
- + "AxArtifactKey:(name=smallEventModel,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:"
- + "key information not found for parent key of key AxReferenceKey:"
- + "(parentKeyName=event1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar)\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "AxArtifactKey:(name=smallEventMap,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvents:INVALID:"
- + "key on event entry key AxArtifactKey:(name=event2,version=0.0.1) does not equal event value key "
- + "AxArtifactKey:(name=event1,version=0.0.1)\n" + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank\n"
- + "AxArtifactKey:(name=event1,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank\n"
- + "********************************";
+ private static final String OBSERVATION_MODEL_STRING =
+ "eventmodel/handling/ApexEventModelTest_ObservationModel.txt";
+ private static final String WARNING_MODEL_STRING = "eventmodel/handling/ApexEventModelTest_WarningModel.txt";
+ private static final String INVALID_MODEL_STRING = "eventmodel/handling/ApexEventModelTest_InvalidModel.txt";
+ private static final String INVALID_MODEL_MALSTRUCTURED_STRING =
+ "eventmodel/handling/ApexEventModelTest_InvalidModelMalStructured.txt";
TestApexModel<AxEventModel> testApexModel;
/**
* Set up the test.
*
- * @throws Exception exceptions from the test
*/
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxEventModel>(AxEventModel.class, new DummyTestApexEventModelCreator());
+ @BeforeEach
+ void setup() {
+ testApexModel = new TestApexModel<>(AxEventModel.class, new DummyTestApexEventModelCreator());
}
@Test
- public void testModelValid() throws Exception {
+ void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test
- public void testApexModelVaidateObservation() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
- assertEquals(OBSERVATION_MODEL_STRING, result.toString());
+ void testApexModelValidateObservation() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateObservation();
+ String expected = ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING);
+ assertEquals(expected, result.toString());
}
@Test
- public void testApexModelVaidateWarning() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertEquals(WARNING_MODEL_STRING, result.toString());
+ void testApexModelValidateWarning() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateWarning();
+ String expected = ResourceUtils.getResourceAsString(WARNING_MODEL_STRING);
+ assertEquals(expected, result.toString());
}
@Test
- public void testModelVaidateInvalidModel() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertEquals(INVALID_MODEL_STRING, result.toString());
+ void testModelValidateInvalidModel() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel();
+ String expected = ResourceUtils.getResourceAsString(INVALID_MODEL_STRING);
+ assertEquals(expected, result.toString());
}
@Test
- public void testModelVaidateMalstructured() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
+ void testModelValidateMalstructured() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateMalstructured();
+ String expected = ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING);
+ assertEquals(expected, result.toString());
}
@Test
- public void testModelWriteReadJson() throws Exception {
+ void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexApiResultTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexApiResultTest.java
index 3c2af18ea..9d009d2b9 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexApiResultTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexApiResultTest.java
@@ -1,55 +1,46 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.modelapi.ApexApiResult.Result;
/**
* Test API results.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexApiResultTest {
+class ApexApiResultTest {
@Test
- public void testApiResult() {
- assertNotNull(new ApexApiResult());
-
- for (final Result result : Result.values()) {
- assertNotNull(new ApexApiResult(result));
- }
-
- assertNotNull(new ApexApiResult(Result.SUCCESS, "Result Message"));
- assertNotNull(new ApexApiResult(Result.FAILED, new IOException("IO Exception message")));
- assertNotNull(new ApexApiResult(Result.FAILED, "Result Message", new IOException("IO Exception message")));
-
+ void testApiResult() {
final ApexApiResult result =
- new ApexApiResult(Result.FAILED, "Result Message", new IOException("IO Exception message"));
+ new ApexApiResult(Result.FAILED, "Result Message", new IOException("IO Exception message"));
assertFalse(result.isOk());
assertTrue(result.isNok());
@@ -74,7 +65,14 @@ public class ApexApiResultTest {
assertEquals("Third Message", result2.getMessages().get(2));
assertEquals("result: OTHER_ERROR\nFirst Message\nSecond Message\nThird Message\n", result2.toString());
- assertEquals("{\n" + "\"result\": \"OTHER_ERROR\",\n" + "\"messages\": [\n" + "\"First Message\",\n"
- + "\"Second Message\",\n" + "\"Third Message\"]\n" + "}\n", result2.toJson());
+ assertEquals("""
+ {
+ "result": "OTHER_ERROR",
+ "messages": [
+ "First Message",
+ "Second Message",
+ "Third Message"]
+ }
+ """, result2.toJson());
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java
index 5ce6b6760..6d9c7e404 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextAlbumTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 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,18 +21,19 @@
package org.onap.policy.apex.model.modelapi;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Context album for API tests.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexEditorApiContextAlbumTest {
+class ApexEditorApiContextAlbumTest {
+
@Test
- public void testContextAlbumCrud() {
+ void testContextAlbumCrud() {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateContextAlbum(null, null);
@@ -44,51 +45,74 @@ public class ApexEditorApiContextAlbumTest {
result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", "0.1.4", "UNDEFINED", null, "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014");
+ assertCreateContextAlbum(apexModel);
+
+ result = apexModel.validateContextAlbum(null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, null, null, null, null, null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", null, null, null, null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", null, null, null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "", null, null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "+++", null, null, null);
+
+ assertUpdateContextAlbum(apexModel);
+
+ assertListContextAlbum(apexModel);
+
+ assertDeleteContextAlbum(apexModel);
+ }
+
+ private static void assertDeleteContextAlbum(ApexModel apexModel) {
+ ApexApiResult result;
+ result = apexModel.deleteContextAlbum("@£%%$", null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapZooby", null, null, null);
+
+ result = apexModel.deleteContextAlbum("MyMap012", "0.1.1");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "--++", null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "0.0.2", null, null);
+
+ result = apexModel.deleteContextAlbum("MyMap012oooo", null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "0.0.1", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", null, null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", null,
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
- assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- result = apexModel.createContextAlbum("MyMap011", "0.1.2", "APPLICATION", "true", "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+
+ result = apexModel.listContextAlbum("MyMap012", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(3, result.getMessages().size());
result = apexModel.deleteContextAlbum("MyMap012", "0.1.2");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1",
- "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012");
+
+ result = apexModel.listContextAlbum("MyMap012", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(2, result.getMessages().size());
- result = apexModel.validateContextAlbum(null, null);
+ result = apexModel.deleteContextAlbum("MyMap012", null);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(2, result.getMessages().size());
+
+ result = apexModel.listContextAlbum("MyMap012", null);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = apexModel.deleteContextAlbum(null, null);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(4, result.getMessages().size());
+
+ result = apexModel.listContextAlbum(null, null);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(0, result.getMessages().size());
+ }
+
+ private static void assertListContextAlbum(ApexModel apexModel) {
+ ApexApiResult result;
+ result = apexModel.listContextAlbum("@£%%$", null);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.listContextAlbum(null, null);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = apexModel.listContextAlbum("MyMap012", null);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = apexModel.listContextAlbum("MyMap012", "0.0.2");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = apexModel.listContextAlbum("MyMap012", "0.2.5");
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ result = apexModel.listContextAlbum("MyMap014", null);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ }
+ private static void assertUpdateContextAlbum(ApexModel apexModel) {
+ ApexApiResult result;
result = apexModel.updateContextAlbum(null, null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
result = apexModel.updateContextAlbum("MyMap002", "0.0.2", null, null, null, null, null, null);
@@ -123,54 +147,50 @@ public class ApexEditorApiContextAlbumTest {
result = apexModel.updateContextAlbum("MyMap012", null, "APPLICATION", "Hello", "StringType", "0.0.1", null,
null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ }
- result = apexModel.listContextAlbum("@£%%$", null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
-
- result = apexModel.listContextAlbum(null, null);
+ private static void assertCreateContextAlbum(ApexModel apexModel) {
+ ApexApiResult result;
+ result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", "0.0.1",
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listContextAlbum("MyMap012", null);
+ result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1",
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listContextAlbum("MyMap012", "0.0.2");
+ result = apexModel.createContextAlbum("MyMap012", "0.1.4", "UNDEFINED", null, "MapType", "0.0.1",
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 014");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.listContextAlbum("MyMap012", "0.2.5");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.listContextAlbum("MyMap014", null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.deleteContextAlbum("@£%%$", null);
+ result = apexModel.createContextAlbum("MyMap012", null, null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
-
- result = apexModel.deleteContextAlbum("MyMap012", "0.1.1");
+ result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", null, null, null, null, null);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", null, null, null, null);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "", null, null, null);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "+++", null, null, null);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapZooby", null, null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.deleteContextAlbum("MyMap012oooo", null);
+ result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "--++", null, null);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "0.0.2", null, null);
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.listContextAlbum("MyMap012", null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(3, result.getMessages().size());
-
- result = apexModel.deleteContextAlbum("MyMap012", "0.1.2");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.listContextAlbum("MyMap012", null);
+ result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", "0.0.1", null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(2, result.getMessages().size());
-
- result = apexModel.deleteContextAlbum("MyMap012", null);
+ result = apexModel.createContextAlbum("MyMap012", null, "EPHEMERAL", "false", "MapType", null, null, null);
+ assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
+ result = apexModel.createContextAlbum("MyMap002", "0.0.2", "APPLICATION", "true", "MapType", null,
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
+ assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
+ result = apexModel.createContextAlbum("MyMap011", "0.1.2", "APPLICATION", "true", "MapType", "0.0.1",
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 002");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(2, result.getMessages().size());
-
- result = apexModel.listContextAlbum("MyMap012", null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.deleteContextAlbum(null, null);
+ result = apexModel.deleteContextAlbum("MyMap012", "0.1.2");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(4, result.getMessages().size());
-
- result = apexModel.listContextAlbum(null, null);
+ result = apexModel.createContextAlbum("MyMap012", "0.1.2", "ZOOBY", "false", "MapType", "0.0.1",
+ "1fa2e430-f2b2-11e6-bc64-92361f002700", "A description of 012");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(0, result.getMessages().size());
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java
index 20310a29e..e7a6b112f 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiContextSchemaTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 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,17 +21,19 @@
package org.onap.policy.apex.model.modelapi;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Context schema for API tests.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexEditorApiContextSchemaTest {
+class ApexEditorApiContextSchemaTest {
+
@Test
- public void testContextSchemaCrud() {
+ void testContextSchemaCrud() {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateContextSchemas(null, null);
@@ -45,59 +47,60 @@ public class ApexEditorApiContextSchemaTest {
result = apexModel.listContextSchemas(null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextSchema("Hello", "0.0.2", "Java", "java.lang.String",
- "1fa2e430-f2b2-11e6-bc64-92361f002671", "A description of hello");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextSchema("Hello", "0.1.2", "Java", "java.lang.String",
- "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of hola");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String",
- "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextSchema("Hello", null, "Java", "java.lang.String", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextSchema("Hello", null, "Java", "java.lang.String", null, null);
- assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
- result = apexModel.deleteContextSchema("Hello", "0.1.4");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String",
- "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa");
+ assertCreateContextSchema(apexModel);
+
+ result = apexModel.validateContextSchemas(null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextSchema("Hello2", null, null, "java.lang.String", null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.createContextSchema("Hello2", null, null, null, null, null);
+ assertUpdateContextSchema(apexModel);
+
+ assertListContextSchemas(apexModel);
+
+ assertDeleteContextSchema(apexModel);
+ }
+
+ private static void assertDeleteContextSchema(ApexModel apexModel) {
+ ApexApiResult result;
+ result = apexModel.deleteContextSchema("@£%%$", null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.createContextSchema("Hello2", null, "Java", "java.lang.String", null, null);
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextSchema("Hello", "0.1.2", "Java", "java.lang.Float",
- "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of hola");
- assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
+ result = apexModel.deleteContextSchema("Hello", "0.1.1");
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
- result = apexModel.deleteContextSchema("Hello", "0.1.4");
- assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String",
- "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa");
+ result = apexModel.deleteContextSchema("Hellooooo", null);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = apexModel.listContextSchemas("Hello", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(4, result.getMessages().size());
- result = apexModel.validateContextSchemas(null, null);
+ result = apexModel.deleteContextSchema("Hello", "0.1.2");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.updateContextSchema(null, null, null, null, null, null);
- assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.listContextSchemas("Hello", null);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(3, result.getMessages().size());
- result = apexModel.updateContextSchema("Hello", "0.0.2", null, null, null, "An updated description of hello");
+ result = apexModel.deleteContextSchema("Hello", null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.updateContextSchema("Hello", "0.0.2", null, null, null, null);
+
+ result = apexModel.listContextSchemas("Hello", null);
+ assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+
+ result = apexModel.listContextSchemas(null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.updateContextSchema("Hello", "0.1.2", "Java", "java.lang.Integer",
- "1fa2e430-f2b2-11e6-bc64-92361f002673", "A further updated description of hola");
+
+ result = apexModel.deleteContextSchema(null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(5, result.getMessages().size());
- result = apexModel.updateContextSchema("Hello2", "0.0.2", null, null, null, "An updated description of hello");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ result = apexModel.listContextSchemas(null, null);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ assertEquals(0, result.getMessages().size());
+ }
+ private static void assertListContextSchemas(ApexModel apexModel) {
+ ApexApiResult result;
result = apexModel.listContextSchemas("@£%%$", null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
@@ -112,42 +115,61 @@ public class ApexEditorApiContextSchemaTest {
result = apexModel.listContextSchemas(null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
assertEquals(9, result.getMessages().size());
+ }
- result = apexModel.deleteContextSchema("@£%%$", null);
+ private static void assertUpdateContextSchema(ApexModel apexModel) {
+ ApexApiResult result;
+ result = apexModel.updateContextSchema(null, null, null, null, null, null);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.deleteContextSchema("Hello", "0.1.1");
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ result = apexModel.updateContextSchema("Hello", "0.0.2", null, null, null, "An updated description of hello");
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = apexModel.updateContextSchema("Hello", "0.0.2", null, null, null, null);
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = apexModel.updateContextSchema("Hello", "0.1.2", "Java", "java.lang.Integer",
+ "1fa2e430-f2b2-11e6-bc64-92361f002673", "A further updated description of hola");
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.deleteContextSchema("Hellooooo", null);
+ result = apexModel.updateContextSchema("Hello2", "0.0.2", null, null, null, "An updated description of hello");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
+ }
- result = apexModel.listContextSchemas("Hello", null);
+ private static void assertCreateContextSchema(ApexModel apexModel) {
+ ApexApiResult result;
+ result = apexModel.createContextSchema("Hello", "0.0.2", "Java", "java.lang.String",
+ "1fa2e430-f2b2-11e6-bc64-92361f002671", "A description of hello");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(4, result.getMessages().size());
-
- result = apexModel.deleteContextSchema("Hello", "0.1.2");
+ result = apexModel.createContextSchema("Hello", "0.1.2", "Java", "java.lang.String",
+ "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of hola");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.listContextSchemas("Hello", null);
+ result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String",
+ "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(3, result.getMessages().size());
-
- result = apexModel.deleteContextSchema("Hello", null);
+ result = apexModel.createContextSchema("Hello", null, "Java", "java.lang.String", null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
-
- result = apexModel.listContextSchemas("Hello", null);
- assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
-
- result = apexModel.listContextSchemas(null, null);
+ result = apexModel.createContextSchema("Hello", null, "Java", "java.lang.String", null, null);
+ assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
+ result = apexModel.deleteContextSchema("Hello", "0.1.4");
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String",
+ "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- result = apexModel.deleteContextSchema(null, null);
+ result = apexModel.createContextSchema("Hello2", null, null, "java.lang.String", null, null);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.createContextSchema("Hello2", null, null, null, null, null);
+ assertEquals(ApexApiResult.Result.FAILED, result.getResult());
+ result = apexModel.createContextSchema("Hello2", null, "Java", "java.lang.String", null, null);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(5, result.getMessages().size());
- result = apexModel.listContextSchemas(null, null);
+ result = apexModel.createContextSchema("Hello", "0.1.2", "Java", "java.lang.Float",
+ "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of hola");
+ assertEquals(ApexApiResult.Result.CONCEPT_EXISTS, result.getResult());
+
+ result = apexModel.deleteContextSchema("Hello", "0.1.4");
+ assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
+ result = apexModel.createContextSchema("Hello", "0.1.4", "Java", "java.lang.String",
+ "1fa2e430-f2b2-11e6-bc64-92361f002672", "A description of connichi wa");
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
- assertEquals(0, result.getMessages().size());
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
index ac9265e84..c94882b16 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiEventTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,18 +22,19 @@
package org.onap.policy.apex.model.modelapi;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test events for API tests.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexEditorApiEventTest {
+class ApexEditorApiEventTest {
+
@Test
- public void testEventCrud() {
+ void testEventCrud() {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateEvent(null, null);
@@ -141,7 +142,7 @@ public class ApexEditorApiEventTest {
result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", null, null, true);
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.createContextSchema("eventContextItem0", "0.0.1", "Java", "java.lang.Integer",
+ apexModel.createContextSchema("eventContextItem0", "0.0.1", "Java", "java.lang.Integer",
"1fa2e430-f2b2-11e6-bc64-92361f002673", "A further updated description of hola");
result = apexModel.createEventPar("MyEvent002", "0.0.2", "NewPar00", "eventContextItem0", null, false);
assertEquals(ApexApiResult.Result.SUCCESS, result.getResult());
@@ -173,7 +174,7 @@ public class ApexEditorApiEventTest {
result = apexModel.deleteEventPar("@££%%%", "0.0.2", "NewPar04");
assertEquals(ApexApiResult.Result.FAILED, result.getResult());
- result = apexModel.deleteEventPar("NonExistantEvent", "0.0.2", "NewPar04");
+ result = apexModel.deleteEventPar("NonExistentEvent", "0.0.2", "NewPar04");
assertEquals(ApexApiResult.Result.CONCEPT_DOES_NOT_EXIST, result.getResult());
assertEquals(4, apexModel.listEventPar("MyEvent002", null, null).getMessages().size());
result = apexModel.deleteEventPar("MyEvent002", "0.0.2", "NewPar04");
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java
index 2519b8cb2..831f81503 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiKeyInfoTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 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,18 +21,18 @@
package org.onap.policy.apex.model.modelapi;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Key information for API tests.
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexEditorApiKeyInfoTest {
+class ApexEditorApiKeyInfoTest {
@Test
- public void testKeyInfoCrud() {
+ void testKeyInfoCrud() {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateKeyInformation(null, null);
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java
index 0a4d72214..cdc035d8d 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiPolicyTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 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,18 +21,19 @@
package org.onap.policy.apex.model.modelapi;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test policies for API.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexEditorApiPolicyTest {
+class ApexEditorApiPolicyTest {
+
@Test
- public void testMyTestPolicyCrud() {
+ void testMyTestPolicyCrud() {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validatePolicy(null, null);
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
index 15e53f925..b0a727138 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexEditorApiTaskTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,9 +22,9 @@
package org.onap.policy.apex.model.modelapi;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.modelapi.impl.ApexModelImpl;
/**
@@ -32,9 +32,10 @@ import org.onap.policy.apex.model.modelapi.impl.ApexModelImpl;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexEditorApiTaskTest {
+class ApexEditorApiTaskTest {
+
@Test
- public void testTaskCrud() {
+ void testTaskCrud() {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.validateTask(null, null);
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
index f28d0e634..dbd4615b6 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ApexModelApiTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,18 +22,18 @@
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.UUID;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.modelapi.impl.ApexModelImpl;
import org.onap.policy.common.utils.resources.TextFileUtils;
@@ -42,23 +42,23 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexModelApiTest {
+class ApexModelApiTest {
private Connection connection;
- @Before
- public void setup() throws Exception {
+ @BeforeEach
+ void setup() throws Exception {
// Hold the h2 database up for entire tests
connection = DriverManager.getConnection("jdbc:h2:mem:testdb");
}
- @After
- public void teardown() throws Exception {
+ @AfterEach
+ void teardown() throws Exception {
// Close the h2 database after tests
connection.close();
}
@Test
- public void testApexModelLoadFromFile() {
+ void testApexModelLoadFromFile() {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.loadFromFile("src/main/resources/models/PolicyModel.json");
@@ -82,7 +82,7 @@ public class ApexModelApiTest {
}
@Test
- public void testApexModelSaveToFile() throws IOException {
+ void testApexModelSaveToFile() throws IOException {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
ApexApiResult result = apexModel.loadFromFile("src/test/resources/models/PolicyModel.json");
@@ -108,7 +108,7 @@ public class ApexModelApiTest {
}
@Test
- public void testApexModelUrl() throws IOException {
+ void testApexModelUrl() throws IOException {
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
assertThatThrownBy(() -> apexModel.readFromUrl(null)).isInstanceOf(IllegalArgumentException.class);
@@ -143,7 +143,7 @@ public class ApexModelApiTest {
}
@Test
- public void testApexModelMisc() throws IOException {
+ void testApexModelMisc() throws IOException {
final ApexModelImpl apexModelImpl = (ApexModelImpl) new ApexModelFactory().createApexModel(null);
ApexApiResult result = null;
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
index d3b32b923..8569f969d 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ModelFacadeTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,18 +22,18 @@
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Properties;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.modelapi.impl.ModelFacade;
-public class ModelFacadeTest {
+class ModelFacadeTest {
@Test
- public void testModelFacade() {
+ void testModelFacade() {
assertThatThrownBy(() -> new ModelFacade(null, null))
.hasMessage("apexModel may not be null");
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
index 5bbc95992..e1675be12 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/ModelHandlerFacadeTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +22,13 @@
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.modelapi.impl.ModelHandlerFacade;
import org.onap.policy.common.utils.resources.TextFileUtils;
@@ -37,10 +37,10 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ModelHandlerFacadeTest {
+class ModelHandlerFacadeTest {
@Test
- public void testModelHandlerFacade() throws IOException {
+ void testModelHandlerFacade() throws IOException {
assertThatThrownBy(() -> new ModelHandlerFacade(null, null))
.hasMessage("apexModel may not be null");
final ApexModel apexModel = new ApexModelFactory().createApexModel(null);
diff --git a/model/src/test/java/org/onap/policy/apex/model/modelapi/RealModelTest.java b/model/src/test/java/org/onap/policy/apex/model/modelapi/RealModelTest.java
index d9336bd9e..bf84350fd 100644
--- a/model/src/test/java/org/onap/policy/apex/model/modelapi/RealModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/modelapi/RealModelTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022, 2024 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,18 +20,18 @@
package org.onap.policy.apex.model.modelapi;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.common.utils.resources.TextFileUtils;
-public class RealModelTest {
- @Test
- public void testRealModel() throws Exception {
+class RealModelTest {
+ @Test
+ void testRealModel() throws Exception {
final String modelString = TextFileUtils.getTextFileAsString("src/test/resources/models/PolicyModel.json");
AxPolicyModel policyModel = new ApexModelReader<AxPolicyModel>(AxPolicyModel.class).read(modelString);
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/ExceptionsTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/ExceptionsTest.java
index 0afb48b3c..9b1e64a4b 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/ExceptionsTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/ExceptionsTest.java
@@ -1,39 +1,41 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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.concepts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test model exceptions.
+ *
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ExceptionsTest {
+class ExceptionsTest {
@Test
- public void test() {
+ void test() {
assertNotNull(new PolicyException("Message"));
assertNotNull(new PolicyException("Message", new IOException()));
@@ -44,8 +46,8 @@ public class ExceptionsTest {
assertNotNull(new PolicyRuntimeException("Message", new IOException()));
final PolicyRuntimeException re =
- new PolicyRuntimeException("Runtime Message", new IOException("IO runtime exception message"));
+ new PolicyRuntimeException("Runtime Message", new IOException("IO runtime exception message"));
assertEquals("Runtime Message\ncaused by: Runtime Message\ncaused by: IO runtime exception message",
- re.getCascadedMessage());
+ re.getCascadedMessage());
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java
index fbfc7c4a0..fd6d33064 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/LogicTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,11 @@
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;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -37,10 +37,10 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class LogicTest {
+class LogicTest {
@Test
- public void testLogic() {
+ void testLogic() {
final DummyLogicReader logicReader = new DummyLogicReader();
assertNotNull(new AxLogic());
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java
index 526f5a628..3fe7d010e 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PoliciesTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2022, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +22,13 @@
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;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Map;
import java.util.TreeMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
@@ -41,10 +41,10 @@ import org.onap.policy.apex.model.policymodel.handling.SupportApexPolicyModelCre
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class PoliciesTest {
+class PoliciesTest {
@Test
- public void testPolicies() {
+ void testPolicies() {
final TreeMap<String, AxState> stateMap = new TreeMap<>();
final TreeMap<String, AxState> stateMapEmpty = new TreeMap<>();
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java
index b699b5d48..b04757714 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/PolicyModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,11 +22,11 @@
package org.onap.policy.apex.model.policymodel.concepts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
@@ -44,10 +44,10 @@ import org.onap.policy.apex.model.policymodel.handling.SupportApexPolicyModelCre
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class PolicyModelTest {
+class PolicyModelTest {
@Test
- public void testPolicyModel() {
+ void testPolicyModel() {
assertNotNull(new AxPolicyModel());
assertNotNull(new AxPolicyModel(new AxArtifactKey()));
assertNotNull(new AxPolicyModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation(),
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java
index 049783a7f..b2cf1f27c 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateOutputTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,11 +23,11 @@
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;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -38,10 +38,10 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class StateOutputTest {
+class StateOutputTest {
@Test
- public void testStateOutput() {
+ void testStateOutput() {
assertNotNull(new AxStateOutput());
assertNotNull(new AxStateOutput(new AxReferenceKey()));
assertNotNull(new AxStateOutput(new AxReferenceKey(), new AxReferenceKey(), new AxArtifactKey()));
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java
index 568c47f61..078fd6f52 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTaskReferenceTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,11 @@
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;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -37,10 +37,10 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class StateTaskReferenceTest {
+class StateTaskReferenceTest {
@Test
- public void testStateTaskReference() {
+ void testStateTaskReference() {
assertNotNull(new AxStateTaskReference());
assertNotNull(new AxStateTaskReference(new AxReferenceKey()));
assertNotNull(new AxStateTaskReference(new AxReferenceKey(), AxStateTaskOutputType.UNDEFINED,
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java
index 7fbe78078..d5f5899fc 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/StateTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,14 +22,14 @@
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;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
@@ -41,10 +41,10 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class StateTest {
+class StateTest {
@Test
- public void testState() {
+ void testState() {
final TreeMap<String, AxStateOutput> soEmptyMap = new TreeMap<>();
final TreeSet<AxArtifactKey> ctxtEmptySet = new TreeSet<>();
final TreeMap<String, AxStateFinalizerLogic> sflEmptyMap = new TreeMap<>();
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java
index 4255b495d..25eb774fa 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TaskParameterTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,11 @@
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;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -37,10 +37,10 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.Validat
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TaskParameterTest {
+class TaskParameterTest {
@Test
- public void testTaskParameter() {
+ void testTaskParameter() {
assertNotNull(new AxTaskParameter());
assertNotNull(new AxTaskParameter(new AxReferenceKey()));
assertNotNull(new AxTaskParameter(new AxReferenceKey(), "DefaultValue"));
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
index 9c7866c85..519e21e2b 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/concepts/TasksTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,14 +22,14 @@
package org.onap.policy.apex.model.policymodel.concepts;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
@@ -41,10 +41,10 @@ import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TasksTest {
+class TasksTest {
@Test
- public void testTasks() {
+ void testTasks() {
final TreeMap<String, AxTaskParameter> tpEmptyMap = new TreeMap<>();
final TreeSet<AxArtifactKey> ctxtEmptySet = new TreeSet<>();
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
index 48e4f87f9..01f7062e1 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/ApexPolicyModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,72 +22,23 @@
package org.onap.policy.apex.model.policymodel.handling;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.common.utils.resources.ResourceUtils;
-public class ApexPolicyModelTest {
+class ApexPolicyModelTest {
private static final String VALID_MODEL_STRING = "***validation of model successful***";
- private static final String OBSERVATION_MODEL_STRING = "\n"
- + "***observations noted during validation of model***\n"
- + "AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,"
- + "localName=state):org.onap.policy.apex.model.policymodel.concepts.AxState:OBSERVATION:"
- + "state output stateOutput0 is not used directly by any task\n"
- + "********************************";
-
- private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=policy,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicy:WARNING:state AxReferenceKey:"
- + "(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=anotherState) "
- + "is not referenced in the policy execution tree\n" + "********************************";
-
- private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined\n"
- + "********************************";
-
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1):"
- + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:"
- + "keyInfoMap may not be empty\n" + "AxArtifactKey:(name=policyModel,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=policyModel,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=policyModel_Schemas,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=policyModel_Events,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=policyModel_Albums,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=policyModel_Tasks,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=policyModel_Policies,version=0.0.1)\n"
- + "AxArtifactKey:(name=policyModel_Schemas,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:"
- + "contextSchemas may not be empty\n" + "AxArtifactKey:(name=policyModel_Events,version=0.0.1):"
- + "org.onap.policy.apex.model.eventmodel.concepts.AxEvents:INVALID:eventMap may not be empty\n"
- + "AxArtifactKey:(name=policyModel_Albums,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty\n"
- + "AxArtifactKey:(name=policyModel_Tasks,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxTasks:INVALID:taskMap may not be empty\n"
- + "AxArtifactKey:(name=policyModel_Policies,version=0.0.1)"
- + ":org.onap.policy.apex.model.policymodel.concepts.AxPolicies:INVALID:policyMap may not be empty\n"
- + "********************************";
+ private static final String OBSERVATION_MODEL_STRING = "policymodel/handling/ApexPolicyModel_ObservationModel.txt";
+ private static final String WARNING_MODEL_STRING = "policymodel/handling/ApexPolicyModel_WarningModel.txt";
+ private static final String INVALID_MODEL_STRING = "policymodel/handling/ApexPolicyModelTest_InvalidModel.txt";
+ private static final String INVALID_MODEL_MALSTRUCTURED_STRING =
+ "policymodel/handling/ApexPolicyModelTest_InvalidMalStructuredModel.txt";
TestApexModel<AxPolicyModel> testApexModel;
@@ -96,43 +47,43 @@ public class ApexPolicyModelTest {
*
* @throws Exception on setup errors
*/
- @Before
+ @BeforeEach
public void setup() throws Exception {
- testApexModel = new TestApexModel<AxPolicyModel>(AxPolicyModel.class, new SupportApexPolicyModelCreator());
+ testApexModel = new TestApexModel<>(AxPolicyModel.class, new SupportApexPolicyModelCreator());
}
@Test
- public void testModelValid() throws Exception {
+ void testModelValid() throws Exception {
final AxValidationResult result = testApexModel.testApexModelValid();
assertEquals(VALID_MODEL_STRING, result.toString());
}
@Test
- public void testApexModelVaidateObservation() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
- assertEquals(OBSERVATION_MODEL_STRING, result.toString());
+ void testApexModelValidateObservation() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateObservation();
+ assertEquals(ResourceUtils.getResourceAsString(OBSERVATION_MODEL_STRING), result.toString());
}
@Test
- public void testApexModelVaidateWarning() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertEquals(WARNING_MODEL_STRING, result.toString());
+ void testApexModelValidateWarning() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateWarning();
+ assertEquals(ResourceUtils.getResourceAsString(WARNING_MODEL_STRING), result.toString());
}
@Test
- public void testModelVaidateInvalidModel() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertEquals(INVALID_MODEL_STRING, result.toString());
+ void testModelValidateInvalidModel() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateInvalidModel();
+ assertEquals(ResourceUtils.getResourceAsString(INVALID_MODEL_STRING), result.toString());
}
@Test
- public void testModelVaidateMalstructured() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
+ void testModelValidateMalstructured() throws Exception {
+ final AxValidationResult result = testApexModel.testApexModelValidateMalstructured();
+ assertEquals(ResourceUtils.getResourceAsString(INVALID_MODEL_MALSTRUCTURED_STRING), result.toString());
}
@Test
- public void testModelWriteReadJson() throws Exception {
+ void testModelWriteReadJson() throws Exception {
testApexModel.testApexModelWriteReadJson();
}
}
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
index b1e2d5cbd..a3e1859a9 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyAnalyserTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,15 +22,15 @@
package org.onap.policy.apex.model.policymodel.handling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-public class PolicyAnalyserTest {
+class PolicyAnalyserTest {
@Test
- public void test() {
+ void test() {
final AxPolicyModel apexModel = new SupportApexPolicyModelCreator().getModel();
final PolicyAnalyser policyAnalyser = new PolicyAnalyser();
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReaderTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReaderTest.java
index a2cbe7415..b9885e39d 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReaderTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyLogicReaderTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 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,9 +23,9 @@ package org.onap.policy.apex.model.policymodel.handling;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.policymodel.concepts.AxLogic;
@@ -35,10 +35,10 @@ import org.onap.policy.apex.model.policymodel.concepts.AxLogic;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class PolicyLogicReaderTest {
+class PolicyLogicReaderTest {
@Test
- public void test() {
+ void test() {
final AxReferenceKey logicKey = new AxReferenceKey("LogicParent", "0.0.1", "LogicInstanceName");
final PolicyLogicReader plReader = new PolicyLogicReader();
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
index 691880d6b..ea3bc5564 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelComparerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2022, 2024 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,21 +21,21 @@
package org.onap.policy.apex.model.policymodel.handling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
import org.onap.policy.common.utils.resources.TextFileUtils;
-public class PolicyModelComparerTest {
+class PolicyModelComparerTest {
@Test
- public void testPolicyComparer() throws IOException {
+ void testPolicyComparer() throws IOException {
final AxPolicyModel leftApexModel = new SupportApexPolicyModelCreator().getModel();
final AxPolicyModel rightApexModel = new AxPolicyModel(leftApexModel);
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelMergerTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelMergerTest.java
index 2bdf7499f..0625068cf 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelMergerTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelMergerTest.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, 2024 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,10 +23,10 @@
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
@@ -37,10 +37,10 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTaskLogic;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class PolicyModelMergerTest {
+class PolicyModelMergerTest {
@Test
- public void testPolicyModelMerger() throws ApexModelException {
+ void testPolicyModelMerger() throws ApexModelException {
final AxPolicyModel leftPolicyModel = new SupportApexPolicyModelCreator().getModel();
final AxPolicyModel rightPolicyModel = new SupportApexPolicyModelCreator().getModel();
diff --git a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java
index 902206d51..070b29ff2 100644
--- a/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/policymodel/handling/PolicyModelSplitterTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,19 +22,19 @@
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.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Set;
import java.util.TreeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-public class PolicyModelSplitterTest {
+class PolicyModelSplitterTest {
@Test
- public void test() throws ApexModelException {
+ void test() throws ApexModelException {
final AxPolicyModel apexModel = new SupportApexPolicyModelCreator().getModel();
final Set<AxArtifactKey> requiredPolicySet = new TreeSet<AxArtifactKey>();
diff --git a/model/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java b/model/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java
index 2512133e7..5b75e3202 100644
--- a/model/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/utilities/CollectionUtilitiesTest.java
@@ -1,46 +1,47 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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.utilities;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class CollectionUtilitiesTest {
+class CollectionUtilitiesTest {
@Test
- public void testNullLists() {
- int result = 0;
+ void testNullLists() {
+ int result;
result = CollectionUtils.compareLists(null, null);
assertEquals(0, result);
- List<String> leftList = new ArrayList<String>();
+ List<String> leftList = new ArrayList<>();
result = CollectionUtils.compareLists(leftList, null);
assertEquals(-1, result);
- List<String> rightList = new ArrayList<String>();
+ List<String> rightList = new ArrayList<>();
result = CollectionUtils.compareLists(null, rightList);
assertEquals(1, result);
diff --git a/model/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java b/model/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java
index 69c2d4763..d51ca4c34 100644
--- a/model/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/utilities/DirectoryUtilsTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 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,19 +21,19 @@
package org.onap.policy.apex.model.utilities;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.resources.TextFileUtils;
-public class DirectoryUtilsTest {
+class DirectoryUtilsTest {
@Test
- public void test() throws IOException {
+ void test() throws IOException {
DirectoryUtils.emptyDirectory(new File("/i/dont/exist"));
File tempDir = Files.createTempDirectory("test").toFile();
diff --git a/model/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java b/model/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java
index 20780b271..22c6d659d 100644
--- a/model/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/utilities/KeyComparerTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 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,10 +21,10 @@
package org.onap.policy.apex.model.utilities;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.utilities.comparison.KeyComparer;
import org.onap.policy.apex.model.utilities.comparison.KeyDifference;
@@ -33,15 +33,15 @@ import org.onap.policy.apex.model.utilities.comparison.KeyDifference;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class KeyComparerTest {
+class KeyComparerTest {
@Test
- public void test() {
+ void test() {
KeyDifference<String> keyDifference = new KeyComparer<String>().compareKeys("Hello", "Goodbye");
assertFalse(keyDifference.isEqual());
- assertEquals("Hello", keyDifference.getLeftKey().toString());
- assertEquals("Goodbye", keyDifference.getRightKey().toString());
+ assertEquals("Hello", keyDifference.getLeftKey());
+ assertEquals("Goodbye", keyDifference.getRightKey());
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));
diff --git a/model/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java b/model/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java
index b4e88e20d..ee473d9f7 100644
--- a/model/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/utilities/KeyedMapComparerTest.java
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 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,11 +21,11 @@
package org.onap.policy.apex.model.utilities;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.TreeMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.apex.model.utilities.comparison.KeyedMapComparer;
import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
@@ -34,10 +34,10 @@ import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class KeyedMapComparerTest {
+class KeyedMapComparerTest {
@Test
- public void test() {
+ void test() {
TreeMap<String, String> leftMap = new TreeMap<String, String>();
leftMap.put("B", "BBBBB");
leftMap.put("C", "CCCCC");
diff --git a/model/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java b/model/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java
index 1d6f29fe5..01d849efd 100644
--- a/model/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/utilities/TextFileUtilsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2024 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,12 +21,12 @@
package org.onap.policy.apex.model.utilities;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.resources.TextFileUtils;
/**
@@ -34,12 +34,12 @@ import org.onap.policy.common.utils.resources.TextFileUtils;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class TextFileUtilsTest {
+class TextFileUtilsTest {
private static final String FILE_CONTENT = "This is the contents of a text file";
@Test
- public void test() throws IOException {
+ void test() throws IOException {
final File tempTextFile = File.createTempFile("Test", "txt");
TextFileUtils.putStringAsTextFile(FILE_CONTENT, tempTextFile.getAbsolutePath());
diff --git a/model/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java b/model/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java
index c3a36b7b9..296f35d49 100644
--- a/model/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/utilities/TreeMapUtilsTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,13 +23,13 @@
package org.onap.policy.apex.model.utilities;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* Test the tree map utilities.
diff --git a/model/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java b/model/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java
index ae5d53ec3..d5c913d91 100644
--- a/model/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java
+++ b/model/src/test/java/org/onap/policy/apex/model/utilities/json/JsonHandlerTest.java
@@ -1,40 +1,41 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2024 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.utilities.json;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.gson.GsonBuilder;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class JsonHandlerTest {
+class JsonHandlerTest {
private static final String VALUE = "value";
@Test
- public void testAssertions() throws IOException {
+ void testAssertions() throws IOException {
final OverTheMoonObject jsonObject = new OverTheMoonObject(VALUE);
final String jsonString = new GsonBuilder().create().toJson(jsonObject);
diff --git a/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_InvalidModel.txt b/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_InvalidModel.txt
new file mode 100644
index 000000000..bb3f256cd
--- /dev/null
+++ b/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_InvalidModel.txt
@@ -0,0 +1,7 @@
+
+***validation of model failed***
+AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000
+AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank
+AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000
+AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:duplicate UUID found on keyInfoMap entry AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):00000000-0000-0000-0000-000000000000
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_InvalidModelMalStructured.txt b/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_InvalidModelMalStructured.txt
new file mode 100644
index 000000000..c375c13ce
--- /dev/null
+++ b/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_InvalidModelMalStructured.txt
@@ -0,0 +1,5 @@
+
+***validation of model failed***
+AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000
+AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:INVALID:key information not found for key AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_ValidModel.txt b/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_ValidModel.txt
new file mode 100644
index 000000000..ba08a0b02
--- /dev/null
+++ b/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_ValidModel.txt
@@ -0,0 +1,5 @@
+
+***warnings issued during validation of model***
+AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry
+AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_WarningModel.txt b/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_WarningModel.txt
new file mode 100644
index 000000000..0b7ec4af1
--- /dev/null
+++ b/model/src/test/resources/basicmodel/handling/SupportApexBasicModelTest_WarningModel.txt
@@ -0,0 +1,7 @@
+
+***warnings issued during validation of model***
+AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry
+AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry
+AxArtifactKey:(name=Unref0,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry
+AxArtifactKey:(name=Unref1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/contextmodel/handling/ApexContextModel_InvalidMalStructuredModel.txt b/model/src/test/resources/contextmodel/handling/ApexContextModel_InvalidMalStructuredModel.txt
new file mode 100644
index 000000000..636a22342
--- /dev/null
+++ b/model/src/test/resources/contextmodel/handling/ApexContextModel_InvalidMalStructuredModel.txt
@@ -0,0 +1,7 @@
+
+***validation of model failed***
+AxArtifactKey:(name=ContextModel,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:INVALID:key information not found for key AxArtifactKey:(name=contextAlbum1,version=0.0.2)
+AxArtifactKey:(name=contextAlbum1,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:WARNING:key not found for key information entry
+AxArtifactKey:(name=ContextSchemas,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:key on schemas entry AxArtifactKey:(name=MapType,version=0.0.1) does not equal entry key AxArtifactKey:(name=MapType,version=0.0.2)
+AxArtifactKey:(name=contextAlbums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:INVALID:key on context album entry key AxArtifactKey:(name=contextAlbum1,version=0.0.1) does not equal context album value key AxArtifactKey:(name=contextAlbum1,version=0.0.2)
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/contextmodel/handling/ApexContextModel_InvalidModel.txt b/model/src/test/resources/contextmodel/handling/ApexContextModel_InvalidModel.txt
new file mode 100644
index 000000000..d6fa068da
--- /dev/null
+++ b/model/src/test/resources/contextmodel/handling/ApexContextModel_InvalidModel.txt
@@ -0,0 +1,5 @@
+
+***validation of model failed***
+AxArtifactKey:(name=StringType,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema:INVALID:no schemaDefinition specified, schemaDefinition may not be blank
+AxArtifactKey:(name=contextAlbum0,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/contextmodel/handling/ApexContextModel_ObservationModel.txt b/model/src/test/resources/contextmodel/handling/ApexContextModel_ObservationModel.txt
new file mode 100644
index 000000000..cf27f0a80
--- /dev/null
+++ b/model/src/test/resources/contextmodel/handling/ApexContextModel_ObservationModel.txt
@@ -0,0 +1,4 @@
+
+***observations noted during validation of model***
+AxArtifactKey:(name=contextAlbum1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/contextmodel/handling/ApexContextModel_WarningModel.txt b/model/src/test/resources/contextmodel/handling/ApexContextModel_WarningModel.txt
new file mode 100644
index 000000000..f8b177b0a
--- /dev/null
+++ b/model/src/test/resources/contextmodel/handling/ApexContextModel_WarningModel.txt
@@ -0,0 +1,4 @@
+
+***warnings issued during validation of model***
+AxArtifactKey:(name=contextAlbum1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/eventmodel/handling/ApexEventModelTest_InvalidModel.txt b/model/src/test/resources/eventmodel/handling/ApexEventModelTest_InvalidModel.txt
new file mode 100644
index 000000000..53a398363
--- /dev/null
+++ b/model/src/test/resources/eventmodel/handling/ApexEventModelTest_InvalidModel.txt
@@ -0,0 +1,37 @@
+
+***validation of model failed***
+AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:keyInfoMap may not be empty
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=smallEventModel,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=Schemas,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=BigIntType,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=BooleanType,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=IntType,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=MapType,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=SetType,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=StringType,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=smallEventMap,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=event0,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par0)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par2)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par3)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par4)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par5)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=par6)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=event1,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:duplicate key AxArtifactKey:(name=event1,version=0.0.1) found
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=event1,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:duplicate key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar) found
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar)
+AxArtifactKey:(name=event0,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event0,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:INVALID:parent key on parameter field AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar) does not equal event key
+AxArtifactKey:(name=smallEventMap,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvents:INVALID:key on event entry key AxArtifactKey:(name=event2,version=0.0.1) does not equal event value key AxArtifactKey:(name=event1,version=0.0.1)
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:INVALID:parent key on parameter field AxReferenceKey:(parentKeyName=event0,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar) does not equal event key
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/eventmodel/handling/ApexEventModelTest_InvalidModelMalStructured.txt b/model/src/test/resources/eventmodel/handling/ApexEventModelTest_InvalidModelMalStructured.txt
new file mode 100644
index 000000000..5c94674d4
--- /dev/null
+++ b/model/src/test/resources/eventmodel/handling/ApexEventModelTest_InvalidModelMalStructured.txt
@@ -0,0 +1,20 @@
+
+***validation of model failed***
+AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:keyInfoMap may not be empty
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=smallEventModel,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=Schemas,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=SetType,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=smallEventMap,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=event1,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:duplicate key AxArtifactKey:(name=event1,version=0.0.1) found
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for key AxArtifactKey:(name=event1,version=0.0.1)
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:duplicate key AxReferenceKey:(parentKeyName=event1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar) found
+AxArtifactKey:(name=smallEventModel,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEventModel:INVALID:key information not found for parent key of key AxReferenceKey:(parentKeyName=event1,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=theOnlyPar)
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+AxArtifactKey:(name=smallEventMap,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvents:INVALID:key on event entry key AxArtifactKey:(name=event2,version=0.0.1) does not equal event value key AxArtifactKey:(name=event1,version=0.0.1)
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/eventmodel/handling/ApexEventModelTest_ObservationModel.txt b/model/src/test/resources/eventmodel/handling/ApexEventModelTest_ObservationModel.txt
new file mode 100644
index 000000000..8d2321df1
--- /dev/null
+++ b/model/src/test/resources/eventmodel/handling/ApexEventModelTest_ObservationModel.txt
@@ -0,0 +1,9 @@
+
+***observations noted during validation of model***
+AxArtifactKey:(name=event0,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event0,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+AxArtifactKey:(name=event2,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event2,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/eventmodel/handling/ApexEventModelTest_WarningModel.txt b/model/src/test/resources/eventmodel/handling/ApexEventModelTest_WarningModel.txt
new file mode 100644
index 000000000..8c17042cf
--- /dev/null
+++ b/model/src/test/resources/eventmodel/handling/ApexEventModelTest_WarningModel.txt
@@ -0,0 +1,12 @@
+
+***warnings issued during validation of model***
+AxArtifactKey:(name=event0,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:WARNING:nameSpace on event is blank
+AxArtifactKey:(name=event0,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event0,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:WARNING:nameSpace on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event1,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+AxArtifactKey:(name=event2,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:WARNING:nameSpace on event is blank
+AxArtifactKey:(name=event2,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:source on event is blank
+AxArtifactKey:(name=event2,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvent:OBSERVATION:target on event is blank
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/policymodel/handling/ApexPolicyModelTest_InvalidMalStructuredModel.txt b/model/src/test/resources/policymodel/handling/ApexPolicyModelTest_InvalidMalStructuredModel.txt
new file mode 100644
index 000000000..0a57a46e4
--- /dev/null
+++ b/model/src/test/resources/policymodel/handling/ApexPolicyModelTest_InvalidMalStructuredModel.txt
@@ -0,0 +1,16 @@
+
+***validation of model failed***
+AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:keyInfoMap may not be empty
+AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel,version=0.0.1)
+AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_KeyInfo,version=0.0.1)
+AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Schemas,version=0.0.1)
+AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Events,version=0.0.1)
+AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Albums,version=0.0.1)
+AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Tasks,version=0.0.1)
+AxArtifactKey:(name=policyModel,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel:INVALID:key information not found for key AxArtifactKey:(name=policyModel_Policies,version=0.0.1)
+AxArtifactKey:(name=policyModel_Schemas,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:contextSchemas may not be empty
+AxArtifactKey:(name=policyModel_Events,version=0.0.1):org.onap.policy.apex.model.eventmodel.concepts.AxEvents:INVALID:eventMap may not be empty
+AxArtifactKey:(name=policyModel_Albums,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:OBSERVATION:albums are empty
+AxArtifactKey:(name=policyModel_Tasks,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxTasks:INVALID:taskMap may not be empty
+AxArtifactKey:(name=policyModel_Policies,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicies:INVALID:policyMap may not be empty
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/policymodel/handling/ApexPolicyModelTest_InvalidModel.txt b/model/src/test/resources/policymodel/handling/ApexPolicyModelTest_InvalidModel.txt
new file mode 100644
index 000000000..c3a0ad78d
--- /dev/null
+++ b/model/src/test/resources/policymodel/handling/ApexPolicyModelTest_InvalidModel.txt
@@ -0,0 +1,5 @@
+
+***validation of model failed***
+AxArtifactKey:(name=contextAlbum0,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined
+AxArtifactKey:(name=contextAlbum1,version=0.0.1):org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:scope is not defined
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/policymodel/handling/ApexPolicyModel_ObservationModel.txt b/model/src/test/resources/policymodel/handling/ApexPolicyModel_ObservationModel.txt
new file mode 100644
index 000000000..43a1cc530
--- /dev/null
+++ b/model/src/test/resources/policymodel/handling/ApexPolicyModel_ObservationModel.txt
@@ -0,0 +1,4 @@
+
+***observations noted during validation of model***
+AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=state):org.onap.policy.apex.model.policymodel.concepts.AxState:OBSERVATION:state output stateOutput0 is not used directly by any task
+******************************** \ No newline at end of file
diff --git a/model/src/test/resources/policymodel/handling/ApexPolicyModel_WarningModel.txt b/model/src/test/resources/policymodel/handling/ApexPolicyModel_WarningModel.txt
new file mode 100644
index 000000000..79c5c310a
--- /dev/null
+++ b/model/src/test/resources/policymodel/handling/ApexPolicyModel_WarningModel.txt
@@ -0,0 +1,4 @@
+
+***warnings issued during validation of model***
+AxArtifactKey:(name=policy,version=0.0.1):org.onap.policy.apex.model.policymodel.concepts.AxPolicy:WARNING:state AxReferenceKey:(parentKeyName=policy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=anotherState) is not referenced in the policy execution tree
+******************************** \ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 0927ebb9c..67db076e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
<groupId>org.onap.policy.parent</groupId>
<artifactId>integration</artifactId>
<version>5.0.0-SNAPSHOT</version>
- <relativePath />
+ <relativePath/>
</parent>
<groupId>org.onap.policy.apex-pdp</groupId>
@@ -88,6 +88,26 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>