aboutsummaryrefslogtreecommitdiffstats
path: root/model/context-model/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'model/context-model/src/test')
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java248
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java95
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java229
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java124
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ContextComparisonTest.java189
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModelCreator.java122
-rw-r--r--model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java148
-rw-r--r--model/context-model/src/test/resources/logback-test.xml78
8 files changed, 0 insertions, 1233 deletions
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
deleted file mode 100644
index 44161b329..000000000
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextAlbumsTest.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 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.contextmodel.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-
-/**
- * Context album tests.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ContextAlbumsTest {
-
- @Test
- public void testNewAxContectAlbum() {
- assertNotNull(new AxContextAlbum());
- assertNotNull(new AxContextAlbum(new AxArtifactKey()));
- assertNotNull(new AxContextAlbum(new AxArtifactKey(), "AlbumScope", false, new AxArtifactKey()));
- }
-
- @Test
- public void testContextAlbums() {
- final AxArtifactKey albumKey = new AxArtifactKey("AlbumName", "0.0.1");
- final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
-
- final AxContextAlbum album = new AxContextAlbum(albumKey, "AlbumScope", false, albumSchemaKey);
- assertNotNull(album);
-
- final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
- album.setKey(newKey);
- assertEquals("NewAlbumName:0.0.1", album.getKey().getId());
- assertEquals("NewAlbumName:0.0.1", album.getKeys().get(0).getId());
- album.setKey(albumKey);
-
- assertThatThrownBy(() -> album.setScope(""))
- .hasMessage("parameter \"scope\": value \"\", does not match regular expression "
- + "\"[A-Za-z0-9\\-_]+\"");
-
- album.setScope("NewAlbumScope");
- assertEquals("NewAlbumScope", album.getScope());
-
- assertEquals(false, album.isWritable());
- album.setWritable(true);
- assertEquals(true, album.isWritable());
-
- final AxArtifactKey newSchemaKey = new AxArtifactKey("NewAlbumSchemaName", "0.0.1");
- album.setItemSchema(newSchemaKey);
- assertEquals("NewAlbumSchemaName:0.0.1", album.getItemSchema().getId());
- album.setItemSchema(albumSchemaKey);
- }
-
- private AxContextAlbum setTestAlbum() {
- final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
- final AxArtifactKey newSchemaKey = new AxArtifactKey("NewAlbumSchemaName", "0.0.1");
-
- final AxContextAlbum album = new AxContextAlbum(newKey, "AlbumScope", false, newSchemaKey);
-
- album.setScope("NewAlbumScope");
- album.setWritable(true);
-
- return album;
- }
-
- @Test
- public void testAxvalidationAlbum() {
- final AxContextAlbum album = setTestAlbum();
- AxValidationResult result = new AxValidationResult();
- result = album.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- album.setKey(AxArtifactKey.getNullKey());
- result = new AxValidationResult();
- result = album.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
- album.setKey(newKey);
- result = new AxValidationResult();
- result = album.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- album.setScope("UNDEFINED");
- result = new AxValidationResult();
- result = album.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- album.setScope("NewAlbumScope");
- result = new AxValidationResult();
- result = album.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- album.setItemSchema(AxArtifactKey.getNullKey());
- result = new AxValidationResult();
- result = album.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
- album.setItemSchema(albumSchemaKey);
- result = new AxValidationResult();
- result = album.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- }
-
- @Test
- public void testEqualsAlbum() {
- final AxContextAlbum album = setTestAlbum();
- final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
- final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
- album.setItemSchema(albumSchemaKey);
-
- final AxContextAlbum clonedAlbum = new AxContextAlbum(album);
- assertEquals("AxContextAlbum(key=AxArtifactKey:(name=NewAlbumName,version=0.0.1), "
- + "scope=NewAlbumScope, isWritable=true, itemSchema="
- + "AxArtifactKey:(name=AlbumSchemaName,version=0.0.1))", clonedAlbum.toString());
-
- assertNotEquals(0, album.hashCode());
- // disabling sonar because this code tests the equals() method
- assertEquals(album, album); // NOSONAR
- assertEquals(album, clonedAlbum);
- assertNotNull(album);
- assertNotEquals(album, (Object) "Hello");
- assertNotEquals(album, new AxContextAlbum(new AxArtifactKey(), "Scope", false, AxArtifactKey.getNullKey()));
- assertNotEquals(album, new AxContextAlbum(newKey, "Scope", false, AxArtifactKey.getNullKey()));
- assertNotEquals(album, new AxContextAlbum(newKey, "NewAlbumScope", false, AxArtifactKey.getNullKey()));
- assertNotEquals(album, new AxContextAlbum(newKey, "NewAlbumScope", true, AxArtifactKey.getNullKey()));
- assertEquals(album, new AxContextAlbum(newKey, "NewAlbumScope", true, albumSchemaKey));
-
- assertEquals(0, album.compareTo(album));
- assertEquals(0, album.compareTo(clonedAlbum));
- assertNotEquals(0, album.compareTo(null));
- assertNotEquals(0, album.compareTo(new AxArtifactKey()));
- assertNotEquals(0, album.compareTo(
- new AxContextAlbum(new AxArtifactKey(), "Scope", false, AxArtifactKey.getNullKey())));
- assertNotEquals(0, album.compareTo(new AxContextAlbum(newKey, "Scope", false, AxArtifactKey.getNullKey())));
- assertNotEquals(0, album
- .compareTo(new AxContextAlbum(newKey, "NewAlbumScope", false, AxArtifactKey.getNullKey())));
- assertNotEquals(0,
- album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, AxArtifactKey.getNullKey())));
- assertEquals(0, album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, albumSchemaKey)));
- }
-
- @Test
- public void testMultipleAlbums() {
- final AxContextAlbums albums = new AxContextAlbums();
- final AxContextAlbum album = setTestAlbum();
- final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
- AxValidationResult result = new AxValidationResult();
- result = albums.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- // Observation, no albums in album map
- albums.setKey(new AxArtifactKey("AlbumsKey", "0.0.1"));
- result = new AxValidationResult();
- result = albums.validate(result);
- assertEquals(ValidationResult.OBSERVATION, result.getValidationResult());
-
- albums.getAlbumsMap().put(newKey, album);
- result = new AxValidationResult();
- result = albums.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- albums.getAlbumsMap().put(AxArtifactKey.getNullKey(), null);
- result = new AxValidationResult();
- result = albums.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- albums.getAlbumsMap().remove(AxArtifactKey.getNullKey());
- result = new AxValidationResult();
- result = albums.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- albums.getAlbumsMap().put(new AxArtifactKey("NullValueKey", "0.0.1"), null);
- result = new AxValidationResult();
- result = albums.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- albums.getAlbumsMap().remove(new AxArtifactKey("NullValueKey", "0.0.1"));
- result = new AxValidationResult();
- result = albums.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- }
-
- @Test
- public void testClonedAlbums() {
- final AxContextAlbums albums = new AxContextAlbums();
- final AxContextAlbum album = setTestAlbum();
- final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
- albums.setKey(new AxArtifactKey("AlbumsKey", "0.0.1"));
- albums.getAlbumsMap().put(newKey, album);
- albums.clean();
-
- final AxContextAlbums clonedAlbums = new AxContextAlbums(albums);
- assertThat(clonedAlbums.toString()).startsWith(
- "AxContextAlbums(key=AxArtifactKey:(name=AlbumsKey,version=0.0.1)");
-
- assertNotEquals(0, albums.hashCode());
-
- assertEquals(albums, clonedAlbums);
- assertNotNull(albums);
- assertNotEquals(albums, (Object) "Hello");
- assertNotEquals(albums, new AxContextAlbums(new AxArtifactKey()));
-
- assertEquals(0, albums.compareTo(albums));
- assertEquals(0, albums.compareTo(clonedAlbums));
- assertNotEquals(0, albums.compareTo(null));
- assertNotEquals(0, albums.compareTo(new AxArtifactKey()));
- assertNotEquals(0, albums.compareTo(new AxContextAlbums(new AxArtifactKey())));
-
- clonedAlbums.get(newKey).setScope("YetAnotherScope");
- assertNotEquals(0, albums.compareTo(clonedAlbums));
-
- assertEquals("NewAlbumName", albums.get("NewAlbumName").getKey().getName());
- assertEquals("NewAlbumName", albums.get("NewAlbumName", "0.0.1").getKey().getName());
- assertEquals(1, albums.getAll("NewAlbumName", "0.0.1").size());
- assertEquals(0, albums.getAll("NonExistantAlbumName").size());
- }
-}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java
deleted file mode 100644
index b148ef6be..000000000
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextModelTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 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.contextmodel.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
-
-/**
- * Context model tests.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ContextModelTest {
-
- @Test
- public void test() {
- assertNotNull(new AxContextModel());
- assertNotNull(new AxContextModel(new AxArtifactKey()));
- assertNotNull(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxKeyInformation()));
- assertNotNull(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation()));
-
- final AxArtifactKey modelKey = new AxArtifactKey("ModelKey", "0.0.1");
- final AxArtifactKey schemasKey = new AxArtifactKey("SchemasKey", "0.0.1");
- final AxArtifactKey albumsKey = new AxArtifactKey("SchemasKey", "0.0.1");
- final AxArtifactKey keyInfoKey = new AxArtifactKey("SchemasKey", "0.0.1");
- final AxContextModel model = new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
- new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey));
- model.register();
-
- model.clean();
- assertNotNull(model);
- assertThat(model.toString()).startsWith("AxContextModel(super=AxContextModel:(key=AxArtifactKey:");
-
- final AxContextModel clonedModel = new AxContextModel(model);
-
- assertNotEquals(0, model.hashCode());
-
- // disabling sonar because this code tests the equals() method
- assertEquals(model, model); // NOSONAR
- assertEquals(model, clonedModel);
- assertNotEquals(model, (Object) "Hello");
- assertNotEquals(model, new AxContextModel(new AxArtifactKey()));
- assertNotEquals(model, new AxContextModel(new AxArtifactKey(), new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation()));
- assertNotEquals(model, new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation()));
- assertNotEquals(model, new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation(keyInfoKey)));
- assertNotEquals(model, new AxContextModel(modelKey, new AxContextSchemas(schemasKey), new AxContextAlbums(),
- new AxKeyInformation(keyInfoKey)));
- assertEquals(model, new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
- new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey)));
-
- assertEquals(0, model.compareTo(model));
- assertEquals(0, model.compareTo(clonedModel));
- assertNotEquals(0, model.compareTo(new AxArtifactKey()));
- assertNotEquals(0, model.compareTo(new AxContextModel(new AxArtifactKey(), new AxContextSchemas(),
- new AxContextAlbums(), new AxKeyInformation())));
- assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation())));
- assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(), new AxContextAlbums(),
- new AxKeyInformation(keyInfoKey))));
- assertNotEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
- new AxContextAlbums(), new AxKeyInformation(keyInfoKey))));
- assertEquals(0, model.compareTo(new AxContextModel(modelKey, new AxContextSchemas(schemasKey),
- new AxContextAlbums(albumsKey), new AxKeyInformation(keyInfoKey))));
- }
-}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
deleted file mode 100644
index 52cca14bf..000000000
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/concepts/ContextSchemasTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020-2021 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.contextmodel.concepts;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-
-/**
- * Context schema tests.
- */
-public class ContextSchemasTest {
-
- @Test
- public void testNewAxContextSchema() {
- assertNotNull(new AxContextSchema());
- assertNotNull(new AxContextSchema(new AxArtifactKey(), "SchemaFlavour", "SchemaDefinition"));
-
- }
-
- @Test
- public void testContextSchemas() {
- final AxContextSchema schema = new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour",
- "SchemaDefinition");
- assertNotNull(schema);
-
- final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
- schema.setKey(newKey);
- assertEquals("NewSchemaName:0.0.1", schema.getKey().getId());
- assertEquals("NewSchemaName:0.0.1", schema.getKeys().get(0).getId());
-
- assertThatThrownBy(() -> schema.setSchemaFlavour(""))
- .hasMessage("parameter \"schemaFlavour\": value \"\", "
- + "does not match regular expression \"[A-Za-z0-9\\-_]+\"");
- schema.setSchemaFlavour("NewSchemaFlavour");
- assertEquals("NewSchemaFlavour", schema.getSchemaFlavour());
-
- schema.setSchema("NewSchemaDefinition");
- assertEquals("NewSchemaDefinition", schema.getSchema());
- }
-
- private AxContextSchema setTestSchema() {
- final AxContextSchema schema = new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour",
- "SchemaDefinition");
- final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
- schema.setKey(newKey);
- schema.setSchemaFlavour("NewSchemaFlavour");
- schema.setSchema("NewSchemaDefinition");
-
- return schema;
- }
-
- @Test
- public void testAxvalidationSchema() {
- AxContextSchema schema = setTestSchema();
- AxValidationResult result = new AxValidationResult();
- result = schema.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- schema.setKey(AxArtifactKey.getNullKey());
- result = new AxValidationResult();
- result = schema.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
- schema.setKey(newKey);
- result = new AxValidationResult();
- result = schema.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- schema.setSchemaFlavour("UNDEFINED");
- result = new AxValidationResult();
- result = schema.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- schema.setSchemaFlavour("NewSchemaFlavour");
- result = new AxValidationResult();
- result = schema.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- schema.setSchema("");
- result = new AxValidationResult();
- result = schema.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- schema.setSchema("NewSchemaDefinition");
- result = new AxValidationResult();
- result = schema.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
- }
-
- @Test
- public void testEqualsSchema() {
- AxContextSchema schema = setTestSchema();
- schema.clean();
-
- final AxContextSchema clonedSchema = new AxContextSchema(schema);
- assertEquals("AxContextSchema(key=AxArtifactKey:(name=NewSchemaName,version=0.0.1), "
- + "schemaFlavour=NewSchemaFlavour, schemaDefinition=NewSchemaDefinition)",
- clonedSchema.toString());
-
- assertNotEquals(0, schema.hashCode());
-
- // disabling sonar because this code tests the equals() method
- assertEquals(schema, schema); // NOSONAR
- assertEquals(schema, clonedSchema);
- assertNotNull(schema);
- assertNotEquals(schema, (Object) "Hello");
- assertNotEquals(schema, new AxContextSchema(new AxArtifactKey(), "Flavour", "Def"));
-
- final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
- assertNotEquals(schema, new AxContextSchema(newKey, "Flavour", "Def"));
- assertNotEquals(schema, new AxContextSchema(newKey, "NewSchemaFlavour", "Def"));
- assertEquals(schema, new AxContextSchema(newKey, "NewSchemaFlavour", "NewSchemaDefinition"));
-
- assertEquals(0, schema.compareTo(schema));
- assertEquals(0, schema.compareTo(clonedSchema));
- assertNotEquals(0, schema.compareTo(null));
- assertNotEquals(0, schema.compareTo(new AxArtifactKey()));
- assertNotEquals(0, schema.compareTo(new AxContextSchema(new AxArtifactKey(), "Flavour", "Def")));
- assertNotEquals(0, schema.compareTo(new AxContextSchema(newKey, "Flavour", "Def")));
- assertNotEquals(0, schema.compareTo(new AxContextSchema(newKey, "NewSchemaFlavour", "Def")));
- assertEquals(0, schema.compareTo(new AxContextSchema(newKey, "NewSchemaFlavour", "NewSchemaDefinition")));
- }
-
- @Test
- public void testMultipleSchemas() {
- final AxContextSchemas schemas = new AxContextSchemas();
- AxValidationResult result = new AxValidationResult();
- result = schemas.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- // Still invalid, no schemas in schema map
- schemas.setKey(new AxArtifactKey("SchemasKey", "0.0.1"));
- result = new AxValidationResult();
- result = schemas.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- AxContextSchema schema = setTestSchema();
- final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
- schemas.getSchemasMap().put(newKey, schema);
- result = new AxValidationResult();
- result = schemas.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- schemas.getSchemasMap().put(AxArtifactKey.getNullKey(), null);
- result = new AxValidationResult();
- result = schemas.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- schemas.getSchemasMap().remove(AxArtifactKey.getNullKey());
- result = new AxValidationResult();
- result = schemas.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- schemas.getSchemasMap().put(new AxArtifactKey("NullValueKey", "0.0.1"), null);
- result = new AxValidationResult();
- result = schemas.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
-
- schemas.getSchemasMap().remove(new AxArtifactKey("NullValueKey", "0.0.1"));
- result = new AxValidationResult();
- result = schemas.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
-
- }
-
- @Test
- public void testClonedSchemas() {
- final AxContextSchemas schemas = new AxContextSchemas();
- AxContextSchema schema = setTestSchema();
- final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
- schemas.setKey(new AxArtifactKey("SchemasKey", "0.0.1"));
- schemas.getSchemasMap().put(newKey, schema);
- schemas.clean();
-
- final AxContextSchemas clonedSchemas = new AxContextSchemas(schemas);
- assertThat(clonedSchemas.toString())
- .startsWith("AxContextSchemas(key=AxArtifactKey:(name=SchemasKey,version=0.0.1),");
-
- assertNotEquals(0, schemas.hashCode());
-
- assertEquals(schemas, clonedSchemas);
- assertNotNull(schemas);
- assertNotEquals(schemas, (Object) "Hello");
- assertNotEquals(schemas, new AxContextSchemas(new AxArtifactKey()));
-
- assertEquals(0, schemas.compareTo(schemas));
- assertEquals(0, schemas.compareTo(clonedSchemas));
- assertNotEquals(0, schemas.compareTo(null));
- assertNotEquals(0, schemas.compareTo(new AxArtifactKey()));
- assertNotEquals(0, schemas.compareTo(new AxContextSchemas(new AxArtifactKey())));
-
- clonedSchemas.get(newKey).setSchemaFlavour("YetAnotherFlavour");
- assertNotEquals(0, schemas.compareTo(clonedSchemas));
-
- assertEquals("NewSchemaName", schemas.get("NewSchemaName").getKey().getName());
- assertEquals("NewSchemaName", schemas.get("NewSchemaName", "0.0.1").getKey().getName());
- assertEquals(1, schemas.getAll("NewSchemaName", "0.0.1").size());
- assertEquals(0, schemas.getAll("NonExistantSchemaName").size());
- }
-}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
deleted file mode 100644
index 998469bac..000000000
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ApexContextModelTest.java
+++ /dev/null
@@ -1,124 +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.contextmodel.handling;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-
-/**
- * Apex context model tests.
- *
- * @author liam
- *
- */
-public class ApexContextModelTest {
-
- private static final String VALID_MODEL_STRING = "***validation of model successful***";
-
- private static final String OBSERVATION_MODEL_STRING = "\n"
- + "***observations noted during validation of model***\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n"
- + "********************************";
-
- private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:"
- + "UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n"
- + "********************************";
-
- private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=StringType,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema:INVALID:"
- + "no schemaDefinition specified, schemaDefinition may not be blank\n"
- + "AxArtifactKey:(name=contextAlbum0,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum:INVALID:"
- + "scope is not defined\n" + "********************************";
-
- private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n"
- + "AxArtifactKey:(name=ContextModel,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:INVALID:"
- + "key information not found for key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
- + "AxArtifactKey:(name=contextAlbum1,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextModel:WARNING:"
- + "key not found for key information entry\n" + "AxArtifactKey:(name=ContextSchemas,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas:INVALID:"
- + "key on schemas entry AxArtifactKey:(name=MapType,version=0.0.1) "
- + "does not equal entry key AxArtifactKey:(name=MapType,version=0.0.2)\n"
- + "AxArtifactKey:(name=contextAlbums,version=0.0.1):"
- + "org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums:INVALID:"
- + "key on context album entry key AxArtifactKey:(name=contextAlbum1,version=0.0.1) "
- + "does not equal context album value key AxArtifactKey:(name=contextAlbum1,version=0.0.2)\n"
- + "********************************";
-
- TestApexModel<AxContextModel> testApexModel;
-
- /**
- * Set up tests.
- *
- * @throws Exception a testing exception
- */
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxContextModel>(AxContextModel.class, new TestApexContextModelCreator());
- }
-
- @Test
- public void testModelValid() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelValid();
- assertEquals(VALID_MODEL_STRING, result.toString());
- }
-
- @Test
- public void testApexModelVaidateObservation() throws Exception {
- final AxValidationResult result = testApexModel.testApexModelVaidateObservation();
- assertEquals(OBSERVATION_MODEL_STRING, result.toString());
- }
-
- @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/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ContextComparisonTest.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ContextComparisonTest.java
deleted file mode 100644
index 483bc3661..000000000
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/ContextComparisonTest.java
+++ /dev/null
@@ -1,189 +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.contextmodel.handling;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
-import org.onap.policy.apex.model.utilities.comparison.KeyedMapDifference;
-
-/**
- * Test context comparisons.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class ContextComparisonTest {
- private AxContextModel emptyModel;
- private AxContextModel fullModel;
- private AxContextModel noGlobalContextModel;
- private AxContextModel shellModel;
- private AxContextModel singleEntryModel;
-
- /**
- * Set up tests.
- */
- @Before
- public void getContext() {
- final TestContextComparisonFactory factory = new TestContextComparisonFactory();
- emptyModel = factory.getEmptyModel();
- fullModel = factory.getFullModel();
- noGlobalContextModel = factory.getNoGlobalContextModel();
- shellModel = factory.getShellModel();
- singleEntryModel = factory.getSingleEntryModel();
- }
-
- @Test
- public void testEmptyEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), emptyModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(emptyModel.getSchemas().getSchemasMap(), schemaResult.getIdenticalValues());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), emptyModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(emptyModel.getAlbums().getAlbumsMap(), albumResult.getIdenticalValues());
- }
-
- @Test
- public void testEmptyFull() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), fullModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(fullModel.getSchemas().getSchemasMap(), schemaResult.getRightOnly());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), fullModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(fullModel.getAlbums().getAlbumsMap(), albumResult.getRightOnly());
- }
-
- @Test
- public void testFullEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(fullModel.getSchemas(), emptyModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(fullModel.getSchemas().getSchemasMap(), schemaResult.getLeftOnly());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(fullModel.getAlbums(), emptyModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(fullModel.getAlbums().getAlbumsMap(), albumResult.getLeftOnly());
- }
-
- @Test
- public void testEmptyNoGlobalContext() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), noGlobalContextModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(noGlobalContextModel.getSchemas().getSchemasMap(), schemaResult.getRightOnly());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), noGlobalContextModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(noGlobalContextModel.getAlbums().getAlbumsMap(), albumResult.getRightOnly());
- }
-
- @Test
- public void testNoGlobalContextEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(noGlobalContextModel.getSchemas(), emptyModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(noGlobalContextModel.getSchemas().getSchemasMap(), schemaResult.getLeftOnly());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(noGlobalContextModel.getAlbums(), emptyModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(noGlobalContextModel.getAlbums().getAlbumsMap(), albumResult.getLeftOnly());
- }
-
- @Test
- public void testEmptyShell() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), shellModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(shellModel.getSchemas().getSchemasMap(), schemaResult.getRightOnly());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), shellModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(shellModel.getAlbums().getAlbumsMap(), albumResult.getRightOnly());
- }
-
- @Test
- public void testShellEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(shellModel.getSchemas(), emptyModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(shellModel.getSchemas().getSchemasMap(), schemaResult.getLeftOnly());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(shellModel.getAlbums(), emptyModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(shellModel.getAlbums().getAlbumsMap(), albumResult.getLeftOnly());
- }
-
- @Test
- public void testEmptySingleEntry() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(emptyModel.getSchemas(), singleEntryModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(singleEntryModel.getSchemas().getSchemasMap(), schemaResult.getRightOnly());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(emptyModel.getAlbums(), singleEntryModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(singleEntryModel.getAlbums().getAlbumsMap(), albumResult.getRightOnly());
- }
-
- @Test
- public void testSingleEntryEmpty() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(singleEntryModel.getSchemas(), emptyModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(singleEntryModel.getSchemas().getSchemasMap(), schemaResult.getLeftOnly());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(singleEntryModel.getAlbums(), emptyModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(singleEntryModel.getAlbums().getAlbumsMap(), albumResult.getLeftOnly());
- }
-
- @Test
- public void testFullFull() {
- final KeyedMapDifference<AxArtifactKey, AxContextSchema> schemaResult = new ContextComparer()
- .compare(fullModel.getSchemas(), fullModel.getSchemas());
- assertNotNull(schemaResult);
- assertEquals(fullModel.getSchemas().getSchemasMap(), schemaResult.getIdenticalValues());
-
- final KeyedMapDifference<AxArtifactKey, AxContextAlbum> albumResult = new ContextComparer()
- .compare(fullModel.getAlbums(), fullModel.getAlbums());
- assertNotNull(albumResult);
- assertEquals(fullModel.getAlbums().getAlbumsMap(), albumResult.getIdenticalValues());
- }
-}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModelCreator.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModelCreator.java
deleted file mode 100644
index 3fe7e3aa2..000000000
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestApexContextModelCreator.java
+++ /dev/null
@@ -1,122 +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.contextmodel.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.test.TestApexModelCreator;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas;
-
-public class TestApexContextModelCreator implements TestApexModelCreator<AxContextModel> {
-
- @Override
- public AxContextModel getModel() {
- final AxContextSchema schema0 = new AxContextSchema(new AxArtifactKey("StringType", "0.0.1"), "Java",
- "org.onap.policy.apex.concept.TestContextItem000");
- final AxContextSchema schema1 = new AxContextSchema(new AxArtifactKey("MapType", "0.0.1"), "Java",
- "org.onap.policy.apex.concept.TestContextItem00A");
-
- final AxContextSchemas contextSchemas = new AxContextSchemas(new AxArtifactKey("ContextSchemas", "0.0.1"));
- contextSchemas.getSchemasMap().put(schema0.getKey(), schema0);
- contextSchemas.getSchemasMap().put(schema1.getKey(), schema1);
-
- final AxContextAlbum contextAlbum0 =
- new AxContextAlbum(new AxArtifactKey("contextAlbum0", "0.0.1"), "APPLICATION", true, schema0.getKey());
- final AxContextAlbum contextAlbum1 =
- new AxContextAlbum(new AxArtifactKey("contextAlbum1", "0.0.1"), "GLOBAL", false, schema1.getKey());
-
- final AxContextAlbums axContext = new AxContextAlbums(new AxArtifactKey("contextAlbums", "0.0.1"));
- axContext.getAlbumsMap().put(contextAlbum0.getKey(), contextAlbum0);
- axContext.getAlbumsMap().put(contextAlbum1.getKey(), contextAlbum1);
-
- final AxKeyInformation keyInformation = new AxKeyInformation(new AxArtifactKey("KeyInfoMapKey", "0.0.1"));
- final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"),
- contextSchemas, axContext, keyInformation);
-
- contextModel.setKeyInformation(keyInformation);
- contextModel.getKeyInformation().getKeyInfoMap().put(schema0.getKey(), new AxKeyInfo(schema0.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000001"), "axContextSchema0"));
- contextModel.getKeyInformation().getKeyInfoMap().put(schema1.getKey(), new AxKeyInfo(schema1.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000002"), "axContextSchema1"));
- contextModel.getKeyInformation().getKeyInfoMap().put(contextSchemas.getKey(), new AxKeyInfo(
- contextSchemas.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000003"), "ContextSchemas"));
- contextModel.getKeyInformation().getKeyInfoMap().put(contextAlbum0.getKey(), new AxKeyInfo(
- contextAlbum0.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000004"), "contextAlbum0"));
- contextModel.getKeyInformation().getKeyInfoMap().put(contextAlbum1.getKey(), new AxKeyInfo(
- contextAlbum1.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000005"), "contextAlbum1"));
- contextModel.getKeyInformation().getKeyInfoMap().put(axContext.getKey(), new AxKeyInfo(axContext.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000006"), "axContext"));
- contextModel.getKeyInformation().getKeyInfoMap().put(contextModel.getKey(), new AxKeyInfo(contextModel.getKey(),
- UUID.fromString("00000000-0000-0000-0000-000000000007"), "contextModel"));
- contextModel.getKeyInformation().getKeyInfoMap().put(keyInformation.getKey(), new AxKeyInfo(
- keyInformation.getKey(), UUID.fromString("00000000-0000-0000-0000-000000000008"), "keyInformation"));
-
- return contextModel;
- }
-
- @Override
- public AxContextModel getInvalidModel() {
- final AxContextModel contextModel = getModel();
-
- contextModel.getAlbums().get(new AxArtifactKey("contextAlbum0", "0.0.1")).setScope("UNDEFINED");
-
- contextModel.getSchemas().get(new AxArtifactKey("StringType", "0.0.1")).setSchema("");
-
- return contextModel;
- }
-
- @Override
- public AxContextModel getMalstructuredModel() {
- final AxContextModel contextModel = getModel();
-
- contextModel.getAlbums().get(new AxArtifactKey("contextAlbum1", "0.0.1"))
- .setKey(new AxArtifactKey("contextAlbum1", "0.0.2"));;
- contextModel.getSchemas().get(new AxArtifactKey("MapType", "0.0.1"))
- .setKey(new AxArtifactKey("MapType", "0.0.2"));;
-
- return contextModel;
- }
-
- @Override
- public AxContextModel getObservationModel() {
- final AxContextModel contextModel = getModel();
-
- contextModel.getKeyInformation().get("contextAlbum1", "0.0.1").setDescription("");
-
- return contextModel;
- }
-
- @Override
- public AxContextModel getWarningModel() {
- final AxContextModel contextModel = getModel();
-
- contextModel.getKeyInformation().get("contextAlbum1", "0.0.1")
- .setUuid(UUID.fromString("00000000-0000-0000-0000-000000000000"));
-
- return contextModel;
- }
-}
diff --git a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java b/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java
deleted file mode 100644
index f7c7a1345..000000000
--- a/model/context-model/src/test/java/org/onap/policy/apex/model/contextmodel/handling/TestContextComparisonFactory.java
+++ /dev/null
@@ -1,148 +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.contextmodel.handling;
-
-import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextModel;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchema;
-
-/**
- * This class creates sample Policy Models.
- *
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestContextComparisonFactory {
-
- /**
- * Get a full context model.
- * @return the model
- */
- public AxContextModel getFullModel() {
- final AxContextSchema testContextSchema000 =
- new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema000");
- final AxContextSchema testContextSchema00A =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00A", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00A");
- final AxContextSchema testContextSchema00C =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00C");
-
- final AxContextAlbum externalContextAlbum = new AxContextAlbum(
- new AxArtifactKey("ExternalContextAlbum", "0.0.1"), "EXTERNAL", false, testContextSchema000.getKey());
- final AxContextAlbum globalContextAlbum = new AxContextAlbum(new AxArtifactKey("GlobalContextAlbum", "0.0.1"),
- "GLOBAL", true, testContextSchema00A.getKey());
- final AxContextAlbum policy0ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy0ContextAlbum", "0.0.1"),
- "APPLICATION", true, testContextSchema00C.getKey());
- final AxContextAlbum policy1ContextAlbum = new AxContextAlbum(
- new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema00C.getKey());
-
- final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
- contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
- contextModel.getSchemas().getSchemasMap().put(testContextSchema00A.getKey(), testContextSchema00A);
- contextModel.getSchemas().getSchemasMap().put(testContextSchema00C.getKey(), testContextSchema00C);
-
- contextModel.getAlbums().getAlbumsMap().put(externalContextAlbum.getKey(), externalContextAlbum);
- contextModel.getAlbums().getAlbumsMap().put(globalContextAlbum.getKey(), globalContextAlbum);
- contextModel.getAlbums().getAlbumsMap().put(policy0ContextAlbum.getKey(), policy0ContextAlbum);
- contextModel.getAlbums().getAlbumsMap().put(policy1ContextAlbum.getKey(), policy1ContextAlbum);
-
- return contextModel;
- }
-
- public AxContextModel getEmptyModel() {
- return new AxContextModel(new AxArtifactKey("Context", "0.0.1"));
- }
-
- /**
- * Get a skeleton model.
- * @return The model
- */
- public AxContextModel getShellModel() {
- final AxContextSchema testContextSchema000 =
- new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema000");
- final AxContextSchema testContextSchema00A =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00A", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00A");
- final AxContextSchema testContextSchema00C =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00C");
-
- final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
- contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
- contextModel.getSchemas().getSchemasMap().put(testContextSchema00A.getKey(), testContextSchema00A);
- contextModel.getSchemas().getSchemasMap().put(testContextSchema00C.getKey(), testContextSchema00C);
-
- return contextModel;
- }
-
- /**
- * Get a single entry model.
- * @return The single entry model
- */
- public AxContextModel getSingleEntryModel() {
- final AxContextSchema testContextSchema000 =
- new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema000");
-
- final AxContextAlbum policy1ContextAlbum = new AxContextAlbum(
- new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema000.getKey());
-
- final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
- contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
-
- contextModel.getAlbums().getAlbumsMap().put(policy1ContextAlbum.getKey(), policy1ContextAlbum);
-
- return contextModel;
- }
-
- /**
- * Get a model with no global entries.
- * @return the model
- */
- public AxContextModel getNoGlobalContextModel() {
- final AxContextSchema testContextSchema000 =
- new AxContextSchema(new AxArtifactKey("TestContextSchema000", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema000");
- final AxContextSchema testContextSchema00C =
- new AxContextSchema(new AxArtifactKey("TestContextSchema00C", "0.0.1"), "JAVA",
- "org.onap.policy.apex.concept.TestContextSchema00C");
-
- final AxContextAlbum externalContextAlbum = new AxContextAlbum(
- new AxArtifactKey("ExternalContextAlbum", "0.0.1"), "EXTERNAL", false, testContextSchema000.getKey());
- final AxContextAlbum policy0ContextAlbum = new AxContextAlbum(new AxArtifactKey("Policy0ContextAlbum", "0.0.1"),
- "APPLICATION", true, testContextSchema00C.getKey());
- final AxContextAlbum policy1ContextAlbum = new AxContextAlbum(
- new AxArtifactKey("Policy1ContextAlbum ", "0.0.1"), "APPLICATION", true, testContextSchema00C.getKey());
-
- final AxContextModel contextModel = new AxContextModel(new AxArtifactKey("ContextModel", "0.0.1"));
- contextModel.getSchemas().getSchemasMap().put(testContextSchema000.getKey(), testContextSchema000);
- contextModel.getSchemas().getSchemasMap().put(testContextSchema00C.getKey(), testContextSchema00C);
-
- contextModel.getAlbums().getAlbumsMap().put(externalContextAlbum.getKey(), externalContextAlbum);
- contextModel.getAlbums().getAlbumsMap().put(policy0ContextAlbum.getKey(), policy0ContextAlbum);
- contextModel.getAlbums().getAlbumsMap().put(policy1ContextAlbum.getKey(), policy1ContextAlbum);
-
- return contextModel;
- }
-}
diff --git a/model/context-model/src/test/resources/logback-test.xml b/model/context-model/src/test/resources/logback-test.xml
deleted file mode 100644
index af4993550..000000000
--- a/model/context-model/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,78 +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.onap.policy.apex.core.contextmodel" level="INFO" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="org.apache.zookeeper.ClientCnxn" level="OFF" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="org.onap.policy.apex.core" level="INFO" 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>