-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
- <parent>\r
- <groupId>org.openecomp.so</groupId>\r
- <artifactId>so</artifactId>\r
- <version>1.1.0-SNAPSHOT</version>\r
- </parent>\r
-\r
- <groupId>org.openecomp.so</groupId>\r
- <artifactId>asdc-controller</artifactId>\r
- <name>asdc-controller</name>\r
- <description>ASDC CLient and Controller</description>\r
- <packaging>war</packaging>\r
-\r
- <build>\r
- <finalName>${project.artifactId}-${project.version}</finalName>\r
- <plugins>\r
- <plugin>\r
- <artifactId>maven-war-plugin</artifactId>\r
- <version>2.4</version>\r
- <configuration>\r
- <warSourceDirectory>WebContent</warSourceDirectory>\r
- <failOnMissingWebXml>false</failOnMissingWebXml>\r
- <attachClasses>true</attachClasses>\r
- </configuration>\r
- </plugin>\r
- </plugins>\r
- </build>\r
-\r
- <dependencies>\r
- <dependency>\r
- <groupId>org.codehaus.jackson</groupId>\r
- <artifactId>jackson-mapper-asl</artifactId>\r
- <version>1.9.13</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.mockito</groupId>\r
- <artifactId>mockito-all</artifactId>\r
- <version>1.10.19</version>\r
- <scope>test</scope>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.openecomp.so</groupId>\r
- <artifactId>mso-catalog-db</artifactId>\r
- <version>${project.version}</version>\r
- </dependency>\r
-\r
- <dependency>\r
- <groupId>org.jboss.spec.javax.ejb</groupId>\r
- <artifactId>jboss-ejb-api_3.2_spec</artifactId>\r
- <version>1.0.0.Final</version>\r
- <scope>provided</scope>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.jboss.ejb3</groupId>\r
- <artifactId>jboss-ejb3-ext-api</artifactId>\r
- <version>2.2.0.Final</version>\r
- <scope>provided</scope>\r
- </dependency>\r
-\r
- <dependency>\r
- <groupId>javax.servlet</groupId>\r
- <artifactId>javax.servlet-api</artifactId>\r
- <version>3.1.0</version>\r
- <scope>test</scope>\r
- </dependency>\r
- \r
- <!-- <dependency>\r
- <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>\r
- <artifactId>sdc-distribution-client</artifactId>\r
- <version>1.1.16</version>\r
- <exclusions>\r
- <exclusion> \r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-log4j12</artifactId>\r
- </exclusion>\r
- </exclusions> \r
- </dependency> -->\r
- \r
- <dependency>\r
- <groupId>org.apache.httpcomponents</groupId>\r
- <artifactId>httpclient</artifactId>\r
- <version>4.4.1</version>\r
- <scope>compile</scope>\r
- <exclusions>\r
- <exclusion> \r
- <groupId>org.apache.httpcomponents</groupId>\r
- <artifactId>httpclient</artifactId>\r
- </exclusion>\r
- </exclusions>\r
- </dependency>\r
- \r
- <dependency>\r
- <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>\r
- <artifactId>sdc-distribution-client</artifactId>\r
- <version>1.1.32-SNAPSHOT</version>\r
- <exclusions>\r
- <exclusion> \r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-log4j12</artifactId>\r
- </exclusion>\r
- </exclusions>\r
- </dependency>\r
-\r
-\r
- <dependency>\r
- <groupId>org.openecomp.sdc.sdc-tosca</groupId>\r
- <artifactId>sdc-tosca</artifactId>\r
- <version>1.1.32-SNAPSHOT</version>\r
- </dependency> \r
- \r
-\r
- <dependency>\r
- <groupId>org.apache.httpcomponents</groupId>\r
- <artifactId>httpmime</artifactId>\r
- <version>4.5</version>\r
- </dependency>\r
-\r
- <dependency>\r
- <groupId>org.openecomp.so</groupId>\r
- <artifactId>common</artifactId>\r
- <version>${project.version}</version>\r
- </dependency>\r
-\r
- <dependency>\r
- <groupId>org.yaml</groupId>\r
- <artifactId>snakeyaml</artifactId>\r
- <version>1.15</version>\r
- </dependency>\r
-\r
- <dependency>\r
- <groupId>javax</groupId>\r
- <artifactId>javaee-web-api</artifactId>\r
- <version>6.0</version>\r
- <scope>provided</scope>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.openecomp.so</groupId>\r
- <artifactId>status-control</artifactId>\r
- <version>${project.version}</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>commons-io</groupId>\r
- <artifactId>commons-io</artifactId>\r
- </dependency>\r
- </dependencies>\r
-\r
-</project>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>so</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>asdc-controller</artifactId>
+ <name>asdc-controller</name>
+ <description>ASDC CLient and Controller</description>
+ <packaging>war</packaging>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <warSourceDirectory>WebContent</warSourceDirectory>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ <attachClasses>true</attachClasses>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.9.13</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jmockit</groupId>
+ <artifactId>jmockit</artifactId>
+ <version>1.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>mso-catalog-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.2_spec</artifactId>
+ <version>1.0.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ejb3</groupId>
+ <artifactId>jboss-ejb3-ext-api</artifactId>
+ <version>2.2.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- <dependency>
+ <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
+ <artifactId>sdc-distribution-client</artifactId>
+ <version>1.1.16</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency> -->
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.4.1</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
+ <artifactId>sdc-distribution-client</artifactId>
+ <version>1.1.32-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.openecomp.sdc.sdc-tosca</groupId>
+ <artifactId>sdc-tosca</artifactId>
+ <version>1.1.32-SNAPSHOT</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ <version>4.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.15</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-web-api</artifactId>
+ <version>6.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.so</groupId>
+ <artifactId>status-control</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.asdc.installer.heat.tests;\r
+\r
+import java.io.IOException;\r
+import java.io.UnsupportedEncodingException;\r
+import java.net.URISyntaxException;\r
+import java.nio.file.Files;\r
+import java.nio.file.Paths;\r
+import java.security.MessageDigest;\r
+import java.security.NoSuchAlgorithmException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.commons.codec.binary.Base64;\r
+import org.apache.commons.lang3.tuple.Pair;\r
+import org.junit.AfterClass;\r
+import org.junit.Before;\r
+import org.junit.BeforeClass;\r
+import org.junit.Test;\r
+import org.mockito.Mockito;\r
+import org.openecomp.mso.asdc.client.ASDCConfiguration;\r
+import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;\r
+import org.openecomp.mso.asdc.client.tests.ASDCControllerTest;\r
+import org.openecomp.mso.asdc.installer.ToscaResourceStructure;\r
+import org.openecomp.mso.asdc.installer.VfResourceStructure;\r
+import org.openecomp.mso.asdc.installer.heat.ToscaResourceInstaller;\r
+import org.openecomp.mso.db.catalog.CatalogDatabase;\r
+import org.openecomp.mso.db.catalog.beans.AllottedResource;\r
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;\r
+import org.openecomp.mso.db.catalog.beans.NetworkResource;\r
+import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;\r
+import org.openecomp.mso.db.catalog.beans.Service;\r
+import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;\r
+import org.openecomp.mso.db.catalog.beans.ServiceToNetworks;\r
+import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization;\r
+import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;\r
+import org.openecomp.mso.db.catalog.beans.ToscaCsar;\r
+import org.openecomp.mso.db.catalog.beans.VfModule;\r
+import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;\r
+import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles;\r
+import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom;\r
+import org.openecomp.mso.db.catalog.beans.VnfResource;\r
+import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;\r
+import org.openecomp.mso.properties.MsoJavaProperties;\r
+import org.openecomp.mso.properties.MsoPropertiesException;\r
+import org.openecomp.mso.properties.MsoPropertiesFactory;\r
+import org.openecomp.sdc.api.IDistributionClient;\r
+import org.openecomp.sdc.api.notification.IArtifactInfo;\r
+import org.openecomp.sdc.api.notification.INotificationData;\r
+import org.openecomp.sdc.api.notification.IResourceInstance;\r
+import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;\r
+import org.openecomp.sdc.api.results.IDistributionClientResult;\r
+import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;\r
+import org.openecomp.sdc.tosca.parser.impl.FilterType;\r
+import org.openecomp.sdc.tosca.parser.impl.SdcTypes;\r
+import org.openecomp.sdc.toscaparser.api.Group;\r
+import org.openecomp.sdc.toscaparser.api.NodeTemplate;\r
+import org.openecomp.sdc.toscaparser.api.elements.Metadata;\r
+import org.openecomp.sdc.toscaparser.api.parameters.Input;\r
+import org.openecomp.sdc.utils.DistributionActionResultEnum;\r
+\r
+import mockit.Mock;\r
+import mockit.MockUp;\r
+\r
+public class ToscaResourceInstallerTest {\r
+\r
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();\r
+\r
+ private static String heatExample;\r
+ private static String heatExampleMD5HashBase64;\r
+\r
+ private static INotificationData iNotif;\r
+\r
+ private static IDistributionClientDownloadResult downloadResult;\r
+ private static IDistributionClientDownloadResult downloadCorruptedResult;\r
+\r
+ private static IDistributionClientResult successfulClientInitResult;\r
+ private static IDistributionClientResult unsuccessfulClientInitResult;\r
+\r
+ private static IDistributionClient distributionClient;\r
+\r
+ private static IArtifactInfo artifactInfo1;\r
+\r
+ private static IResourceInstance resource1;\r
+\r
+ private static VfResourceStructure vrs;\r
+\r
+ public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString()\r
+ .substring(5);\r
+ public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString()\r
+ .substring(5);\r
+ public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString()\r
+ .substring(5);\r
+ public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json")\r
+ .toString().substring(5);\r
+ public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader()\r
+ .getResource("mso-with-NULL.json").toString().substring(5);\r
+\r
+ @BeforeClass\r
+ public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException,\r
+ NoSuchAlgorithmException, ArtifactInstallerException {\r
+\r
+ heatExample = new String(Files.readAllBytes(Paths.get(\r
+ ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI())));\r
+ MessageDigest md = MessageDigest.getInstance("MD5");\r
+ byte[] md5Hash = md.digest(heatExample.getBytes());\r
+ heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash);\r
+\r
+ iNotif = Mockito.mock(INotificationData.class);\r
+\r
+ // Create fake ArtifactInfo\r
+ artifactInfo1 = Mockito.mock(IArtifactInfo.class);\r
+ Mockito.when(artifactInfo1.getArtifactChecksum())\r
+ .thenReturn(ToscaResourceInstallerTest.heatExampleMD5HashBase64);\r
+\r
+ Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1");\r
+ Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT);\r
+ Mockito.when(artifactInfo1.getArtifactURL())\r
+ .thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");\r
+ Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1");\r
+ Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1");\r
+\r
+ distributionClient = Mockito.mock(IDistributionClient.class);\r
+\r
+ // Now provision the NotificationData mock\r
+ List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>();\r
+ listArtifact.add(artifactInfo1);\r
+\r
+ // Create fake resource Instance\r
+ resource1 = Mockito.mock(IResourceInstance.class);\r
+ // Mockito.when(resource1.getResourceType()).thenReturn("VF");\r
+ Mockito.when(resource1.getResourceName()).thenReturn("resourceName");\r
+ Mockito.when(resource1.getArtifacts()).thenReturn(listArtifact);\r
+\r
+ List<IResourceInstance> resources = new ArrayList<>();\r
+ resources.add(resource1);\r
+\r
+ Mockito.when(iNotif.getResources()).thenReturn(resources);\r
+ Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1");\r
+ Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1");\r
+ Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1");\r
+ Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0");\r
+\r
+ downloadResult = Mockito.mock(IDistributionClientDownloadResult.class);\r
+ Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes());\r
+ Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);\r
+ Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success");\r
+\r
+ downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class);\r
+ Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample + "badone").getBytes());\r
+ Mockito.when(downloadCorruptedResult.getDistributionActionResult())\r
+ .thenReturn(DistributionActionResultEnum.SUCCESS);\r
+ Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success");\r
+\r
+ vrs = new VfResourceStructure(iNotif, resource1);\r
+ try {\r
+ vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult);\r
+ } catch (UnsupportedEncodingException e) {\r
+ e.printStackTrace();\r
+ }\r
+ try {\r
+ vrs.createVfModuleStructures();\r
+ } catch (ArtifactInstallerException e) {\r
+ e.printStackTrace();\r
+ }\r
+ vrs.getNotification();\r
+ vrs.getArtifactsMapByUUID();\r
+ vrs.getCatalogNetworkResourceCustomization();\r
+ vrs.getCatalogResourceCustomization();\r
+ vrs.getCatalogService();\r
+ vrs.getCatalogServiceToAllottedResources();\r
+ vrs.getCatalogServiceToNetworks();\r
+ vrs.getCatalogVnfResource();\r
+ vrs.getResourceInstance();\r
+ vrs.getVfModulesStructureList();\r
+ vrs.getVfModuleStructure();\r
+ vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());\r
+ vrs.setCatalogResourceCustomization(new AllottedResourceCustomization());\r
+ vrs.setCatalogService(new Service());\r
+ vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources());\r
+ vrs.setCatalogServiceToNetworks(new ServiceToNetworks());\r
+ vrs.setCatalogVnfResource(new VnfResource());\r
+ vrs.setSuccessfulDeployment();\r
+\r
+ AllottedResourceCustomization arc = new AllottedResourceCustomization();\r
+ arc.setModelCustomizationUuid("modelCustomizationUuid");\r
+ List<AllottedResourceCustomization> allottedResources = new ArrayList<>();\r
+ allottedResources.add(arc);\r
+\r
+ NetworkResourceCustomization nrc = new NetworkResourceCustomization();\r
+ nrc.setModelCustomizationUuid("modelCustomizationUuid");\r
+ List<NetworkResourceCustomization> networkResources = new ArrayList<>();\r
+ networkResources.add(nrc);\r
+\r
+ new MockUp<CatalogDatabase>() {\r
+ @Mock\r
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(\r
+ String serviceModelUuid) {\r
+ return allottedResources;\r
+ }\r
+ };\r
+ new MockUp<CatalogDatabase>() {\r
+ @Mock\r
+ public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {\r
+ return networkResources;\r
+ }\r
+ };\r
+\r
+ // Mock now the ASDC distribution client behavior\r
+ successfulClientInitResult = Mockito.mock(IDistributionClientResult.class);\r
+ Mockito.when(successfulClientInitResult.getDistributionActionResult())\r
+ .thenReturn(DistributionActionResultEnum.SUCCESS);\r
+\r
+ unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class);\r
+ Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult())\r
+ .thenReturn(DistributionActionResultEnum.GENERAL_ERROR);\r
+\r
+ }\r
+\r
+ @Before\r
+ public final void initBeforeEachTest() throws MsoPropertiesException {\r
+ // load the config\r
+ msoPropertiesFactory.removeAllMsoProperties();\r
+ msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);\r
+ }\r
+\r
+ @AfterClass\r
+ public static final void kill() throws MsoPropertiesException {\r
+\r
+ msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void isResourceAlreadyDeployedAllotedResourceTest() {\r
+ Mockito.when(resource1.getResourceType()).thenReturn("VF");\r
+ Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource");\r
+ ToscaResourceInstaller tri = new ToscaResourceInstaller();\r
+\r
+ try {\r
+ tri.isResourceAlreadyDeployed(vrs);\r
+ } catch (ArtifactInstallerException e) {\r
+ }\r
+ }\r
+\r
+ @Test(expected=Exception.class)\r
+ public void installTheResourceTest() {\r
+\r
+ ToscaResourceStructure trs = new ToscaResourceStructure();\r
+ trs.getAllottedResource();\r
+ trs.getAllottedList();\r
+ trs.getCatalogAllottedResourceCustomization();\r
+ trs.getCatalogAllottedServiceToResourceCustomization();\r
+ trs.getCatalogNetworkResource();\r
+ trs.getCatalogNetworkResourceCustomization();\r
+ trs.getCatalogResourceCustomization();\r
+ trs.getCatalogService();\r
+ trs.getCatalogTempNetworkHeatTemplateLookup();\r
+ trs.getCatalogToscaCsar();\r
+ trs.getCatalogVfModule();\r
+ trs.getCatalogVfModuleCustomization();\r
+ trs.getCatalogVfModuleToHeatFiles();\r
+ trs.getCatalogVfServiceToResourceCustomization();\r
+ trs.getCatalogVlServiceToResourceCustomization();\r
+ trs.getCatalogVnfResCustomToVfModuleCustom();\r
+ trs.getCatalogVnfResource();\r
+ trs.getCatalogVnfResourceCustomization();\r
+ trs.getEnvHeatTemplateUUID();\r
+ trs.getHeatFilesUUID();\r
+ trs.getHeatTemplateUUID();\r
+ trs.getNetworkTypes();\r
+ trs.getSdcCsarHelper();\r
+ trs.getServiceMetadata();\r
+ trs.getServiceToResourceCustomization();\r
+ trs.getServiceVersion();\r
+ trs.getToscaArtifact();\r
+ trs.getVfTypes();\r
+ trs.getVolHeatEnvTemplateUUID();\r
+ trs.getVolHeatTemplateUUID();\r
+\r
+ NodeTemplate nodeTemplate = Mockito.mock(NodeTemplate.class);\r
+ List<NodeTemplate> alnt = new ArrayList<>();\r
+ trs.setAllottedList(alnt);\r
+ trs.setAllottedResource(new AllottedResource());\r
+ trs.setCatalogAllottedResourceCustomization(new AllottedResourceCustomization());\r
+ trs.setCatalogAllottedServiceToResourceCustomization(new ServiceToResourceCustomization());\r
+ trs.setCatalogNetworkResource(new NetworkResource());\r
+ trs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());\r
+ trs.setCatalogResourceCustomization(new AllottedResourceCustomization());\r
+ trs.setCatalogService(new Service());\r
+ trs.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());\r
+ trs.setCatalogToscaCsar(new ToscaCsar());\r
+ trs.setCatalogVfModule(new VfModule());\r
+ trs.setCatalogVfModuleCustomization(new VfModuleCustomization());\r
+ trs.setCatalogVfModuleToHeatFiles(new VfModuleToHeatFiles());\r
+ trs.setCatalogVfServiceToResourceCustomization(new ServiceToResourceCustomization());\r
+ trs.setCatalogVlServiceToResourceCustomization(new ServiceToResourceCustomization());\r
+ trs.setCatalogVnfResCustomToVfModuleCustom(new VnfResCustomToVfModuleCustom());\r
+ trs.setCatalogVnfResource(new VnfResource());\r
+ trs.setCatalogVnfResourceCustomization(new VnfResourceCustomization());\r
+ trs.setEnvHeatTemplateUUID("envHeatTemplateUUID");\r
+ trs.setHeatFilesUUID("heatFilesUUID");\r
+ trs.setHeatTemplateUUID("heatTemplateUUID");\r
+ trs.setNetworkTypes(alnt);\r
+ trs.setVolHeatTemplateUUID("volHeatTemplateUUID");\r
+ trs.setSdcCsarHelper(new ISdcCsarHelper() {\r
+\r
+ @Override\r
+ public boolean hasTopology(NodeTemplate arg0) {\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public NodeTemplate getVnfConfig(String arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getVfcListByVf(String arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<Group> getVfModulesByVf(String arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getTypeOfNodeTemplate(NodeTemplate arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getServiceVlList() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getServiceVfList() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getServiceSubstitutionMappingsTypeName() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getServiceNodeTemplatesByType(String arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getServiceNodeTemplates() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getServiceNodeTemplateBySdcType(SdcTypes arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Map<String, Object> getServiceMetadataProperties() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Metadata getServiceMetadata() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<Input> getServiceInputs() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Object getServiceInputLeafValueOfDefaultAsObject(String arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getServiceInputLeafValueOfDefault(String arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getNodeTemplatePropertyLeafValue(NodeTemplate arg0, String arg1) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Object getNodeTemplatePropertyAsObject(NodeTemplate arg0, String arg1) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<Pair<NodeTemplate, NodeTemplate>> getNodeTemplatePairsByReqName(List<NodeTemplate> arg0,\r
+ List<NodeTemplate> arg1, String arg2) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getNodeTemplateCustomizationUuid(NodeTemplate arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getNodeTemplateBySdcType(NodeTemplate arg0, SdcTypes arg1) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getMetadataPropertyValue(Metadata arg0, String arg1) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getMembersOfVfModule(NodeTemplate arg0, Group arg1) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getGroupPropertyLeafValue(Group arg0, String arg1) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Object getGroupPropertyAsObject(Group arg0, String arg1) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfcAsObject(NodeTemplate arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Map<String, Map<String, Object>> getCpPropertiesFromVfc(NodeTemplate arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getCpListByVf(String arg0) {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getConformanceLevel() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<NodeTemplate> getAllottedResources() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Map<String, String> filterNodeTemplatePropertiesByValue(NodeTemplate arg0, FilterType arg1,\r
+ String arg2) {\r
+ return null;\r
+ }\r
+ });\r
+ // trs.setServiceMetadata(new Metadata(new HashMap<>()));\r
+ trs.setServiceToResourceCustomization(new ServiceToResourceCustomization());\r
+ trs.setServiceVersion("1.0");\r
+ trs.setToscaArtifact(new IArtifactInfo() {\r
+\r
+ @Override\r
+ public List<IArtifactInfo> getRelatedArtifacts() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public IArtifactInfo getGeneratedArtifact() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getArtifactVersion() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getArtifactUUID() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getArtifactURL() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getArtifactType() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public Integer getArtifactTimeout() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getArtifactName() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getArtifactDescription() {\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public String getArtifactChecksum() {\r
+ return null;\r
+ }\r
+ });\r
+ trs.setVfTypes(alnt);\r
+ trs.setVnfAlreadyInstalled(true);\r
+ trs.setVolHeatEnvTemplateUUID("volHeatEnvTemplateUUID");\r
+ trs.isVnfAlreadyInstalled();\r
+\r
+ trs.updateResourceStructure(artifactInfo1);\r
+ ToscaResourceInstaller tri = new ToscaResourceInstaller();\r
+\r
+ try {\r
+ tri.installTheResource(trs, vrs);\r
+ } catch (ArtifactInstallerException e) {\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.asdc.installer.heat.tests;\r
+\r
+import java.io.IOException;\r
+import java.io.UnsupportedEncodingException;\r
+import java.net.URISyntaxException;\r
+import java.nio.file.Files;\r
+import java.nio.file.Paths;\r
+import java.security.MessageDigest;\r
+import java.security.NoSuchAlgorithmException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.apache.commons.codec.binary.Base64;\r
+import org.junit.AfterClass;\r
+import org.junit.Before;\r
+import org.junit.BeforeClass;\r
+import org.junit.Test;\r
+import org.mockito.Mockito;\r
+import org.openecomp.mso.asdc.client.ASDCConfiguration;\r
+import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;\r
+import org.openecomp.mso.asdc.client.tests.ASDCControllerTest;\r
+import org.openecomp.mso.asdc.installer.VfResourceStructure;\r
+import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller;\r
+import org.openecomp.mso.db.catalog.CatalogDatabase;\r
+import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;\r
+import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;\r
+import org.openecomp.mso.db.catalog.beans.Service;\r
+import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;\r
+import org.openecomp.mso.db.catalog.beans.ServiceToNetworks;\r
+import org.openecomp.mso.db.catalog.beans.VnfResource;\r
+import org.openecomp.mso.properties.MsoJavaProperties;\r
+import org.openecomp.mso.properties.MsoPropertiesException;\r
+import org.openecomp.mso.properties.MsoPropertiesFactory;\r
+import org.openecomp.sdc.api.IDistributionClient;\r
+import org.openecomp.sdc.api.notification.IArtifactInfo;\r
+import org.openecomp.sdc.api.notification.INotificationData;\r
+import org.openecomp.sdc.api.notification.IResourceInstance;\r
+import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;\r
+import org.openecomp.sdc.api.results.IDistributionClientResult;\r
+import org.openecomp.sdc.utils.DistributionActionResultEnum;\r
+\r
+import mockit.Mock;\r
+import mockit.MockUp;\r
+\r
+public class VfResourceInstallerTest {\r
+ private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();\r
+\r
+ private static String heatExample;\r
+ private static String heatExampleMD5HashBase64;\r
+\r
+ private static INotificationData iNotif;\r
+\r
+ private static IDistributionClientDownloadResult downloadResult;\r
+ private static IDistributionClientDownloadResult downloadCorruptedResult;\r
+\r
+ private static IDistributionClientResult successfulClientInitResult;\r
+ private static IDistributionClientResult unsuccessfulClientInitResult;\r
+\r
+ private static IDistributionClient distributionClient;\r
+\r
+ private static IArtifactInfo artifactInfo1;\r
+\r
+ private static IResourceInstance resource1;\r
+\r
+ private static VfResourceStructure vrs;\r
+\r
+ public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString()\r
+ .substring(5);\r
+ public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString()\r
+ .substring(5);\r
+ public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString()\r
+ .substring(5);\r
+ public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json")\r
+ .toString().substring(5);\r
+ public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader()\r
+ .getResource("mso-with-NULL.json").toString().substring(5);\r
+\r
+ @BeforeClass\r
+ public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException,\r
+ NoSuchAlgorithmException, ArtifactInstallerException {\r
+\r
+ heatExample = new String(Files.readAllBytes(Paths.get(\r
+ ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI())));\r
+ MessageDigest md = MessageDigest.getInstance("MD5");\r
+ byte[] md5Hash = md.digest(heatExample.getBytes());\r
+ heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash);\r
+\r
+ iNotif = Mockito.mock(INotificationData.class);\r
+\r
+ // Create fake ArtifactInfo\r
+ artifactInfo1 = Mockito.mock(IArtifactInfo.class);\r
+ Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(VfResourceInstallerTest.heatExampleMD5HashBase64);\r
+\r
+ Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1");\r
+ Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT);\r
+ Mockito.when(artifactInfo1.getArtifactURL())\r
+ .thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");\r
+ Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1");\r
+ Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1");\r
+\r
+ distributionClient = Mockito.mock(IDistributionClient.class);\r
+\r
+ // Now provision the NotificationData mock\r
+ List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>();\r
+ listArtifact.add(artifactInfo1);\r
+\r
+ // Create fake resource Instance\r
+ resource1 = Mockito.mock(IResourceInstance.class);\r
+// Mockito.when(resource1.getResourceType()).thenReturn("VF");\r
+ Mockito.when(resource1.getResourceName()).thenReturn("resourceName");\r
+ Mockito.when(resource1.getArtifacts()).thenReturn(listArtifact);\r
+\r
+ List<IResourceInstance> resources = new ArrayList<>();\r
+ resources.add(resource1);\r
+\r
+ Mockito.when(iNotif.getResources()).thenReturn(resources);\r
+ Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1");\r
+ Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1");\r
+ Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1");\r
+ Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0");\r
+\r
+ downloadResult = Mockito.mock(IDistributionClientDownloadResult.class);\r
+ Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes());\r
+ Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);\r
+ Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success");\r
+\r
+ downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class);\r
+ Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample + "badone").getBytes());\r
+ Mockito.when(downloadCorruptedResult.getDistributionActionResult())\r
+ .thenReturn(DistributionActionResultEnum.SUCCESS);\r
+ Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success");\r
+\r
+ vrs = new VfResourceStructure(iNotif, resource1);\r
+ try {\r
+ vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult);\r
+ } catch (UnsupportedEncodingException e) {\r
+ e.printStackTrace();\r
+ }\r
+ try {\r
+ vrs.createVfModuleStructures();\r
+ } catch (ArtifactInstallerException e) {\r
+ e.printStackTrace();\r
+ }\r
+ vrs.getNotification();\r
+ vrs.getArtifactsMapByUUID();\r
+ vrs.getCatalogNetworkResourceCustomization();\r
+ vrs.getCatalogResourceCustomization();\r
+ vrs.getCatalogService();\r
+ vrs.getCatalogServiceToAllottedResources();\r
+ vrs.getCatalogServiceToNetworks();\r
+ vrs.getCatalogVnfResource();\r
+ vrs.getResourceInstance();\r
+ vrs.getVfModulesStructureList();\r
+ vrs.getVfModuleStructure();\r
+ vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());\r
+ vrs.setCatalogResourceCustomization(new AllottedResourceCustomization());\r
+ vrs.setCatalogService(new Service());\r
+ vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources());\r
+ vrs.setCatalogServiceToNetworks(new ServiceToNetworks());\r
+ vrs.setCatalogVnfResource(new VnfResource());\r
+ vrs.setSuccessfulDeployment();\r
+ \r
+ AllottedResourceCustomization arc= new AllottedResourceCustomization();\r
+ arc.setModelCustomizationUuid("modelCustomizationUuid");\r
+ List<AllottedResourceCustomization> allottedResources = new ArrayList<>();\r
+ allottedResources.add(arc);\r
+ \r
+ NetworkResourceCustomization nrc = new NetworkResourceCustomization();\r
+ nrc.setModelCustomizationUuid("modelCustomizationUuid");\r
+ List<NetworkResourceCustomization> networkResources = new ArrayList<>();\r
+ networkResources.add(nrc);\r
+ \r
+ new MockUp<CatalogDatabase>() {\r
+ @Mock\r
+ public List<AllottedResourceCustomization> getAllAllottedResourcesByServiceModelUuid(String serviceModelUuid) {\r
+ return allottedResources;\r
+ }\r
+ };\r
+ new MockUp<CatalogDatabase>() {\r
+ @Mock\r
+ public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {\r
+ return networkResources;\r
+ }\r
+ };\r
+ \r
+ // Mock now the ASDC distribution client behavior\r
+ successfulClientInitResult = Mockito.mock(IDistributionClientResult.class);\r
+ Mockito.when(successfulClientInitResult.getDistributionActionResult())\r
+ .thenReturn(DistributionActionResultEnum.SUCCESS);\r
+\r
+ unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class);\r
+ Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult())\r
+ .thenReturn(DistributionActionResultEnum.GENERAL_ERROR);\r
+\r
+ }\r
+\r
+ @Before\r
+ public final void initBeforeEachTest() throws MsoPropertiesException {\r
+ // load the config\r
+ msoPropertiesFactory.removeAllMsoProperties();\r
+ msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP);\r
+ }\r
+\r
+ @AfterClass\r
+ public static final void kill() throws MsoPropertiesException {\r
+\r
+ msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void isResourceAlreadyDeployedAllotedResourceTest() {\r
+ \r
+ Mockito.when(resource1.getResourceType()).thenReturn("VF");\r
+ Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource");\r
+ VfResourceInstaller vfri = new VfResourceInstaller();\r
+\r
+ try {\r
+ vfri.isResourceAlreadyDeployed(vrs);\r
+ } catch (ArtifactInstallerException e) {\r
+ }\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void isResourceAlreadyDeployedTest() {\r
+ \r
+ Mockito.when(resource1.getResourceType()).thenReturn("VF");\r
+ Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource");\r
+ VfResourceInstaller vfri = new VfResourceInstaller();\r
+ \r
+ try {\r
+ vfri.isResourceAlreadyDeployed(vrs);\r
+ } catch (ArtifactInstallerException e) {\r
+ }\r
+ \r
+ }\r
+ @Test\r
+ public void isResourceAlreadyDeployedDuplicateNtwrkTest() {\r
+ \r
+ Mockito.when(resource1.getResourceType()).thenReturn("VL");\r
+ Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource");\r
+ VfResourceInstaller vfri = new VfResourceInstaller();\r
+ \r
+ try {\r
+ vfri.isResourceAlreadyDeployed(vrs);\r
+ } catch (ArtifactInstallerException e) {\r
+ }\r
+ \r
+ }\r
+\r
+ @Test(expected=Exception.class)\r
+ public void installTheResourceTest() {\r
+ VfResourceInstaller vfri = new VfResourceInstaller();\r
+ try {\r
+ vfri.installTheResource(vrs);\r
+ } catch (ArtifactInstallerException e) {\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*- \r
+ * ============LICENSE_START======================================================= \r
+ * ONAP - SO \r
+ * ================================================================================ \r
+ * Copyright (C) 2017 Huawei Intellectual Property. All rights reserved. \r
+ * ================================================================================ \r
+ * Licensed under the Apache License, Version 2.0 (the "License"); \r
+ * you may not use this file except in compliance with the License. \r
+ * You may obtain a copy of the License at \r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0 \r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software \r
+ * distributed under the License is distributed on an "AS IS" BASIS, \r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
+ * See the License for the specific language governing permissions and \r
+ * limitations under the License. \r
+ * ============LICENSE_END========================================================= \r
+ */ \r
+\r
+ \r
+package org.openecomp.mso.bpmn.infrastructure;\r
+\r
+import org.junit.Test;\r
+import org.openecomp.mso.bpmn.common.WorkflowTest;\r
+import org.openecomp.mso.bpmn.mock.StubResponseAAI;\r
+\r
+public class StubResponseAAITest extends WorkflowTest{\r
+\r
+ @Test\r
+ public void testStubResponseAAIforNullAndDefaultInputs()\r
+ {\r
+ try{\r
+ StubResponseAAI.MockPutTunnelXConnect(null, null, null, null, null);\r
+ StubResponseAAI.MockGetAllottedResource(null, null, null, null, null);\r
+ StubResponseAAI.MockPutAllottedResource(null, null, null, null);\r
+ StubResponseAAI.MockPutAllottedResource_500(null, null, null, null);\r
+ StubResponseAAI.MockDeleteAllottedResource(null, null, null, null, null);\r
+ StubResponseAAI.MockPatchAllottedResource(null, null, null, null);\r
+ StubResponseAAI.MockQueryAllottedResourceById(null, null);\r
+ StubResponseAAI.MockGetServiceInstance(null, null, null, null);\r
+ StubResponseAAI.MockGetServiceInstance_404(null, null, null);\r
+ StubResponseAAI.MockGetServiceInstance_500(null, null, null);\r
+ StubResponseAAI.MockGetServiceInstance_500(null, null, null, null);\r
+ StubResponseAAI.MockNodeQueryServiceInstanceByName(null, null);\r
+ StubResponseAAI.MockNodeQueryServiceInstanceByName_404(null);\r
+ StubResponseAAI.MockNodeQueryServiceInstanceByName_500(null);\r
+ StubResponseAAI.MockNodeQueryServiceInstanceById(null, null);\r
+ StubResponseAAI.MockNodeQueryServiceInstanceById_404(null);\r
+ StubResponseAAI.MockNodeQueryServiceInstanceById_500(null);\r
+ StubResponseAAI.MockDeleteServiceInstance(null, null, null, null);\r
+ StubResponseAAI.MockGetServiceInstance(null, null, null, null, 0);\r
+ StubResponseAAI.MockGetServiceInstance(null, null, null, 0);\r
+ StubResponseAAI.MockDeleteServiceInstance(null, null, null, null, 0);\r
+ StubResponseAAI.MockDeleteServiceInstance(null, null, null, 0);\r
+ StubResponseAAI.MockDeleteServiceInstance_404(null, null, null, null);\r
+ StubResponseAAI.MockDeleteServiceInstance_500(null, null, null, null);\r
+ StubResponseAAI.MockPutServiceInstance(null, null, null, null);\r
+ StubResponseAAI.MockPutServiceInstance_500(null, null, null);\r
+ StubResponseAAI.MockGetServiceSubscription(null, null, null);\r
+ StubResponseAAI.MockDeleteServiceSubscription(null, null, 0);\r
+ StubResponseAAI.MockDeleteServiceInstanceId(null, null, null);\r
+ StubResponseAAI.MockPutServiceSubscription(null, null);\r
+ StubResponseAAI.MockGetServiceSubscription(null, null, 0);\r
+ StubResponseAAI.MockGetCustomer(null, null);\r
+ StubResponseAAI.MockDeleteCustomer(null);\r
+ StubResponseAAI.MockPutCustomer(null);\r
+ StubResponseAAI.MockPutCustomer_500(null);\r
+ StubResponseAAI.MockGetGenericVnfById(null, null);\r
+ StubResponseAAI.MockGetGenericVnfById(null, null, 0);\r
+ StubResponseAAI.MockGetGenericVnfByIdWithPriority(null, 0, null);\r
+ StubResponseAAI.MockGetGenericVnfByIdWithPriority(null, null, 0, null, 0);\r
+ StubResponseAAI.MockGetGenericVnfByIdWithDepth(null, 0, null);\r
+ StubResponseAAI.MockGetGenericVnfById_404(null);\r
+ StubResponseAAI.MockGetGenericVnfById_500(null);\r
+ StubResponseAAI.MockGetGenericVnfByName(null, null);\r
+ StubResponseAAI.MockGetGenericVnfByNameWithDepth(null, 0, null);\r
+ StubResponseAAI.MockGetGenericVnfByName_404(null);\r
+ StubResponseAAI.MockDeleteGenericVnf(null, null);\r
+ StubResponseAAI.MockDeleteGenericVnf(null, null, 0);\r
+ StubResponseAAI.MockDeleteGenericVnf_500(null, null);\r
+ StubResponseAAI.MockPutGenericVnf(null);\r
+ StubResponseAAI.MockPutGenericVnf(null, null, 0);\r
+ StubResponseAAI.MockPutGenericVnf(null, 0);\r
+ StubResponseAAI.MockPutGenericVnf_Bad(null, 0);\r
+ StubResponseAAI.MockPatchGenericVnf(null);\r
+ StubResponseAAI.MockGetVceById(null, null);\r
+ StubResponseAAI.MockGetVceByName(null, null);\r
+ StubResponseAAI.MockDeleteVce(null, null, 0);\r
+ StubResponseAAI.MockPutVce(null);\r
+ StubResponseAAI.MockGetGenericVceByNameWithDepth(null, 0, null);\r
+ StubResponseAAI.MockGetVceGenericQuery(null, 0, 0, null);\r
+ StubResponseAAI.MockGetTenantGenericQuery(null, null, null);\r
+ StubResponseAAI.MockGetTenant(null, null);\r
+ StubResponseAAI.MockGetNetwork(null, null, 0);\r
+ StubResponseAAI.MockGetNetworkByIdWithDepth(null, null, null);\r
+ StubResponseAAI.MockGetNetworkCloudRegion(null, null);\r
+ StubResponseAAI.MockGetNetworkByName(null, null);\r
+ StubResponseAAI.MockGetNetworkByName_404(null, null);\r
+ StubResponseAAI.MockGetNetworkCloudRegion_404(null);\r
+ StubResponseAAI.MockPutNetwork(null, 0, null);\r
+ StubResponseAAI.MockPutNetwork(null, null, 0);\r
+ StubResponseAAI.MockGetNetworkName(null, null, 0);\r
+ StubResponseAAI.MockGetNetworkVpnBinding(null, null);\r
+ StubResponseAAI.MockGetNetworkPolicy(null, null);\r
+ StubResponseAAI.MockGetNetworkVpnBinding(null, null, 0);\r
+ StubResponseAAI.MockGetNetworkPolicy(null, null, 0);\r
+ StubResponseAAI.MockGetNetworkTableReference(null, null);\r
+ StubResponseAAI.MockPutNetworkIdWithDepth(null, null, null);\r
+ StubResponseAAI.MockGetNetworkPolicyfqdn(null, null, 0);\r
+ StubResponseAAI.MockGetNetworkRouteTable(null, null, 0);\r
+ StubResponseAAI.MockPatchVfModuleId(null, null);\r
+ StubResponseAAI.MockVNFAdapterRestVfModule();\r
+ StubResponseAAI.MockDBUpdateVfModule();\r
+ StubResponseAAI.MockSDNCAdapterVfModule();\r
+ StubResponseAAI.MockAAIVfModule();\r
+ StubResponseAAI.MockGetCloudRegion(null, 0, null);\r
+ StubResponseAAI.MockGetVolumeGroupById(null, null, null);\r
+ StubResponseAAI.MockPutVolumeGroupById(null, null, null, 0);\r
+ StubResponseAAI.MockGetVolumeGroupByName(null, null, null, 0);\r
+ StubResponseAAI.MockDeleteVolumeGroupById(null, null, null, 0);\r
+ StubResponseAAI.MockGetVolumeGroupByName_404(null, null);\r
+ StubResponseAAI.MockDeleteVolumeGroup(null, null, null);\r
+ StubResponseAAI.MockGetVfModuleId(null, null, null, 0);\r
+ StubResponseAAI.MockGetVfModuleByNameWithDepth(null, null, 0, null, 0);\r
+ StubResponseAAI.MockGetVfModuleIdNoResponse(null, null, null);\r
+ StubResponseAAI.MockPutVfModuleIdNoResponse(null, null, null);\r
+ StubResponseAAI.MockPutVfModuleId(null, null);\r
+ StubResponseAAI.MockPutVfModuleId(null, null, 0);\r
+ StubResponseAAI.MockDeleteVfModuleId(null, null, null, 0);\r
+ StubResponseAAI.MockAAIVfModuleBadPatch(null, 0);\r
+ StubResponseAAI.MockGetPserverByVnfId(null, null, 0);\r
+ StubResponseAAI.MockGetGenericVnfsByVnfId(null, null, 0);\r
+ StubResponseAAI.MockSetInMaintFlagByVnfId(null, 0);\r
+ StubResponseAAI.MockGetVceById();\r
+ StubResponseAAI.MockGetVceByName();\r
+ StubResponseAAI.MockPutVce();\r
+ StubResponseAAI.MockDeleteVce();\r
+ StubResponseAAI.MockDeleteVce_404();\r
+ StubResponseAAI.MockDeleteServiceSubscription();\r
+ StubResponseAAI.MockGetServiceSubscription();\r
+ StubResponseAAI.MockGetServiceSubscription_200Empty();\r
+ StubResponseAAI.MockGetServiceSubscription_404();\r
+ StubResponseAAI.MockGENPSIPutServiceInstance();\r
+ StubResponseAAI.MockGENPSIPutServiceSubscription();\r
+ StubResponseAAI.MockGENPSIPutServiceInstance_get500();\r
+ StubResponseAAI.MockGetGenericVnfById();\r
+ StubResponseAAI.MockGetGenericVnfById_404();\r
+ StubResponseAAI.MockGetGenericVnfByName();\r
+ StubResponseAAI.MockGetGenericVnfByName_hasRelationships();\r
+ StubResponseAAI.MockGetGenericVnfById_hasRelationships();\r
+ StubResponseAAI.MockGetGenericVnfById_500();\r
+ StubResponseAAI.MockGetGenericVnfByName_404();\r
+ StubResponseAAI.MockPutGenericVnf();\r
+ StubResponseAAI.MockPutGenericVnf_400();\r
+ StubResponseAAI.MockDeleteGenericVnf();\r
+ StubResponseAAI.MockDeleteGenericVnf_404();\r
+ StubResponseAAI.MockDeleteGenericVnf_500();\r
+ StubResponseAAI.MockDeleteGenericVnf_412();\r
+ }\r
+ catch(Exception ex)\r
+ {\r
+ \r
+ System.err.println(ex);\r
+ }\r
+ \r
+ }\r
+}\r