summaryrefslogtreecommitdiffstats
path: root/model/basic-model/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'model/basic-model/src/test')
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java84
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java108
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java189
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java78
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java177
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/DummyEntity.java164
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ExceptionsTest.java66
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ValidationTest.java90
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelExceptionTest.java39
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java94
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java105
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java52
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java63
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java67
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyApexBasicModelCreator.java123
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyAxModelWithReferences.java71
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java294
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java116
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator0.java64
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator1.java68
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator2.java64
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java111
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java217
-rw-r--r--model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java65
-rw-r--r--model/basic-model/src/test/resources/logback-test.xml70
25 files changed, 0 insertions, 2639 deletions
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java
deleted file mode 100644
index 44a9de49e..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxConceptGetterImplTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.util.NavigableMap;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import org.junit.Test;
-
-/**
- * Test the AxConceptGetterImpl class.
- */
-public class AxConceptGetterImplTest {
-
- @Test
- public void testAxConceptGetterImpl() {
- NavigableMap<AxArtifactKey, AxArtifactKey> keyMap = new TreeMap<>();
-
- AxConceptGetterImpl<AxArtifactKey> getter = new AxConceptGetterImpl<>(keyMap);
- assertNotNull(getter);
-
- AxArtifactKey keyA = new AxArtifactKey("A", "0.0.1");
- assertNull(getter.get(keyA));
-
- assertThatThrownBy(() -> getter.get((String) null))
- .hasMessage("conceptKeyName may not be null");
- assertNull(getter.get("W"));
-
- AxArtifactKey keyZ = new AxArtifactKey("Z", "0.0.1");
- keyMap.put(keyZ, keyZ);
- assertNull(getter.get("W"));
-
- AxArtifactKey keyW001 = new AxArtifactKey("W", "0.0.1");
- keyMap.put(keyW001, keyW001);
- assertEquals(keyW001, getter.get("W"));
-
- AxArtifactKey keyW002 = new AxArtifactKey("W", "0.0.2");
- keyMap.put(keyW002, keyW002);
- assertEquals(keyW002, getter.get("W"));
-
- keyMap.remove(keyZ);
- assertEquals(keyW002, getter.get("W"));
-
- assertThatThrownBy(() -> getter.get((String) null, "0.0.1"))
- .hasMessage("conceptKeyName may not be null");
- assertEquals(keyW002, getter.get("W", "0.0.2"));
- assertEquals(keyW002, getter.get("W", (String) null));
-
- assertEquals(new TreeSet<AxArtifactKey>(keyMap.values()), getter.getAll(null));
- assertEquals(new TreeSet<AxArtifactKey>(keyMap.values()), getter.getAll(null, null));
-
- assertEquals(keyW001, getter.getAll("W", null).iterator().next());
- assertEquals(keyW002, getter.getAll("W", "0.0.2").iterator().next());
- assertEquals(0, getter.getAll("A", null).size());
- assertEquals(0, getter.getAll("Z", null).size());
-
- keyMap.put(keyZ, keyZ);
- assertEquals(keyW002, getter.getAll("W", "0.0.2").iterator().next());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
deleted file mode 100644
index 0c7edee28..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyInfoTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2022 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.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.UUID;
-import org.junit.Test;
-
-
-public class AxKeyInfoTest {
-
- @Test
- public void testNullAxKeyInfo() {
- assertNotNull(new AxKeyInfo());
- assertNotNull(new AxKeyInfo(new AxArtifactKey()));
- assertNotNull(new AxKeyInfo(new AxArtifactKey(), UUID.randomUUID(), "Key description"));
- }
-
- @Test
- public void testAxKeyInfo() {
- AxKeyInfo testKeyInfo = new AxKeyInfo();
- testKeyInfo.setKey((new AxArtifactKey("PN", "0.0.1")));
- assertEquals("PN:0.0.1", testKeyInfo.getKey().getId());
- assertTrue(testKeyInfo.matchesId("PN:0.0.1"));
-
- AxArtifactKey key = new AxArtifactKey("key", "0.0.1");
- testKeyInfo.setKey(key);
- assertEquals(key, testKeyInfo.getKey());
-
- UUID uuid = UUID.randomUUID();
- testKeyInfo.setUuid(uuid);
- assertEquals(uuid, testKeyInfo.getUuid());
- testKeyInfo.setDescription("Key Description");
- assertEquals("Key Description", testKeyInfo.getDescription());
-
- AxKeyInfo clonedReferenceKey = new AxKeyInfo(testKeyInfo);
- assertTrue(clonedReferenceKey.toString()
- .startsWith("AxKeyInfo:(artifactId=AxArtifactKey:(name=key,version=0.0.1),uuid="));
-
- assertNotEquals(0, testKeyInfo.hashCode());
- // disabling sonar because this code tests the equals() method
- assertEquals(testKeyInfo, testKeyInfo); // NOSONAR
- assertEquals(testKeyInfo, clonedReferenceKey);
- assertNotNull(testKeyInfo);
- Object differentKeyType = new AxArtifactKey();
- assertNotEquals(testKeyInfo, differentKeyType);
- assertNotEquals(testKeyInfo, new AxKeyInfo(new AxArtifactKey()));
- assertNotEquals(testKeyInfo, new AxKeyInfo(key, UUID.randomUUID(), "Some Description"));
- 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() {
- AxKeyInfo testKeyInfo = new AxKeyInfo();
- testKeyInfo.setKey((new AxArtifactKey("PN", "0.0.1")));
-
- AxValidationResult result = new AxValidationResult();
- result = testKeyInfo.validate(result);
- assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult());
-
- testKeyInfo.setDescription("");
- result = testKeyInfo.validate(result);
- assertEquals(AxValidationResult.ValidationResult.OBSERVATION, result.getValidationResult());
-
- testKeyInfo.setUuid(new UUID(0, 0));
- result = testKeyInfo.validate(result);
- assertEquals(AxValidationResult.ValidationResult.WARNING, result.getValidationResult());
-
- testKeyInfo.setKey(AxArtifactKey.getNullKey());
- result = testKeyInfo.validate(result);
- assertEquals(AxValidationResult.ValidationResult.INVALID, result.getValidationResult());
-
- assertNotNull(AxKeyInfo.generateReproducibleUuid(null));
- assertNotNull(AxKeyInfo.generateReproducibleUuid("SeedString"));
-
- testKeyInfo.clean();
- assertNotNull(testKeyInfo);
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
deleted file mode 100644
index 010f4b8a3..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.lang.reflect.Field;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility;
-
-public class AxKeyTest {
-
- private static AxArtifactKey someKey0;
- private static AxArtifactKey someKey1;
- private static AxArtifactKey someKey2;
- private static AxArtifactKey someKey3;
- private static AxArtifactKey someKey4;
- private static AxArtifactKey someKey5;
- private static AxArtifactKey someKey6;
-
- /**
- * Sets data in Keys for the tests.
- */
- @Before
- public void setKeys() {
- someKey0 = new AxArtifactKey();
- someKey1 = new AxArtifactKey("name", "0.0.1");
- someKey2 = new AxArtifactKey(someKey1);
- someKey3 = new AxArtifactKey(someKey1.getId());
- someKey4 = new AxArtifactKey(someKey1);
- someKey5 = new AxArtifactKey(someKey1);
- someKey6 = new AxArtifactKey(someKey1);
- }
-
- private void setKeyValues() {
- someKey0.setName("zero");
- someKey0.setVersion("0.0.2");
- someKey3.setVersion("0.0.2");
- someKey4.setVersion("0.1.2");
- someKey5.setVersion("1.2.2");
- someKey6.setVersion("3");
- }
-
- @Test
- public 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]\"");
-
- assertEquals(AxArtifactKey.getNullKey(), someKey0);
-
- assertEquals(someKey1, someKey2);
- assertEquals(someKey1, someKey3);
-
- assertEquals(someKey2, someKey1.getKey());
- assertEquals(1, someKey1.getKeys().size());
-
- setKeyValues();
-
- someKey0.clean();
- assertNotNull(someKey0.toString());
-
- AxArtifactKey someKey7 = new AxArtifactKey(someKey1);
- assertEquals(150332875, someKey7.hashCode());
- assertEquals(0, someKey7.compareTo(someKey1));
- assertEquals(-12, someKey7.compareTo(someKey0));
-
- assertThatThrownBy(() -> someKey0.compareTo(null))
- .hasMessage("comparison object may not be null");
- assertEquals(0, someKey0.compareTo(someKey0));
- assertEquals(353602977, someKey0.compareTo(new AxReferenceKey()));
-
- assertNotNull(someKey0);
- // disabling sonar because this code tests the equals() method
- assertEquals(someKey0, someKey0); // NOSONAR
- assertNotEquals(someKey0, (Object) new AxReferenceKey());
- }
-
- @Test
- public void testAxCompatibility() {
- setKeyValues();
-
- assertEquals(Compatibility.DIFFERENT, someKey0.getCompatibility(new AxReferenceKey()));
- assertEquals(Compatibility.DIFFERENT, someKey0.getCompatibility(someKey1));
- assertEquals(Compatibility.IDENTICAL, someKey2.getCompatibility(someKey1));
- assertEquals(Compatibility.PATCH, someKey3.getCompatibility(someKey1));
- assertEquals(Compatibility.MINOR, someKey4.getCompatibility(someKey1));
- assertEquals(Compatibility.MAJOR, someKey5.getCompatibility(someKey1));
- assertEquals(Compatibility.MAJOR, someKey6.getCompatibility(someKey1));
-
- assertTrue(someKey1.isCompatible(someKey2));
- assertTrue(someKey1.isCompatible(someKey3));
- assertTrue(someKey1.isCompatible(someKey4));
- assertFalse(someKey1.isCompatible(someKey0));
- assertFalse(someKey1.isCompatible(someKey5));
- assertFalse(someKey1.isCompatible(new AxReferenceKey()));
- }
-
- @Test
- public void testAxValidation() {
- setKeyValues();
-
- assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey0.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey1.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey2.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey3.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey4.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey5.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID,
- someKey6.validate(new AxValidationResult()).getValidationResult());
- }
-
- @Test
- public void testNullKey() {
- setKeyValues();
-
- AxArtifactKey nullKey0 = AxArtifactKey.getNullKey();
- assertTrue(nullKey0.isNullKey());
- AxArtifactKey nullKey1 = new AxArtifactKey();
- assertTrue(nullKey1.isNullKey());
- AxArtifactKey nullKey2 = new AxArtifactKey(AxKey.NULL_KEY_NAME, AxKey.NULL_KEY_VERSION);
- assertTrue(nullKey2.isNullKey());
- AxArtifactKey notnullKey = new AxArtifactKey("Blah", AxKey.NULL_KEY_VERSION);
- assertFalse(notnullKey.isNullKey());
- }
-
-
- @Test
- public void testValidation() throws IllegalArgumentException, IllegalAccessException,
- NoSuchFieldException, SecurityException {
- AxArtifactKey testKey = new AxArtifactKey("TheKey", "0.0.1");
- assertEquals("TheKey:0.0.1", testKey.getId());
-
- Field nameField = testKey.getClass().getDeclaredField("name");
- nameField.setAccessible(true);
- nameField.set(testKey, "Key Name");
- AxValidationResult validationResult = new AxValidationResult();
- testKey.validate(validationResult);
- nameField.set(testKey, "TheKey");
- nameField.setAccessible(false);
- assertEquals(
- "name invalid-parameter name with value Key Name "
- + "does not match regular expression [A-Za-z0-9\\-_\\.]+",
- validationResult.getMessageList().get(0).getMessage());
-
- Field versionField = testKey.getClass().getDeclaredField("version");
- versionField.setAccessible(true);
- versionField.set(testKey, "Key Version");
- AxValidationResult validationResultV = new AxValidationResult();
- testKey.validate(validationResultV);
- versionField.set(testKey, "0.0.1");
- versionField.setAccessible(false);
- assertEquals(
- "version invalid-parameter version with value Key Version "
- + "does not match regular expression [A-Za-z0-9.]+",
- validationResultV.getMessageList().get(0).getMessage());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java
deleted file mode 100644
index 5346b6b21..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyUseTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility;
-
-public class AxKeyUseTest {
-
- @Test
- public void test() {
- assertNotNull(new AxKeyUse());
- assertNotNull(new AxKeyUse(new AxArtifactKey()));
- assertNotNull(new AxKeyUse(new AxReferenceKey()));
-
- AxArtifactKey key = new AxArtifactKey("Key", "0.0.1");
- AxKeyUse keyUse = new AxKeyUse();
- keyUse.setKey(key);
- assertEquals(key, keyUse.getKey());
- assertEquals("Key:0.0.1", keyUse.getId());
- assertEquals(key, keyUse.getKeys().get(0));
-
- assertEquals(Compatibility.IDENTICAL, keyUse.getCompatibility(key));
- assertTrue(keyUse.isCompatible(key));
-
- keyUse.clean();
- assertNotNull(keyUse);
-
- AxValidationResult result = new AxValidationResult();
- result = keyUse.validate(result);
- assertNotNull(result);
-
- assertNotEquals(0, keyUse.hashCode());
-
- AxKeyUse clonedKeyUse = new AxKeyUse(keyUse);
- assertEquals("AxKeyUse:(usedKey=AxArtifactKey:(name=Key,version=0.0.1))", clonedKeyUse.toString());
-
- assertNotEquals(0, keyUse.hashCode());
- // disabling sonar because this code tests the equals() method
- assertEquals(keyUse, keyUse); // NOSONAR
- assertEquals(keyUse, clonedKeyUse);
- assertNotEquals(keyUse, (Object) "Hello");
- assertEquals(keyUse, new AxKeyUse(key));
-
- assertEquals(0, keyUse.compareTo(keyUse));
- assertEquals(0, keyUse.compareTo(clonedKeyUse));
- assertNotEquals(0, keyUse.compareTo(new AxArtifactKey()));
- assertEquals(0, keyUse.compareTo(new AxKeyUse(key)));
-
- AxKeyUse keyUseNull = new AxKeyUse(AxArtifactKey.getNullKey());
- AxValidationResult resultNull = new AxValidationResult();
- assertEquals(false, keyUseNull.validate(resultNull).isValid());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java
deleted file mode 100644
index 515587558..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxReferenceKeyTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.concepts;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.lang.reflect.Field;
-import org.junit.Test;
-
-
-public 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"));
- 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());
-
- 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));
-
- AxValidationResult result = new AxValidationResult();
- result = testReferenceKey.validate(result);
- assertEquals(AxValidationResult.ValidationResult.VALID, result.getValidationResult());
-
- testReferenceKey.clean();
-
- AxReferenceKey clonedReferenceKey = new AxReferenceKey(testReferenceKey);
- assertEquals("AxReferenceKey:(parentKeyName=NPKN,parentKeyVersion=0.0.1,parentLocalName=NPKLN,localName=NLN)",
- clonedReferenceKey.toString());
-
- assertNotEquals(0, testReferenceKey.hashCode());
- // disabling sonar because this code tests the equals() method
- assertEquals(testReferenceKey, testReferenceKey); // NOSONAR
- assertEquals(testReferenceKey, clonedReferenceKey);
- assertNotEquals(testReferenceKey, (Object) "Hello");
- assertNotEquals(testReferenceKey, new AxReferenceKey("PKN", "0.0.2", "PLN", "LN"));
- assertNotEquals(testReferenceKey, new AxReferenceKey("NPKN", "0.0.2", "PLN", "LN"));
- assertNotEquals(testReferenceKey, new AxReferenceKey("NPKN", "0.0.1", "PLN", "LN"));
- assertNotEquals(testReferenceKey, new AxReferenceKey("NPKN", "0.0.1", "NPLN", "LN"));
- assertEquals(testReferenceKey, new AxReferenceKey("NPKN", "0.0.1", "NPKLN", "NLN"));
-
- assertEquals(0, testReferenceKey.compareTo(testReferenceKey));
- assertEquals(0, testReferenceKey.compareTo(clonedReferenceKey));
- assertNotEquals(0, testReferenceKey.compareTo(new AxArtifactKey()));
- assertNotEquals(0, testReferenceKey.compareTo(new AxReferenceKey("PKN", "0.0.2", "PLN", "LN")));
- assertNotEquals(0, testReferenceKey.compareTo(new AxReferenceKey("NPKN", "0.0.2", "PLN", "LN")));
- 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());
-
- assertThatThrownBy(() -> testReferenceKey.equals(null))
- .hasMessage("comparison object may not be null");
- assertThatThrownBy(() -> testReferenceKey.copyTo(null))
- .hasMessage("target may not be null");
- assertThatThrownBy(() -> testReferenceKey.copyTo(new AxArtifactKey("Key", "0.0.1")))
- .hasMessage("org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey is not an instance of "
- + "org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey");
- AxReferenceKey targetRefKey = new AxReferenceKey();
- assertEquals(testReferenceKey, testReferenceKey.copyTo(targetRefKey));
- }
-
- @Test
- public void testValidation() throws IllegalArgumentException, IllegalAccessException,
- NoSuchFieldException, SecurityException {
- AxReferenceKey testReferenceKey = new AxReferenceKey();
- testReferenceKey.setParentArtifactKey(new AxArtifactKey("PN", "0.0.1"));
- assertEquals("PN:0.0.1", testReferenceKey.getParentArtifactKey().getId());
-
- Field parentNameField = testReferenceKey.getClass().getDeclaredField("parentKeyName");
- parentNameField.setAccessible(true);
- parentNameField.set(testReferenceKey, "Parent Name");
- AxValidationResult validationResult = new AxValidationResult();
- testReferenceKey.validate(validationResult);
- parentNameField.set(testReferenceKey, "ParentName");
- parentNameField.setAccessible(false);
- assertEquals(
- "parentKeyName invalid-parameter parentKeyName with value Parent Name "
- + "does not match regular expression [A-Za-z0-9\\-_\\.]+",
- validationResult.getMessageList().get(0).getMessage());
-
- Field parentVersionField = testReferenceKey.getClass().getDeclaredField("parentKeyVersion");
- parentVersionField.setAccessible(true);
- parentVersionField.set(testReferenceKey, "Parent Version");
- AxValidationResult validationResultPV = new AxValidationResult();
- testReferenceKey.validate(validationResultPV);
- parentVersionField.set(testReferenceKey, "0.0.1");
- parentVersionField.setAccessible(false);
- assertEquals(
- "parentKeyVersion invalid-parameter parentKeyVersion with value Parent Version "
- + "does not match regular expression [A-Za-z0-9.]+",
- validationResultPV.getMessageList().get(0).getMessage());
-
- Field parentLocalNameField = testReferenceKey.getClass().getDeclaredField("parentLocalName");
- parentLocalNameField.setAccessible(true);
- parentLocalNameField.set(testReferenceKey, "Parent Local Name");
- AxValidationResult validationResultPL = new AxValidationResult();
- testReferenceKey.validate(validationResultPL);
- parentLocalNameField.set(testReferenceKey, "ParentLocalName");
- parentLocalNameField.setAccessible(false);
- assertEquals(
- "parentLocalName invalid-parameter parentLocalName with value "
- + "Parent Local Name does not match regular expression [A-Za-z0-9\\-_\\.]+|^$",
- validationResultPL.getMessageList().get(0).getMessage());
-
- Field localNameField = testReferenceKey.getClass().getDeclaredField("localName");
- localNameField.setAccessible(true);
- localNameField.set(testReferenceKey, "Local Name");
- AxValidationResult validationResultLN = new AxValidationResult();
- testReferenceKey.validate(validationResultLN);
- localNameField.set(testReferenceKey, "LocalName");
- localNameField.setAccessible(false);
- assertEquals(
- "localName invalid-parameter localName with value Local Name "
- + "does not match regular expression [A-Za-z0-9\\-_\\.]+|^$",
- validationResultLN.getMessageList().get(0).getMessage());
-
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/DummyEntity.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/DummyEntity.java
deleted file mode 100644
index 2b16e89ed..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/DummyEntity.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 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 java.util.Arrays;
-import java.util.List;
-
-public class DummyEntity extends AxConcept {
- private static final long serialVersionUID = -2962570563281067894L;
-
- protected AxReferenceKey key;
- private double doubleValue;
-
- public DummyEntity() {
- this.key = new AxReferenceKey();
- this.doubleValue = 0;
- }
-
- public DummyEntity(Double doubleValue) {
- this.key = new AxReferenceKey();
- this.doubleValue = doubleValue;
- }
-
- public DummyEntity(AxReferenceKey key, Double doubleValue) {
- this.key = key;
- this.doubleValue = doubleValue;
- }
-
- @Override
- public AxReferenceKey getKey() {
- return key;
- }
-
- @Override
- public List<AxKey> getKeys() {
- return Arrays.asList((AxKey) getKey());
- }
-
- public void setKey(AxReferenceKey key) {
- this.key = key;
- }
-
- public boolean checkSetKey() {
- return (this.key != null);
- }
-
- public double getDoubleValue() {
- return doubleValue;
- }
-
- public void setDoubleValue(double doubleValue) {
- this.doubleValue = doubleValue;
- }
-
- @Override
- public AxValidationResult validate(AxValidationResult result) {
- return key.validate(result);
- }
-
- @Override
- public void clean() {
- key.clean();
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("doubleValue=");
- builder.append(doubleValue);
- return builder.toString();
- }
-
- @Override
- public AxConcept copyTo(AxConcept target) {
- final Object copyObject = ((target == null) ? new DummyEntity() : target);
- if (copyObject instanceof DummyEntity) {
- final DummyEntity copy = ((DummyEntity) copyObject);
- if (this.checkSetKey()) {
- copy.setKey(new AxReferenceKey(key));
- } else {
- copy.key = null;
- }
- copy.doubleValue = doubleValue;
- return copy;
- } else {
- return null;
- }
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((key == null) ? 0 : key.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- DummyEntity other = (DummyEntity) obj;
- if (key == null) {
- if (other.key != null) {
- return false;
- }
- } else if (!key.equals(other.key)) {
- return false;
- }
- if (doubleValue != other.doubleValue) {
- return false;
- }
- return true;
- }
-
- @Override
- public int compareTo(AxConcept otherObj) {
- if (otherObj == null) {
- return -1;
- }
- if (this == otherObj) {
- return 0;
- }
- DummyEntity other = (DummyEntity) otherObj;
- if (key == null) {
- if (other.key != null) {
- return 1;
- }
- } else if (!key.equals(other.key)) {
- return key.compareTo(other.key);
- }
- if (doubleValue != other.doubleValue) {
- return Double.valueOf(doubleValue).compareTo(other.doubleValue);
- }
-
- return 0;
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ExceptionsTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ExceptionsTest.java
deleted file mode 100644
index ff87bc2d0..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ExceptionsTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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.assertNotNull;
-
-import java.io.IOException;
-import org.junit.Test;
-
-
-public 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()));
-
- 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);
- assertEquals("Runtime Message\ncaused by: Runtime Message\ncaused by: IO runtime exception message",
- 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",
- ace.getCascadedMessage());
- assertEquals(ckey, ace.getObject());
- }
-
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ValidationTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ValidationTest.java
deleted file mode 100644
index 21ae9b65c..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/ValidationTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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 org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-
-public class ValidationTest {
-
- @Test
- public void test() {
- 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());
-
- AxValidationMessage vmess0 = new AxValidationMessage(AxArtifactKey.getNullKey(), AxArtifactKey.class,
- 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());
-
- AxValidationMessage vmess1 = new AxValidationMessage(AxArtifactKey.getNullKey(), AxArtifactKey.class,
- ValidationResult.OBSERVATION, "Some message");
- result.addValidationMessage(vmess1);
-
- assertTrue(result.isOk());
- assertTrue(result.isValid());
- assertEquals(AxValidationResult.ValidationResult.OBSERVATION, result.getValidationResult());
- assertNotNull(result.getMessageList());
- assertNotNull("hello", result.toString());
-
- AxValidationMessage vmess2 = new AxValidationMessage(AxArtifactKey.getNullKey(), AxArtifactKey.class,
- 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());
-
- AxValidationMessage vmess3 = new AxValidationMessage(AxArtifactKey.getNullKey(), AxArtifactKey.class,
- 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());
-
- 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());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelExceptionTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelExceptionTest.java
deleted file mode 100644
index 2571ea65b..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelExceptionTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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 java.io.IOException;
-import org.junit.Test;
-
-public class ApexModelExceptionTest {
-
- @Test
- public void test() {
- assertNotNull(new ApexModelException("Message"));
- assertNotNull(new ApexModelException("Message", new IOException()));
-
- ApexModelException ame = new ApexModelException("Message", new IOException("IO exception message"));
- assertEquals("Message\ncaused by: Message\ncaused by: IO exception message", ame.getCascadedMessage());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
deleted file mode 100644
index 0f8f956ab..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelFileWriterTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-
-public class ApexModelFileWriterTest {
-
- @Test
- public void testModelFileWriter() throws IOException, ApexException {
- ApexModelFileWriter<AxModel> modelFileWriter = new ApexModelFileWriter<>(true);
-
- modelFileWriter.setValidate(true);
- assertTrue(modelFileWriter.isValidate());
-
- File tempFile = File.createTempFile("ApexFileWriterTest", "test");
- File tempDir = tempFile.getParentFile();
-
- File jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/ApexFileWriterTest.json");
-
- AxModel model = new DummyApexBasicModelCreator().getModel();
-
- modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
-
- jsonTempFile.delete();
- new File(tempDir.getAbsolutePath() + "/aaa").delete();
- new File(tempDir.getAbsolutePath() + "/ccc").delete();
-
- jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
-
- modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
-
- jsonTempFile.delete();
-
- 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();
-
- File dirA = new File(tempDir.getAbsolutePath() + "/aaa");
- // File dirB = new File(tempDir.getAbsolutePath() + "/aaa/bbb");
- dirA.createNewFile();
- // dirB.createNewFile();
-
- jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
- final File jsonTempFile01 = jsonTempFile;
- assertThatThrownBy(
- () -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile01.getAbsolutePath()))
- .hasMessageContaining("could not create directory");
-
- dirA.delete();
-
- dirA = new File(tempDir.getAbsolutePath() + "/aaa");
- File fileB = new File(tempDir.getAbsolutePath() + "/aaa/bbb");
- dirA.mkdir();
- fileB.createNewFile();
-
- jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
-
- File jsonTempFile02 = jsonTempFile;
- assertThatThrownBy(
- () -> modelFileWriter.apexModelWriteJsonFile(model, AxModel.class, jsonTempFile02.getAbsolutePath()))
- .hasMessageContaining("error processing file");
-
- fileB.delete();
- dirA.delete();
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
deleted file mode 100644
index 1152771ea..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReaderTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-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.runners.MockitoJUnitRunner;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ApexModelReaderTest {
- @Test
- public void testModelReader() throws IOException, ApexException {
- AxModel model = new DummyApexBasicModelCreator().getModel();
- AxModel invalidModel = new DummyApexBasicModelCreator().getInvalidModel();
-
- ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
- modelWriter.setValidate(true);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- modelWriter.write(model, baos);
-
- ByteArrayOutputStream baosInvalid = new ByteArrayOutputStream();
- modelWriter.setValidate(false);
- modelWriter.write(invalidModel, baosInvalid);
-
- ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class, true);
-
- modelReader.setValidate(true);
- assertTrue(modelReader.isValidate());
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- AxModel readModel = modelReader.read(bais);
- assertEquals(model, readModel);
-
- ByteArrayInputStream baisInvalid = new ByteArrayInputStream(baosInvalid.toByteArray());
- assertThatThrownBy(() -> modelReader.read(baisInvalid))
- .hasMessageStartingWith("Apex concept validation failed");
- modelReader.setValidate(false);
- assertFalse(modelReader.isValidate());
-
- ByteArrayInputStream bais2 = new ByteArrayInputStream(baos.toByteArray());
- AxModel readModel2 = modelReader.read(bais2);
- assertEquals(model, readModel2);
-
- ByteArrayOutputStream baosJson = new ByteArrayOutputStream();
- modelWriter.write(model, baosJson);
-
- ByteArrayInputStream baisJson = new ByteArrayInputStream(baosJson.toByteArray());
- AxModel readModelJson = modelReader.read(baisJson);
- assertEquals(model, readModelJson);
-
- String dummyString = "SomeDummyText";
- ByteArrayInputStream baisDummy = new ByteArrayInputStream(dummyString.getBytes());
- assertThatThrownBy(() -> modelReader.read(baisDummy))
- .hasMessageContaining("Unable to unmarshal Apex concept");
- ByteArrayInputStream nullBais = null;
- assertThatThrownBy(() -> modelReader.read(nullBais))
- .hasMessage("concept stream may not be null");
-
- assertThatThrownBy(() -> {
- FileInputStream fis = new FileInputStream(new File("somewhere/over/the/rainbow"));
- modelReader.read(fis);
- }).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();
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
deleted file mode 100644
index c95106aa8..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelSaverTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 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.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.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-
-public class ApexModelSaverTest {
-
- @Test
- public void testModelSaver() throws IOException, ApexException {
- AxModel model = new DummyApexBasicModelCreator().getModel();
- assertNotNull(model);
-
- Path tempPath = Files.createTempDirectory("ApexTest");
- assertNotNull(tempPath);
-
- ApexModelSaver<AxModel> modelSaver =
- new ApexModelSaver<AxModel>(AxModel.class, model, tempPath.toAbsolutePath().toString());
- assertNotNull(modelSaver);
- modelSaver.apexModelWriteJson();
-
- Files.deleteIfExists(new File(tempPath.toAbsolutePath() + "/BasicModel.json").toPath());
- Files.deleteIfExists(tempPath);
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
deleted file mode 100644
index 13e72d3e2..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelStringWriterTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import org.junit.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 {
-
- @Test
- public void testModelStringWriter() throws IOException, ApexException {
- AxModel basicModel = new DummyApexBasicModelCreator().getModel();
- assertNotNull(basicModel);
-
- AxKeyInfo intKeyInfo = basicModel.getKeyInformation().get("IntegerKIKey");
- AxKeyInfo floatKeyInfo = basicModel.getKeyInformation().get("FloatKIKey");
-
- // Ensure marshalling is OK
- ApexModelStringWriter<AxKeyInfo> stringWriter = new ApexModelStringWriter<AxKeyInfo>(true);
-
- assertNotNull(stringWriter.writeJsonString(intKeyInfo, AxKeyInfo.class));
- assertNotNull(stringWriter.writeJsonString(floatKeyInfo, AxKeyInfo.class));
-
- assertNotNull(stringWriter.writeString(intKeyInfo, AxKeyInfo.class));
- assertNotNull(stringWriter.writeString(floatKeyInfo, AxKeyInfo.class));
-
- assertNotNull(stringWriter.writeString(intKeyInfo, AxKeyInfo.class));
- assertNotNull(stringWriter.writeString(floatKeyInfo, AxKeyInfo.class));
-
- assertThatThrownBy(() -> stringWriter.writeString(null, AxKeyInfo.class)).hasMessage("concept may not be null");
- assertThatThrownBy(() -> stringWriter.writeString(null, AxKeyInfo.class)).hasMessage("concept may not be null");
- assertThatThrownBy(() -> stringWriter.writeJsonString(null, AxKeyInfo.class))
- .hasMessage("error writing JSON string");
- stringWriter.setValidate(true);
- assertTrue(stringWriter.isValidate());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
deleted file mode 100644
index 063855976..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriterTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ApexModelWriterTest {
- @Test
- public void testModelWriter() throws IOException, ApexException {
- ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
-
- modelWriter.setValidate(true);
- assertTrue(modelWriter.isValidate());
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- AxModel model = new DummyApexBasicModelCreator().getModel();
-
- modelWriter.write(model, baos);
-
- modelWriter.setValidate(false);
- modelWriter.write(model, baos);
-
- modelWriter.setValidate(true);
- model.getKeyInformation().getKeyInfoMap().clear();
- assertThatThrownBy(() -> modelWriter.write(model, baos))
- .hasMessageContaining("Apex concept (BasicModel:0.0.1) validation failed");
- model.getKeyInformation().generateKeyInfo(model);
-
- assertThatThrownBy(() -> modelWriter.write(null, baos))
- .hasMessage("concept may not be null");
-
- ByteArrayOutputStream nullBaos = null;
- assertThatThrownBy(() -> modelWriter.write(model, nullBaos))
- .hasMessage("concept stream may not be null");
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyApexBasicModelCreator.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyApexBasicModelCreator.java
deleted file mode 100644
index 353722b2d..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyApexBasicModelCreator.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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.util.UUID;
-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.AxKeyInformation;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
-
-public class DummyApexBasicModelCreator implements TestApexModelCreator<AxModel> {
-
- @Override
- public AxModel getModel() {
- AxModel basicModel = new AxModel();
-
- basicModel.setKey(new AxArtifactKey("BasicModel", "0.0.1"));
- basicModel.setKeyInformation(new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1")));
-
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKey(), new AxKeyInfo(basicModel.getKey()));
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKeyInformation().getKey(),
- new AxKeyInfo(basicModel.getKeyInformation().getKey()));
-
- AxKeyInfo intKeyInfo = new AxKeyInfo(new AxArtifactKey("IntegerKIKey", "0.0.1"), UUID.randomUUID(),
- "IntegerKIKey description");
- basicModel.getKeyInformation().getKeyInfoMap().put(intKeyInfo.getKey(), new AxKeyInfo(intKeyInfo.getKey()));
-
- AxKeyInfo floatKeyInfo = new AxKeyInfo(new AxArtifactKey("FloatKIKey", "0.0.1"), UUID.randomUUID(),
- "FloatKIKey description");
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKeyInfo.getKey(), new AxKeyInfo(floatKeyInfo.getKey()));
-
- return basicModel;
- }
-
- @Override
- public final AxModel getMalstructuredModel() {
- AxModel basicModel = new AxModel();
-
- // Note: No Data types
- basicModel.setKey(new AxArtifactKey("BasicModelKey", "0.0.1"));
- basicModel.setKeyInformation(new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1")));
-
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKey(), new AxKeyInfo(basicModel.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000000"),
- "\nbasic model description\nThis is a multi line description\nwith another line of text."));
-
- return basicModel;
- }
-
- @Override
- public final AxModel getObservationModel() {
- AxModel basicModel = getModel();
-
- // Set key information as blank
- basicModel.getKeyInformation().getKeyInfoMap().get(basicModel.getKey()).setDescription("");
-
- return basicModel;
- }
-
- @Override
- public final AxModel getWarningModel() {
- AxModel basicModel = getModel();
-
- // Add unreferenced key information
- AxKeyInfo unreferencedKeyInfo0 = new AxKeyInfo(new AxArtifactKey("Unref0", "0.0.1"));
- AxKeyInfo unreferencedKeyInfo1 = new AxKeyInfo(new AxArtifactKey("Unref1", "0.0.1"));
-
- basicModel.getKeyInformation().getKeyInfoMap().put(unreferencedKeyInfo0.getKey(), unreferencedKeyInfo0);
- basicModel.getKeyInformation().getKeyInfoMap().put(unreferencedKeyInfo1.getKey(), unreferencedKeyInfo1);
-
- return basicModel;
- }
-
- @Override
- public final AxModel getInvalidModel() {
- AxModel basicModel = new AxModel();
-
- basicModel.setKey(new AxArtifactKey("BasicModelKey", "0.0.1"));
- basicModel.setKeyInformation(new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1")));
-
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKey(), new AxKeyInfo(basicModel.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000000"),
- "nbasic model description\nThis is a multi line description\nwith another line of text."));
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKeyInformation().getKey(),
- new AxKeyInfo(basicModel.getKeyInformation().getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000000"), ""));
-
- return basicModel;
- }
-
- /**
- * Get the model with its references.
- * @return the model with its references
- */
- public final DummyAxModelWithReferences getModelWithReferences() {
- AxModel model = getModel();
-
- DummyAxModelWithReferences modelWithReferences = new DummyAxModelWithReferences(model.getKey());
- modelWithReferences.setKeyInformation(model.getKeyInformation());
- modelWithReferences.setReferenceKeyList();
-
- return modelWithReferences;
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyAxModelWithReferences.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyAxModelWithReferences.java
deleted file mode 100644
index 887755d03..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/DummyAxModelWithReferences.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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.util.ArrayList;
-import java.util.List;
-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;
-
-public class DummyAxModelWithReferences extends AxModel {
- private static final long serialVersionUID = -8194956638511120008L;
-
- private List<AxKey> extrakeyList = new ArrayList<>();
-
- public DummyAxModelWithReferences(final AxArtifactKey key) {
- super(key);
- }
-
- @Override
- public List<AxKey> getKeys() {
- List<AxKey> keys = super.getKeys();
- keys.addAll(extrakeyList);
-
- 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) {
- 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/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java
deleted file mode 100644
index 905a27f38..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelConceptsTest.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 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.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Set;
-import org.junit.Before;
-import org.junit.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;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKeyUse;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
-
-public class SupportApexBasicModelConceptsTest {
- TestApexModel<AxModel> testApexModel;
-
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxModel>(AxModel.class, new DummyApexBasicModelCreator());
- }
-
- @Test
- public void testModelConcepts() {
- final AxModel model = testApexModel.getModel();
- assertNotNull(model);
- model.clean();
- assertNotNull(model);
-
- AxValidationResult result = new AxValidationResult();
- result = model.validate(result);
- assertEquals(ValidationResult.WARNING, result.getValidationResult());
-
- model.register();
- assertEquals(model.getKeyInformation(), ModelService.getModel(AxKeyInformation.class));
-
- final AxModel clonedModel = new AxModel(model);
- assertTrue(clonedModel.toString().startsWith("AxModel:(key=AxArtifactKey:(name=BasicModel"));
-
- assertNotEquals(0, model.hashCode());
-
- // disabling sonar because this code tests the equals() method
- assertEquals(model, model); // NOSONAR
- assertEquals(model, clonedModel);
- assertNotNull(model);
- assertNotEquals(model, (Object) "Hello");
- clonedModel.getKey().setVersion("0.0.2");
- assertNotEquals(model, clonedModel);
- clonedModel.getKey().setVersion("0.0.1");
-
- assertEquals(0, model.compareTo(model));
- assertNotEquals(0, model.compareTo(null));
- assertNotEquals(0, model.compareTo(new AxReferenceKey()));
- assertEquals(0, model.compareTo(clonedModel));
- clonedModel.getKey().setVersion("0.0.2");
- assertNotEquals(0, model.compareTo(clonedModel));
- clonedModel.getKey().setVersion("0.0.1");
-
- assertNotNull(model.getKeys());
-
- model.getKeyInformation().generateKeyInfo(model);
- assertNotNull(model.getKeyInformation());
-
- }
-
- @Test
- public void testKeyInformation() {
-
- final AxModel model = testApexModel.getModel();
- final AxKeyInformation keyI = model.getKeyInformation();
- final AxKeyInformation clonedKeyI = new AxKeyInformation(keyI);
-
- assertNotNull(keyI);
- assertNotEquals(keyI, (Object) new AxArtifactKey());
- assertEquals(keyI, clonedKeyI);
-
- clonedKeyI.setKey(new AxArtifactKey());
- assertNotEquals(keyI, clonedKeyI);
- clonedKeyI.setKey(keyI.getKey());
-
- assertEquals(0, keyI.compareTo(keyI));
- assertEquals(0, keyI.compareTo(clonedKeyI));
- assertNotEquals(0, keyI.compareTo(null));
- assertNotEquals(0, keyI.compareTo(new AxArtifactKey()));
-
- clonedKeyI.setKey(new AxArtifactKey());
- assertNotEquals(0, keyI.compareTo(clonedKeyI));
- clonedKeyI.setKey(keyI.getKey());
- assertEquals(0, keyI.compareTo(clonedKeyI));
-
- clonedKeyI.getKeyInfoMap().clear();
- assertNotEquals(0, keyI.compareTo(clonedKeyI));
-
- AxKeyInfo keyInfo = keyI.get("BasicModel");
- assertNotNull(keyInfo);
-
- keyInfo = keyI.get(new AxArtifactKey("BasicModel", "0.0.1"));
- assertNotNull(keyInfo);
-
- Set<AxKeyInfo> keyInfoSet = keyI.getAll("BasicModel");
- assertNotNull(keyInfoSet);
-
- keyInfoSet = keyI.getAll("BasicModel", "0..0.1");
- assertNotNull(keyInfoSet);
-
- List<AxKey> keys = model.getKeys();
- assertNotEquals(0, keys.size());
-
- keys = keyI.getKeys();
- assertNotEquals(0, keys.size());
-
- model.getKeyInformation().generateKeyInfo(model);
- assertNotNull(model.getKeyInformation());
- model.getKeyInformation().getKeyInfoMap().clear();
- model.getKeyInformation().generateKeyInfo(model);
- assertNotNull(model.getKeyInformation());
- }
-
- @Test
- public void testClonedKey() {
- final AxModel model = testApexModel.getModel();
- final AxKeyInformation keyI = model.getKeyInformation();
- final AxKeyInformation clonedKeyI = new AxKeyInformation(keyI);
- AxValidationResult result = new AxValidationResult();
-
- clonedKeyI.setKey(AxArtifactKey.getNullKey());
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- clonedKeyI.setKey(keyI.getKey());
-
- clonedKeyI.getKeyInfoMap().clear();
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- clonedKeyI.generateKeyInfo(model);
-
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- clonedKeyI.getKeyInfoMap().put(AxArtifactKey.getNullKey(), null);
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- clonedKeyI.getKeyInfoMap().clear();
- clonedKeyI.generateKeyInfo(model);
-
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- clonedKeyI.getKeyInfoMap().put(new AxArtifactKey("SomeKey", "0.0.1"), null);
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- clonedKeyI.getKeyInfoMap().clear();
- clonedKeyI.generateKeyInfo(model);
-
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- final AxKeyInfo mk = clonedKeyI.get(new AxArtifactKey("BasicModel", "0.0.1"));
- assertNotNull(mk);
- mk.setKey(AxArtifactKey.getNullKey());
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- clonedKeyI.getKeyInfoMap().clear();
- clonedKeyI.generateKeyInfo(model);
-
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- final AxModel clonedModel = new AxModel(model);
- clonedModel.setKey(AxArtifactKey.getNullKey());
- result = new AxValidationResult();
- result = clonedModel.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- clonedModel.setKey(model.getKey());
- result = new AxValidationResult();
- result = clonedKeyI.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
- }
-
- @Test
- public void testModelConceptsWithReferences() {
- final DummyAxModelWithReferences mwr = new DummyApexBasicModelCreator().getModelWithReferences();
- assertNotNull(mwr);
- mwr.getKeyInformation().getKeyInfoMap().clear();
- mwr.getKeyInformation().generateKeyInfo(mwr);
-
- AxValidationResult result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- // Duplicate key error
- mwr.addKey(mwr.getKey());
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- mwr.removeKey(mwr.getKey());
-
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- // Null Reference Key
- mwr.addKey(AxReferenceKey.getNullKey());
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- mwr.removeKey(AxReferenceKey.getNullKey());
-
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- // Duplicate Reference Key
- final AxReferenceKey rKey = new AxReferenceKey(mwr.getKey(), "LocalName");
- mwr.addKey(rKey);
- mwr.addKey(rKey);
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- mwr.removeKey(rKey);
- mwr.removeKey(rKey);
-
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- // Key Use is legal
- final AxKeyUse keyU = new AxKeyUse(mwr.getKey());
- mwr.addKey(keyU);
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
- mwr.removeKey(keyU);
-
- // Key Use on bad artifact key
- final AxKeyUse keyBadUsage = new AxKeyUse(new AxArtifactKey("SomeKey", "0.0.1"));
- mwr.addKey(keyBadUsage);
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- mwr.removeKey(keyBadUsage);
-
- // Key Use on bad reference key
- final AxKeyUse keyBadReferenceUsage = new AxKeyUse(new AxReferenceKey("SomeKey", "0.0.1", "Local"));
- mwr.addKey(keyBadReferenceUsage);
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- mwr.removeKey(keyBadReferenceUsage);
-
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
deleted file mode 100644
index 68f755886..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexBasicModelTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2022 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.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;
-
-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" + "********************************";
-
- 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" + "********************************";
-
- 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());
- }
-
- @Test
- public void testModelValid() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelValid();
- assertEquals(VALID_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testApexModelVaidateObservation() throws Exception {
- assertThatThrownBy(testApexModel::testApexModelVaidateObservation)
- .hasMessage("model should have observations");
- }
-
- @Test
- public void testApexModelVaidateWarning() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertEquals(WARNING_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testModelVaidateInvalidModel() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertEquals(INVALID_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testModelVaidateMalstructured() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertEquals(INVALID_MODEL_MALSTRUCTURED_STRING, result.toString());
- }
-
- @Test
- public void testModelWriteReadJson() throws Exception {
- testApexModel.testApexModelWriteReadJson();
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator0.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator0.java
deleted file mode 100644
index e835bc0fc..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator0.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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 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.AxKeyInformation;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
-
-public class SupportApexModelCreator0 implements TestApexModelCreator<AxModel> {
-
- @Override
- public AxModel getModel() {
- AxModel basicModel = new AxModel();
-
- basicModel.setKey(new AxArtifactKey("BasicModel", "0.0.1"));
- basicModel.setKeyInformation(new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1")));
-
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKey(), new AxKeyInfo(basicModel.getKey()));
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKeyInformation().getKey(),
- new AxKeyInfo(basicModel.getKeyInformation().getKey()));
-
- return basicModel;
- }
-
- @Override
- public final AxModel getMalstructuredModel() {
- return getModel();
- }
-
- @Override
- public final AxModel getObservationModel() {
- return getModel();
- }
-
- @Override
- public final AxModel getWarningModel() {
- return getModel();
- }
-
- @Override
- public final AxModel getInvalidModel() {
- return getModel();
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator1.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator1.java
deleted file mode 100644
index 9ad34a38c..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator1.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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.util.UUID;
-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.AxKeyInformation;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
-
-public class SupportApexModelCreator1 implements TestApexModelCreator<AxModel> {
-
- @Override
- public AxModel getModel() {
- return getInvalidModel();
- }
-
- @Override
- public final AxModel getMalstructuredModel() {
- return getInvalidModel();
- }
-
- @Override
- public final AxModel getObservationModel() {
- return getInvalidModel();
- }
-
- @Override
- public final AxModel getWarningModel() {
- return getInvalidModel();
- }
-
- @Override
- public final AxModel getInvalidModel() {
- AxModel basicModel = new AxModel();
-
- basicModel.setKey(new AxArtifactKey("BasicModelKey", "0.0.1"));
- basicModel.setKeyInformation(new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1")));
-
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKey(), new AxKeyInfo(basicModel.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000000"),
- "nbasic model description\nThis is a multi line description\nwith another line of text."));
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKeyInformation().getKey(),
- new AxKeyInfo(basicModel.getKeyInformation().getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000000"), ""));
-
- return basicModel;
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator2.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator2.java
deleted file mode 100644
index 0ab7aab7f..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportApexModelCreator2.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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 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.AxKeyInformation;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator;
-
-public class SupportApexModelCreator2 implements TestApexModelCreator<AxModel> {
-
- @Override
- public AxModel getModel() {
- AxModel basicModel = new AxModel();
-
- basicModel.setKey(new AxArtifactKey("BasicModel", "0.0.1"));
- basicModel.setKeyInformation(new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1")));
-
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKey(), new AxKeyInfo(basicModel.getKey()));
- basicModel.getKeyInformation().getKeyInfoMap().put(basicModel.getKeyInformation().getKey(),
- new AxKeyInfo(basicModel.getKeyInformation().getKey()));
- basicModel.getKeyInformation().get("BasicModel").setDescription("");
- return basicModel;
- }
-
- @Override
- public final AxModel getMalstructuredModel() {
- return getModel();
- }
-
- @Override
- public final AxModel getObservationModel() {
- return getModel();
- }
-
- @Override
- public final AxModel getWarningModel() {
- return getModel();
- }
-
- @Override
- public final AxModel getInvalidModel() {
- return getModel();
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
deleted file mode 100644
index d55a9da29..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportBasicModelTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2022 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.handling;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
-
-public class SupportBasicModelTest {
-
- @Test
- public void testNormalModelCreator() throws ApexException {
- final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
- new DummyApexBasicModelCreator());
-
- testApexModel.testApexModelValid();
- assertThatThrownBy(testApexModel::testApexModelVaidateObservation)
- .hasMessage("model should have observations");
- testApexModel.testApexModelVaidateWarning();
- testApexModel.testApexModelVaidateInvalidModel();
- testApexModel.testApexModelVaidateMalstructured();
-
- testApexModel.testApexModelWriteReadJson();
- }
-
- @Test
- public void testModelsUnequal() throws ApexException {
- final TestApexModel<AxModel> testApexModel0 = new TestApexModel<AxModel>(AxModel.class,
- new DummyApexBasicModelCreator());
- final TestApexModel<AxModel> testApexModel1 = new TestApexModel<AxModel>(AxModel.class,
- new DummyApexBasicModelCreator());
-
- testApexModel1.getModel().getKey().setVersion("0.0.2");
-
- assertThatThrownBy(() -> testApexModel0.checkModelEquality(testApexModel0.getModel(), testApexModel1.getModel(),
- "Models are not equal")).hasMessage("Models are not equal");
- }
-
- @Test
- public void testModelCreator0() throws ApexException {
- final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
- new SupportApexModelCreator0());
-
- testApexModel.testApexModelValid();
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateObservation())
- .hasMessage("model should have observations");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateWarning())
- .hasMessage("model should have warnings");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateInvalidModel())
- .hasMessage("model should not be valid ***validation of model successful***");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateMalstructured())
- .hasMessage("model should not be valid ***validation of model successful***");
- }
-
- @Test
- public void testModelCreator1() throws ApexException {
- final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
- new SupportApexModelCreator1());
-
- assertThatThrownBy(() -> testApexModel.testApexModelValid())
- .hasMessageStartingWith("model is invalid");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateObservation())
- .hasMessageStartingWith("model is invalid");
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateWarning())
- .hasMessageStartingWith("model is invalid");
- testApexModel.testApexModelVaidateInvalidModel();
- testApexModel.testApexModelVaidateMalstructured();
- }
-
- @Test
- public void testModelCreator2() throws ApexException {
- final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
- new SupportApexModelCreator2());
-
- testApexModel.testApexModelValid();
- testApexModel.testApexModelVaidateObservation();
- assertThatThrownBy(() -> testApexModel.testApexModelVaidateWarning())
- .hasMessage("model should have warnings");
- }
-
- @Test
- public void testModelCreator1Json() throws ApexException {
- final TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class,
- new SupportApexModelCreator1());
-
- assertThatThrownBy(() -> testApexModel.testApexModelWriteReadJson())
- .hasMessageStartingWith("error processing file");
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
deleted file mode 100644
index 1783fc00f..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/SupportConceptGetterTest.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2022 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.Assert.assertNull;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.UUID;
-import org.junit.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 {
-
- private static final AxKeyInfo intKI01 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey01", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey01 description");
- private static final AxKeyInfo intKI11 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey11", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey11 description");
- private static final AxKeyInfo intKI21 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey21", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey21 description");
- private static final AxKeyInfo intKI22 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey22", "0.0.2"),
- UUID.randomUUID(), "IntegerKIKey22 description");
- private static final AxKeyInfo intKI23 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey23", "0.0.3"),
- UUID.randomUUID(), "IntegerKIKey23 description");
- private static final AxKeyInfo intKI24 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey24", "0.0.4"),
- UUID.randomUUID(), "IntegerKIKey24 description");
- private static final AxKeyInfo intKI25 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey25", "0.0.5"),
- UUID.randomUUID(), "IntegerKIKey25 description");
- private static final AxKeyInfo intKI26 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey26", "0.0.6"),
- UUID.randomUUID(), "IntegerKIKey26 description");
- private static final AxKeyInfo intKI31 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey31", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey31 description");
- private static final AxKeyInfo intKI41 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey41", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey41 description");
- private static final AxKeyInfo intKI51 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey51", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey51 description");
- private static final AxKeyInfo intKI52 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey52", "0.0.2"),
- UUID.randomUUID(), "IntegerKIKey52 description");
- private static final AxKeyInfo intKI53 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey53", "0.0.3"),
- UUID.randomUUID(), "IntegerKIKey53 description");
- private static final AxKeyInfo intKI54 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey54", "0.0.4"),
- UUID.randomUUID(), "IntegerKIKey54 description");
- private static final AxKeyInfo intKI61 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey61", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey61 description");
- private static final AxKeyInfo intKI62 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey62", "0.0.2"),
- UUID.randomUUID(), "IntegerKIKey62 description");
- private static final AxKeyInfo intKI63 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey63", "0.0.3"),
- UUID.randomUUID(), "IntegerKIKey63 description");
- private static final AxKeyInfo intKI64 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey64", "0.0.4"),
- UUID.randomUUID(), "IntegerKIKey64 description");
- private static final AxKeyInfo intKI71 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey71", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey71 description");
- private static final AxKeyInfo intKI81 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey81", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey81 description");
- private static final AxKeyInfo intKI91 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey91", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey91 description");
- private static final AxKeyInfo floatKI01 = new AxKeyInfo(new AxArtifactKey("FloatKIKey01", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey01 description");
- private static final AxKeyInfo floatKI11 = new AxKeyInfo(new AxArtifactKey("FloatKIKey11", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey11 description");
- private static final AxKeyInfo floatKI21 = new AxKeyInfo(new AxArtifactKey("FloatKIKey21", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey21 description");
- private static final AxKeyInfo floatKI31 = new AxKeyInfo(new AxArtifactKey("FloatKIKey31", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey31 description");
- private static final AxKeyInfo floatKI41 = new AxKeyInfo(new AxArtifactKey("FloatKIKey41", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey41 description");
- private static final AxKeyInfo floatKI51 = new AxKeyInfo(new AxArtifactKey("FloatKIKey51", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey51 description");
- private static final AxKeyInfo floatKI61 = new AxKeyInfo(new AxArtifactKey("FloatKIKey61", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey61 description");
- private static final AxKeyInfo floatKI71 = new AxKeyInfo(new AxArtifactKey("FloatKIKey71", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey71 description");
- private static final AxKeyInfo floatKI81 = new AxKeyInfo(new AxArtifactKey("FloatKIKey81", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey81 description");
- private static final AxKeyInfo floatKI82 = new AxKeyInfo(new AxArtifactKey("FloatKIKey82", "0.0.2"),
- UUID.randomUUID(), "IntegerKIKey82 description");
- private static final AxKeyInfo floatKI83 = new AxKeyInfo(new AxArtifactKey("FloatKIKey83", "0.0.3"),
- UUID.randomUUID(), "IntegerKIKey83 description");
- private static final AxKeyInfo floatKI91 = new AxKeyInfo(new AxArtifactKey("FloatKIKey91", "0.0.1"),
- UUID.randomUUID(), "IntegerKIKey91 description");
- private static final AxKeyInfo floatKI92 = new AxKeyInfo(new AxArtifactKey("FloatKIKey92", "0.0.2"),
- UUID.randomUUID(), "IntegerKIKey92 description");
- private static final AxKeyInfo floatKI93 = new AxKeyInfo(new AxArtifactKey("FloatKIKey93", "0.0.3"),
- UUID.randomUUID(), "IntegerKIKey93 description");
-
- @Test
- public void testConceptGetterInteger() {
- AxModel basicModel = setTestBasicModel();
-
- assertNull(basicModel.getKeyInformation().get("NonExistantKey", "0.0.6"));
- assertEquals(intKI26, basicModel.getKeyInformation().get("IntegerKIKey26", "0.0.6"));
- assertEquals(intKI62, basicModel.getKeyInformation().get("IntegerKIKey62", "0.0.2"));
- assertEquals(intKI21, basicModel.getKeyInformation().get("IntegerKIKey21", "0.0.1"));
- assertEquals(intKI61, basicModel.getKeyInformation().get("IntegerKIKey61", "0.0.1"));
-
- assertNull(basicModel.getKeyInformation().get("NonExistantKey"));
-
- assertEquals(intKI01, basicModel.getKeyInformation().get("IntegerKIKey01"));
- assertEquals(intKI11, basicModel.getKeyInformation().get("IntegerKIKey11"));
- assertEquals(intKI26, basicModel.getKeyInformation().get("IntegerKIKey26"));
- assertEquals(intKI31, basicModel.getKeyInformation().get("IntegerKIKey31"));
- assertEquals(intKI41, basicModel.getKeyInformation().get("IntegerKIKey41"));
- assertEquals(intKI54, basicModel.getKeyInformation().get("IntegerKIKey54"));
- assertEquals(intKI64, basicModel.getKeyInformation().get("IntegerKIKey64"));
- assertEquals(intKI71, basicModel.getKeyInformation().get("IntegerKIKey71"));
- assertEquals(intKI81, basicModel.getKeyInformation().get("IntegerKIKey81"));
- assertEquals(intKI91, basicModel.getKeyInformation().get("IntegerKIKey91"));
- }
-
- @Test
- public void testConceptGetterFloat() {
- AxModel basicModel = setTestBasicModel();
-
- assertEquals(floatKI01, basicModel.getKeyInformation().get("FloatKIKey01"));
- assertEquals(floatKI11, basicModel.getKeyInformation().get("FloatKIKey11"));
- assertEquals(floatKI21, basicModel.getKeyInformation().get("FloatKIKey21"));
- assertEquals(floatKI31, basicModel.getKeyInformation().get("FloatKIKey31"));
- assertEquals(floatKI41, basicModel.getKeyInformation().get("FloatKIKey41"));
- assertEquals(floatKI51, basicModel.getKeyInformation().get("FloatKIKey51"));
- assertEquals(floatKI61, basicModel.getKeyInformation().get("FloatKIKey61"));
- assertEquals(floatKI71, basicModel.getKeyInformation().get("FloatKIKey71"));
- assertEquals(floatKI83, basicModel.getKeyInformation().get("FloatKIKey83"));
- assertEquals(floatKI93, basicModel.getKeyInformation().get("FloatKIKey93"));
- }
-
- @Test
- public 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);
-
- modelReader.setValidate(false);
- modelWriter.setValidate(false);
-
- File tempJsonFile = File.createTempFile("ApexModel", "json");
- modelWriter.apexModelWriteJsonFile(basicModel, AxModel.class, tempJsonFile.getCanonicalPath());
-
- FileInputStream jsonFileInputStream = new FileInputStream(tempJsonFile);
- AxModel readJsonModel = modelReader.read(jsonFileInputStream);
- jsonFileInputStream.close();
- assertEquals(basicModel, readJsonModel);
- assertEquals(intKI91, readJsonModel.getKeyInformation().get("IntegerKIKey91"));
- assertNotNull(readJsonModel.getKeyInformation().get("FloatKIKey"));
- tempJsonFile.delete();
- }
-
- private AxModel setTestBasicModel() {
- AxModel basicModel = new DummyApexBasicModelCreator().getModel();
- assertNotNull(basicModel);
-
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI31.getKey(), intKI31);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI24.getKey(), intKI24);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI11.getKey(), intKI11);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI64.getKey(), intKI64);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI41.getKey(), intKI41);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI51.getKey(), intKI51);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI23.getKey(), intKI23);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI81.getKey(), intKI81);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI71.getKey(), intKI71);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI01.getKey(), intKI01);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI91.getKey(), intKI91);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI52.getKey(), intKI52);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI53.getKey(), intKI53);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI62.getKey(), intKI62);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI54.getKey(), intKI54);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI26.getKey(), intKI26);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI22.getKey(), intKI22);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI25.getKey(), intKI25);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI21.getKey(), intKI21);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI61.getKey(), intKI61);
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI63.getKey(), intKI63);
-
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI11.getKey(), floatKI11);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI83.getKey(), floatKI83);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI51.getKey(), floatKI51);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI71.getKey(), floatKI71);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI21.getKey(), floatKI21);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI81.getKey(), floatKI81);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI92.getKey(), floatKI92);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI91.getKey(), floatKI91);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI01.getKey(), floatKI01);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI82.getKey(), floatKI82);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI61.getKey(), floatKI61);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI41.getKey(), floatKI41);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI31.getKey(), floatKI31);
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI93.getKey(), floatKI93);
-
- return basicModel;
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java
deleted file mode 100644
index 746e10607..000000000
--- a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/ModelServiceTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.model.basicmodel.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 org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.policy.apex.model.basicmodel.handling.DummyApexBasicModelCreator;
-
-public class ModelServiceTest {
-
- @Test
- public 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");
- ModelService.registerModel(AxKeyInformation.class,
- new DummyApexBasicModelCreator().getModel().getKeyInformation());
- assertTrue(ModelService.existsModel(AxKeyInformation.class));
- assertNotNull(ModelService.getModel(AxKeyInformation.class));
-
- ModelService.deregisterModel(AxKeyInformation.class);
-
- 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");
- ModelService.registerModel(AxKeyInformation.class,
- new DummyApexBasicModelCreator().getModel().getKeyInformation());
- assertTrue(ModelService.existsModel(AxKeyInformation.class));
- assertNotNull(ModelService.getModel(AxKeyInformation.class));
-
- 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");
- }
-}
diff --git a/model/basic-model/src/test/resources/logback-test.xml b/model/basic-model/src/test/resources/logback-test.xml
deleted file mode 100644
index c52f2ded6..000000000
--- a/model/basic-model/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2016-2018 Ericsson. All rights reserved.
- ================================================================================
- 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=========================================================
--->
-
-<configuration>
-
- <contextName>Apex</contextName>
- <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
- <property name="LOG_DIR" value="${java.io.tmpdir}/apex_logging/" />
-
- <!-- USE FOR STD OUT ONLY -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
- </encoder>
- </appender>
-
- <root level="INFO">
- <appender-ref ref="STDOUT" />
- </root>
-
- <logger name="org.infinispan" level="INFO" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="org.apache.zookeeper.ClientCnxn" level="OFF" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>${LOG_DIR}/apex.log</file>
- <encoder>
- <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
- %logger{26} - %msg %n %ex{full}</pattern>
- </encoder>
- </appender>
-
- <appender name="CTXT_FILE" class="ch.qos.logback.core.FileAppender">
- <file>${LOG_DIR}/apex_ctxt.log</file>
- <encoder>
- <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
- %logger{26} - %msg %n %ex{full}</pattern>
- </encoder>
- </appender>
-
- <logger name="org.onap.policy.apex.core.context.impl.monitoring" level="INFO" additivity="false">
- <appender-ref ref="CTXT_FILE" />
- </logger>
-
- <logger name="org.onap.policy.apex.core.context" level="INFO" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-</configuration>