diff options
author | ramverma <ram.krishna.verma@ericsson.com> | 2018-05-25 11:55:45 +0100 |
---|---|---|
committer | ramverma <ram.krishna.verma@ericsson.com> | 2018-05-25 16:25:25 +0100 |
commit | 6029d25f5f3ad43fe02ffe1a4beb1eda0a6ae5e3 (patch) | |
tree | 489296a005ced47a3a4acffc6ce64b65f5367d77 /model/basic-model/src/test/java | |
parent | 5abd3063949496c231ed8d3013c2ab17fc9288bb (diff) |
Adding apex event-model module
- Adding apex event-model module
- Fixing namespaces
Change-Id: If37a1773000ca99eb5d97703fdeb5788ce55365c
Issue-ID: POLICY-856
Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'model/basic-model/src/test/java')
-rw-r--r-- | model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModel.java | 137 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/AxKeyTest.java) | 12 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxKeyInfo.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxKeyInfo.java) | 8 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxReferenceKey.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxReferenceKey.java) | 10 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestEntity.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestEntity.java) | 12 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestExceptions.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestExceptions.java) | 10 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestValidation.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestValidation.java) | 12 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/testKeyUse.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/testKeyUse.java) | 12 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/EntityTest.java) | 58 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/TestDaoMisc.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/TestDaoMisc.java) | 50 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/AxModelWithReferences.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/AxModelWithReferences.java) | 10 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModel.java | 133 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java) | 60 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelCreator.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelCreator.java) | 12 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator0.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator0.java) | 12 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator1.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator1.java) | 12 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator2.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator2.java) | 12 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestBasicModelTest.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestBasicModelTest.java) | 68 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestConceptGetter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestConceptGetter.java) | 14 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestExceptions.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestExceptions.java) | 4 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelFileWriter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelFileWriter.java) | 8 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelReader.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelReader.java) | 10 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelSaver.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelSaver.java) | 8 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelStringWriter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelStringWriter.java) | 10 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelWriter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelWriter.java) | 8 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestSchemaGenerator.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestSchemaGenerator.java) | 48 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/IllegalParameters.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/IllegalParameters.java) | 4 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/LegalParameters.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/LegalParameters.java) | 4 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestAbstractParameters.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestAbstractParameters.java) | 26 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestModelService.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestModelService.java) | 50 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestParameterService.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestParameterService.java) | 42 | ||||
-rw-r--r-- | model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java (renamed from model/basic-model/src/test/java/org/onap/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java) | 6 |
32 files changed, 439 insertions, 443 deletions
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/concepts/AxKeyTest.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java index a454aaf92..6ac46b14e 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/AxKeyTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/AxKeyTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.concepts; +package org.onap.policy.apex.model.basicmodel.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -27,11 +27,11 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; +import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/concepts/TestAxKeyInfo.java index 6af662bdf..8368634bf 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxKeyInfo.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxKeyInfo.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.concepts; +package org.onap.policy.apex.model.basicmodel.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -29,9 +29,9 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/concepts/TestAxReferenceKey.java index 7ec3cbbbf..dbc925d66 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestAxReferenceKey.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestAxReferenceKey.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.concepts; +package org.onap.policy.apex.model.basicmodel.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -27,10 +27,10 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/concepts/TestEntity.java index 3e821f7c5..6ba380bb8 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestEntity.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestEntity.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.concepts; +package org.onap.policy.apex.model.basicmodel.concepts; import java.util.Arrays; import java.util.List; @@ -29,11 +29,11 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; +import org.onap.policy.apex.model.basicmodel.concepts.AxKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; +import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter; @Entity @Table(name = "TestEntity") 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/policy/apex/model/basicmodel/concepts/TestExceptions.java index 1d37cd8ed..1fc5209b0 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestExceptions.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestExceptions.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.concepts; +package org.onap.policy.apex.model.basicmodel.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -26,10 +26,10 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.ApexConceptException; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/concepts/TestValidation.java index e8eff5230..93eb78b7c 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/TestValidation.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/TestValidation.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.concepts; +package org.onap.policy.apex.model.basicmodel.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -26,11 +26,11 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationMessage; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/concepts/testKeyUse.java index ca1e5c191..10706f36a 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/concepts/testKeyUse.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/concepts/testKeyUse.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.concepts; +package org.onap.policy.apex.model.basicmodel.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -27,11 +27,11 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyUse; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; +import org.onap.policy.apex.model.basicmodel.concepts.AxKey.Compatibility; public class testKeyUse { 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/policy/apex/model/basicmodel/dao/EntityTest.java index 87779848e..e5d597375 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/EntityTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/EntityTest.java @@ -1,24 +1,24 @@ -/* +/*- * ============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; +package org.onap.policy.apex.model.basicmodel.dao; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -38,14 +38,11 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.concepts.TestEntity; /** * JUnit test class @@ -75,16 +72,14 @@ public class EntityTest { try { apexDao.init(null); fail("Test should throw an exception here"); - } - catch (final Exception e) { + } 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) { + } catch (final Exception e) { assertEquals("Apex persistence unit parameter not set", e.getMessage()); } @@ -93,15 +88,13 @@ public class EntityTest { try { apexDao.init(daoParameters); fail("Test should throw an exception here"); - } - catch (final Exception e) { + } 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) { + } catch (final Exception e) { assertEquals("Apex DAO has not been initialized", e.getMessage()); } apexDao.close(); @@ -110,7 +103,7 @@ public class EntityTest { @Test public void testEntityTestAllOpsJPA() throws ApexException { final DAOParameters daoParameters = new DAOParameters(); - daoParameters.setPluginClass("org.onap.apex.model.basicmodel.dao.impl.DefaultApexDao"); + daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); daoParameters.setPersistenceUnit("DAOTest"); apexDao = new ApexDaoFactory().createApexDao(daoParameters); @@ -123,7 +116,7 @@ public class EntityTest { @Test public void testEntityTestBadVals() throws ApexException { final DAOParameters daoParameters = new DAOParameters(); - daoParameters.setPluginClass("org.onap.apex.model.basicmodel.dao.impl.DefaultApexDao"); + daoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); daoParameters.setPersistenceUnit("DAOTest"); apexDao = new ApexDaoFactory().createApexDao(daoParameters); @@ -163,13 +156,16 @@ public class EntityTest { 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"); + 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); @@ -182,7 +178,7 @@ public class EntityTest { 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")); + final AxKeyInfo keyInfoBack2 = apexDao.getArtifact(AxKeyInfo.class, new AxArtifactKey("A-KEY3", "0.0.1")); assertNull(keyInfoBack2); final Set<AxKeyInfo> keyInfoSetIn = new TreeSet<AxKeyInfo>(); 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/policy/apex/model/basicmodel/dao/TestDaoMisc.java index 9109bc24b..9f5b72d39 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/dao/TestDaoMisc.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/dao/TestDaoMisc.java @@ -1,24 +1,24 @@ -/* +/*- * ============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; +package org.onap.policy.apex.model.basicmodel.dao; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -27,10 +27,8 @@ 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; +import org.onap.policy.apex.model.basicmodel.dao.converters.CDATAConditioner; +import org.onap.policy.apex.model.basicmodel.dao.converters.UUID2String; /** * @author Liam Fallon (liam.fallon@ericsson.com) @@ -39,7 +37,7 @@ public class TestDaoMisc { @Test public void testUUID2StringMopUp() { - UUID2String uuid2String = new UUID2String(); + final UUID2String uuid2String = new UUID2String(); assertEquals("", uuid2String.convertToDatabaseColumn(null)); } @@ -47,45 +45,47 @@ public class TestDaoMisc { public void testCDataConditionerMopUp() { assertNull(CDATAConditioner.clean(null)); } - + @Test public void testDaoFactory() { - DAOParameters daoParameters = new DAOParameters(); + final 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) { + } catch (final 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()); + } catch (final 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(); + final 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()); + + 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/policy/apex/model/basicmodel/handling/AxModelWithReferences.java index e08b4482c..38359052b 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/AxModelWithReferences.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/AxModelWithReferences.java @@ -18,15 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; public class AxModelWithReferences extends AxModel { private static final long serialVersionUID = -8194956638511120008L; diff --git a/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModel.java b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModel.java new file mode 100644 index 000000000..d0423eb3a --- /dev/null +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModel.java @@ -0,0 +1,133 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.model.basicmodel.handling; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +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.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; +import org.onap.policy.apex.model.basicmodel.dao.DAOParameters; +import org.onap.policy.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 { + final AxValidationResult result = testApexModel.testApexModelValid(); + assertTrue(result.toString().equals(VALID_MODEL_STRING)); + } + + @Test + public void testApexModelVaidateObservation() throws Exception { + try { + testApexModel.testApexModelVaidateObservation(); + } catch (final ApexException e) { + assertEquals("model should have observations", e.getMessage()); + } + } + + @Test + public void testApexModelVaidateWarning() throws Exception { + final AxValidationResult result = testApexModel.testApexModelVaidateWarning(); + assertTrue(result.toString().equals(WARNING_MODEL_STRING)); + } + + @Test + public void testModelVaidateInvalidModel() throws Exception { + final AxValidationResult result = testApexModel.testApexModelVaidateInvalidModel(); + assertTrue(result.toString().equals(INVALID_MODEL_STRING)); + } + + @Test + public void testModelVaidateMalstructured() throws Exception { + final 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 { + final DAOParameters daoParameters = new DAOParameters(); + daoParameters.setPluginClass("org.onap.policy.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.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" + + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" + + "********************************"; + + private static final String WARNING_MODEL_STRING = "\n" + "***warnings issued during validation of model***\n" + + "AxArtifactKey:(name=FloatKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" + + "AxArtifactKey:(name=IntegerKIKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" + + "AxArtifactKey:(name=Unref0,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" + + "AxArtifactKey:(name=Unref1,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:WARNING:key not found for key information entry\n" + + "********************************"; + + private static final String INVALID_MODEL_STRING = "\n" + "***validation of model failed***\n" + + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n" + + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:OBSERVATION:description is blank\n" + + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n" + + "AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation:INVALID:duplicate UUID found on keyInfoMap entry AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1):00000000-0000-0000-0000-000000000000\n" + + "********************************"; + + private static final String INVALID_MODEL_MALSTRUCTURED_STRING = "\n" + "***validation of model failed***\n" + + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo:WARNING:UUID is a zero UUID: 00000000-0000-0000-0000-000000000000\n" + + "AxArtifactKey:(name=BasicModelKey,version=0.0.1):org.onap.policy.apex.model.basicmodel.concepts.AxModel:INVALID:key information not found for key AxArtifactKey:(name=KeyInfoMapKey,version=0.0.1)\n" + + "********************************"; +} 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/policy/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java index 9d29c08f0..1ab7a2666 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelConcepts.java @@ -1,24 +1,24 @@ -/* +/*- * ============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; +package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -31,17 +31,17 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyUse; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; +import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult.ValidationResult; +import org.onap.policy.apex.model.basicmodel.service.ModelService; +import org.onap.policy.apex.model.basicmodel.test.TestApexModel; public class TestApexBasicModelConcepts { TestApexModel<AxModel> testApexModel; @@ -53,7 +53,7 @@ public class TestApexBasicModelConcepts { @Test public void testModelConcepts() { - AxModel model = testApexModel.getModel(); + final AxModel model = testApexModel.getModel(); assertNotNull(model); model.clean(); assertNotNull(model); @@ -65,7 +65,7 @@ public class TestApexBasicModelConcepts { model.register(); assertEquals(model.getKeyInformation(), ModelService.getModel(AxKeyInformation.class)); - AxModel clonedModel = new AxModel(model); + final AxModel clonedModel = new AxModel(model); assertTrue(clonedModel.toString().startsWith("AxModel:(key=AxArtifactKey:(name=BasicModel")); assertFalse(model.hashCode() == 0); @@ -91,8 +91,8 @@ public class TestApexBasicModelConcepts { model.getKeyInformation().generateKeyInfo(model); assertNotNull(model.getKeyInformation()); - AxKeyInformation keyI = model.getKeyInformation(); - AxKeyInformation clonedKeyI = new AxKeyInformation(keyI); + final AxKeyInformation keyI = model.getKeyInformation(); + final AxKeyInformation clonedKeyI = new AxKeyInformation(keyI); assertFalse(keyI.equals(null)); assertFalse(keyI.equals(new AxArtifactKey())); @@ -177,7 +177,7 @@ public class TestApexBasicModelConcepts { result = clonedKeyI.validate(result); assertEquals(ValidationResult.VALID, result.getValidationResult()); - AxKeyInfo mk = clonedKeyI.get(new AxArtifactKey("BasicModel", "0.0.1")); + final AxKeyInfo mk = clonedKeyI.get(new AxArtifactKey("BasicModel", "0.0.1")); assertNotNull(mk); mk.setKey(AxArtifactKey.getNullKey()); result = new AxValidationResult(); @@ -189,7 +189,7 @@ public class TestApexBasicModelConcepts { result = new AxValidationResult(); result = clonedKeyI.validate(result); assertEquals(ValidationResult.VALID, result.getValidationResult()); - + clonedModel.setKey(AxArtifactKey.getNullKey()); result = new AxValidationResult(); result = clonedModel.validate(result); @@ -200,14 +200,14 @@ public class TestApexBasicModelConcepts { result = clonedKeyI.validate(result); assertEquals(ValidationResult.VALID, result.getValidationResult()); } - + @Test public void testModelConceptsWithReferences() { - AxModelWithReferences mwr = new TestApexBasicModelCreator().getModelWithReferences(); + final 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()); @@ -235,7 +235,7 @@ public class TestApexBasicModelConcepts { assertEquals(ValidationResult.VALID, result.getValidationResult()); // Duplicate Reference Key - AxReferenceKey rKey = new AxReferenceKey(mwr.getKey(), "LocalName"); + final AxReferenceKey rKey = new AxReferenceKey(mwr.getKey(), "LocalName"); mwr.addKey(rKey); mwr.addKey(rKey); result = new AxValidationResult(); @@ -247,9 +247,9 @@ public class TestApexBasicModelConcepts { result = new AxValidationResult(); result = mwr.validate(result); assertEquals(ValidationResult.VALID, result.getValidationResult()); - + // Key Use is legal - AxKeyUse keyU = new AxKeyUse(mwr.getKey()); + final AxKeyUse keyU = new AxKeyUse(mwr.getKey()); mwr.addKey(keyU); result = new AxValidationResult(); result = mwr.validate(result); @@ -257,7 +257,7 @@ public class TestApexBasicModelConcepts { mwr.removeKey(keyU); // Key Use on bad artifact key - AxKeyUse keyBU = new AxKeyUse(new AxArtifactKey("SomeKey", "0.0.1")); + final AxKeyUse keyBU = new AxKeyUse(new AxArtifactKey("SomeKey", "0.0.1")); mwr.addKey(keyBU); result = new AxValidationResult(); result = mwr.validate(result); @@ -265,7 +265,7 @@ public class TestApexBasicModelConcepts { mwr.removeKey(keyBU); // Key Use on bad reference key - AxKeyUse keyBRU = new AxKeyUse(new AxReferenceKey("SomeKey", "0.0.1", "Local")); + final AxKeyUse keyBRU = new AxKeyUse(new AxReferenceKey("SomeKey", "0.0.1", "Local")); mwr.addKey(keyBRU); result = new AxValidationResult(); result = mwr.validate(result); 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/policy/apex/model/basicmodel/handling/TestApexBasicModelCreator.java index fca6c4425..762c7555f 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexBasicModelCreator.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexBasicModelCreator.java @@ -18,15 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator; public class TestApexBasicModelCreator implements TestApexModelCreator<AxModel> { 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/policy/apex/model/basicmodel/handling/TestApexTestModelCreator0.java index 4b3c00226..ff958373e 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator0.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator0.java @@ -18,13 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator; public class TestApexTestModelCreator0 implements TestApexModelCreator<AxModel> { 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/policy/apex/model/basicmodel/handling/TestApexTestModelCreator1.java index e208bd850..d2aa738a0 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator1.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator1.java @@ -18,15 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator; public class TestApexTestModelCreator1 implements TestApexModelCreator<AxModel> { 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/policy/apex/model/basicmodel/handling/TestApexTestModelCreator2.java index 9b9eb13ac..85751bf12 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestApexTestModelCreator2.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestApexTestModelCreator2.java @@ -18,13 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.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; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator; public class TestApexTestModelCreator2 implements TestApexModelCreator<AxModel> { 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/policy/apex/model/basicmodel/handling/TestBasicModelTest.java index ea5433f08..9ddd3cc7e 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestBasicModelTest.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestBasicModelTest.java @@ -1,33 +1,33 @@ -/* +/*- * ============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; +package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import 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; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.test.TestApexModel; /** * @author Liam Fallon (liam.fallon@ericsson.com) @@ -36,14 +36,14 @@ public class TestBasicModelTest { @Test public void testNormalModelCreator() throws ApexException { - TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexBasicModelCreator()); + final TestApexModel<AxModel> testApexModel = + new TestApexModel<AxModel>(AxModel.class, new TestApexBasicModelCreator()); testApexModel.testApexModelValid(); try { testApexModel.testApexModelVaidateObservation(); fail("Test should throw an exception"); - } - catch (Exception e) { + } catch (final Exception e) { assertEquals("model should have observations", e.getMessage()); } testApexModel.testApexModelVaidateWarning(); @@ -56,100 +56,94 @@ public class TestBasicModelTest { @Test public void testModelCreator0() throws ApexException { - TestApexModel<AxModel> testApexModel = new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator0()); + final TestApexModel<AxModel> testApexModel = + new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator0()); testApexModel.testApexModelValid(); try { testApexModel.testApexModelVaidateObservation(); fail("Test should throw an exception"); - } - catch (Exception e) { + } catch (final Exception e) { assertEquals("model should have observations", e.getMessage()); } try { testApexModel.testApexModelVaidateWarning(); fail("Test should throw an exception"); - } - catch (Exception e) { + } catch (final Exception e) { assertEquals("model should have warnings", e.getMessage()); } try { testApexModel.testApexModelVaidateInvalidModel(); fail("Test should throw an exception"); - } - catch (Exception e) { + } catch (final 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) { + } catch (final 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()); + final TestApexModel<AxModel> testApexModel = + new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator1()); try { testApexModel.testApexModelValid(); fail("Test should throw an exception"); - } - catch (Exception e) { + } catch (final Exception e) { assertTrue(e.getMessage().startsWith("model is invalid")); } try { testApexModel.testApexModelVaidateObservation(); fail("Test should throw an exception"); - } - catch (Exception e) { + } catch (final Exception e) { assertTrue(e.getMessage().startsWith("model is invalid")); } try { testApexModel.testApexModelVaidateWarning(); fail("Test should throw an exception"); - } - catch (Exception e) { + } catch (final 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()); + final 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) { + } catch (final 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()); + final TestApexModel<AxModel> testApexModel = + new TestApexModel<AxModel>(AxModel.class, new TestApexTestModelCreator1()); try { testApexModel.testApexModelWriteReadJSON(); fail("Test should throw an exception"); - } - catch (Exception e) { + } catch (final Exception e) { assertTrue(e.getMessage().startsWith("error processing file")); } try { testApexModel.testApexModelWriteReadXML(); fail("Test should throw an exception"); - } - catch (Exception e) { + } catch (final 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/policy/apex/model/basicmodel/handling/TestConceptGetter.java index a6ff9dc0b..83545bf06 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestConceptGetter.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestConceptGetter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -30,12 +30,12 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelFileWriter; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/handling/TestExceptions.java index 0dd271f98..5c8922793 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestExceptions.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestExceptions.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -26,7 +26,7 @@ import static org.junit.Assert.assertNotNull; import java.io.IOException; import org.junit.Test; -import org.onap.apex.model.basicmodel.handling.ApexModelException; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelException; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/handling/TestModelFileWriter.java index c2116a1d2..ec4d0a5a9 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelFileWriter.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelFileWriter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -27,9 +27,9 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelFileWriter; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/handling/TestModelReader.java index 134f6ff89..140817e00 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelReader.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelReader.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -34,10 +34,10 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/handling/TestModelSaver.java index 182d341aa..08f123cba 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelSaver.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelSaver.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.apex.model.basicmodel.handling; import java.io.File; import java.io.IOException; @@ -26,9 +26,9 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelSaver; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/handling/TestModelStringWriter.java index 2f4fcd2c7..d2a504676 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelStringWriter.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelStringWriter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -28,10 +28,10 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInfo; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelStringWriter; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/handling/TestModelWriter.java index a21c148b6..8e5af45b3 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestModelWriter.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestModelWriter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.handling; +package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -29,9 +29,9 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.model.basicmodel.concepts.AxModel; +import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/handling/TestSchemaGenerator.java index 2e10b51b6..cdf3b4615 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/handling/TestSchemaGenerator.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/handling/TestSchemaGenerator.java @@ -1,24 +1,24 @@ -/* +/*- * ============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; +package org.onap.policy.apex.model.basicmodel.handling; import static org.junit.Assert.assertTrue; @@ -30,7 +30,6 @@ 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) @@ -41,50 +40,51 @@ public class TestSchemaGenerator { 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"}; + + 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"}; + + 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"}; + + 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"}; + + final String[] args4 = { "org.onap.policy.apex.model.basicmodel.concepts.AxModel" }; ApexSchemaGenerator.main(args4); - assertTrue(baos4.toString().contains("targetNamespace=\"http://www.ericsson.com/apex\"")); + assertTrue(baos4.toString().contains("targetNamespace=\"http://www.onap.org/policy/apex-pdp\"")); 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()}; - + final String[] args5 = + { "org.onap.policy.apex.model.basicmodel.concepts.AxModel", tempFile.getCanonicalPath() }; + ApexSchemaGenerator.main(args5); assertTrue(tempFile.length() > 100); System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); 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/policy/apex/model/basicmodel/service/IllegalParameters.java index 3cb4808bf..3a7fdf530 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/IllegalParameters.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/IllegalParameters.java @@ -18,9 +18,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.service; +package org.onap.policy.apex.model.basicmodel.service; -import org.onap.apex.model.basicmodel.service.AbstractParameters; +import org.onap.policy.apex.model.basicmodel.service.AbstractParameters; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/service/LegalParameters.java index 2bab6fd2a..3de3ecb58 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/LegalParameters.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/LegalParameters.java @@ -18,9 +18,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.service; +package org.onap.policy.apex.model.basicmodel.service; -import org.onap.apex.model.basicmodel.service.AbstractParameters; +import org.onap.policy.apex.model.basicmodel.service.AbstractParameters; /** * @author Liam Fallon (liam.fallon@ericsson.com) 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/policy/apex/model/basicmodel/service/TestAbstractParameters.java index e9a0e2f0a..7afa14440 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestAbstractParameters.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestAbstractParameters.java @@ -1,24 +1,24 @@ -/* +/*- * ============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; +package org.onap.policy.apex.model.basicmodel.service; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -35,17 +35,21 @@ public class TestAbstractParameters { public void testAbstractParameters() { final LegalParameters parameters = new LegalParameters(); assertNotNull(parameters); - assertEquals("AbstractParameters [parameterClassName=org.onap.apex.model.basicmodel.service.LegalParameters]", parameters.toString()); + assertEquals( + "AbstractParameters [parameterClassName=org.onap.policy.apex.model.basicmodel.service.LegalParameters]", + parameters.toString()); assertEquals(LegalParameters.class, parameters.getParameterClass()); - assertEquals("org.onap.apex.model.basicmodel.service.LegalParameters", parameters.getParameterClassName()); - + assertEquals("org.onap.policy.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()); + } catch (final Exception e) { + assertEquals( + "class \"somewhere.over.the.rainbow\" not found or not an instance of \"org.onap.policy.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/policy/apex/model/basicmodel/service/TestModelService.java index 51af9baaf..9c20d837f 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestModelService.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestModelService.java @@ -1,24 +1,24 @@ -/* +/*- * ============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; +package org.onap.policy.apex.model.basicmodel.service; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -26,9 +26,8 @@ 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; +import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation; +import org.onap.policy.apex.model.basicmodel.handling.TestApexBasicModelCreator; /** * @author Liam Fallon (liam.fallon@ericsson.com) @@ -42,36 +41,41 @@ public class TestModelService { assertFalse(ModelService.existsModel(AxKeyInformation.class)); try { ModelService.getModel(AxKeyInformation.class); + } catch (final Exception e) { + assertEquals( + "Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation not found in model service", + e.getMessage()); } - 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()); + + 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()); + } catch (final Exception e) { + assertEquals( + "Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation not found in model service", + e.getMessage()); } - ModelService.registerModel(AxKeyInformation.class, new TestApexBasicModelCreator().getModel().getKeyInformation()); + 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()); + } catch (final Exception e) { + assertEquals( + "Model for org.onap.policy.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/policy/apex/model/basicmodel/service/TestParameterService.java index ff2a9c876..e84b3e252 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/service/TestParameterService.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/service/TestParameterService.java @@ -1,24 +1,24 @@ -/* +/*- * ============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; +package org.onap.policy.apex.model.basicmodel.service; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -26,7 +26,6 @@ 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) @@ -40,38 +39,41 @@ public class TestParameterService { assertFalse(ParameterService.existsParameters(LegalParameters.class)); try { ParameterService.getParameters(LegalParameters.class); + } catch (final Exception e) { + assertEquals( + "Parameters for org.onap.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service", + e.getMessage()); } - 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()); + } catch (final Exception e) { + assertEquals( + "Parameters for org.onap.policy.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.policy.apex.model.basicmodel.service.LegalParameters not found in parameter service", + e.getMessage()); } - 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/policy/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java index b723439b5..bde0956b8 100644 --- a/model/basic-model/src/test/java/org/onap/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java +++ b/model/basic-model/src/test/java/org/onap/policy/apex/model/basicmodel/xml/TestAxReferenceKeyAdapter.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.apex.model.basicmodel.xml; +package org.onap.policy.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; +import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; +import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter; /** * @author Liam Fallon (liam.fallon@ericsson.com) |