summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorBlimkie, Steven (sb787e) <steven.blimkie@amdocs.com>2017-06-27 21:08:37 +0300
committerBlimkie, Steven (sb787e) <steven.blimkie@amdocs.com>2017-06-27 21:10:57 +0300
commitfe17f093d5c61207949eebef95b83baf5139be50 (patch)
tree776be9df8cd4cf8e5a69bde1f0ed741e78ab08fb /src/test/java
parentfaa407b9cd0430c1e6b8b668392fe5e33f792432 (diff)
Allow handling of legact model artifacts
Change-Id: I3d4c5e51140d4d05b3fd871d58c2590421c0e9db Signed-off-by: Blimkie, Steven (sb787e) <steven.blimkie@amdocs.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/openecomp/modelloader/entity/model/ModelArtifactParserTest.java330
-rw-r--r--src/test/java/org/openecomp/modelloader/entity/model/ModelParserFactoryTest.java58
-rw-r--r--src/test/java/org/openecomp/modelloader/entity/model/ModelSorterTest.java93
-rw-r--r--src/test/java/org/openecomp/modelloader/entity/model/ModelV8ArtifactParserTest.java104
-rw-r--r--src/test/java/org/openecomp/modelloader/entity/model/NamedQueryArtifactParserTest.java64
-rw-r--r--src/test/java/org/openecomp/modelloader/restclient/AaiRestClientTest.java2
6 files changed, 434 insertions, 217 deletions
diff --git a/src/test/java/org/openecomp/modelloader/entity/model/ModelArtifactParserTest.java b/src/test/java/org/openecomp/modelloader/entity/model/ModelArtifactParserTest.java
index 994c4db..ac32f58 100644
--- a/src/test/java/org/openecomp/modelloader/entity/model/ModelArtifactParserTest.java
+++ b/src/test/java/org/openecomp/modelloader/entity/model/ModelArtifactParserTest.java
@@ -1,205 +1,125 @@
-/**
- * ============LICENSE_START=======================================================
- * Model Loader
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property.
- * Copyright © 2017 Amdocs
- * 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.
- * ============LICENSE_END=========================================================
- *
- * ECOMP and OpenECOMP are trademarks
- * and service marks of AT&T Intellectual Property.
- */
-package org.openecomp.modelloader.entity.model;
-
-import static org.junit.Assert.assertTrue;
-
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.List;
-
-import org.junit.Test;
-import org.openecomp.modelloader.entity.Artifact;
-
-public class ModelArtifactParserTest {
-
- @Test
- public void testParseModelFileNoDeps() throws Exception {
- final String MODEL_FILE = "src/test/resources/models/l3-network-widget.xml";
-
- try {
- byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
-
- ModelArtifactParser parser = new ModelArtifactParser();
- List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
-
- assertTrue(modelList.size() == 1);
-
- ModelArtifact model = (ModelArtifact) modelList.get(0);
- System.out.println(model.toString());
-
- assertTrue(model.getModelInvariantId().equalsIgnoreCase("3d560d81-57d0-438b-a2a1-5334dba0651a"));
- assertTrue(model.getType().toString().equalsIgnoreCase("MODEL"));
- System.out.println(model.getDependentModelIds().size());
- assertTrue(model.getDependentModelIds().size() == 0);
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
- @Test
- public void testParseModelFileDeps() throws Exception {
- final String MODEL_FILE = "src/test/resources/models/AAI-stellService-service-1.xml";
-
- try {
- byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
-
- ModelArtifactParser parser = new ModelArtifactParser();
- List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
-
- assertTrue(modelList.size() == 1);
-
- ModelArtifact model = (ModelArtifact) modelList.get(0);
- System.out.println(model.toString());
-
- assertTrue(model.getModelInvariantId().equalsIgnoreCase("fedf9da3-6a74-4813-8fa2-221a98b0e7ad"));
- assertTrue(model.getModelVerId().equalsIgnoreCase("e0373537-7f66-4094-9939-e2f5de6ff5f6"));
- assertTrue(model.getType().toString().equalsIgnoreCase("MODEL"));
- assertTrue(model.getDependentModelIds().size() == 3);
- assertTrue(model.getDependentModelIds().contains("5c12984d-db0f-4300-a0e0-9791775cc40f|88bdbadf-db8a-490f-881e-c8effcbc3f66"));
- assertTrue(model.getDependentModelIds().contains("959b7c09-9f34-4e5f-8b63-505381db176e|374d0899-bbc2-4403-9320-fe9bebef75c6"));
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
- @Test
- public void testParseCompleteModel() throws Exception {
- final String MODEL_FILE = "src/test/resources/models/complete-model.xml";
-
- try {
- byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
-
- ModelArtifactParser parser = new ModelArtifactParser();
- List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
-
- for (Artifact art : modelList) {
- ModelArtifact model = (ModelArtifact) art;
- System.out.println(model.toString());
- }
-
- assertTrue(modelList.size() == 5);
-
- ModelArtifact model1 = (ModelArtifact)modelList.get(0);
- assertTrue(model1.getModelVerId().equalsIgnoreCase("88bdbadf-db8a-490f-881e-c8effcbc3f66"));
- assertTrue(model1.getType().toString().equalsIgnoreCase("MODEL"));
- assertTrue(model1.getDependentModelIds().size() == 1);
- assertTrue(model1.getDependentModelIds().contains("3d560d81-57d0-438b-a2a1-5334dba0651a|9111f20f-e680-4001-b83f-19a2fc23bfc1"));
-
- ModelArtifact model4 = (ModelArtifact)modelList.get(4);
- assertTrue(model4.getModelInvariantId().equalsIgnoreCase("fedf9da3-6a74-4813-8fa2-221a98b0e7ad"));
- assertTrue(model4.getType().toString().equalsIgnoreCase("MODEL"));
- assertTrue(model4.getDependentModelIds().size() == 3);
- assertTrue(model4.getDependentModelIds().contains("5c12984d-db0f-4300-a0e0-9791775cc40f|88bdbadf-db8a-490f-881e-c8effcbc3f66"));
- assertTrue(model4.getDependentModelIds().contains("82194af1-3c2c-485a-8f44-420e22a9eaa4|46b92144-923a-4d20-b85a-3cbd847668a9"));
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
- @Test
- public void testParseNamedQuery() throws Exception {
- final String MODEL_FILE = "src/test/resources/models/named-query-wan-connector.xml";
-
- try {
- byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
-
- ModelArtifactParser parser = new ModelArtifactParser();
- List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
-
- assertTrue(modelList.size() == 1);
-
- ModelArtifact model = (ModelArtifact) modelList.get(0);
- System.out.println(model.toString());
-
- assertTrue(model.getNameVersionId().equalsIgnoreCase("94cac189-8d88-4d63-a194-f44214e080ff"));
- assertTrue(model.getType().toString().equalsIgnoreCase("NAMED_QUERY"));
- assertTrue(model.getDependentModelIds().size() == 4);
- assertTrue(model.getDependentModelIds().contains("d09dd9da-0148-46cd-a947-591afc844d24"));
- assertTrue(model.getDependentModelIds().contains("997fc7-fca1-451f-b953-9a1e6197b4d6"));
- assertTrue(model.getDependentModelIds().contains("897df7ea-8938-42b0-bc57-46e913a4d93b"));
- assertTrue(model.getDependentModelIds().contains("f2b24d95-c582-48d5-b2d6-c5b3a94ce812"));
- } catch (Exception e) {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
- @Test
- public void testParseModelFileInvalidArtifact() throws Exception {
- final String MODEL_FILE = "src/test/resources/models/invalid-model.xml";
-
- try {
- byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
-
- ModelArtifactParser parser = new ModelArtifactParser();
- List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
-
- assertTrue(modelList == null || modelList.isEmpty());
- }
- catch (Exception e) {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
- @Test
- public void testParseModelFileIncompleteArtifact() throws Exception {
- final String MODEL_FILE = "src/test/resources/models/incomplete-model.xml";
-
- try {
- byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
-
- ModelArtifactParser parser = new ModelArtifactParser();
- List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
-
- assertTrue(modelList == null || modelList.isEmpty());
- }
- catch (Exception e) {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
- @Test
- public void testParseModelFileIncompleteArtifacts() throws Exception {
- final String MODEL_FILE = "src/test/resources/models/incomplete-models.xml";
-
- try {
- byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
-
- ModelArtifactParser parser = new ModelArtifactParser();
- List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
-
- assertTrue(modelList == null || modelList.isEmpty());
- }
- catch (Exception e) {
- e.printStackTrace();
- assertTrue(false);
- }
- }
-
-}
+/**
+ * ============LICENSE_START=======================================================
+ * Model Loader
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ */
+package org.openecomp.modelloader.entity.model;
+
+import static org.junit.Assert.assertTrue;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import org.junit.Test;
+import org.openecomp.modelloader.entity.Artifact;
+
+public class ModelArtifactParserTest {
+
+ @Test
+ public void testParseModelFileNoDeps() throws Exception {
+ final String MODEL_FILE = "src/test/resources/models/l3-network-widget.xml";
+
+ try {
+ byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
+
+ ModelArtifactParser parser = new ModelArtifactParser();
+ List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
+
+ assertTrue(modelList.size() == 1);
+
+ ModelArtifact model = (ModelArtifact) modelList.get(0);
+ System.out.println(model.toString());
+
+ assertTrue(model.getModelInvariantId().equalsIgnoreCase("3d560d81-57d0-438b-a2a1-5334dba0651a"));
+ assertTrue(model.getModelNamespace().equalsIgnoreCase("http://org.openecomp.aai.inventory/v9"));
+ assertTrue(model.getModelNamespaceVersion().equalsIgnoreCase("v9"));
+ assertTrue(model.getType().toString().equalsIgnoreCase("MODEL"));
+ System.out.println(model.getDependentModelIds().size());
+ assertTrue(model.getDependentModelIds().size() == 0);
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ @Test
+ public void testParseModelFileDeps() throws Exception {
+ final String MODEL_FILE = "src/test/resources/models/AAI-stellService-service-1.xml";
+
+ try {
+ byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
+
+ ModelArtifactParser parser = new ModelArtifactParser();
+ List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
+
+ assertTrue(modelList.size() == 1);
+
+ ModelArtifact model = (ModelArtifact) modelList.get(0);
+ System.out.println(model.toString());
+
+ assertTrue(model.getModelInvariantId().equalsIgnoreCase("fedf9da3-6a74-4813-8fa2-221a98b0e7ad"));
+ assertTrue(model.getModelVerId().equalsIgnoreCase("e0373537-7f66-4094-9939-e2f5de6ff5f6"));
+ assertTrue(model.getType().toString().equalsIgnoreCase("MODEL"));
+ assertTrue(model.getDependentModelIds().size() == 3);
+ assertTrue(model.getDependentModelIds().contains("5c12984d-db0f-4300-a0e0-9791775cc40f|88bdbadf-db8a-490f-881e-c8effcbc3f66"));
+ assertTrue(model.getDependentModelIds().contains("959b7c09-9f34-4e5f-8b63-505381db176e|374d0899-bbc2-4403-9320-fe9bebef75c6"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ @Test
+ public void testParseModelFileInvalidArtifact() throws Exception {
+ final String MODEL_FILE = "src/test/resources/models/invalid-model.xml";
+
+ try {
+ byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
+
+ ModelArtifactParser parser = new ModelArtifactParser();
+ List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
+
+ assertTrue(modelList == null || modelList.isEmpty());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ @Test
+ public void testParseModelFileIncompleteArtifact() throws Exception {
+ final String MODEL_FILE = "src/test/resources/models/incomplete-model.xml";
+
+ try {
+ byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
+
+ ModelArtifactParser parser = new ModelArtifactParser();
+ List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
+
+ assertTrue(modelList == null || modelList.isEmpty());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+}
diff --git a/src/test/java/org/openecomp/modelloader/entity/model/ModelParserFactoryTest.java b/src/test/java/org/openecomp/modelloader/entity/model/ModelParserFactoryTest.java
new file mode 100644
index 0000000..46db11a
--- /dev/null
+++ b/src/test/java/org/openecomp/modelloader/entity/model/ModelParserFactoryTest.java
@@ -0,0 +1,58 @@
+/**
+ * ============LICENSE_START=======================================================
+ * Model Loader
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ */
+package org.openecomp.modelloader.entity.model;
+
+import static org.junit.Assert.assertTrue;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import org.junit.Test;
+
+public class ModelParserFactoryTest {
+
+ @Test
+ public void testParserFactory() throws Exception {
+ final String MODEL_FILE_V8 = "src/test/resources/models/v8-wan-connector-model.xml";
+ final String MODEL_FILE_V9 = "src/test/resources/models/AAI-VL-resource-1.xml";
+ final String MODEL_FILE_NAMED_QUERY = "src/test/resources/models/named-query-wan-connector.xml";
+
+
+ try {
+ byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE_V8));
+ IModelParser parser = ModelParserFactory.createModelParser(xmlBytes, "v8-wan-connector-model.xml");
+ assertTrue(parser instanceof ModelV8ArtifactParser);
+
+ xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE_V9));
+ parser = ModelParserFactory.createModelParser(xmlBytes, "AAI-VL-resource-1.xml");
+ assertTrue(parser instanceof ModelArtifactParser);
+
+ xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE_NAMED_QUERY));
+ parser = ModelParserFactory.createModelParser(xmlBytes, "named-query-wan-connector.xml");
+ assertTrue(parser instanceof NamedQueryArtifactParser);
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+}
diff --git a/src/test/java/org/openecomp/modelloader/entity/model/ModelSorterTest.java b/src/test/java/org/openecomp/modelloader/entity/model/ModelSorterTest.java
index 03eaa39..fdc81da 100644
--- a/src/test/java/org/openecomp/modelloader/entity/model/ModelSorterTest.java
+++ b/src/test/java/org/openecomp/modelloader/entity/model/ModelSorterTest.java
@@ -54,8 +54,9 @@ public class ModelSorterTest {
List<Artifact> modelList = new ArrayList<Artifact>();
ModelArtifact model = new ModelArtifact();
- model.setNameVersionId("aaaaa");
- model.addDependentModelId("xyz");
+ model.setModelInvariantId("aaa");
+ model.setModelVerId("111");
+ model.addDependentModelId("xyz|123");
modelList.add(model);
ModelSorter sorter = new ModelSorter();
@@ -82,17 +83,17 @@ public class ModelSorterTest {
ModelArtifact aaaa = new ModelArtifact();
aaaa.setModelInvariantId("aaaa");
- aaaa.setModelVerId("mvaaaa");
- aaaa.addDependentModelId("cccc|mvcccc");
+ aaaa.setModelVerId("mvaaaa");
+ aaaa.addDependentModelId("cccc|mvcccc");
ModelArtifact bbbb = new ModelArtifact();
bbbb.setModelInvariantId("bbbb");
- bbbb.setModelVerId("mvbbbb");
- bbbb.addDependentModelId("aaaa|mvaaaa");
+ bbbb.setModelVerId("mvbbbb");
+ bbbb.addDependentModelId("aaaa|mvaaaa");
ModelArtifact cccc = new ModelArtifact();
cccc.setModelInvariantId("cccc");
- cccc.setModelVerId("mvcccc");
+ cccc.setModelVerId("mvcccc");
modelList.add(aaaa);
modelList.add(bbbb);
@@ -109,19 +110,89 @@ public class ModelSorterTest {
assertEquals(aaaa, sortedList.get(1));
assertEquals(bbbb, sortedList.get(2));
}
+
+ @Test
+ public void multipleModelsV8() {
+
+ List<Artifact> modelList = new ArrayList<Artifact>();
+
+ ModelV8Artifact aaaa = new ModelV8Artifact();
+ aaaa.setModelNameVersionId("aaaa");
+ aaaa.addDependentModelId("cccc");
+
+ ModelV8Artifact bbbb = new ModelV8Artifact();
+ bbbb.setModelNameVersionId("bbbb");
+ bbbb.addDependentModelId("aaaa");
+
+ ModelV8Artifact cccc = new ModelV8Artifact();
+ cccc.setModelNameVersionId("cccc");
+
+ modelList.add(aaaa);
+ modelList.add(bbbb);
+ modelList.add(cccc);
+ ModelSorter sorter = new ModelSorter();
+ sorter = new ModelSorter();
+
+ List<Artifact> sortedList = sorter.sort(modelList);
+ assertNotNull(sortedList);
+ assertEquals(3, sortedList.size());
+
+ assertEquals(cccc, sortedList.get(0));
+ assertEquals(aaaa, sortedList.get(1));
+ assertEquals(bbbb, sortedList.get(2));
+ }
+
+ @Test
+ public void multipleModelsAndNamedQueries() {
+
+ List<Artifact> modelList = new ArrayList<Artifact>();
+
+ ModelArtifact aaaa = new ModelArtifact();
+ aaaa.setModelInvariantId("aaaa");
+ aaaa.setModelVerId("1111");
+ aaaa.addDependentModelId("cccc|2222");
+
+ NamedQueryArtifact nq1 = new NamedQueryArtifact();
+ nq1.setNamedQueryUuid("nq1");
+ nq1.addDependentModelId("aaaa|1111");
+
+ NamedQueryArtifact nq2 = new NamedQueryArtifact();
+ nq2.setNamedQueryUuid("nq2");
+ nq2.addDependentModelId("existing-model");
+
+
+ modelList.add(nq1);
+ modelList.add(nq2);
+ modelList.add(aaaa);
+
+ ModelSorter sorter = new ModelSorter();
+ sorter = new ModelSorter();
+
+ List<Artifact> sortedList = sorter.sort(modelList);
+ assertNotNull(sortedList);
+ assertEquals(3, sortedList.size());
+
+ System.out.println(sortedList.get(0) + "-" + sortedList.get(1) + "-" + sortedList.get(2));
+ assertEquals(aaaa, sortedList.get(0));
+ assertEquals(nq2, sortedList.get(1));
+ assertEquals(nq1, sortedList.get(2));
+ }
+
@Test(expected = RuntimeException.class)
public void circularDependency() {
List<Artifact> modelList = new ArrayList<Artifact>();
ModelArtifact aaaa = new ModelArtifact();
- aaaa.setNameVersionId("aaaa");
- aaaa.addDependentModelId("bbbb");
+ aaaa.setModelInvariantId("aaaa");
+ aaaa.setModelVerId("1111");
+ aaaa.addDependentModelId("bbbb|1111");
ModelArtifact bbbb = new ModelArtifact();
- bbbb.setNameVersionId("bbbb");
- bbbb.addDependentModelId("aaaa");
+ bbbb.setModelInvariantId("bbbb");
+ bbbb.setModelVerId("1111");
+ bbbb.addDependentModelId("aaaa|1111");
modelList.add(aaaa);
modelList.add(bbbb);
diff --git a/src/test/java/org/openecomp/modelloader/entity/model/ModelV8ArtifactParserTest.java b/src/test/java/org/openecomp/modelloader/entity/model/ModelV8ArtifactParserTest.java
new file mode 100644
index 0000000..098bc8c
--- /dev/null
+++ b/src/test/java/org/openecomp/modelloader/entity/model/ModelV8ArtifactParserTest.java
@@ -0,0 +1,104 @@
+/**
+ * ============LICENSE_START=======================================================
+ * Model Loader
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ */
+package org.openecomp.modelloader.entity.model;
+
+import static org.junit.Assert.assertTrue;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import org.junit.Test;
+import org.openecomp.modelloader.entity.Artifact;
+
+public class ModelV8ArtifactParserTest {
+
+ @Test
+ public void testParseModelFile() throws Exception {
+ final String MODEL_FILE = "src/test/resources/models/v8-wan-connector-model.xml";
+
+ try {
+ byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
+
+ ModelV8ArtifactParser parser = new ModelV8ArtifactParser();
+ List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
+
+ assertTrue(modelList.size() == 1);
+
+ ModelV8Artifact model = (ModelV8Artifact) modelList.get(0);
+ System.out.println(model.toString());
+
+ assertTrue(model.getModelNameVersionId().equalsIgnoreCase("93d9d45d-7eec-4371-9083-675e4c353de3"));
+ assertTrue(model.getModelNamespace().equalsIgnoreCase("http://com.att.aai.inventory/v7"));
+ assertTrue(model.getModelNamespaceVersion().equalsIgnoreCase("v7"));
+ assertTrue(model.getType().toString().equalsIgnoreCase("MODEL_V8"));
+ assertTrue(model.getDependentModelIds().size() == 7);
+ assertTrue(model.getDependentModelIds().contains("d09dd9da-0148-46cd-a947-591afc844d24"));
+ assertTrue(model.getDependentModelIds().contains("997fc7-fca1-451f-b953-9a1e6197b4d6"));
+ assertTrue(model.getDependentModelIds().contains("ae16244f-4d29-4801-a559-e25f2db2a4c3"));
+ assertTrue(model.getDependentModelIds().contains("759dbd4a-2473-46f3-a932-48d987c9b4a1"));
+ assertTrue(model.getDependentModelIds().contains("a6d9de88-4046-4b78-a59e-5691243d292a"));
+ assertTrue(model.getDependentModelIds().contains("35be1acf-1298-48c6-a128-66850083b8bd"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ @Test
+ public void testParseModelFileInvalidArtifact() throws Exception {
+ final String MODEL_FILE = "src/test/resources/models/invalid-model.xml";
+
+ try {
+ byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
+
+ ModelV8ArtifactParser parser = new ModelV8ArtifactParser();
+ List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
+
+ assertTrue(modelList == null || modelList.isEmpty());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+ @Test
+ public void testParseModelFileIncompleteArtifact() throws Exception {
+ final String MODEL_FILE = "src/test/resources/models/incomplete-model.xml";
+
+ try {
+ byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
+
+ ModelV8ArtifactParser parser = new ModelV8ArtifactParser();
+ List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
+
+ assertTrue(modelList == null || modelList.isEmpty());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+}
diff --git a/src/test/java/org/openecomp/modelloader/entity/model/NamedQueryArtifactParserTest.java b/src/test/java/org/openecomp/modelloader/entity/model/NamedQueryArtifactParserTest.java
new file mode 100644
index 0000000..cc9d615
--- /dev/null
+++ b/src/test/java/org/openecomp/modelloader/entity/model/NamedQueryArtifactParserTest.java
@@ -0,0 +1,64 @@
+/**
+ * ============LICENSE_START=======================================================
+ * Model Loader
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * 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.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ */
+package org.openecomp.modelloader.entity.model;
+
+import static org.junit.Assert.assertTrue;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+
+import org.junit.Test;
+import org.openecomp.modelloader.entity.Artifact;
+
+public class NamedQueryArtifactParserTest {
+
+ @Test
+ public void testParseNamedQuery() throws Exception {
+ final String MODEL_FILE = "src/test/resources/models/named-query-wan-connector.xml";
+
+ try {
+ byte[] xmlBytes = Files.readAllBytes(Paths.get(MODEL_FILE));
+
+ NamedQueryArtifactParser parser = new NamedQueryArtifactParser();
+ List<Artifact> modelList = parser.parse(xmlBytes, "test-artifact");
+
+ assertTrue(modelList.size() == 1);
+
+ NamedQueryArtifact model = (NamedQueryArtifact) modelList.get(0);
+ System.out.println(model.toString());
+
+ assertTrue(model.getNamedQueryUuid().equalsIgnoreCase("94cac189-8d88-4d63-a194-f44214e080ff"));
+ assertTrue(model.getType().toString().equalsIgnoreCase("NAMED_QUERY"));
+ assertTrue(model.getDependentModelIds().size() == 4);
+ assertTrue(model.getDependentModelIds().contains("d09dd9da-0148-46cd-a947-591afc844d24"));
+ assertTrue(model.getDependentModelIds().contains("997fc7-fca1-451f-b953-9a1e6197b4d6"));
+ assertTrue(model.getDependentModelIds().contains("897df7ea-8938-42b0-bc57-46e913a4d93b"));
+ assertTrue(model.getDependentModelIds().contains("f2b24d95-c582-48d5-b2d6-c5b3a94ce812"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+ }
+
+}
diff --git a/src/test/java/org/openecomp/modelloader/restclient/AaiRestClientTest.java b/src/test/java/org/openecomp/modelloader/restclient/AaiRestClientTest.java
index 5d9edc9..08a429a 100644
--- a/src/test/java/org/openecomp/modelloader/restclient/AaiRestClientTest.java
+++ b/src/test/java/org/openecomp/modelloader/restclient/AaiRestClientTest.java
@@ -115,7 +115,7 @@ public class AaiRestClientTest {
subURL = subURL + "/";
}
- String url = baseURL + subURL + model.getNameVersionId();
+ String url = baseURL + subURL + model.getUniqueIdentifier();
return url;
}
}