summaryrefslogtreecommitdiffstats
path: root/model/basic-model/src/test/java/org/onap/apex
diff options
context:
space:
mode:
Diffstat (limited to 'model/basic-model/src/test/java/org/onap/apex')
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/AxKeyTest.java119
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxKeyInfo.java108
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxReferenceKey.java112
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestEntity.java175
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestExceptions.java70
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestValidation.java93
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/testKeyUse.java82
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/EntityTest.java300
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/TestDaoMisc.java91
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/AxModelWithReferences.java69
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModel.java137
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java279
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelCreator.java126
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator0.java63
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator1.java75
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator2.java63
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestBasicModelTest.java156
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestConceptGetter.java171
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestExceptions.java44
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelFileWriter.java131
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelReader.java155
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelSaver.java53
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelStringWriter.java99
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelWriter.java98
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestSchemaGenerator.java93
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/IllegalParameters.java32
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/LegalParameters.java32
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestAbstractParameters.java51
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestModelService.java78
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestParameterService.java77
-rw-r--r--model/basic-model/src/test/java/org/onap/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java46
31 files changed, 0 insertions, 3278 deletions
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/AxKeyTest.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/AxKeyTest.java
deleted file mode 100644
index a454aaf92..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/AxKeyTest.java
+++ /dev/null
@@ -1,119 +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.apex.model.basicmodel.concepts;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.concepts.AxKey.Compatibility;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class AxKeyTest {
-
- @Test
- public void testArtifactKey() {
- AxArtifactKey aKey0 = new AxArtifactKey();
- AxArtifactKey aKey1 = new AxArtifactKey("name", "0.0.1");
- AxArtifactKey aKey2 = new AxArtifactKey(aKey1);
- AxArtifactKey aKey3 = new AxArtifactKey(aKey1.getID());
- AxArtifactKey aKey4 = new AxArtifactKey(aKey1);
- AxArtifactKey aKey5 = new AxArtifactKey(aKey1);
- AxArtifactKey aKey6 = new AxArtifactKey(aKey1);
-
- try {
- new AxArtifactKey("some bad key id");
- fail("This test should throw an exception");
- }
- catch (IllegalArgumentException e) {
- assertEquals("parameter \"id\": value \"some bad key id\", does not match regular expression \"[A-Za-z0-9\\-_\\.]+:[0-9].[0-9].[0-9]\"", e.getMessage());
- }
-
- assertEquals(AxArtifactKey.getNullKey(), aKey0);
- assertEquals(aKey1, aKey2);
- assertEquals(aKey1, aKey3);
-
- assertEquals(aKey2, aKey1.getKey());
- assertEquals(1, aKey1.getKeys().size());
-
- aKey0.setName("zero");
- aKey0.setVersion("0.0.2");
- aKey3.setVersion("0.0.2");
- aKey4.setVersion("0.1.2");
- aKey5.setVersion("1.2.2");
- aKey6.setVersion("3");
-
- assertEquals(Compatibility.DIFFERENT, aKey0.getCompatibility(new AxReferenceKey()));
- assertEquals(Compatibility.DIFFERENT, aKey0.getCompatibility(aKey1));
- assertEquals(Compatibility.IDENTICAL, aKey2.getCompatibility(aKey1));
- assertEquals(Compatibility.PATCH, aKey3.getCompatibility(aKey1));
- assertEquals(Compatibility.MINOR, aKey4.getCompatibility(aKey1));
- assertEquals(Compatibility.MAJOR, aKey5.getCompatibility(aKey1));
- assertEquals(Compatibility.MAJOR, aKey6.getCompatibility(aKey1));
-
- assertTrue(aKey1.isCompatible(aKey2));
- assertTrue(aKey1.isCompatible(aKey3));
- assertTrue(aKey1.isCompatible(aKey4));
- assertFalse(aKey1.isCompatible(aKey0));
- assertFalse(aKey1.isCompatible(aKey5));
- assertFalse(aKey1.isCompatible(new AxReferenceKey()));
-
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey0.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey1.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey2.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey3.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey4.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey5.validate(new AxValidationResult()).getValidationResult());
- assertEquals(AxValidationResult.ValidationResult.VALID, aKey6.validate(new AxValidationResult()).getValidationResult());
-
- aKey0.clean();
- assertNotNull(aKey0.toString());
-
- AxArtifactKey aKey7 = new AxArtifactKey(aKey1);
- assertEquals(150332875, aKey7.hashCode());
- assertEquals(0, aKey7.compareTo(aKey1));
- assertEquals(-12, aKey7.compareTo(aKey0));
-
- try {
- aKey0.compareTo(null);
- }
- catch (IllegalArgumentException e) {
- assertEquals("comparison object may not be null", e.getMessage());
- }
-
- assertEquals(0, aKey0.compareTo(aKey0));
- assertEquals(353602977, aKey0.compareTo(new AxReferenceKey()));
-
- assertFalse(aKey0.equals(null));
- assertTrue(aKey0.equals(aKey0));
- assertFalse(((AxKey)aKey0).equals(new AxReferenceKey()));
- }
-
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxKeyInfo.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxKeyInfo.java
deleted file mode 100644
index 6af662bdf..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxKeyInfo.java
+++ /dev/null
@@ -1,108 +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.apex.model.basicmodel.concepts;
-
-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.util.UUID;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestAxKeyInfo {
-
- @Test
- public void testAxKeyInfo() {
- assertNotNull(new AxKeyInfo());
- assertNotNull(new AxKeyInfo(new AxArtifactKey()));
- assertNotNull(new AxKeyInfo(new AxArtifactKey(), UUID.randomUUID(), "Key description"));
-
- AxKeyInfo testKeyInfo = new AxKeyInfo();
- testKeyInfo.setKey((new AxArtifactKey("PN", "0.0.1")));
- assertEquals("PN:0.0.1", testKeyInfo.getKey().getID());
-
- 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="));
-
- assertFalse(testKeyInfo.hashCode() == 0);
-
- assertTrue(testKeyInfo.equals(testKeyInfo));
- assertTrue(testKeyInfo.equals(clonedReferenceKey));
- assertFalse(testKeyInfo.equals(null));
- assertFalse(testKeyInfo.equals(new AxArtifactKey()));
- assertFalse(testKeyInfo.equals(new AxKeyInfo(new AxArtifactKey())));
- assertFalse(testKeyInfo.equals(new AxKeyInfo(key, UUID.randomUUID(), "Some Description")));
- assertFalse(testKeyInfo.equals(new AxKeyInfo(key, uuid, "Some Description")));
- assertTrue(testKeyInfo.equals(new AxKeyInfo(key, uuid, "Key Description")));
-
- assertEquals(0, testKeyInfo.compareTo(testKeyInfo));
- assertEquals(0, testKeyInfo.compareTo(clonedReferenceKey));
- assertNotEquals(0, testKeyInfo.compareTo(null));
- assertNotEquals(0, testKeyInfo.compareTo(new AxArtifactKey()));
- assertNotEquals(0, testKeyInfo.compareTo(new AxKeyInfo(new AxArtifactKey())));
- assertNotEquals(0, testKeyInfo.compareTo(new AxKeyInfo(key, UUID.randomUUID(), "Some Description")));
- assertNotEquals(0, testKeyInfo.compareTo(new AxKeyInfo(key, uuid, "Some Description")));
- assertEquals(0, testKeyInfo.compareTo(new AxKeyInfo(key, uuid, "Key Description")));
-
- assertNotNull(testKeyInfo.getKeys());
-
- 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/apex/model/basicmodel/concepts/TestAxReferenceKey.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxReferenceKey.java
deleted file mode 100644
index 7ec3cbbbf..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxReferenceKey.java
+++ /dev/null
@@ -1,112 +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.apex.model.basicmodel.concepts;
-
-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 org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestAxReferenceKey {
-
- @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());
-
- assertFalse(testReferenceKey.hashCode() == 0);
-
- assertTrue(testReferenceKey.equals(testReferenceKey));
- assertTrue(testReferenceKey.equals(clonedReferenceKey));
- assertFalse(testReferenceKey.equals("Hello"));
- assertFalse(testReferenceKey.equals(new AxReferenceKey("PKN", "0.0.2", "PLN", "LN")));
- assertFalse(testReferenceKey.equals(new AxReferenceKey("NPKN", "0.0.2", "PLN", "LN")));
- assertFalse(testReferenceKey.equals(new AxReferenceKey("NPKN", "0.0.1", "PLN", "LN")));
- assertFalse(testReferenceKey.equals(new AxReferenceKey("NPKN", "0.0.1", "NPLN", "LN")));
- assertTrue(testReferenceKey.equals(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());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestEntity.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestEntity.java
deleted file mode 100644
index 3e821f7c5..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestEntity.java
+++ /dev/null
@@ -1,175 +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.apex.model.basicmodel.concepts;
-
-import java.util.Arrays;
-import java.util.List;
-
-import javax.persistence.EmbeddedId;
-import javax.persistence.Entity;
-import javax.persistence.Table;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.onap.apex.model.basicmodel.concepts.AxConcept;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
-
-@Entity
-@Table(name = "TestEntity")
-
-public class TestEntity extends AxConcept {
- private static final long serialVersionUID = -2962570563281067894L;
-
- @EmbeddedId()
- @XmlElement(name = "key", required = true)
- @XmlJavaTypeAdapter(AxReferenceKeyAdapter.class)
- protected AxReferenceKey key;
-
- private double doubleValue;
-
- public TestEntity() {
- this.key = new AxReferenceKey();
- this.doubleValue = 0;
- }
-
- public TestEntity(Double doubleValue) {
- this.key = new AxReferenceKey();
- this.doubleValue = doubleValue;
- }
-
- public TestEntity(AxReferenceKey key, Double doubleValue) {
- this.key = key;
- this.doubleValue = doubleValue;
- }
-
- public AxReferenceKey getKey() {
- return key;
- }
-
- 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 TestEntity(): target);
- if (copyObject instanceof TestEntity) {
- final TestEntity copy = ((TestEntity) 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;
- TestEntity other = (TestEntity) 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;
- TestEntity other = (TestEntity) 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 new Double(doubleValue).compareTo(other.doubleValue);
-
- return 0;
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestExceptions.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestExceptions.java
deleted file mode 100644
index 1d37cd8ed..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestExceptions.java
+++ /dev/null
@@ -1,70 +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.apex.model.basicmodel.concepts;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexConceptException;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestExceptions {
-
- @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/apex/model/basicmodel/concepts/TestValidation.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestValidation.java
deleted file mode 100644
index e8eff5230..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestValidation.java
+++ /dev/null
@@ -1,93 +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.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.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationMessage;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestValidation {
-
- @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.getCanonicalName(), result.getMessageList().get(3).getObservedClass());
- assertEquals(AxArtifactKey.getNullKey(), result.getMessageList().get(3).getObservedKey());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/testKeyUse.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/testKeyUse.java
deleted file mode 100644
index ca1e5c191..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/testKeyUse.java
+++ /dev/null
@@ -1,82 +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.apex.model.basicmodel.concepts;
-
-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 org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyUse;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.concepts.AxKey.Compatibility;
-
-public class testKeyUse {
-
- @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());
-
- assertFalse(keyUse.hashCode() == 0);
-
- assertTrue(keyUse.equals(keyUse));
- assertTrue(keyUse.equals(clonedKeyUse));
- assertFalse(keyUse.equals("Hello"));
- assertTrue(keyUse.equals(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/apex/model/basicmodel/dao/EntityTest.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/EntityTest.java
deleted file mode 100644
index 87779848e..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/EntityTest.java
+++ /dev/null
@@ -1,300 +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.apex.model.basicmodel.dao;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.UUID;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.TestEntity;
-import org.onap.apex.model.basicmodel.dao.ApexDao;
-import org.onap.apex.model.basicmodel.dao.ApexDaoFactory;
-import org.onap.apex.model.basicmodel.dao.DAOParameters;
-
-/**
- * JUnit test class
- */
-public class EntityTest {
- private Connection connection;
- private ApexDao apexDao;
-
- @Before
- public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
- }
-
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
- @Test
- public void testEntityTestSanity() throws ApexException {
- final DAOParameters daoParameters = new DAOParameters();
-
- apexDao = new ApexDaoFactory().createApexDao(daoParameters);
-
- try {
- apexDao.init(null);
- fail("Test should throw an exception here");
- }
- catch (final Exception e) {
- assertEquals("Apex persistence unit parameter not set", e.getMessage());
- }
-
- try {
- apexDao.init(daoParameters);
- fail("Test should throw an exception here");
- }
- catch (final Exception e) {
- assertEquals("Apex persistence unit parameter not set", e.getMessage());
- }
-
- daoParameters.setPluginClass("somewhere.over.the.rainbow");
- daoParameters.setPersistenceUnit("Dorothy");
- try {
- apexDao.init(daoParameters);
- fail("Test should throw an exception here");
- }
- catch (final Exception e) {
- assertEquals("Creation of Apex persistence unit \"Dorothy\" failed", e.getMessage());
- }
- try {
- apexDao.create(new AxArtifactKey());
- fail("Test should throw an exception here");
- }
- catch (final Exception e) {
- assertEquals("Apex DAO has not been initialized", e.getMessage());
- }
- apexDao.close();
- }
-
- @Test
- public void testEntityTestAllOpsJPA() throws ApexException {
- final DAOParameters daoParameters = new DAOParameters();
- daoParameters.setPluginClass("org.onap.apex.model.basicmodel.dao.impl.DefaultApexDao");
- daoParameters.setPersistenceUnit("DAOTest");
-
- apexDao = new ApexDaoFactory().createApexDao(daoParameters);
- apexDao.init(daoParameters);
-
- testAllOps();
- apexDao.close();
- }
-
- @Test
- public void testEntityTestBadVals() throws ApexException {
- final DAOParameters daoParameters = new DAOParameters();
- daoParameters.setPluginClass("org.onap.apex.model.basicmodel.dao.impl.DefaultApexDao");
- daoParameters.setPersistenceUnit("DAOTest");
-
- apexDao = new ApexDaoFactory().createApexDao(daoParameters);
- apexDao.init(daoParameters);
-
- final AxArtifactKey nullKey = null;
- final AxReferenceKey nullRefKey = null;
- final List<AxArtifactKey> nullKeyList = null;
- final List<AxArtifactKey> emptyKeyList = new ArrayList<>();
- final List<AxReferenceKey> nullRKeyList = null;
- final List<AxReferenceKey> emptyRKeyList = new ArrayList<>();
-
- apexDao.create(nullKey);
- apexDao.create(nullKeyList);
- apexDao.create(emptyKeyList);
-
- apexDao.delete(nullKey);
- apexDao.delete(nullKeyList);
- apexDao.delete(emptyKeyList);
- apexDao.delete(AxArtifactKey.class, nullKey);
- apexDao.delete(AxReferenceKey.class, nullRefKey);
- apexDao.deleteByArtifactKey(AxArtifactKey.class, nullKeyList);
- apexDao.deleteByArtifactKey(AxArtifactKey.class, emptyKeyList);
- apexDao.deleteByReferenceKey(AxReferenceKey.class, nullRKeyList);
- apexDao.deleteByReferenceKey(AxReferenceKey.class, emptyRKeyList);
-
- apexDao.get(null, nullKey);
- apexDao.get(null, nullRefKey);
- apexDao.getAll(null);
- apexDao.getAll(null, nullKey);
- apexDao.getArtifact(null, nullKey);
- apexDao.getArtifact(AxArtifactKey.class, nullKey);
- apexDao.getArtifact(null, nullRefKey);
- apexDao.getArtifact(AxReferenceKey.class, nullRefKey);
- apexDao.size(null);
-
- apexDao.close();
- }
-
- private void testAllOps(){
- final AxArtifactKey aKey0 = new AxArtifactKey("A-KEY0", "0.0.1");
- final AxArtifactKey aKey1 = new AxArtifactKey("A-KEY1", "0.0.1");
- final AxArtifactKey aKey2 = new AxArtifactKey("A-KEY2", "0.0.1");
- final AxKeyInfo keyInfo0 = new AxKeyInfo(aKey0, UUID.fromString("00000000-0000-0000-0000-000000000000"), "key description 0");
- final AxKeyInfo keyInfo1 = new AxKeyInfo(aKey1, UUID.fromString("00000000-0000-0000-0000-000000000001"), "key description 1");
- final AxKeyInfo keyInfo2 = new AxKeyInfo(aKey2, UUID.fromString("00000000-0000-0000-0000-000000000002"), "key description 2");
-
- apexDao.create(keyInfo0);
-
- final AxKeyInfo keyInfoBack0 = apexDao.get(AxKeyInfo.class, aKey0);
- assertTrue(keyInfo0.equals(keyInfoBack0));
-
- final AxKeyInfo keyInfoBackNull = apexDao.get(AxKeyInfo.class, AxArtifactKey.getNullKey());
- assertNull(keyInfoBackNull);
-
- final AxKeyInfo keyInfoBack1 = apexDao.getArtifact(AxKeyInfo.class, aKey0);
- assertTrue(keyInfoBack0.equals(keyInfoBack1));
-
- final AxKeyInfo keyInfoBack2 = apexDao.getArtifact(AxKeyInfo.class, new AxArtifactKey("A-KEY3", "0.0.1"));
- assertNull(keyInfoBack2);
-
- final Set<AxKeyInfo> keyInfoSetIn = new TreeSet<AxKeyInfo>();
- keyInfoSetIn.add(keyInfo1);
- keyInfoSetIn.add(keyInfo2);
-
- apexDao.create(keyInfoSetIn);
-
- Set<AxKeyInfo> keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
-
- keyInfoSetIn.add(keyInfo0);
- assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
-
- apexDao.delete(keyInfo1);
- keyInfoSetIn.remove(keyInfo1);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
-
- apexDao.delete(keyInfoSetIn);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertEquals(0, keyInfoSetOut.size());
-
- keyInfoSetIn.add(keyInfo0);
- keyInfoSetIn.add(keyInfo1);
- keyInfoSetIn.add(keyInfo0);
- apexDao.create(keyInfoSetIn);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
-
- apexDao.delete(AxKeyInfo.class, aKey0);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertEquals(2, keyInfoSetOut.size());
- assertEquals(2, apexDao.size(AxKeyInfo.class));
-
- final Set<AxArtifactKey> keySetIn = new TreeSet<AxArtifactKey>();
- keySetIn.add(aKey1);
- keySetIn.add(aKey2);
-
- final int deletedCount = apexDao.deleteByArtifactKey(AxKeyInfo.class, keySetIn);
- assertEquals(2, deletedCount);
-
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertEquals(0, keyInfoSetOut.size());
-
- keyInfoSetIn.add(keyInfo0);
- keyInfoSetIn.add(keyInfo1);
- keyInfoSetIn.add(keyInfo0);
- apexDao.create(keyInfoSetIn);
- keyInfoSetOut = new TreeSet<AxKeyInfo>(apexDao.getAll(AxKeyInfo.class));
- assertTrue(keyInfoSetIn.equals(keyInfoSetOut));
-
- apexDao.deleteAll(AxKeyInfo.class);
- assertEquals(0, apexDao.size(AxKeyInfo.class));
-
- final AxArtifactKey owner0Key = new AxArtifactKey("Owner0", "0.0.1");
- final AxArtifactKey owner1Key = new AxArtifactKey("Owner1", "0.0.1");
- final AxArtifactKey owner2Key = new AxArtifactKey("Owner2", "0.0.1");
- final AxArtifactKey owner3Key = new AxArtifactKey("Owner3", "0.0.1");
- final AxArtifactKey owner4Key = new AxArtifactKey("Owner4", "0.0.1");
- final AxArtifactKey owner5Key = new AxArtifactKey("Owner5", "0.0.1");
-
- apexDao.create(new TestEntity(new AxReferenceKey(owner0Key, "Entity0"), 100.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner0Key, "Entity1"), 101.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner0Key, "Entity2"), 102.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner0Key, "Entity3"), 103.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner0Key, "Entity4"), 104.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner1Key, "Entity5"), 105.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner1Key, "Entity6"), 106.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner1Key, "Entity7"), 107.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner2Key, "Entity8"), 108.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner2Key, "Entity9"), 109.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner3Key, "EntityA"), 110.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner4Key, "EntityB"), 111.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner5Key, "EntityC"), 112.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner5Key, "EntityD"), 113.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner5Key, "EntityE"), 114.0));
- apexDao.create(new TestEntity(new AxReferenceKey(owner5Key, "EntityF"), 115.0));
-
- TreeSet<TestEntity> testEntitySetOut = new TreeSet<TestEntity>(apexDao.getAll(TestEntity.class));
- assertEquals(16, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<TestEntity>(apexDao.getAll(TestEntity.class, owner0Key));
- assertEquals(5, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<TestEntity>(apexDao.getAll(TestEntity.class, owner1Key));
- assertEquals(3, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<TestEntity>(apexDao.getAll(TestEntity.class, owner2Key));
- assertEquals(2, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<TestEntity>(apexDao.getAll(TestEntity.class, owner3Key));
- assertEquals(1, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<TestEntity>(apexDao.getAll(TestEntity.class, owner4Key));
- assertEquals(1, testEntitySetOut.size());
-
- testEntitySetOut = new TreeSet<TestEntity>(apexDao.getAll(TestEntity.class, owner5Key));
- assertEquals(4, testEntitySetOut.size());
-
- assertNotNull(apexDao.get(TestEntity.class, new AxReferenceKey(owner0Key, "Entity0")));
- assertNotNull(apexDao.getArtifact(TestEntity.class, new AxReferenceKey(owner0Key, "Entity0")));
- assertNull(apexDao.get(TestEntity.class, new AxReferenceKey(owner0Key, "Entity1000")));
- assertNull(apexDao.getArtifact(TestEntity.class, new AxReferenceKey(owner0Key, "Entity1000")));
- apexDao.delete(TestEntity.class, new AxReferenceKey(owner0Key, "Entity0"));
-
- final Set<AxReferenceKey> rKeySetIn = new TreeSet<AxReferenceKey>();
- rKeySetIn.add(new AxReferenceKey(owner4Key, "EntityB"));
- rKeySetIn.add(new AxReferenceKey(owner5Key, "EntityD"));
-
- final int deletedRCount = apexDao.deleteByReferenceKey(TestEntity.class, rKeySetIn);
- assertEquals(2, deletedRCount);
-
- apexDao.update(new TestEntity(new AxReferenceKey(owner5Key, "EntityF"), 120.0));
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/TestDaoMisc.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/TestDaoMisc.java
deleted file mode 100644
index 9109bc24b..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/TestDaoMisc.java
+++ /dev/null
@@ -1,91 +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.apex.model.basicmodel.dao;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import java.util.Properties;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.dao.ApexDaoFactory;
-import org.onap.apex.model.basicmodel.dao.DAOParameters;
-import org.onap.apex.model.basicmodel.dao.converters.CDATAConditioner;
-import org.onap.apex.model.basicmodel.dao.converters.UUID2String;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestDaoMisc {
-
- @Test
- public void testUUID2StringMopUp() {
- UUID2String uuid2String = new UUID2String();
- assertEquals("", uuid2String.convertToDatabaseColumn(null));
- }
-
- @Test
- public void testCDataConditionerMopUp() {
- assertNull(CDATAConditioner.clean(null));
- }
-
- @Test
- public void testDaoFactory() {
- DAOParameters daoParameters = new DAOParameters();
-
- daoParameters.setPluginClass("somewhere.over.the.rainbow");
- try {
- new ApexDaoFactory().createApexDao(daoParameters);
- fail("test shold throw an exception here");
- }
- catch (Exception e) {
- assertEquals("Apex DAO class not found for DAO plugin \"somewhere.over.the.rainbow\"", e.getMessage());
- }
-
- daoParameters.setPluginClass("java.lang.String");
- try {
- new ApexDaoFactory().createApexDao(daoParameters);
- fail("test shold throw an exception here");
- }
- catch (Exception e) {
- assertEquals("Specified Apex DAO plugin class \"java.lang.String\" does not implement the ApexDao interface", e.getMessage());
- }
- }
-
- @Test
- public void testDaoParameters() {
- DAOParameters pars = new DAOParameters();
- pars.setJdbcProperties(new Properties());
- assertEquals(0, pars.getJdbcProperties().size());
-
- pars.setJdbcProperty("name", "Dorothy");
- assertEquals("Dorothy", pars.getJdbcProperty("name"));
-
- pars.setPersistenceUnit("Kansas");
- assertEquals("Kansas", pars.getPersistenceUnit());
-
- pars.setPluginClass("somewhere.over.the.rainbow");
- assertEquals("somewhere.over.the.rainbow", pars.getPluginClass());
-
- assertEquals("DAOParameters [pluginClass=somewhere.over.the.rainbow, persistenceUnit=Kansas, jdbcProperties={name=Dorothy}]", pars.toString());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/AxModelWithReferences.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/AxModelWithReferences.java
deleted file mode 100644
index e08b4482c..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/AxModelWithReferences.java
+++ /dev/null
@@ -1,69 +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.apex.model.basicmodel.handling;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-
-public class AxModelWithReferences extends AxModel {
- private static final long serialVersionUID = -8194956638511120008L;
-
- private List<AxKey> extraKeyList = new ArrayList<>();
-
- public AxModelWithReferences(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;
- }
-
- 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/apex/model/basicmodel/handling/TestApexBasicModel.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModel.java
deleted file mode 100644
index e4d91b7a2..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModel.java
+++ /dev/null
@@ -1,137 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.dao.DAOParameters;
-import org.onap.apex.model.basicmodel.test.TestApexModel;
-
-public class TestApexBasicModel {
- private Connection connection;
- TestApexModel<AxModel> testApexModel;
-
- @Before
- public void setup() throws Exception {
- Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
- connection = DriverManager.getConnection("jdbc:derby:memory:apex_test;create=true");
-
- testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexBasicModelCreator());
- }
-
- @After
- public void teardown() throws Exception {
- connection.close();
- new File("derby.log").delete();
- }
-
- @Test
- public void testModelValid() throws Exception {
- AxValidationResult result = testApexModel.testApexModelValid();
- assertTrue(result.toString().equals(VALID_MODEL_STRING));
- }
-
- @Test
- public void testApexModelVaidateObservation() throws Exception {
- try {
- testApexModel.testApexModelVaidateObservation();
- }
- catch (ApexException e) {
- assertEquals("model should have observations", e.getMessage());
- }
- }
-
- @Test
- public void testApexModelVaidateWarning() throws Exception {
- AxValidationResult result = testApexModel.testApexModelVaidateWarning();
- assertTrue(result.toString().equals(WARNING_MODEL_STRING));
- }
-
- @Test
- public void testModelVaidateInvalidModel() throws Exception {
- AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel();
- assertTrue(result.toString().equals(INVALID_MODEL_STRING));
- }
-
- @Test
- public void testModelVaidateMalstructured() throws Exception {
- AxValidationResult result = testApexModel.testApexModelVaidateMalstructured();
- assertTrue(result.toString().equals(INVALID_MODEL_MALSTRUCTURED_STRING));
- }
-
- @Test
- public void testModelWriteReadXML() throws Exception {
- testApexModel.testApexModelWriteReadXML();
- }
-
- @Test
- public void testModelWriteReadJSON() throws Exception {
- testApexModel.testApexModelWriteReadJSON();
- }
-
- @Test
- public void testModelWriteReadJPA() throws Exception {
- DAOParameters daoParameters = new DAOParameters();
- daoParameters.setPluginClass("org.onap.apex.model.basicmodel.dao.impl.DefaultApexDao");
- daoParameters.setPersistenceUnit("DAOTest");
-
- testApexModel.testApexModelWriteReadJPA(daoParameters);
- }
-
- // 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.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.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.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "AxArtifactKey:(name=Unref0,version=0.0.1):org.onap.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" +
- "AxArtifactKey:(name=Unref1,version=0.0.1):org.onap.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.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.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n" +
- "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.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.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.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.apex.model.basicmodel.concepts.AxModel:INVALID:key information not found for key AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)\n" +
- "********************************";
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java
deleted file mode 100644
index 9d29c08f0..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java
+++ /dev/null
@@ -1,279 +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.apex.model.basicmodel.handling;
-
-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.util.List;
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxKeyUse;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult;
-import org.onap.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult;
-import org.onap.apex.model.basicmodel.service.ModelService;
-import org.onap.apex.model.basicmodel.test.TestApexModel;
-
-public class TestApexBasicModelConcepts {
- TestApexModel<AxModel> testApexModel;
-
- @Before
- public void setup() throws Exception {
- testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexBasicModelCreator());
- }
-
- @Test
- public void testModelConcepts() {
- 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));
-
- AxModel clonedModel = new AxModel(model);
- assertTrue(clonedModel.toString().startsWith("AxModel:(key=AxArtifactKey:(name=BasicModel"));
-
- assertFalse(model.hashCode() == 0);
-
- assertTrue(model.equals(model));
- assertTrue(model.equals(clonedModel));
- assertFalse(model.equals(null));
- assertFalse(model.equals("Hello"));
- clonedModel.getKey().setVersion("0.0.2");
- assertFalse(model.equals(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());
-
- AxKeyInformation keyI = model.getKeyInformation();
- AxKeyInformation clonedKeyI = new AxKeyInformation(keyI);
-
- assertFalse(keyI.equals(null));
- assertFalse(keyI.equals(new AxArtifactKey()));
- assertTrue(keyI.equals(clonedKeyI));
-
- clonedKeyI.setKey(new AxArtifactKey());
- assertFalse(keyI.equals(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());
-
- 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());
-
- 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());
-
- 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() {
- AxModelWithReferences mwr = new TestApexBasicModelCreator().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
- 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
- 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
- AxKeyUse keyBU = new AxKeyUse(new AxArtifactKey("SomeKey", "0.0.1"));
- mwr.addKey(keyBU);
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- mwr.removeKey(keyBU);
-
- // Key Use on bad reference key
- AxKeyUse keyBRU = new AxKeyUse(new AxReferenceKey("SomeKey", "0.0.1", "Local"));
- mwr.addKey(keyBRU);
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.INVALID, result.getValidationResult());
- mwr.removeKey(keyBRU);
-
- result = new AxValidationResult();
- result = mwr.validate(result);
- assertEquals(ValidationResult.VALID, result.getValidationResult());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelCreator.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelCreator.java
deleted file mode 100644
index fca6c4425..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelCreator.java
+++ /dev/null
@@ -1,126 +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.apex.model.basicmodel.handling;
-
-import java.util.UUID;
-
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModelCreator;
-
-public class TestApexBasicModelCreator 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 intKI = new AxKeyInfo(new AxArtifactKey("IntegerKIKey", "0.0.1"), UUID.randomUUID(), "IntegerKIKey description");
- basicModel.getKeyInformation().getKeyInfoMap().put(intKI.getKey(), new AxKeyInfo(intKI.getKey()));
-
- AxKeyInfo floatKI = new AxKeyInfo(new AxArtifactKey("FloatKIKey", "0.0.1"), UUID.randomUUID(), "FloatKIKey description");
- basicModel.getKeyInformation().getKeyInfoMap().put(floatKI.getKey(), new AxKeyInfo(floatKI.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;
- }
-
- public final AxModelWithReferences getModelWithReferences() {
- AxModel model = getModel();
-
- AxModelWithReferences modelWithReferences = new AxModelWithReferences(model.getKey());
- modelWithReferences.setKeyInformation(model.getKeyInformation());
- modelWithReferences.setReferenceKeyList();
-
- return modelWithReferences;
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator0.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator0.java
deleted file mode 100644
index 4b3c00226..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator0.java
+++ /dev/null
@@ -1,63 +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.apex.model.basicmodel.handling;
-
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModelCreator;
-
-public class TestApexTestModelCreator0 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/apex/model/basicmodel/handling/TestApexTestModelCreator1.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator1.java
deleted file mode 100644
index e208bd850..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator1.java
+++ /dev/null
@@ -1,75 +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.apex.model.basicmodel.handling;
-
-import java.util.UUID;
-
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModelCreator;
-
-public class TestApexTestModelCreator1 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/apex/model/basicmodel/handling/TestApexTestModelCreator2.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator2.java
deleted file mode 100644
index 9b9eb13ac..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator2.java
+++ /dev/null
@@ -1,63 +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.apex.model.basicmodel.handling;
-
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModelCreator;
-
-public class TestApexTestModelCreator2 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/apex/model/basicmodel/handling/TestBasicModelTest.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestBasicModelTest.java
deleted file mode 100644
index ea5433f08..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestBasicModelTest.java
+++ /dev/null
@@ -1,156 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.test.TestApexModel;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestBasicModelTest {
-
- @Test
- public void testNormalModelCreator() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexBasicModelCreator());
-
- testApexModel.testApexModelValid();
- try {
- testApexModel.testApexModelVaidateObservation();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertEquals("model should have observations", e.getMessage());
- }
- testApexModel.testApexModelVaidateWarning();
- testApexModel.testApexModelVaidateInvalidModel();
- testApexModel.testApexModelVaidateMalstructured();
-
- testApexModel.testApexModelWriteReadJSON();
- testApexModel.testApexModelWriteReadXML();
- }
-
- @Test
- public void testModelCreator0() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator0());
-
- testApexModel.testApexModelValid();
- try {
- testApexModel.testApexModelVaidateObservation();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertEquals("model should have observations", e.getMessage());
- }
- try {
- testApexModel.testApexModelVaidateWarning();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertEquals("model should have warnings", e.getMessage());
- }
- try {
- testApexModel.testApexModelVaidateInvalidModel();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertEquals("should not be valid ***validation of model successful***", e.getMessage());
- }
- try {
- testApexModel.testApexModelVaidateMalstructured();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertEquals("should not be valid ***validation of model successful***", e.getMessage());
- }
- }
-
- @Test
- public void testModelCreator1() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator1());
-
- try {
- testApexModel.testApexModelValid();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().startsWith("model is invalid"));
- }
- try {
- testApexModel.testApexModelVaidateObservation();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().startsWith("model is invalid"));
- }
- try {
- testApexModel.testApexModelVaidateWarning();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().startsWith("model is invalid"));
- }
- testApexModel.testApexModelVaidateInvalidModel();
- testApexModel.testApexModelVaidateMalstructured();
- }
-
- @Test
- public void testModelCreator2() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator2());
-
- testApexModel.testApexModelValid();
- testApexModel.testApexModelVaidateObservation();
- try {
- testApexModel.testApexModelVaidateWarning();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertEquals("model should have warnings", e.getMessage());
- }
- }
-
- @Test
- public void testModelCreator1XMLJSON() throws ApexException {
- TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator1());
-
- try {
- testApexModel.testApexModelWriteReadJSON();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().startsWith("error processing file"));
- }
-
- try {
- testApexModel.testApexModelWriteReadXML();
- fail("Test should throw an exception");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().startsWith("error processing file"));
- }
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestConceptGetter.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestConceptGetter.java
deleted file mode 100644
index a6ff9dc0b..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestConceptGetter.java
+++ /dev/null
@@ -1,171 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.UUID;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxArtifactKey;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelFileWriter;
-import org.onap.apex.model.basicmodel.handling.ApexModelReader;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestConceptGetter {
-
- @Test
- public void testConceptGetter() throws IOException, ApexException {
- AxModel basicModel = new TestApexBasicModelCreator().getModel();
- assertNotNull(basicModel);
-
- AxKeyInfo intKI01 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey01", "0.0.1"), UUID.randomUUID(), "IntegerKIKey01 description");
- AxKeyInfo intKI11 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey11", "0.0.1"), UUID.randomUUID(), "IntegerKIKey11 description");
- AxKeyInfo intKI21 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey21", "0.0.1"), UUID.randomUUID(), "IntegerKIKey21 description");
- AxKeyInfo intKI22 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey22", "0.0.2"), UUID.randomUUID(), "IntegerKIKey22 description");
- AxKeyInfo intKI23 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey23", "0.0.3"), UUID.randomUUID(), "IntegerKIKey23 description");
- AxKeyInfo intKI24 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey24", "0.0.4"), UUID.randomUUID(), "IntegerKIKey24 description");
- AxKeyInfo intKI25 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey25", "0.0.5"), UUID.randomUUID(), "IntegerKIKey25 description");
- AxKeyInfo intKI26 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey26", "0.0.6"), UUID.randomUUID(), "IntegerKIKey26 description");
- AxKeyInfo intKI31 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey31", "0.0.1"), UUID.randomUUID(), "IntegerKIKey31 description");
- AxKeyInfo intKI41 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey41", "0.0.1"), UUID.randomUUID(), "IntegerKIKey41 description");
- AxKeyInfo intKI51 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey51", "0.0.1"), UUID.randomUUID(), "IntegerKIKey51 description");
- AxKeyInfo intKI52 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey52", "0.0.2"), UUID.randomUUID(), "IntegerKIKey52 description");
- AxKeyInfo intKI53 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey53", "0.0.3"), UUID.randomUUID(), "IntegerKIKey53 description");
- AxKeyInfo intKI54 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey54", "0.0.4"), UUID.randomUUID(), "IntegerKIKey54 description");
- AxKeyInfo intKI61 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey61", "0.0.1"), UUID.randomUUID(), "IntegerKIKey61 description");
- AxKeyInfo intKI62 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey62", "0.0.2"), UUID.randomUUID(), "IntegerKIKey62 description");
- AxKeyInfo intKI63 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey63", "0.0.3"), UUID.randomUUID(), "IntegerKIKey63 description");
- AxKeyInfo intKI64 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey64", "0.0.4"), UUID.randomUUID(), "IntegerKIKey64 description");
- AxKeyInfo intKI71 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey71", "0.0.1"), UUID.randomUUID(), "IntegerKIKey71 description");
- AxKeyInfo intKI81 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey81", "0.0.1"), UUID.randomUUID(), "IntegerKIKey81 description");
- AxKeyInfo intKI91 = new AxKeyInfo(new AxArtifactKey("IntegerKIKey91", "0.0.1"), UUID.randomUUID(), "IntegerKIKey91 description");
- 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);
-
- AxKeyInfo floatKI01 = new AxKeyInfo(new AxArtifactKey("FloatKIKey01", "0.0.1"), UUID.randomUUID(), "IntegerKIKey01 description");
- AxKeyInfo floatKI11 = new AxKeyInfo(new AxArtifactKey("FloatKIKey11", "0.0.1"), UUID.randomUUID(), "IntegerKIKey11 description");
- AxKeyInfo floatKI21 = new AxKeyInfo(new AxArtifactKey("FloatKIKey21", "0.0.1"), UUID.randomUUID(), "IntegerKIKey21 description");
- AxKeyInfo floatKI31 = new AxKeyInfo(new AxArtifactKey("FloatKIKey31", "0.0.1"), UUID.randomUUID(), "IntegerKIKey31 description");
- AxKeyInfo floatKI41 = new AxKeyInfo(new AxArtifactKey("FloatKIKey41", "0.0.1"), UUID.randomUUID(), "IntegerKIKey41 description");
- AxKeyInfo floatKI51 = new AxKeyInfo(new AxArtifactKey("FloatKIKey51", "0.0.1"), UUID.randomUUID(), "IntegerKIKey51 description");
- AxKeyInfo floatKI61 = new AxKeyInfo(new AxArtifactKey("FloatKIKey61", "0.0.1"), UUID.randomUUID(), "IntegerKIKey61 description");
- AxKeyInfo floatKI71 = new AxKeyInfo(new AxArtifactKey("FloatKIKey71", "0.0.1"), UUID.randomUUID(), "IntegerKIKey71 description");
- AxKeyInfo floatKI81 = new AxKeyInfo(new AxArtifactKey("FloatKIKey81", "0.0.1"), UUID.randomUUID(), "IntegerKIKey81 description");
- AxKeyInfo floatKI82 = new AxKeyInfo(new AxArtifactKey("FloatKIKey82", "0.0.2"), UUID.randomUUID(), "IntegerKIKey82 description");
- AxKeyInfo floatKI83 = new AxKeyInfo(new AxArtifactKey("FloatKIKey83", "0.0.3"), UUID.randomUUID(), "IntegerKIKey83 description");
- AxKeyInfo floatKI91 = new AxKeyInfo(new AxArtifactKey("FloatKIKey91", "0.0.1"), UUID.randomUUID(), "IntegerKIKey91 description");
- AxKeyInfo floatKI92 = new AxKeyInfo(new AxArtifactKey("FloatKIKey92", "0.0.2"), UUID.randomUUID(), "IntegerKIKey92 description");
- AxKeyInfo floatKI93 = new AxKeyInfo(new AxArtifactKey("FloatKIKey93", "0.0.3"), UUID.randomUUID(), "IntegerKIKey93 description");
- 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);
-
- assertNull(basicModel.getKeyInformation().get("NonExistantKey", "0.0.6"));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey26", "0.0.6").equals(intKI26));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey62", "0.0.2").equals(intKI62));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey21", "0.0.1").equals(intKI21));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey61", "0.0.1").equals(intKI61));
-
- assertNull(basicModel.getKeyInformation().get("NonExistantKey"));
-
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey01").equals(intKI01));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey11").equals(intKI11));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey26").equals(intKI26));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey31").equals(intKI31));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey41").equals(intKI41));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey54").equals(intKI54));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey64").equals(intKI64));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey71").equals(intKI71));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey81").equals(intKI81));
- assertTrue(basicModel.getKeyInformation().get("IntegerKIKey91").equals(intKI91));
-
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey01").equals(floatKI01));
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey11").equals(floatKI11));
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey21").equals(floatKI21));
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey31").equals(floatKI31));
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey41").equals(floatKI41));
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey51").equals(floatKI51));
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey61").equals(floatKI61));
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey71").equals(floatKI71));
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey83").equals(floatKI83));
- assertTrue(basicModel.getKeyInformation().get("FloatKIKey93").equals(floatKI93));
-
-
- // Ensure marshalling and unmarshalling is OK
- ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class);
- ApexModelFileWriter<AxModel> modelWriter = new ApexModelFileWriter<AxModel>(true);
-
- modelReader.setValidateFlag(false);
- modelWriter.setValidateFlag(false);
-
- File tempXMLFile = File.createTempFile("ApexModel", "xml");
- modelWriter.apexModelWriteJSONFile(basicModel, AxModel.class, tempXMLFile.getCanonicalPath());
-
- FileInputStream xmlFileInputStream = new FileInputStream(tempXMLFile);
- AxModel readXMLModel = modelReader.read(xmlFileInputStream);
- xmlFileInputStream.close();
- assertTrue(basicModel.equals(readXMLModel));
- assertTrue(readXMLModel.getKeyInformation().get("IntegerKIKey91").equals(intKI91));
- assertNotNull(readXMLModel.getKeyInformation().get("FloatKIKey"));
- tempXMLFile.delete();
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestExceptions.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestExceptions.java
deleted file mode 100644
index 0dd271f98..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestExceptions.java
+++ /dev/null
@@ -1,44 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.handling.ApexModelException;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestExceptions {
-
- @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/apex/model/basicmodel/handling/TestModelFileWriter.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelFileWriter.java
deleted file mode 100644
index c2116a1d2..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelFileWriter.java
+++ /dev/null
@@ -1,131 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelFileWriter;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestModelFileWriter {
-
- @Test
- public void testModelFileWriter() throws IOException, ApexException {
- AxModel model = new TestApexBasicModelCreator().getModel();
-
- ApexModelFileWriter<AxModel> modelFileWriter = new ApexModelFileWriter<>(true);
-
- modelFileWriter.setValidateFlag(true);
- assertTrue(modelFileWriter.isValidateFlag());
-
- File tempFile = File.createTempFile("ApexFileWriterTest", "test");
- File tempDir = tempFile.getParentFile();
- tempFile.delete();
-
- File jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/ApexFileWriterTest.json");
- File xmlTempFile = new File(tempDir.getAbsolutePath() + "/ccc/ApexFileWriterTest.xml");
-
- modelFileWriter.apexModelWriteJSONFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
-
- modelFileWriter.apexModelWriteXMLFile(model, AxModel.class, xmlTempFile.getAbsolutePath());
-
- jsonTempFile.delete();
- xmlTempFile.delete();
- new File(tempDir.getAbsolutePath() + "/aaa").delete();
- new File(tempDir.getAbsolutePath() + "/ccc").delete();
-
- jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.json");
- xmlTempFile = new File(tempDir.getAbsolutePath() + "/ccc/ddd/ApexFileWriterTest.xml");
-
- modelFileWriter.apexModelWriteJSONFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- modelFileWriter.apexModelWriteXMLFile(model, AxModel.class, xmlTempFile.getAbsolutePath());
-
- jsonTempFile.delete();
- xmlTempFile.delete();
-
- 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");
- jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.xml");
-
- try {
- modelFileWriter.apexModelWriteJSONFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- fail("this test should throw an exception here");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().contains("could not create directory "));
- }
-
- try {
- modelFileWriter.apexModelWriteXMLFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- fail("this test should throw an exception here");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().contains("could not create directory "));
- }
-
- 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");
- jsonTempFile = new File(tempDir.getAbsolutePath() + "/aaa/bbb/ApexFileWriterTest.xml");
-
- try {
- modelFileWriter.apexModelWriteJSONFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- fail("this test should throw an exception here");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().contains("error processing file "));
- }
-
- try {
- modelFileWriter.apexModelWriteXMLFile(model, AxModel.class, jsonTempFile.getAbsolutePath());
- fail("this test should throw an exception here");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().contains("error processing file "));
- }
-
- fileB.delete();
- dirA.delete();
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelReader.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelReader.java
deleted file mode 100644
index 134f6ff89..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelReader.java
+++ /dev/null
@@ -1,155 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-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.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelReader;
-import org.onap.apex.model.basicmodel.handling.ApexModelWriter;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestModelReader {
-
- @Test
- public void testModelReader() throws IOException, ApexException {
- AxModel model = new TestApexBasicModelCreator().getModel();
- AxModel invalidModel = new TestApexBasicModelCreator().getInvalidModel();
-
- ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
- modelWriter.setValidateFlag(true);
- modelWriter.setJsonOutput(true);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- modelWriter.write(model, baos);
-
- ByteArrayOutputStream baosInvalid = new ByteArrayOutputStream();
- modelWriter.setValidateFlag(false);
- modelWriter.write(invalidModel, baosInvalid);
-
- ApexModelReader<AxModel> modelReader = new ApexModelReader<AxModel>(AxModel.class, true);
-
- modelReader.setValidateFlag(true);
- assertTrue(modelReader.getValidateFlag());
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- AxModel readModel = modelReader.read(bais);
- assertEquals(model, readModel);
-
- ByteArrayInputStream baisInvalid = new ByteArrayInputStream(baosInvalid.toByteArray());
- try {
- modelReader.read(baisInvalid);
- fail("test should throw an exceptino here");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().startsWith("Apex concept validation failed"));
- }
-
- modelReader.setValidateFlag(false);
- assertFalse(modelReader.getValidateFlag());
-
- ByteArrayInputStream bais2 = new ByteArrayInputStream(baos.toByteArray());
- AxModel readModel2 = modelReader.read(bais2);
- assertEquals(model, readModel2);
-
- modelWriter.setJsonOutput(false);
-
- ByteArrayOutputStream baosXML = new ByteArrayOutputStream();
- modelWriter.write(model, baosXML);
-
- ByteArrayInputStream baisXML = new ByteArrayInputStream(baosXML.toByteArray());
- AxModel readModelXML = modelReader.read(baisXML);
- assertEquals(model, readModelXML);
-
- String dummyString = "SomeDummyText";
- ByteArrayInputStream baisDummy = new ByteArrayInputStream(dummyString.getBytes());
- try {
- modelReader.read(baisDummy);
- fail("test should throw an exception here");
- }
- catch (Exception e) {
- assertEquals("format of input for Apex concept is neither JSON nor XML", e.getMessage());
- }
-
- try {
- ByteArrayInputStream nullBais = null;
- modelReader.read(nullBais);
- fail("test should throw an exception here");
- }
- catch (Exception e) {
- assertEquals("concept stream may not be null", e.getMessage());
- }
-
- try {
- FileInputStream fis = new FileInputStream(new File("somewhere/over/the/rainbow"));
- modelReader.read(fis);
- fail("test should throw an exception here");
- }
- catch (Exception e) {
- assertTrue(e.getMessage().contains("rainbow"));
- }
-
- File tempFile = File.createTempFile("Apex", "Dummy");
- try {
- BufferedReader br = new BufferedReader(new FileReader(tempFile));
- br.close();
- modelReader.read(br);
- fail("test should throw an exception here");
- }
- catch (Exception e) {
- assertEquals("Unable to read Apex concept ", e.getMessage());
- }
- finally {
- tempFile.delete();
- }
-
- modelReader.setSchema(null);
-
- tempFile = File.createTempFile("Apex", "Dummy");
- try {
- modelReader.setSchema(tempFile.getCanonicalPath());
- fail("test should throw an exception here");
- }
- catch (Exception e) {
- assertEquals("Unable to load schema", e.getMessage());
- }
- finally {
- tempFile.delete();
- }
-
- modelReader.setSchema("xml/example.xsd");
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelSaver.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelSaver.java
deleted file mode 100644
index 182d341aa..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelSaver.java
+++ /dev/null
@@ -1,53 +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.apex.model.basicmodel.handling;
-
-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.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelSaver;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestModelSaver {
-
- @Test
- public void testModelSaver() throws IOException, ApexException {
- AxModel model = new TestApexBasicModelCreator().getModel();
-
- Path tempPath = Files.createTempDirectory("ApexTest");
-
- ApexModelSaver<AxModel> modelSaver = new ApexModelSaver<AxModel>(AxModel.class, model, tempPath.toAbsolutePath().toString());
-
- modelSaver.apexModelWriteXML();
- modelSaver.apexModelWriteJSON();
-
- Files.deleteIfExists(new File(tempPath.toAbsolutePath() + "/BasicModel.json").toPath());
- Files.deleteIfExists(new File(tempPath.toAbsolutePath() + "/BasicModel.xml").toPath());
- Files.deleteIfExists(tempPath);
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelStringWriter.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelStringWriter.java
deleted file mode 100644
index 2f4fcd2c7..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelStringWriter.java
+++ /dev/null
@@ -1,99 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxKeyInfo;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelStringWriter;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestModelStringWriter {
-
- @Test
- public void testModelStringWriter() throws IOException, ApexException {
- AxModel basicModel = new TestApexBasicModelCreator().getModel();
- assertNotNull(basicModel);
-
- AxKeyInfo intKI = basicModel.getKeyInformation().get("IntegerKIKey");
- AxKeyInfo floatKI = basicModel.getKeyInformation().get("FloatKIKey");
-
- // Ensure marshalling is OK
- ApexModelStringWriter<AxKeyInfo> stringWriter = new ApexModelStringWriter<AxKeyInfo>(true);
-
- assertNotNull(stringWriter.writeJSONString(intKI, AxKeyInfo.class));
- assertNotNull(stringWriter.writeJSONString(floatKI, AxKeyInfo.class));
-
- assertNotNull(stringWriter.writeString(intKI, AxKeyInfo.class, true));
- assertNotNull(stringWriter.writeString(floatKI, AxKeyInfo.class, true));
-
- assertNotNull(stringWriter.writeString(intKI, AxKeyInfo.class, false));
- assertNotNull(stringWriter.writeString(floatKI, AxKeyInfo.class, false));
-
- assertNotNull(stringWriter.writeXMLString(intKI, AxKeyInfo.class));
- assertNotNull(stringWriter.writeXMLString(floatKI, AxKeyInfo.class));
-
- try {
- stringWriter.writeString(null, AxKeyInfo.class, true);
- fail("test should thrown an exception here");
- }
- catch (Exception e) {
- assertEquals("concept may not be null", e.getMessage());
- }
-
- try {
- stringWriter.writeString(null, AxKeyInfo.class, false);
- fail("test should thrown an exception here");
- }
- catch (Exception e) {
- assertEquals("concept may not be null", e.getMessage());
- }
-
- try {
- stringWriter.writeJSONString(null, AxKeyInfo.class);
- fail("test should thrown an exception here");
- }
- catch (Exception e) {
- assertEquals("error writing JSON string", e.getMessage());
- }
-
- try {
- stringWriter.writeXMLString(null, AxKeyInfo.class);
- fail("test should thrown an exception here");
- }
- catch (Exception e) {
- assertEquals("error writing XML string", e.getMessage());
- }
-
- stringWriter.setValidateFlag(true);
- assertTrue(stringWriter.isValidateFlag());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelWriter.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelWriter.java
deleted file mode 100644
index a21c148b6..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelWriter.java
+++ /dev/null
@@ -1,98 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.ApexException;
-import org.onap.apex.model.basicmodel.concepts.AxModel;
-import org.onap.apex.model.basicmodel.handling.ApexModelWriter;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestModelWriter {
-
- @Test
- public void testModelWriter() throws IOException, ApexException {
- AxModel model = new TestApexBasicModelCreator().getModel();
-
- ApexModelWriter<AxModel> modelWriter = new ApexModelWriter<AxModel>(AxModel.class);
-
- modelWriter.setValidateFlag(true);
- assertTrue(modelWriter.getValidateFlag());
- assertEquals(0, modelWriter.getCDataFieldSet().size());
-
- assertFalse(modelWriter.isJsonOutput());
- modelWriter.setJsonOutput(true);
- assertTrue(modelWriter.isJsonOutput());
- modelWriter.setJsonOutput(false);
- assertFalse(modelWriter.isJsonOutput());
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- modelWriter.write(model, baos);
- modelWriter.setJsonOutput(true);
- modelWriter.write(model, baos);
- modelWriter.setJsonOutput(false);
-
- modelWriter.setValidateFlag(false);
- modelWriter.write(model, baos);
- modelWriter.setJsonOutput(true);
- modelWriter.write(model, baos);
- modelWriter.setJsonOutput(false);
-
- modelWriter.setValidateFlag(true);
- model.getKeyInformation().getKeyInfoMap().clear();
- try {
- modelWriter.write(model, baos);
- fail("Test should throw an exception here");
- }
- catch (Exception e) {
- assertEquals("Apex concept xml (BasicModel:0.0.1) validation failed", e.getMessage());
- }
- model.getKeyInformation().generateKeyInfo(model);
-
- try {
- modelWriter.write(null, baos);
- fail("Test should throw an exception here");
- }
- catch (Exception e) {
- assertEquals("concept may not be null", e.getMessage());
- }
-
- try {
- ByteArrayOutputStream nullBaos = null;
- modelWriter.write(model, nullBaos);
- fail("Test should throw an exception here");
- }
- catch (Exception e) {
- assertEquals("concept stream may not be null", e.getMessage());
- }
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestSchemaGenerator.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestSchemaGenerator.java
deleted file mode 100644
index 2e10b51b6..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestSchemaGenerator.java
+++ /dev/null
@@ -1,93 +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.apex.model.basicmodel.handling;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.handling.ApexSchemaGenerator;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestSchemaGenerator {
-
- @Test
- public void test() throws IOException {
- final ByteArrayOutputStream baos0 = new ByteArrayOutputStream();
- System.setOut(new PrintStream(baos0));
-
- final String[] args0 = {};
- ApexSchemaGenerator.main(args0);
- assertTrue(baos0.toString().contains("usage: ApexSchemaGenerator apex-root-class [schema-file-name]"));
- System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
- final ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
- System.setOut(new PrintStream(baos1));
-
- final String[] args1 = {"hello", "goodbye", "here"};
- ApexSchemaGenerator.main(args1);
- assertTrue(baos1.toString().contains("usage: ApexSchemaGenerator apex-root-class [schema-file-name]"));
- System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
- final ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
- System.setOut(new PrintStream(baos2));
-
- final String[] args2 = {"hello", "goodbye"};
- ApexSchemaGenerator.main(args2);
- assertTrue(baos2.toString().contains("error on Apex schema output"));
- System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
- final ByteArrayOutputStream baos3 = new ByteArrayOutputStream();
- System.setOut(new PrintStream(baos3));
-
- final String[] args3 = {"hello"};
- ApexSchemaGenerator.main(args3);
- assertTrue(baos3.toString().contains("could not create JAXB context, root class hello not found"));
- System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
- final ByteArrayOutputStream baos4 = new ByteArrayOutputStream();
- System.setOut(new PrintStream(baos4));
-
- final String[] args4 = {"org.onap.apex.model.basicmodel.concepts.AxModel"};
- ApexSchemaGenerator.main(args4);
- assertTrue(baos4.toString().contains("targetNamespace=\"http://www.ericsson.com/apex\""));
- System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
-
- final ByteArrayOutputStream baos5 = new ByteArrayOutputStream();
- System.setOut(new PrintStream(baos5));
-
- final File tempFile = File.createTempFile("ApexSchemaGeneratorTest", "xsd");
- final String[] args5 = {"org.onap.apex.model.basicmodel.concepts.AxModel", tempFile.getCanonicalPath()};
-
- ApexSchemaGenerator.main(args5);
- assertTrue(tempFile.length() > 100);
- System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
- tempFile.delete();
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/IllegalParameters.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/IllegalParameters.java
deleted file mode 100644
index 3cb4808bf..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/IllegalParameters.java
+++ /dev/null
@@ -1,32 +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.apex.model.basicmodel.service;
-
-import org.onap.apex.model.basicmodel.service.AbstractParameters;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class IllegalParameters extends AbstractParameters {
- public IllegalParameters() {
- super("somewhere.over.the.rainbow");
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/LegalParameters.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/LegalParameters.java
deleted file mode 100644
index 2bab6fd2a..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/LegalParameters.java
+++ /dev/null
@@ -1,32 +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.apex.model.basicmodel.service;
-
-import org.onap.apex.model.basicmodel.service.AbstractParameters;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class LegalParameters extends AbstractParameters {
- public LegalParameters() {
- super(LegalParameters.class.getCanonicalName());
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestAbstractParameters.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestAbstractParameters.java
deleted file mode 100644
index e9a0e2f0a..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestAbstractParameters.java
+++ /dev/null
@@ -1,51 +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.apex.model.basicmodel.service;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestAbstractParameters {
-
- @Test
- public void testAbstractParameters() {
- final LegalParameters parameters = new LegalParameters();
- assertNotNull(parameters);
- assertEquals("AbstractParameters [parameterClassName=org.onap.apex.model.basicmodel.service.LegalParameters]", parameters.toString());
-
- assertEquals(LegalParameters.class, parameters.getParameterClass());
- assertEquals("org.onap.apex.model.basicmodel.service.LegalParameters", parameters.getParameterClassName());
-
- try {
- new IllegalParameters();
- fail("test should throw an exception here");
- }
- catch (final Exception e) {
- assertEquals("class \"somewhere.over.the.rainbow\" not found or not an instance of \"org.onap.apex.model.basicmodel.service.IllegalParameters\"", e.getMessage());
- }
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestModelService.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestModelService.java
deleted file mode 100644
index 51af9baaf..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestModelService.java
+++ /dev/null
@@ -1,78 +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.apex.model.basicmodel.service;
-
-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.apex.model.basicmodel.concepts.AxKeyInformation;
-import org.onap.apex.model.basicmodel.handling.TestApexBasicModelCreator;
-import org.onap.apex.model.basicmodel.service.ModelService;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestModelService {
-
- @Test
- public void testModelService() {
- ModelService.clear();
-
- assertFalse(ModelService.existsModel(AxKeyInformation.class));
- try {
- ModelService.getModel(AxKeyInformation.class);
- }
- catch (Exception e) {
- assertEquals("Model for org.onap.apex.model.basicmodel.concepts.AxKeyInformation not found in model service", e.getMessage());
- }
-
- ModelService.registerModel(AxKeyInformation.class, new TestApexBasicModelCreator().getModel().getKeyInformation());
- assertTrue(ModelService.existsModel(AxKeyInformation.class));
- assertNotNull(ModelService.getModel(AxKeyInformation.class));
-
- ModelService.deregisterModel(AxKeyInformation.class);
-
- assertFalse(ModelService.existsModel(AxKeyInformation.class));
- try {
- ModelService.getModel(AxKeyInformation.class);
- }
- catch (Exception e) {
- assertEquals("Model for org.onap.apex.model.basicmodel.concepts.AxKeyInformation not found in model service", e.getMessage());
- }
-
- ModelService.registerModel(AxKeyInformation.class, new TestApexBasicModelCreator().getModel().getKeyInformation());
- assertTrue(ModelService.existsModel(AxKeyInformation.class));
- assertNotNull(ModelService.getModel(AxKeyInformation.class));
-
- ModelService.clear();
- assertFalse(ModelService.existsModel(AxKeyInformation.class));
- try {
- ModelService.getModel(AxKeyInformation.class);
- }
- catch (Exception e) {
- assertEquals("Model for org.onap.apex.model.basicmodel.concepts.AxKeyInformation not found in model service", e.getMessage());
- }
-
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestParameterService.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestParameterService.java
deleted file mode 100644
index ff2a9c876..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestParameterService.java
+++ /dev/null
@@ -1,77 +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.apex.model.basicmodel.service;
-
-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.apex.model.basicmodel.service.ParameterService;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestParameterService {
-
- @Test
- public void testParameterService() {
- ParameterService.clear();
-
- assertFalse(ParameterService.existsParameters(LegalParameters.class));
- try {
- ParameterService.getParameters(LegalParameters.class);
- }
- catch (final Exception e) {
- assertEquals("Parameters for org.onap.apex.model.basicmodel.service.LegalParameters not found in parameter service", e.getMessage());
- }
-
- ParameterService.registerParameters(LegalParameters.class, new LegalParameters());
- assertTrue(ParameterService.existsParameters(LegalParameters.class));
- assertNotNull(ParameterService.getParameters(LegalParameters.class));
-
- ParameterService.deregisterParameters(LegalParameters.class);
-
- assertFalse(ParameterService.existsParameters(LegalParameters.class));
- try {
- ParameterService.getParameters(LegalParameters.class);
- }
- catch (final Exception e) {
- assertEquals("Parameters for org.onap.apex.model.basicmodel.service.LegalParameters not found in parameter service", e.getMessage());
- }
-
- ParameterService.registerParameters(LegalParameters.class, new LegalParameters());
- assertTrue(ParameterService.existsParameters(LegalParameters.class));
- assertNotNull(ParameterService.getParameters(LegalParameters.class));
-
- assertNotNull(ParameterService.getAll());
- ParameterService.clear();
- assertFalse(ParameterService.existsParameters(LegalParameters.class));
- try {
- ParameterService.getParameters(LegalParameters.class);
- }
- catch (final Exception e) {
- assertEquals("Parameters for org.onap.apex.model.basicmodel.service.LegalParameters not found in parameter service", e.getMessage());
- }
-
- }
-}
diff --git a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java b/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java
deleted file mode 100644
index b723439b5..000000000
--- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java
+++ /dev/null
@@ -1,46 +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.apex.model.basicmodel.xml;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Test;
-import org.onap.apex.model.basicmodel.concepts.AxReferenceKey;
-import org.onap.apex.model.basicmodel.xml.AxReferenceKeyAdapter;
-
-/**
- * @author Liam Fallon (liam.fallon@ericsson.com)
- */
-public class TestAxReferenceKeyAdapter {
-
- @Test
- public void test() throws Exception {
- AxReferenceKeyAdapter arka = new AxReferenceKeyAdapter();
- assertNotNull(arka);
-
- AxReferenceKey rKey = new AxReferenceKey("Name", "0.0.1", "PLN", "LN");
-
- String rKeyString = arka.marshal(rKey);
- assertEquals("LN", rKeyString);
- assertEquals(rKey.getLocalName(),arka.unmarshal(rKeyString).getLocalName());
- }
-}