\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<>();\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
+ 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<>();\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