diff options
7 files changed, 517 insertions, 4 deletions
diff --git a/adapters/mso-vnf-adapter/pom.xml b/adapters/mso-vnf-adapter/pom.xml index ba0c87ab5e..9c5d74cb81 100644 --- a/adapters/mso-vnf-adapter/pom.xml +++ b/adapters/mso-vnf-adapter/pom.xml @@ -30,7 +30,7 @@ <version>2.3</version>
<executions>
<execution>
- <id>Synch</id>
+ <id>Synch</id>
<goals>
<goal>wsgen</goal>
</goals>
@@ -42,7 +42,7 @@ </configuration>
</execution>
<execution>
- <id>Asynch</id>
+ <id>Asynch</id>
<goals>
<goal>wsgen</goal>
</goals>
@@ -70,7 +70,7 @@ </plugins>
<pluginManagement>
<plugins>
- <!--This plugin's configuration is used to store Eclipse m2e settings
+ <!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
@@ -144,7 +144,18 @@ <artifactId>status-control</artifactId>
<version>${project.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
<!-- <dependency> -->
<!-- <groupId>org.openecomp.so</groupId> -->
<!-- <artifactId>mso-catalog-db</artifactId> -->
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java new file mode 100644 index 0000000000..b680170abe --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterAsyncImplTest.java @@ -0,0 +1,131 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.adapters.vnf.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.openecomp.mso.adapters.vnf.MsoVnfAdapterAsyncImpl;
+import org.openecomp.mso.entity.MsoRequest;
+import org.openecomp.mso.openstack.beans.HeatStatus;
+import org.openecomp.mso.openstack.beans.StackInfo;
+import org.openecomp.mso.openstack.beans.VnfRollback;
+import org.openecomp.mso.openstack.exceptions.MsoException;
+import org.openecomp.mso.openstack.utils.MsoHeatUtils;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+public class MsoVnfAdapterAsyncImplTest {
+
+ @Test
+ public void healthCheckVNFTest() {
+ MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
+ instance.healthCheckA();
+ }
+
+ @Test
+ public void createVNFTest() {
+ new MockUp<MsoHeatUtils>() {
+ @Mock
+ public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException {
+ StackInfo info = new StackInfo();
+ info.setStatus(HeatStatus.CREATED);
+ return info;
+ }
+ };
+
+ MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+ try {
+
+ instance.createVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", new HashMap<String, String>(), Boolean.FALSE, Boolean.TRUE, "messageId",
+ null, "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void updateVnfTest() {
+ MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ try {
+ instance.updateVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", map, "messageId", msoRequest,
+ "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void queryVnfTest() {
+ MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+ try {
+ instance.queryVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest,
+ "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void deleteVnfTest() {
+ MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+ try {
+ instance.deleteVnfA("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest,
+ "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void rollbackVnfTest() {
+ MsoVnfAdapterAsyncImpl instance = new MsoVnfAdapterAsyncImpl();
+ VnfRollback vnfRollBack = new VnfRollback();
+ vnfRollBack.setCloudSiteId("mdt1");
+ vnfRollBack.setTenantId("88a6ca3ee0394ade9403f075db23167e");
+ vnfRollBack.setVnfId("ff5256d1-5a33-55df-13ab-12abad84e7ff");
+ try {
+ instance.rollbackVnfA(vnfRollBack, "messageId",
+ "http://org.openecomp.mso/notify/adapterNotify/updateVnfNotificationRequest");
+ } catch (Exception e) {
+
+ }
+ }
+}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java new file mode 100644 index 0000000000..77879089e9 --- /dev/null +++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/test/MsoVnfAdapterImplTest.java @@ -0,0 +1,156 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.adapters.vnf.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.ws.Holder;
+
+import org.junit.Test;
+import org.openecomp.mso.adapters.vnf.MsoVnfAdapterImpl;
+import org.openecomp.mso.db.catalog.CatalogDatabase;
+import org.openecomp.mso.db.catalog.beans.VfModule;
+import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
+import org.openecomp.mso.entity.MsoRequest;
+import org.openecomp.mso.openstack.beans.HeatStatus;
+import org.openecomp.mso.openstack.beans.StackInfo;
+import org.openecomp.mso.openstack.beans.VnfRollback;
+import org.openecomp.mso.openstack.exceptions.MsoException;
+import org.openecomp.mso.openstack.utils.MsoHeatUtils;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+public class MsoVnfAdapterImplTest {
+
+ @Test
+ public void healthCheckVNFTest() {
+ MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
+ instance.healthCheck();
+ }
+
+ @Test
+ public void createVnfTest() {
+
+ new MockUp<MsoHeatUtils>() {
+ @Mock
+ public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException {
+ StackInfo info = new StackInfo();
+ info.setStatus(HeatStatus.CREATED);
+ return info;
+ }
+ };
+
+ MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ try {
+ instance.createVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map,
+ Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(),
+ new Holder<VnfRollback>());
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void updateVnfTest() {
+
+ new MockUp<MsoHeatUtils>() {
+ @Mock
+ public StackInfo queryStack(String cloudSiteId, String tenantId, String stackName) throws MsoException {
+ StackInfo info = new StackInfo();
+ info.setStatus(HeatStatus.CREATED);
+ return info;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public VfModuleCustomization getVfModuleCustomizationByModelCustomizationId(String modelCustomizationUuid) {
+ VfModuleCustomization vfcModule = new VfModuleCustomization();
+ VfModule vfm = new VfModule();
+ vfm.setVnfResourceModelUUId("88a6ca3ee0394ade9403f075db23167e");
+ vfcModule.setVfModule(vfm);
+ return vfcModule;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public VnfResource getVnfResourceByModelUuid(String modelUuid) {
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setAicVersionMin("1");
+ vnfResource.setAicVersionMax("2");
+ return vnfResource;
+ }
+ };
+
+ MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+
+ Map<String, String> map = new HashMap<>();
+ map.put("key1", "value1");
+ try {
+ instance.updateVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
+ "volumeGroupHeatStackId|1", "baseVfHeatStackId", "vfModuleStackId",
+ "88a6ca3ee0394ade9403f075db23167e", map, msoRequest, new Holder<Map<String, String>>(),
+ new Holder<VnfRollback>());
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void deleteVnfTest() {
+ new MockUp<MsoHeatUtils>() {
+ @Mock
+ public Map<String, Object> queryStackForOutputs(String cloudSiteId, String tenantId, String stackName)
+ throws MsoException {
+
+ Map<String, Object> outputs = new HashMap<>();
+ outputs.put("Key1", "value1");
+ return outputs;
+ }
+ };
+
+ MsoVnfAdapterImpl instance = new MsoVnfAdapterImpl();
+ MsoRequest msoRequest = new MsoRequest();
+ msoRequest.setRequestId("12345");
+ msoRequest.setServiceInstanceId("12345");
+ try {
+ instance.deleteVfModule("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest,
+ new Holder<Map<String, String>>());
+ } catch (Exception e) {
+
+ }
+ }
+
+}
diff --git a/docs/ONAP SO Debug Env Setup.docx b/docs/ONAP SO Debug Env Setup.docx Binary files differdeleted file mode 100644 index 6d96c0dea1..0000000000 --- a/docs/ONAP SO Debug Env Setup.docx +++ /dev/null diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java new file mode 100644 index 0000000000..da4e87806c --- /dev/null +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.db.catalog.test; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.UUID; + +import org.junit.Test; +import org.openecomp.mso.db.catalog.beans.HeatFiles; + +/** + */ + +public class HeatFilesTest { + + @Test + public final void heatFilesTest() { + + HeatFiles heatFiles = new HeatFiles(); + heatFiles.setFileBody("testBody"); + heatFiles.setArtifactUuid(UUID.randomUUID().toString()); + assertTrue(heatFiles.getFileBody().equals("testBody")); + assertTrue(!heatFiles.toString().contains("8 chars")); + heatFiles.setFileBody(null); + assertTrue(!heatFiles.toString().contains("Not defined")); + heatFiles.setVersion("12"); + assertTrue(heatFiles.getVersion().equals("12")); + + heatFiles.setFileName("File"); + assertTrue(heatFiles.getFileName().equalsIgnoreCase("File")); + + heatFiles.setCreated(null); + assertTrue(heatFiles.getCreated() == null); + heatFiles.setAsdcUuid("asdc"); + + assertTrue(heatFiles.getAsdcUuid().equalsIgnoreCase("asdc")); + + heatFiles.setDescription("desc"); + assertTrue(heatFiles.getDescription().equalsIgnoreCase("desc")); + + + heatFiles.setArtifactChecksum("artifactChecksum"); + assertTrue(heatFiles.getArtifactChecksum().equalsIgnoreCase("artifactChecksum")); + File tempFile; + try { + tempFile = File.createTempFile("heatFiles", "test"); + tempFile.deleteOnExit(); + try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile), "utf-8"))) { + writer.write("something\n"); + writer.write("something2\n"); + } + heatFiles.setFileBody(tempFile.getAbsolutePath()); + assertTrue(heatFiles.getFileBody().contains("test")); + } catch (IOException e) { + e.printStackTrace(); + fail("Exception caught"); + } + + } + +} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java new file mode 100644 index 0000000000..d70f267cc1 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.db.catalog.test; + +import static org.junit.Assert.assertTrue; + +import java.sql.Timestamp; + +import org.junit.Test; +import org.openecomp.mso.db.catalog.beans.ModelRecipe; + +/** + */ + +public class ModelRecipeTest { + + @Test + public final void modelRecipeDataTest() { + ModelRecipe modelRecipe = new ModelRecipe(); + modelRecipe.setAction("action"); + assertTrue(modelRecipe.getAction().equalsIgnoreCase("action")); + modelRecipe.setCreated(new Timestamp(System.currentTimeMillis())); + assertTrue(modelRecipe.getCreated() != null); + modelRecipe.setDescription("description"); + assertTrue(modelRecipe.getDescription().equalsIgnoreCase("description")); + modelRecipe.setId(1); + assertTrue(modelRecipe.getId() == 1); + modelRecipe.setModelId(1); + assertTrue(modelRecipe.getModelId() == 1); + modelRecipe.setModelParamXSD("modelParamXSD"); + assertTrue(modelRecipe.getModelParamXSD().equalsIgnoreCase("modelParamXSD")); + modelRecipe.setOrchestrationUri("orchestrationUri"); + assertTrue(modelRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri")); + modelRecipe.setRecipeTimeout(1); + assertTrue(modelRecipe.getRecipeTimeout() == 1); + modelRecipe.setSchemaVersion("schemaVersion"); + assertTrue(modelRecipe.getSchemaVersion().equalsIgnoreCase("schemaVersion")); +// assertTrue(modelRecipe.toString() != null); + } + +} diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java new file mode 100644 index 0000000000..dcc9810042 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.db.catalog.test; + +import static org.junit.Assert.assertTrue; + +import java.sql.Timestamp; + +import org.junit.Test; +import org.openecomp.mso.db.catalog.beans.Model; + +/** + */ + +public class ModelTest { + + @Test + public final void modelDataTest() { + Model model = new Model(); + model.setId(1); + assertTrue(model.getId() == 1); + + model.setCreated(new Timestamp(System.currentTimeMillis())); + assertTrue(model.getCreated() != null); + model.setModelCustomizationId("modelCustomizationId"); + + assertTrue(model.getModelCustomizationId().equalsIgnoreCase("modelCustomizationId")); + model.setModelCustomizationName("modelCustomizationName"); + assertTrue(model.getModelCustomizationName().equalsIgnoreCase("modelCustomizationName")); + + model.setModelInvariantId("modelInvariantId"); + assertTrue(model.getModelInvariantId().equalsIgnoreCase("modelInvariantId")); + model.setModelName("modelName"); + assertTrue(model.getModelName().equalsIgnoreCase("modelName")); + + model.setModelType("modelType"); + assertTrue(model.getModelType().equalsIgnoreCase("modelType")); + model.setModelVersion("modelVersion"); + assertTrue(model.getModelVersion().equalsIgnoreCase("modelVersion")); + model.setModelVersionId("modelVersionId"); + assertTrue(model.getModelVersionId().equalsIgnoreCase("modelVersionId")); + model.setVersion("1"); + assertTrue(model.getVersion().equalsIgnoreCase("1")); + model.setRecipes(null); + + assertTrue(model.getRecipes() == null); +// assertTrue(model.toString() != null); + + } + +} |