From 96b5a685d0c3afddb632e4a68ca7483f933b55dc Mon Sep 17 00:00:00 2001 From: Rob Daugherty Date: Fri, 9 Mar 2018 15:02:18 -0500 Subject: Revert Reduce log noise/warnings This reverts commit 327b17ab250b4c17cf3f91f5e4cd9bffd89f3d1e. It is seriously impeding our ability complete the promised merge of AT&T 1802 code. While I'm all for coding standards, if we are serious about using spaces instead of tabs, then I think we need to (1) agree with the community when this will happen, (2) do consistently in all files, and (3) enforce it. Change-Id: Ib9b996f6b6c7d81ac9ac95d58b0c7d8cc39675ff Issue-ID: SO-368 Signed-off-by: Rob Daugherty --- .../heat/tests/ToscaResourceInstallerTest.java | 942 ++++++++++----------- .../heat/tests/VfResourceInstallerTest.java | 393 +++++---- 2 files changed, 667 insertions(+), 668 deletions(-) (limited to 'asdc-controller/src/test/java/org/openecomp/mso/asdc/installer') diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java index 48e12c26be..9c20a084c3 100644 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/ToscaResourceInstallerTest.java @@ -84,475 +84,475 @@ import mockit.MockUp; public class ToscaResourceInstallerTest { - private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - - private static String heatExample; - private static String heatExampleMD5HashBase64; - - private static INotificationData iNotif; - - private static IDistributionClientDownloadResult downloadResult; - private static IDistributionClientDownloadResult downloadCorruptedResult; - - private static IDistributionClientResult successfulClientInitResult; - private static IDistributionClientResult unsuccessfulClientInitResult; - - private static IDistributionClient distributionClient; - - private static IArtifactInfo artifactInfo1; - - private static IResourceInstance resource1; - - private static VfResourceStructure vrs; - - public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString() - .substring(5); - public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString() - .substring(5); - public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString() - .substring(5); - public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json") - .toString().substring(5); - public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader() - .getResource("mso-with-NULL.json").toString().substring(5); - - @BeforeClass - public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException, - NoSuchAlgorithmException, ArtifactInstallerException { - - heatExample = new String(Files.readAllBytes(Paths.get( - ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI()))); - MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] md5Hash = md.digest(heatExample.getBytes()); - heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash); - - iNotif = Mockito.mock(INotificationData.class); - - // Create fake ArtifactInfo - artifactInfo1 = Mockito.mock(IArtifactInfo.class); - Mockito.when(artifactInfo1.getArtifactChecksum()) - .thenReturn(ToscaResourceInstallerTest.heatExampleMD5HashBase64); - - Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1"); - Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT); - Mockito.when(artifactInfo1.getArtifactURL()) - .thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); - Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1"); - Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1"); - - distributionClient = Mockito.mock(IDistributionClient.class); - - // Now provision the NotificationData mock - List listArtifact = new ArrayList<>(); - listArtifact.add(artifactInfo1); - - // Create fake resource Instance - resource1 = Mockito.mock(IResourceInstance.class); - // Mockito.when(resource1.getResourceType()).thenReturn("VF"); - Mockito.when(resource1.getResourceName()).thenReturn("resourceName"); - Mockito.when(resource1.getArtifacts()).thenReturn(listArtifact); - - List resources = new ArrayList<>(); - resources.add(resource1); - - Mockito.when(iNotif.getResources()).thenReturn(resources); - Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1"); - Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1"); - Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1"); - Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0"); - - downloadResult = Mockito.mock(IDistributionClientDownloadResult.class); - Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes()); - Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); - Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success"); - - downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class); - Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample + "badone").getBytes()); - Mockito.when(downloadCorruptedResult.getDistributionActionResult()) - .thenReturn(DistributionActionResultEnum.SUCCESS); - Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success"); - - vrs = new VfResourceStructure(iNotif, resource1); - try { - vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - try { - vrs.createVfModuleStructures(); - } catch (ArtifactInstallerException e) { - e.printStackTrace(); - } - vrs.getNotification(); - vrs.getArtifactsMapByUUID(); - vrs.getCatalogNetworkResourceCustomization(); - vrs.getCatalogResourceCustomization(); - vrs.getCatalogService(); - vrs.getCatalogServiceToAllottedResources(); - vrs.getCatalogServiceToNetworks(); - vrs.getCatalogVnfResource(); - vrs.getResourceInstance(); - vrs.getVfModulesStructureList(); - vrs.getVfModuleStructure(); - vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization()); - vrs.setCatalogResourceCustomization(new AllottedResourceCustomization()); - vrs.setCatalogService(new Service()); - vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources()); - vrs.setCatalogServiceToNetworks(new ServiceToNetworks()); - vrs.setCatalogVnfResource(new VnfResource()); - vrs.setSuccessfulDeployment(); - - AllottedResourceCustomization arc = new AllottedResourceCustomization(); - arc.setModelCustomizationUuid("modelCustomizationUuid"); - List allottedResources = new ArrayList<>(); - allottedResources.add(arc); - - NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - nrc.setModelCustomizationUuid("modelCustomizationUuid"); - List networkResources = new ArrayList<>(); - networkResources.add(nrc); - - new MockUp() { - @Mock - public List getAllAllottedResourcesByServiceModelUuid( - String serviceModelUuid) { - return allottedResources; - } - }; - new MockUp() { - @Mock - public List getAllNetworksByServiceModelUuid(String serviceModelUuid) { - return networkResources; - } - }; - - // Mock now the ASDC distribution client behavior - successfulClientInitResult = Mockito.mock(IDistributionClientResult.class); - Mockito.when(successfulClientInitResult.getDistributionActionResult()) - .thenReturn(DistributionActionResultEnum.SUCCESS); - - unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class); - Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult()) - .thenReturn(DistributionActionResultEnum.GENERAL_ERROR); - - } - - @Before - public final void initBeforeEachTest() throws MsoPropertiesException { - // load the config - msoPropertiesFactory.removeAllMsoProperties(); - msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); - } - - @AfterClass - public static final void kill() throws MsoPropertiesException { - - msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC); - - } - - @Test - public void isResourceAlreadyDeployedAllotedResourceTest() { - Mockito.when(resource1.getResourceType()).thenReturn("VF"); - Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource"); - ToscaResourceInstaller tri = new ToscaResourceInstaller(); - - try { - tri.isResourceAlreadyDeployed(vrs); - } catch (ArtifactInstallerException e) { - } - } - - @Test(expected = Exception.class) - public void installTheResourceTest() { - - ToscaResourceStructure trs = new ToscaResourceStructure(); - trs.getAllottedResource(); - trs.getAllottedList(); - trs.getCatalogAllottedResourceCustomization(); - trs.getCatalogAllottedServiceToResourceCustomization(); - trs.getCatalogNetworkResource(); - trs.getCatalogNetworkResourceCustomization(); - trs.getCatalogResourceCustomization(); - trs.getCatalogService(); - trs.getCatalogTempNetworkHeatTemplateLookup(); - trs.getCatalogToscaCsar(); - trs.getCatalogVfModule(); - trs.getCatalogVfModuleCustomization(); - trs.getCatalogVfModuleToHeatFiles(); - trs.getCatalogVfServiceToResourceCustomization(); - trs.getCatalogVlServiceToResourceCustomization(); - trs.getCatalogVnfResCustomToVfModuleCustom(); - trs.getCatalogVnfResource(); - trs.getCatalogVnfResourceCustomization(); - trs.getEnvHeatTemplateUUID(); - trs.getHeatFilesUUID(); - trs.getHeatTemplateUUID(); - trs.getNetworkTypes(); - trs.getSdcCsarHelper(); - trs.getServiceMetadata(); - trs.getServiceToResourceCustomization(); - trs.getServiceVersion(); - trs.getToscaArtifact(); - trs.getVfTypes(); - trs.getVolHeatEnvTemplateUUID(); - trs.getVolHeatTemplateUUID(); - - NodeTemplate nodeTemplate = Mockito.mock(NodeTemplate.class); - List alnt = new ArrayList<>(); - trs.setAllottedList(alnt); - trs.setAllottedResource(new AllottedResource()); - trs.setCatalogAllottedResourceCustomization(new AllottedResourceCustomization()); - trs.setCatalogAllottedServiceToResourceCustomization(new ServiceToResourceCustomization()); - trs.setCatalogNetworkResource(new NetworkResource()); - trs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization()); - trs.setCatalogResourceCustomization(new AllottedResourceCustomization()); - trs.setCatalogService(new Service()); - trs.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup()); - trs.setCatalogToscaCsar(new ToscaCsar()); - trs.setCatalogVfModule(new VfModule()); - trs.setCatalogVfModuleCustomization(new VfModuleCustomization()); - trs.setCatalogVfModuleToHeatFiles(new VfModuleToHeatFiles()); - trs.setCatalogVfServiceToResourceCustomization(new ServiceToResourceCustomization()); - trs.setCatalogVlServiceToResourceCustomization(new ServiceToResourceCustomization()); - trs.setCatalogVnfResCustomToVfModuleCustom(new VnfResCustomToVfModuleCustom()); - trs.setCatalogVnfResource(new VnfResource()); - trs.setCatalogVnfResourceCustomization(new VnfResourceCustomization()); - trs.setEnvHeatTemplateUUID("envHeatTemplateUUID"); - trs.setHeatFilesUUID("heatFilesUUID"); - trs.setHeatTemplateUUID("heatTemplateUUID"); - trs.setNetworkTypes(alnt); - trs.setVolHeatTemplateUUID("volHeatTemplateUUID"); - trs.setSdcCsarHelper(new ISdcCsarHelper() { - - @Override - public boolean hasTopology(NodeTemplate arg0) { - return false; - } - - @Override - public NodeTemplate getVnfConfig(String arg0) { - return null; - } - - @Override - public List getVfcListByVf(String arg0) { - return null; - } - - @Override - public List getVfModulesByVf(String arg0) { - return null; - } - - @Override - public String getTypeOfNodeTemplate(NodeTemplate arg0) { - return null; - } - - @Override - public List getServiceVlList() { - return null; - } - - @Override - public List getServiceVfList() { - return null; - } - - @Override - public String getServiceSubstitutionMappingsTypeName() { - return null; - } - - @Override - public List getServiceNodeTemplatesByType(String arg0) { - return null; - } - - @Override - public List getServiceNodeTemplates() { - return null; - } - - @Override - public List getServiceNodeTemplateBySdcType(SdcTypes arg0) { - return null; - } - - @Override - public Map getServiceMetadataProperties() { - return null; - } - - @Override - public Metadata getServiceMetadata() { - return null; - } - - @Override - public List getServiceInputs() { - return null; - } - - @Override - public Object getServiceInputLeafValueOfDefaultAsObject(String arg0) { - return null; - } - - @Override - public String getServiceInputLeafValueOfDefault(String arg0) { - return null; - } - - @Override - public String getNodeTemplatePropertyLeafValue(NodeTemplate arg0, String arg1) { - return null; - } - - @Override - public Object getNodeTemplatePropertyAsObject(NodeTemplate arg0, String arg1) { - return null; - } - - @Override - public List> getNodeTemplatePairsByReqName(List arg0, - List arg1, String arg2) { - return null; - } - - @Override - public String getNodeTemplateCustomizationUuid(NodeTemplate arg0) { - return null; - } - - @Override - public List getNodeTemplateChildren(NodeTemplate arg0) { - return null; - } - - @Override - public List getNodeTemplateBySdcType(NodeTemplate arg0, SdcTypes arg1) { - return null; - } - - @Override - public String getMetadataPropertyValue(Metadata arg0, String arg1) { - return null; - } - - @Override - public List getMembersOfVfModule(NodeTemplate arg0, Group arg1) { - return null; - } - - @Override - public String getGroupPropertyLeafValue(Group arg0, String arg1) { - return null; - } - - @Override - public Object getGroupPropertyAsObject(Group arg0, String arg1) { - return null; - } - - @Override - public Map> getCpPropertiesFromVfcAsObject(NodeTemplate arg0) { - return null; - } - - @Override - public Map> getCpPropertiesFromVfc(NodeTemplate arg0) { - return null; - } - - @Override - public List getCpListByVf(String arg0) { - return null; - } - - @Override - public String getConformanceLevel() { - return null; - } - - @Override - public List getAllottedResources() { - return null; - } - - @Override - public Map filterNodeTemplatePropertiesByValue(NodeTemplate arg0, FilterType arg1, - String arg2) { - return null; - } - }); - // trs.setServiceMetadata(new Metadata(new HashMap<>())); - trs.setServiceToResourceCustomization(new ServiceToResourceCustomization()); - trs.setServiceVersion("1.0"); - trs.setToscaArtifact(new IArtifactInfo() { - - @Override - public List getRelatedArtifacts() { - return null; - } - - @Override - public IArtifactInfo getGeneratedArtifact() { - return null; - } - - @Override - public String getArtifactVersion() { - return null; - } - - @Override - public String getArtifactUUID() { - return null; - } - - @Override - public String getArtifactURL() { - return null; - } - - @Override - public String getArtifactType() { - return null; - } - - @Override - public Integer getArtifactTimeout() { - return null; - } - - @Override - public String getArtifactName() { - return null; - } - - @Override - public String getArtifactDescription() { - return null; - } - - @Override - public String getArtifactChecksum() { - return null; - } - }); - trs.setVfTypes(alnt); - trs.setVnfAlreadyInstalled(true); - trs.setVolHeatEnvTemplateUUID("volHeatEnvTemplateUUID"); - trs.isVnfAlreadyInstalled(); - - trs.updateResourceStructure(artifactInfo1); - ToscaResourceInstaller tri = new ToscaResourceInstaller(); - - try { - tri.installTheResource(trs, vrs); - } catch (ArtifactInstallerException e) { - } - } + private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + + private static String heatExample; + private static String heatExampleMD5HashBase64; + + private static INotificationData iNotif; + + private static IDistributionClientDownloadResult downloadResult; + private static IDistributionClientDownloadResult downloadCorruptedResult; + + private static IDistributionClientResult successfulClientInitResult; + private static IDistributionClientResult unsuccessfulClientInitResult; + + private static IDistributionClient distributionClient; + + private static IArtifactInfo artifactInfo1; + + private static IResourceInstance resource1; + + private static VfResourceStructure vrs; + + public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString() + .substring(5); + public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString() + .substring(5); + public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString() + .substring(5); + public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json") + .toString().substring(5); + public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader() + .getResource("mso-with-NULL.json").toString().substring(5); + + @BeforeClass + public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException, + NoSuchAlgorithmException, ArtifactInstallerException { + + heatExample = new String(Files.readAllBytes(Paths.get( + ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI()))); + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] md5Hash = md.digest(heatExample.getBytes()); + heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash); + + iNotif = Mockito.mock(INotificationData.class); + + // Create fake ArtifactInfo + artifactInfo1 = Mockito.mock(IArtifactInfo.class); + Mockito.when(artifactInfo1.getArtifactChecksum()) + .thenReturn(ToscaResourceInstallerTest.heatExampleMD5HashBase64); + + Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1"); + Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT); + Mockito.when(artifactInfo1.getArtifactURL()) + .thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); + Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1"); + Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1"); + + distributionClient = Mockito.mock(IDistributionClient.class); + + // Now provision the NotificationData mock + List listArtifact = new ArrayList<>(); + listArtifact.add(artifactInfo1); + + // Create fake resource Instance + resource1 = Mockito.mock(IResourceInstance.class); + // Mockito.when(resource1.getResourceType()).thenReturn("VF"); + Mockito.when(resource1.getResourceName()).thenReturn("resourceName"); + Mockito.when(resource1.getArtifacts()).thenReturn(listArtifact); + + List resources = new ArrayList<>(); + resources.add(resource1); + + Mockito.when(iNotif.getResources()).thenReturn(resources); + Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1"); + Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1"); + Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1"); + Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0"); + + downloadResult = Mockito.mock(IDistributionClientDownloadResult.class); + Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes()); + Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); + Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success"); + + downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class); + Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample + "badone").getBytes()); + Mockito.when(downloadCorruptedResult.getDistributionActionResult()) + .thenReturn(DistributionActionResultEnum.SUCCESS); + Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success"); + + vrs = new VfResourceStructure(iNotif, resource1); + try { + vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + try { + vrs.createVfModuleStructures(); + } catch (ArtifactInstallerException e) { + e.printStackTrace(); + } + vrs.getNotification(); + vrs.getArtifactsMapByUUID(); + vrs.getCatalogNetworkResourceCustomization(); + vrs.getCatalogResourceCustomization(); + vrs.getCatalogService(); + vrs.getCatalogServiceToAllottedResources(); + vrs.getCatalogServiceToNetworks(); + vrs.getCatalogVnfResource(); + vrs.getResourceInstance(); + vrs.getVfModulesStructureList(); + vrs.getVfModuleStructure(); + vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization()); + vrs.setCatalogResourceCustomization(new AllottedResourceCustomization()); + vrs.setCatalogService(new Service()); + vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources()); + vrs.setCatalogServiceToNetworks(new ServiceToNetworks()); + vrs.setCatalogVnfResource(new VnfResource()); + vrs.setSuccessfulDeployment(); + + AllottedResourceCustomization arc = new AllottedResourceCustomization(); + arc.setModelCustomizationUuid("modelCustomizationUuid"); + List allottedResources = new ArrayList<>(); + allottedResources.add(arc); + + NetworkResourceCustomization nrc = new NetworkResourceCustomization(); + nrc.setModelCustomizationUuid("modelCustomizationUuid"); + List networkResources = new ArrayList<>(); + networkResources.add(nrc); + + new MockUp() { + @Mock + public List getAllAllottedResourcesByServiceModelUuid( + String serviceModelUuid) { + return allottedResources; + } + }; + new MockUp() { + @Mock + public List getAllNetworksByServiceModelUuid(String serviceModelUuid) { + return networkResources; + } + }; + + // Mock now the ASDC distribution client behavior + successfulClientInitResult = Mockito.mock(IDistributionClientResult.class); + Mockito.when(successfulClientInitResult.getDistributionActionResult()) + .thenReturn(DistributionActionResultEnum.SUCCESS); + + unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class); + Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult()) + .thenReturn(DistributionActionResultEnum.GENERAL_ERROR); + + } + + @Before + public final void initBeforeEachTest() throws MsoPropertiesException { + // load the config + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + } + + @AfterClass + public static final void kill() throws MsoPropertiesException { + + msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC); + + } + + @Test + public void isResourceAlreadyDeployedAllotedResourceTest() { + Mockito.when(resource1.getResourceType()).thenReturn("VF"); + Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource"); + ToscaResourceInstaller tri = new ToscaResourceInstaller(); + + try { + tri.isResourceAlreadyDeployed(vrs); + } catch (ArtifactInstallerException e) { + } + } + + @Test(expected=Exception.class) + public void installTheResourceTest() { + + ToscaResourceStructure trs = new ToscaResourceStructure(); + trs.getAllottedResource(); + trs.getAllottedList(); + trs.getCatalogAllottedResourceCustomization(); + trs.getCatalogAllottedServiceToResourceCustomization(); + trs.getCatalogNetworkResource(); + trs.getCatalogNetworkResourceCustomization(); + trs.getCatalogResourceCustomization(); + trs.getCatalogService(); + trs.getCatalogTempNetworkHeatTemplateLookup(); + trs.getCatalogToscaCsar(); + trs.getCatalogVfModule(); + trs.getCatalogVfModuleCustomization(); + trs.getCatalogVfModuleToHeatFiles(); + trs.getCatalogVfServiceToResourceCustomization(); + trs.getCatalogVlServiceToResourceCustomization(); + trs.getCatalogVnfResCustomToVfModuleCustom(); + trs.getCatalogVnfResource(); + trs.getCatalogVnfResourceCustomization(); + trs.getEnvHeatTemplateUUID(); + trs.getHeatFilesUUID(); + trs.getHeatTemplateUUID(); + trs.getNetworkTypes(); + trs.getSdcCsarHelper(); + trs.getServiceMetadata(); + trs.getServiceToResourceCustomization(); + trs.getServiceVersion(); + trs.getToscaArtifact(); + trs.getVfTypes(); + trs.getVolHeatEnvTemplateUUID(); + trs.getVolHeatTemplateUUID(); + + NodeTemplate nodeTemplate = Mockito.mock(NodeTemplate.class); + List alnt = new ArrayList<>(); + trs.setAllottedList(alnt); + trs.setAllottedResource(new AllottedResource()); + trs.setCatalogAllottedResourceCustomization(new AllottedResourceCustomization()); + trs.setCatalogAllottedServiceToResourceCustomization(new ServiceToResourceCustomization()); + trs.setCatalogNetworkResource(new NetworkResource()); + trs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization()); + trs.setCatalogResourceCustomization(new AllottedResourceCustomization()); + trs.setCatalogService(new Service()); + trs.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup()); + trs.setCatalogToscaCsar(new ToscaCsar()); + trs.setCatalogVfModule(new VfModule()); + trs.setCatalogVfModuleCustomization(new VfModuleCustomization()); + trs.setCatalogVfModuleToHeatFiles(new VfModuleToHeatFiles()); + trs.setCatalogVfServiceToResourceCustomization(new ServiceToResourceCustomization()); + trs.setCatalogVlServiceToResourceCustomization(new ServiceToResourceCustomization()); + trs.setCatalogVnfResCustomToVfModuleCustom(new VnfResCustomToVfModuleCustom()); + trs.setCatalogVnfResource(new VnfResource()); + trs.setCatalogVnfResourceCustomization(new VnfResourceCustomization()); + trs.setEnvHeatTemplateUUID("envHeatTemplateUUID"); + trs.setHeatFilesUUID("heatFilesUUID"); + trs.setHeatTemplateUUID("heatTemplateUUID"); + trs.setNetworkTypes(alnt); + trs.setVolHeatTemplateUUID("volHeatTemplateUUID"); + trs.setSdcCsarHelper(new ISdcCsarHelper() { + + @Override + public boolean hasTopology(NodeTemplate arg0) { + return false; + } + + @Override + public NodeTemplate getVnfConfig(String arg0) { + return null; + } + + @Override + public List getVfcListByVf(String arg0) { + return null; + } + + @Override + public List getVfModulesByVf(String arg0) { + return null; + } + + @Override + public String getTypeOfNodeTemplate(NodeTemplate arg0) { + return null; + } + + @Override + public List getServiceVlList() { + return null; + } + + @Override + public List getServiceVfList() { + return null; + } + + @Override + public String getServiceSubstitutionMappingsTypeName() { + return null; + } + + @Override + public List getServiceNodeTemplatesByType(String arg0) { + return null; + } + + @Override + public List getServiceNodeTemplates() { + return null; + } + + @Override + public List getServiceNodeTemplateBySdcType(SdcTypes arg0) { + return null; + } + + @Override + public Map getServiceMetadataProperties() { + return null; + } + + @Override + public Metadata getServiceMetadata() { + return null; + } + + @Override + public List getServiceInputs() { + return null; + } + + @Override + public Object getServiceInputLeafValueOfDefaultAsObject(String arg0) { + return null; + } + + @Override + public String getServiceInputLeafValueOfDefault(String arg0) { + return null; + } + + @Override + public String getNodeTemplatePropertyLeafValue(NodeTemplate arg0, String arg1) { + return null; + } + + @Override + public Object getNodeTemplatePropertyAsObject(NodeTemplate arg0, String arg1) { + return null; + } + + @Override + public List> getNodeTemplatePairsByReqName(List arg0, + List arg1, String arg2) { + return null; + } + + @Override + public String getNodeTemplateCustomizationUuid(NodeTemplate arg0) { + return null; + } + + @Override + public List getNodeTemplateChildren(NodeTemplate arg0) { + return null; + } + + @Override + public List getNodeTemplateBySdcType(NodeTemplate arg0, SdcTypes arg1) { + return null; + } + + @Override + public String getMetadataPropertyValue(Metadata arg0, String arg1) { + return null; + } + + @Override + public List getMembersOfVfModule(NodeTemplate arg0, Group arg1) { + return null; + } + + @Override + public String getGroupPropertyLeafValue(Group arg0, String arg1) { + return null; + } + + @Override + public Object getGroupPropertyAsObject(Group arg0, String arg1) { + return null; + } + + @Override + public Map> getCpPropertiesFromVfcAsObject(NodeTemplate arg0) { + return null; + } + + @Override + public Map> getCpPropertiesFromVfc(NodeTemplate arg0) { + return null; + } + + @Override + public List getCpListByVf(String arg0) { + return null; + } + + @Override + public String getConformanceLevel() { + return null; + } + + @Override + public List getAllottedResources() { + return null; + } + + @Override + public Map filterNodeTemplatePropertiesByValue(NodeTemplate arg0, FilterType arg1, + String arg2) { + return null; + } + }); + // trs.setServiceMetadata(new Metadata(new HashMap<>())); + trs.setServiceToResourceCustomization(new ServiceToResourceCustomization()); + trs.setServiceVersion("1.0"); + trs.setToscaArtifact(new IArtifactInfo() { + + @Override + public List getRelatedArtifacts() { + return null; + } + + @Override + public IArtifactInfo getGeneratedArtifact() { + return null; + } + + @Override + public String getArtifactVersion() { + return null; + } + + @Override + public String getArtifactUUID() { + return null; + } + + @Override + public String getArtifactURL() { + return null; + } + + @Override + public String getArtifactType() { + return null; + } + + @Override + public Integer getArtifactTimeout() { + return null; + } + + @Override + public String getArtifactName() { + return null; + } + + @Override + public String getArtifactDescription() { + return null; + } + + @Override + public String getArtifactChecksum() { + return null; + } + }); + trs.setVfTypes(alnt); + trs.setVnfAlreadyInstalled(true); + trs.setVolHeatEnvTemplateUUID("volHeatEnvTemplateUUID"); + trs.isVnfAlreadyInstalled(); + + trs.updateResourceStructure(artifactInfo1); + ToscaResourceInstaller tri = new ToscaResourceInstaller(); + + try { + tri.installTheResource(trs, vrs); + } catch (ArtifactInstallerException e) { + } + } } diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java index 04a9ea0a1e..e2239dc952 100644 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/heat/tests/VfResourceInstallerTest.java @@ -63,219 +63,218 @@ import mockit.Mock; import mockit.MockUp; public class VfResourceInstallerTest { - private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); - private static String heatExample; - private static String heatExampleMD5HashBase64; + private static String heatExample; + private static String heatExampleMD5HashBase64; - private static INotificationData iNotif; + private static INotificationData iNotif; - private static IDistributionClientDownloadResult downloadResult; - private static IDistributionClientDownloadResult downloadCorruptedResult; + private static IDistributionClientDownloadResult downloadResult; + private static IDistributionClientDownloadResult downloadCorruptedResult; - private static IDistributionClientResult successfulClientInitResult; - private static IDistributionClientResult unsuccessfulClientInitResult; + private static IDistributionClientResult successfulClientInitResult; + private static IDistributionClientResult unsuccessfulClientInitResult; - private static IDistributionClient distributionClient; + private static IDistributionClient distributionClient; - private static IArtifactInfo artifactInfo1; + private static IArtifactInfo artifactInfo1; - private static IResourceInstance resource1; + private static IResourceInstance resource1; - private static VfResourceStructure vrs; + private static VfResourceStructure vrs; - public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString() - .substring(5); - public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString() - .substring(5); - public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString() - .substring(5); - public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json") - .toString().substring(5); - public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader() - .getResource("mso-with-NULL.json").toString().substring(5); + public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString() + .substring(5); + public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString() + .substring(5); + public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString() + .substring(5); + public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json") + .toString().substring(5); + public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader() + .getResource("mso-with-NULL.json").toString().substring(5); - @BeforeClass - public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException, - NoSuchAlgorithmException, ArtifactInstallerException { + @BeforeClass + public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException, + NoSuchAlgorithmException, ArtifactInstallerException { - heatExample = new String(Files.readAllBytes(Paths.get( - ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI()))); - MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] md5Hash = md.digest(heatExample.getBytes()); - heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash); + heatExample = new String(Files.readAllBytes(Paths.get( + ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI()))); + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] md5Hash = md.digest(heatExample.getBytes()); + heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash); - iNotif = Mockito.mock(INotificationData.class); + iNotif = Mockito.mock(INotificationData.class); - // Create fake ArtifactInfo - artifactInfo1 = Mockito.mock(IArtifactInfo.class); - Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(VfResourceInstallerTest.heatExampleMD5HashBase64); + // Create fake ArtifactInfo + artifactInfo1 = Mockito.mock(IArtifactInfo.class); + Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(VfResourceInstallerTest.heatExampleMD5HashBase64); - Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1"); - Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT); - Mockito.when(artifactInfo1.getArtifactURL()) - .thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); - Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1"); - Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1"); + Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1"); + Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT); + Mockito.when(artifactInfo1.getArtifactURL()) + .thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); + Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1"); + Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1"); - distributionClient = Mockito.mock(IDistributionClient.class); + distributionClient = Mockito.mock(IDistributionClient.class); - // Now provision the NotificationData mock - List listArtifact = new ArrayList<>(); - listArtifact.add(artifactInfo1); + // Now provision the NotificationData mock + List listArtifact = new ArrayList<>(); + listArtifact.add(artifactInfo1); - // Create fake resource Instance - resource1 = Mockito.mock(IResourceInstance.class); + // Create fake resource Instance + resource1 = Mockito.mock(IResourceInstance.class); // Mockito.when(resource1.getResourceType()).thenReturn("VF"); - Mockito.when(resource1.getResourceName()).thenReturn("resourceName"); - Mockito.when(resource1.getArtifacts()).thenReturn(listArtifact); - - List resources = new ArrayList<>(); - resources.add(resource1); - - Mockito.when(iNotif.getResources()).thenReturn(resources); - Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1"); - Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1"); - Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1"); - Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0"); - - downloadResult = Mockito.mock(IDistributionClientDownloadResult.class); - Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes()); - Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); - Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success"); - - downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class); - Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample + "badone").getBytes()); - Mockito.when(downloadCorruptedResult.getDistributionActionResult()) - .thenReturn(DistributionActionResultEnum.SUCCESS); - Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success"); - - vrs = new VfResourceStructure(iNotif, resource1); - try { - vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - try { - vrs.createVfModuleStructures(); - } catch (ArtifactInstallerException e) { - e.printStackTrace(); - } - vrs.getNotification(); - vrs.getArtifactsMapByUUID(); - vrs.getCatalogNetworkResourceCustomization(); - vrs.getCatalogResourceCustomization(); - vrs.getCatalogService(); - vrs.getCatalogServiceToAllottedResources(); - vrs.getCatalogServiceToNetworks(); - vrs.getCatalogVnfResource(); - vrs.getResourceInstance(); - vrs.getVfModulesStructureList(); - vrs.getVfModuleStructure(); - vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization()); - vrs.setCatalogResourceCustomization(new AllottedResourceCustomization()); - vrs.setCatalogService(new Service()); - vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources()); - vrs.setCatalogServiceToNetworks(new ServiceToNetworks()); - vrs.setCatalogVnfResource(new VnfResource()); - vrs.setSuccessfulDeployment(); - - AllottedResourceCustomization arc = new AllottedResourceCustomization(); - arc.setModelCustomizationUuid("modelCustomizationUuid"); - List allottedResources = new ArrayList<>(); - allottedResources.add(arc); - - NetworkResourceCustomization nrc = new NetworkResourceCustomization(); - nrc.setModelCustomizationUuid("modelCustomizationUuid"); - List networkResources = new ArrayList<>(); - networkResources.add(nrc); - - new MockUp() { - @Mock - public List getAllAllottedResourcesByServiceModelUuid(String serviceModelUuid) { - return allottedResources; - } - }; - new MockUp() { - @Mock - public List getAllNetworksByServiceModelUuid(String serviceModelUuid) { - return networkResources; - } - }; - - // Mock now the ASDC distribution client behavior - successfulClientInitResult = Mockito.mock(IDistributionClientResult.class); - Mockito.when(successfulClientInitResult.getDistributionActionResult()) - .thenReturn(DistributionActionResultEnum.SUCCESS); - - unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class); - Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult()) - .thenReturn(DistributionActionResultEnum.GENERAL_ERROR); - - } - - @Before - public final void initBeforeEachTest() throws MsoPropertiesException { - // load the config - msoPropertiesFactory.removeAllMsoProperties(); - msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); - } - - @AfterClass - public static final void kill() throws MsoPropertiesException { - - msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC); - - } - - @Test - public void isResourceAlreadyDeployedAllotedResourceTest() { - - Mockito.when(resource1.getResourceType()).thenReturn("VF"); - Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource"); - VfResourceInstaller vfri = new VfResourceInstaller(); - - try { - vfri.isResourceAlreadyDeployed(vrs); - } catch (ArtifactInstallerException e) { - } - - } - - @Test - public void isResourceAlreadyDeployedTest() { - - Mockito.when(resource1.getResourceType()).thenReturn("VF"); - Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource"); - VfResourceInstaller vfri = new VfResourceInstaller(); - - try { - vfri.isResourceAlreadyDeployed(vrs); - } catch (ArtifactInstallerException e) { - } - - } - - @Test - public void isResourceAlreadyDeployedDuplicateNtwrkTest() { - - Mockito.when(resource1.getResourceType()).thenReturn("VL"); - Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource"); - VfResourceInstaller vfri = new VfResourceInstaller(); - - try { - vfri.isResourceAlreadyDeployed(vrs); - } catch (ArtifactInstallerException e) { - } - - } - - @Test(expected = Exception.class) - public void installTheResourceTest() { - VfResourceInstaller vfri = new VfResourceInstaller(); - try { - vfri.installTheResource(vrs); - } catch (ArtifactInstallerException e) { - } - } + Mockito.when(resource1.getResourceName()).thenReturn("resourceName"); + Mockito.when(resource1.getArtifacts()).thenReturn(listArtifact); + + List resources = new ArrayList<>(); + resources.add(resource1); + + Mockito.when(iNotif.getResources()).thenReturn(resources); + Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1"); + Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1"); + Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1"); + Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0"); + + downloadResult = Mockito.mock(IDistributionClientDownloadResult.class); + Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes()); + Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); + Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success"); + + downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class); + Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample + "badone").getBytes()); + Mockito.when(downloadCorruptedResult.getDistributionActionResult()) + .thenReturn(DistributionActionResultEnum.SUCCESS); + Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success"); + + vrs = new VfResourceStructure(iNotif, resource1); + try { + vrs.addArtifactToStructure(distributionClient, artifactInfo1, downloadResult); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + try { + vrs.createVfModuleStructures(); + } catch (ArtifactInstallerException e) { + e.printStackTrace(); + } + vrs.getNotification(); + vrs.getArtifactsMapByUUID(); + vrs.getCatalogNetworkResourceCustomization(); + vrs.getCatalogResourceCustomization(); + vrs.getCatalogService(); + vrs.getCatalogServiceToAllottedResources(); + vrs.getCatalogServiceToNetworks(); + vrs.getCatalogVnfResource(); + vrs.getResourceInstance(); + vrs.getVfModulesStructureList(); + vrs.getVfModuleStructure(); + vrs.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization()); + vrs.setCatalogResourceCustomization(new AllottedResourceCustomization()); + vrs.setCatalogService(new Service()); + vrs.setCatalogServiceToAllottedResources(new ServiceToAllottedResources()); + vrs.setCatalogServiceToNetworks(new ServiceToNetworks()); + vrs.setCatalogVnfResource(new VnfResource()); + vrs.setSuccessfulDeployment(); + + AllottedResourceCustomization arc= new AllottedResourceCustomization(); + arc.setModelCustomizationUuid("modelCustomizationUuid"); + List allottedResources = new ArrayList<>(); + allottedResources.add(arc); + + NetworkResourceCustomization nrc = new NetworkResourceCustomization(); + nrc.setModelCustomizationUuid("modelCustomizationUuid"); + List networkResources = new ArrayList<>(); + networkResources.add(nrc); + + new MockUp() { + @Mock + public List getAllAllottedResourcesByServiceModelUuid(String serviceModelUuid) { + return allottedResources; + } + }; + new MockUp() { + @Mock + public List getAllNetworksByServiceModelUuid(String serviceModelUuid) { + return networkResources; + } + }; + + // Mock now the ASDC distribution client behavior + successfulClientInitResult = Mockito.mock(IDistributionClientResult.class); + Mockito.when(successfulClientInitResult.getDistributionActionResult()) + .thenReturn(DistributionActionResultEnum.SUCCESS); + + unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class); + Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult()) + .thenReturn(DistributionActionResultEnum.GENERAL_ERROR); + + } + + @Before + public final void initBeforeEachTest() throws MsoPropertiesException { + // load the config + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + } + + @AfterClass + public static final void kill() throws MsoPropertiesException { + + msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC); + + } + + @Test + public void isResourceAlreadyDeployedAllotedResourceTest() { + + Mockito.when(resource1.getResourceType()).thenReturn("VF"); + Mockito.when(resource1.getCategory()).thenReturn("Allotted Resource"); + VfResourceInstaller vfri = new VfResourceInstaller(); + + try { + vfri.isResourceAlreadyDeployed(vrs); + } catch (ArtifactInstallerException e) { + } + + } + + @Test + public void isResourceAlreadyDeployedTest() { + + Mockito.when(resource1.getResourceType()).thenReturn("VF"); + Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource"); + VfResourceInstaller vfri = new VfResourceInstaller(); + + try { + vfri.isResourceAlreadyDeployed(vrs); + } catch (ArtifactInstallerException e) { + } + + } + @Test + public void isResourceAlreadyDeployedDuplicateNtwrkTest() { + + Mockito.when(resource1.getResourceType()).thenReturn("VL"); + Mockito.when(resource1.getCategory()).thenReturn("Not Allotted Resource"); + VfResourceInstaller vfri = new VfResourceInstaller(); + + try { + vfri.isResourceAlreadyDeployed(vrs); + } catch (ArtifactInstallerException e) { + } + + } + + @Test(expected=Exception.class) + public void installTheResourceTest() { + VfResourceInstaller vfri = new VfResourceInstaller(); + try { + vfri.installTheResource(vrs); + } catch (ArtifactInstallerException e) { + } + } } -- cgit 1.2.3-korg