From 62cd6aaaf74aa91ee0037c0e155c8e7284f07567 Mon Sep 17 00:00:00 2001 From: Arthur Martella Date: Fri, 8 Sep 2017 13:27:46 -0400 Subject: 1710 Rebase - Second Attempt This commit rebases changes from openecomp-mso/internal-staging-1710 up to and including this codecloud commit: 54483fc6606ddb1591a2e9da61bff8712325f924 Wed Sep 6 18:12:56 2017 -0400 Rebasing was done on a branch on top of this commit in so/master in ONAP: 93fbdfbe46104f8859d4754040f979cb7997c157 Thu Sep 7 16:42:59 2017 +0000 Change-Id: I4ad9abf40da32bf5bdca43e868b8fa2dbcd9dc59 Issue-id: SO-107 Signed-off-by: Arthur Martella --- .../mso/asdc/client/ASDCConfiguration.java | 14 +- .../openecomp/mso/asdc/client/ASDCController.java | 108 +- .../mso/asdc/healthcheck/HealthCheckHandler.java | 20 +- .../mso/asdc/installer/ToscaResourceStructure.java | 412 +++++++ .../mso/asdc/installer/VfResourceStructure.java | 9 + .../installer/heat/ToscaResourceInstaller.java | 1130 ++++++++++++++++++++ .../asdc/installer/heat/VfResourceInstaller.java | 97 +- .../mso/asdc/util/ASDCNotificationLogging.java | 199 +++- .../org/openecomp/mso/asdc/util/YamlEditor.java | 4 +- .../resources/resource-examples/cloud-nimbus.sh | 12 + .../resource-examples/hot-nimbus-oam_v1.0.env | 18 + .../resource-examples/hot-nimbus-oam_v1.0.yaml | 109 ++ .../resource-examples/nested-oam_v1.0.yaml | 156 +++ .../resource-examples/notif-structure.json | 138 +++ .../resource-examples/resource_Extvl.csar | Bin 0 -> 1353 bytes .../service-ServiceFdnt-csar-0904-2.csar | Bin 0 -> 41245 bytes .../service-ServiceFdnt-with-allotted.csar | Bin 0 -> 44991 bytes .../resource-examples/service_Rg511NfmService.csar | Bin 0 -> 59733 bytes .../service_Rg516VmmscSrvc_csar.csar | Bin 0 -> 275560 bytes .../resource-examples/vnf-module-artifact.json | 45 + .../mso/asdc/ASDCControllerSingletonESTest.java | 38 - .../ASDCControllerSingletonESTestscaffolding.java | 120 --- .../client/DistributionStatusMessageESTest.java | 134 --- ...DistributionStatusMessageESTestscaffolding.java | 79 -- .../exceptions/ASDCControllerExceptionESTest.java | 26 - .../ASDCControllerExceptionESTestscaffolding.java | 82 -- .../exceptions/ASDCDownloadExceptionESTest.java | 24 - .../ASDCDownloadExceptionESTestscaffolding.java | 82 -- .../exceptions/ASDCParametersExceptionESTest.java | 24 - .../ASDCParametersExceptionESTestscaffolding.java | 82 -- .../ArtifactInstallerExceptionESTest.java | 24 - ...rtifactInstallerExceptionESTestscaffolding.java | 82 -- .../openecomp/mso/asdc/client/tests/YamlTest.java | 14 +- .../asdc/installer/BigDecimalVersionESTest.java | 138 --- .../BigDecimalVersionESTestscaffolding.java | 77 -- .../mso/asdc/installer/VfModuleArtifactESTest.java | 154 --- .../VfModuleArtifactESTestscaffolding.java | 83 -- .../mso/asdc/installer/VfModuleMetaDataESTest.java | 517 --------- .../VfModuleMetaDataESTestscaffolding.java | 78 -- .../asdc/installer/VfModuleStructureESTest.java | 97 -- .../VfModuleStructureESTestscaffolding.java | 96 -- .../asdc/util/ASDCNotificationLoggingESTest.java | 272 ----- .../ASDCNotificationLoggingESTestscaffolding.java | 82 -- .../openecomp/mso/asdc/util/YamlEditorESTest.java | 420 -------- .../mso/asdc/util/YamlEditorESTestscaffolding.java | 255 ----- 45 files changed, 2412 insertions(+), 3139 deletions(-) create mode 100644 asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java create mode 100644 asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java create mode 100644 asdc-controller/src/main/resources/resource-examples/cloud-nimbus.sh create mode 100644 asdc-controller/src/main/resources/resource-examples/hot-nimbus-oam_v1.0.env create mode 100644 asdc-controller/src/main/resources/resource-examples/hot-nimbus-oam_v1.0.yaml create mode 100644 asdc-controller/src/main/resources/resource-examples/nested-oam_v1.0.yaml create mode 100644 asdc-controller/src/main/resources/resource-examples/notif-structure.json create mode 100644 asdc-controller/src/main/resources/resource-examples/resource_Extvl.csar create mode 100644 asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-csar-0904-2.csar create mode 100644 asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-with-allotted.csar create mode 100644 asdc-controller/src/main/resources/resource-examples/service_Rg511NfmService.csar create mode 100644 asdc-controller/src/main/resources/resource-examples/service_Rg516VmmscSrvc_csar.csar create mode 100644 asdc-controller/src/main/resources/resource-examples/vnf-module-artifact.json delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleMetaDataESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleMetaDataESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTestscaffolding.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTest.java delete mode 100644 asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTestscaffolding.java (limited to 'asdc-controller/src') diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java index 61ca698678..bb4b9655c4 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java @@ -30,13 +30,13 @@ import java.util.List; import java.util.Map.Entry; import java.util.Properties; -import org.codehaus.jackson.JsonNode; - -import org.openecomp.sdc.api.consumer.IConfiguration; import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; import org.openecomp.mso.properties.MsoJsonProperties; import org.openecomp.mso.properties.MsoPropertiesException; import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.sdc.api.consumer.IConfiguration; + +import com.fasterxml.jackson.databind.JsonNode; public class ASDCConfiguration implements IConfiguration { @@ -74,6 +74,7 @@ public class ASDCConfiguration implements IConfiguration { public static final String HEAT_NET="HEAT_NET"; public static final String HEAT_VOL="HEAT_VOL"; public static final String OTHER="OTHER"; + public static final String TOSCA_CSAR="TOSCA_CSAR"; public static final String VF_MODULES_METADATA="VF_MODULES_METADATA"; @@ -84,6 +85,7 @@ public class ASDCConfiguration implements IConfiguration { HEAT_NET, HEAT_VOL, OTHER, + TOSCA_CSAR, VF_MODULES_METADATA}; public static final List SUPPORTED_ARTIFACT_TYPES_LIST = Collections.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES)); @@ -110,6 +112,10 @@ public class ASDCConfiguration implements IConfiguration { refreshASDCConfig (); } + + public java.lang.Boolean isUseHttpsWithDmaap() { + return false; + } public String getAsdcControllerName () { return asdcControllerName; @@ -399,7 +405,7 @@ public class ASDCConfiguration implements IConfiguration { if (msoProp.getJsonRootNode ().get (PARAMETER_PATTERN) != null) { Iterator > it = msoProp.getJsonRootNode () .get (PARAMETER_PATTERN) - .getFields (); + .fields(); Entry entry; while (it.hasNext ()) { diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java index a95d25fcbb..736cd1a7f6 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java @@ -21,8 +21,12 @@ package org.openecomp.mso.asdc.client; +import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.util.List; + import org.openecomp.sdc.api.IDistributionClient; import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; import org.openecomp.sdc.api.consumer.INotificationCallback; @@ -39,7 +43,9 @@ import org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException; import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; import org.openecomp.mso.asdc.installer.IVfResourceInstaller; +import org.openecomp.mso.asdc.installer.ToscaResourceStructure; import org.openecomp.mso.asdc.installer.VfResourceStructure; +import org.openecomp.mso.asdc.installer.heat.ToscaResourceInstaller; import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller; import org.openecomp.mso.asdc.util.ASDCNotificationLogging; import org.openecomp.mso.logger.MessageEnum; @@ -57,6 +63,9 @@ public class ASDCController { protected String controllerName; + protected ToscaResourceInstaller toscaInstaller; + + /** * Inner class for Notification callback * @@ -135,6 +144,7 @@ public class ASDCController { isAsdcClientAutoManaged = true; this.controllerName = controllerConfigName; this.resourceInstaller = new VfResourceInstaller(); + toscaInstaller = new ToscaResourceInstaller(); } public ASDCController (String controllerConfigName, IDistributionClient asdcClient, IVfResourceInstaller resourceinstaller) { @@ -148,6 +158,7 @@ public class ASDCController { distributionClient = asdcClient; this.controllerName = controllerConfigName; this.resourceInstaller = new VfResourceInstaller(); + toscaInstaller = new ToscaResourceInstaller(); } /** @@ -272,7 +283,7 @@ public class ASDCController { private boolean checkResourceAlreadyDeployed (VfResourceStructure resource) throws ArtifactInstallerException { - if (this.resourceInstaller.isResourceAlreadyDeployed (resource)) { + if (toscaInstaller.isResourceAlreadyDeployed (resource)) { LOGGER.info (MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST, resource.getResourceInstance().getResourceInstanceName(), resource.getResourceInstance().getResourceUUID(), @@ -366,6 +377,36 @@ public class ASDCController { } + private void writeArtifactToFile (IArtifactInfo artifact, + IDistributionClientDownloadResult resultArtifact) throws ASDCDownloadException { + + LOGGER.debug ("Trying to download the artifact : " + artifact.getArtifactURL () + + UUID_PARAM + + artifact.getArtifactUUID () + + ")"); + + File spoolFile = new File(System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactName()); + + + byte[] payloadBytes = resultArtifact.getArtifactPayload(); + + try { + LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***WRITE FILE ARTIFACT NAME", "ASDC", artifact.getArtifactName()); + + FileOutputStream outFile = new FileOutputStream(System.getProperty("mso.config.path") + "/ASDC" + "/" + artifact.getArtifactName()); + outFile.write(payloadBytes, 0, payloadBytes.length); + outFile.close(); + } catch (Exception e) { + e.printStackTrace(); + LOGGER.error(MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL, + artifact.getArtifactName (), + artifact.getArtifactURL (), + artifact.getArtifactUUID (), + resultArtifact.getDistributionMessageResult (), "", "", MsoLogger.ErrorCode.DataError, "ASDC write to file failed"); + } + + } + private void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) { @@ -394,7 +435,7 @@ public class ASDCController { } } - private void deployResourceStructure (VfResourceStructure resourceStructure) throws ArtifactInstallerException { + private void deployResourceStructure (VfResourceStructure resourceStructure, ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException { LOGGER.info (MessageEnum.ASDC_START_DEPLOY_ARTIFACT, resourceStructure.getResourceInstance().getResourceInstanceName(), resourceStructure.getResourceInstance().getResourceUUID(), "ASDC", "deployResourceStructure"); try { @@ -403,10 +444,27 @@ public class ASDCController { if(resourceType.equals("VF") && !category.equalsIgnoreCase("Allotted Resource")){ resourceStructure.createVfModuleStructures(); } - resourceInstaller.installTheResource (resourceStructure); + //resourceInstaller.installTheResource (resourceStructure); + + //ToscaResourceInstaller tri = new ToscaResourceInstaller(); + toscaInstaller.installTheResource(toscaResourceStructure, resourceStructure); + + /* if(toscaResourceStructure.isVnfAlreadyInstalled()){ + LOGGER.info (MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST, + toscaResourceStructure.getCatalogVnfResource().getModelName(), + toscaResourceStructure.getCatalogVnfResource().getModelUuid(), + toscaResourceStructure.getCatalogVnfResource().getModelUuid(),"",""); + + + this.sendDeployNotificationsForResource(resourceStructure,DistributionStatusEnum.ALREADY_DOWNLOADED,null); + this.sendDeployNotificationsForResource(resourceStructure,DistributionStatusEnum.ALREADY_DEPLOYED,null); + } */ } catch (ArtifactInstallerException e) { - + LOGGER.info (MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL, + resourceStructure.getResourceInstance().getResourceName(), + resourceStructure.getResourceInstance().getResourceUUID(), + String.valueOf (resourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure"); sendDeployNotificationsForResource(resourceStructure,DistributionStatusEnum.DEPLOY_ERROR,e.getMessage()); throw e; } @@ -497,6 +555,9 @@ public class ASDCController { LOGGER.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif)); LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, iNotif.getServiceUUID(), "ASDC", "treatNotification"); this.changeControllerStatus(ASDCControllerStatus.BUSY); + + + // Process only the Resource artifacts in MSO for (IResourceInstance resource : iNotif.getResources()) { @@ -505,6 +566,7 @@ public class ASDCController { if ("VF".equals(resource.getResourceType()) || "VL".equals(resource.getResourceType())) { this.processResourceNotification(iNotif,resource); } + } @@ -522,6 +584,7 @@ public class ASDCController { private void processResourceNotification (INotificationData iNotif,IResourceInstance resource) { // For each artifact, create a structure describing the VFModule in a ordered flat level VfResourceStructure resourceStructure = new VfResourceStructure(iNotif,resource); + ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(); try { @@ -542,7 +605,9 @@ public class ASDCController { } - this.deployResourceStructure(resourceStructure); + this.processCsarServiceArtifacts(iNotif, toscaResourceStructure); + + this.deployResourceStructure(resourceStructure, toscaResourceStructure); } } catch (ArtifactInstallerException | ASDCDownloadException | UnsupportedEncodingException e) { @@ -551,6 +616,39 @@ public class ASDCController { } } + private void processCsarServiceArtifacts (INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) { + + List serviceArtifacts = iNotif.getServiceArtifacts(); + + for(IArtifactInfo artifact : serviceArtifacts){ + + if(artifact.getArtifactType().equals(ASDCConfiguration.TOSCA_CSAR)){ + + try{ + + toscaResourceStructure.setToscaArtifact(artifact); + + IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,iNotif.getDistributionID()); + + writeArtifactToFile(artifact, resultArtifact); + + toscaResourceStructure.updateResourceStructure(artifact); + + toscaResourceStructure.setServiceVersion(iNotif.getServiceVersion()); + + LOGGER.debug(ASDCNotificationLogging.dumpCSARNotification(iNotif, toscaResourceStructure)); + + + } catch(Exception e){ + System.out.println("Whats the error " + e.getMessage()); + LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG, + "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processCsarServiceArtifacts", e); + } + } + + } + } + private static final String UNKNOWN="Unknown"; /** diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java index f0b6ec4853..05c049a1ed 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java @@ -21,16 +21,6 @@ package org.openecomp.mso.asdc.healthcheck; -import org.openecomp.mso.MsoStatusUtil; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJsonProperties; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.openecomp.mso.HealthCheckUtils; -import org.openecomp.mso.utils.UUIDChecker; -import org.apache.http.HttpStatus; - import javax.ws.rs.GET; import javax.ws.rs.HEAD; import javax.ws.rs.Path; @@ -38,6 +28,14 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; +import org.apache.http.HttpStatus; +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJsonProperties; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.mso.utils.UUIDChecker; + @Path("/") public class HealthCheckHandler { @@ -87,7 +85,7 @@ import javax.ws.rs.core.Response; return null; } - if (msoProperties !=null && msoProperties.getJsonRootNode().getElements().hasNext()) { + if (msoProperties !=null && msoProperties.getJsonRootNode().elements().hasNext()) { return msoProperties; } else { msoLogger.error (MessageEnum.ASDC_PROPERTIES_NOT_FOUND , MSO_PROP_ASDC, "", "", MsoLogger.ErrorCode.DataError, "ASDC properties not found"); diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java new file mode 100644 index 0000000000..edba81ac00 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ToscaResourceStructure.java @@ -0,0 +1,412 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.installer; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + + +import java.util.List; + +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +//import org.openecomp.generic.tosca.parser.model.Metadata; +//import org.openecomp.sdc.tosca.parser.factory.SdcCsarHelperFactory; +//import org.openecomp.sdc.tosca.parser.factory.SdcCsarHelperFactory; +///import org.openecomp.generic.tosca.parser.model.Metadata; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; +import org.openecomp.sdc.tosca.parser.impl.SdcCsarHelperImpl; +import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames; + + +import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; + + + +import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.openecomp.sdc.toscaparser.api.elements.Metadata; + +import org.openecomp.mso.db.catalog.beans.AllottedResource; +import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; +import org.openecomp.mso.db.catalog.beans.NetworkResource; +import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; +import org.openecomp.mso.db.catalog.beans.Service; +import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization; +import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup; +import org.openecomp.mso.db.catalog.beans.ToscaCsar; +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.openecomp.mso.db.catalog.beans.VfModuleCustomization; +import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles; +import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +public class ToscaResourceStructure { + + Metadata serviceMetadata; + private Service catalogService; + ISdcCsarHelper sdcCsarHelper; + List allottedList; + List networkTypes; + List vfTypes; + String heatTemplateUUID; + String volHeatTemplateUUID; + String volHeatEnvTemplateUUID; + String envHeatTemplateUUID; + String heatFilesUUID; + boolean isVnfAlreadyInstalled = false; + String serviceVersion; + + private NetworkResourceCustomization catalogNetworkResourceCustomization; + + private NetworkResource catalogNetworkResource; + + private AllottedResourceCustomization catalogResourceCustomization; + + private VfModule vfModule; + + private VfModuleCustomization vfModuleCustomization; + + private VnfResource vnfResource; + + private VnfResourceCustomization vnfResourceCustomization; + + private ServiceToResourceCustomization serviceToResourceCustomization; + + private AllottedResource allottedResource; + + private AllottedResourceCustomization allottedResourceCustomization; + + private VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom; + + private TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup; + + private VfModuleToHeatFiles vfModuleToHeatFiles; + + private IArtifactInfo toscaArtifact; + + private ToscaCsar toscaCsar; + + private ServiceToResourceCustomization vfServiceToResourceCustomization; + + private ServiceToResourceCustomization allottedServiceToResourceCustomization; + + private ServiceToResourceCustomization vlServiceToResourceCustomization; + + protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); + + + public ToscaResourceStructure(){ + } + + public void updateResourceStructure(IArtifactInfo artifact){ + + + try { + + SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();//Autoclosable + + + File spoolFile = new File(System.getProperty("mso.config.path") + "ASDC/" + artifact.getArtifactName()); + + + + System.out.println("PATH IS " + spoolFile.getAbsolutePath()); + LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***PATH", "ASDC", spoolFile.getAbsolutePath()); + + + sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath()); + + }catch(Exception e){ + System.out.println("System out " + e.getMessage()); + LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG, + "Exception caught during parser *****LOOK********* " + artifact.getArtifactName(), "ASDC", "processResourceNotification", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processResourceNotification", e); + } + + + serviceMetadata = sdcCsarHelper.getServiceMetadata(); + + + } + + public String getHeatTemplateUUID() { + return heatTemplateUUID; + } + + public void setHeatTemplateUUID(String heatTemplateUUID) { + this.heatTemplateUUID = heatTemplateUUID; + } + + public List getAllottedList() { + return allottedList; + } + + public void setAllottedList(List allottedList) { + this.allottedList = allottedList; + } + + public ISdcCsarHelper getSdcCsarHelper() { + return sdcCsarHelper; + } + + public void setSdcCsarHelper(ISdcCsarHelper sdcCsarHelper) { + this.sdcCsarHelper = sdcCsarHelper; + } + + public Metadata getServiceMetadata() { + return serviceMetadata; + } + + public Service getCatalogService() { + return catalogService; + } + + public void setServiceMetadata(Metadata serviceMetadata) { + this.serviceMetadata = serviceMetadata; + } + + public void setCatalogService(Service catalogService) { + this.catalogService = catalogService; + } + + public List getNetworkTypes() { + return networkTypes; + } + + public void setNetworkTypes(List networkTypes) { + this.networkTypes = networkTypes; + } + + public List getVfTypes() { + return vfTypes; + } + + public void setVfTypes(List vfTypes) { + this.vfTypes = vfTypes; + } + + public AllottedResourceCustomization getCatalogResourceCustomization() { + return catalogResourceCustomization; + } + + public void setCatalogResourceCustomization( + AllottedResourceCustomization catalogResourceCustomization) { + this.catalogResourceCustomization = catalogResourceCustomization; + } + + // Network Only + public NetworkResourceCustomization getCatalogNetworkResourceCustomization() { + return catalogNetworkResourceCustomization; + } + // Network Only + public void setCatalogNetworkResourceCustomization(NetworkResourceCustomization catalogNetworkResourceCustomization) { + this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization; + } + + public NetworkResource getCatalogNetworkResource() { + return catalogNetworkResource; + } + + public void setCatalogNetworkResource(NetworkResource catalogNetworkResource) { + this.catalogNetworkResource = catalogNetworkResource; + } + + public VfModule getCatalogVfModule() { + return vfModule; + } + + public void setCatalogVfModule(VfModule vfModule) { + this.vfModule = vfModule; + } + + public VnfResource getCatalogVnfResource() { + return vnfResource; + } + + public void setCatalogVnfResource(VnfResource vnfResource) { + this.vnfResource = vnfResource; + } + + public VnfResourceCustomization getCatalogVnfResourceCustomization() { + return vnfResourceCustomization; + } + + public void setCatalogVnfResourceCustomization( + VnfResourceCustomization vnfResourceCustomization) { + this.vnfResourceCustomization = vnfResourceCustomization; + } + + public VfModuleCustomization getCatalogVfModuleCustomization() { + return vfModuleCustomization; + } + + public void setCatalogVfModuleCustomization(VfModuleCustomization vfModuleCustomization) { + this.vfModuleCustomization = vfModuleCustomization; + } + + public ServiceToResourceCustomization getServiceToResourceCustomization() { + return serviceToResourceCustomization; + } + + public void setServiceToResourceCustomization( + ServiceToResourceCustomization serviceToResourceCustomization) { + this.serviceToResourceCustomization = serviceToResourceCustomization; + } + + public AllottedResource getAllottedResource() { + return allottedResource; + } + + public void setAllottedResource(AllottedResource allottedResource) { + this.allottedResource = allottedResource; + } + + public AllottedResourceCustomization getCatalogAllottedResourceCustomization() { + return allottedResourceCustomization; + } + + public void setCatalogAllottedResourceCustomization( + AllottedResourceCustomization allottedResourceCustomization) { + this.allottedResourceCustomization = allottedResourceCustomization; + } + + public VnfResCustomToVfModuleCustom getCatalogVnfResCustomToVfModuleCustom() { + return vnfResCustomToVfModuleCustom; + } + + public void setCatalogVnfResCustomToVfModuleCustom( + VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom) { + this.vnfResCustomToVfModuleCustom = vnfResCustomToVfModuleCustom; + } + + public TempNetworkHeatTemplateLookup getCatalogTempNetworkHeatTemplateLookup() { + return tempNetworkHeatTemplateLookup; + } + + public void setCatalogTempNetworkHeatTemplateLookup( + TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) { + this.tempNetworkHeatTemplateLookup = tempNetworkHeatTemplateLookup; + } + + public String getHeatFilesUUID() { + return heatFilesUUID; + } + + public void setHeatFilesUUID(String heatFilesUUID) { + this.heatFilesUUID = heatFilesUUID; + } + + public VfModuleToHeatFiles getCatalogVfModuleToHeatFiles() { + return vfModuleToHeatFiles; + } + + public void setCatalogVfModuleToHeatFiles(VfModuleToHeatFiles vfModuleToHeatFiles) { + this.vfModuleToHeatFiles = vfModuleToHeatFiles; + } + + public IArtifactInfo getToscaArtifact() { + return toscaArtifact; + } + + public void setToscaArtifact(IArtifactInfo toscaArtifact) { + this.toscaArtifact = toscaArtifact; + } + + public ToscaCsar getCatalogToscaCsar() { + return toscaCsar; + } + + public void setCatalogToscaCsar(ToscaCsar toscaCsar) { + this.toscaCsar = toscaCsar; + } + + public boolean isVnfAlreadyInstalled() { + return isVnfAlreadyInstalled; + } + + public void setVnfAlreadyInstalled(boolean isVnfAlreadyInstalled) { + this.isVnfAlreadyInstalled = isVnfAlreadyInstalled; + } + + public ServiceToResourceCustomization getCatalogVfServiceToResourceCustomization() { + return vfServiceToResourceCustomization; + } + + public void setCatalogVfServiceToResourceCustomization( + ServiceToResourceCustomization vfServiceToResourceCustomization) { + this.vfServiceToResourceCustomization = vfServiceToResourceCustomization; + } + + public ServiceToResourceCustomization getCatalogAllottedServiceToResourceCustomization() { + return allottedServiceToResourceCustomization; + } + + public void setCatalogAllottedServiceToResourceCustomization( + ServiceToResourceCustomization allottedServiceToResourceCustomization) { + this.allottedServiceToResourceCustomization = allottedServiceToResourceCustomization; + } + + public ServiceToResourceCustomization getCatalogVlServiceToResourceCustomization() { + return vlServiceToResourceCustomization; + } + + public void setCatalogVlServiceToResourceCustomization( + ServiceToResourceCustomization vlServiceToResourceCustomization) { + this.vlServiceToResourceCustomization = vlServiceToResourceCustomization; + } + + public String getVolHeatTemplateUUID() { + return volHeatTemplateUUID; + } + + public void setVolHeatTemplateUUID(String volHeatTemplateUUID) { + this.volHeatTemplateUUID = volHeatTemplateUUID; + } + + public String getEnvHeatTemplateUUID() { + return envHeatTemplateUUID; + } + + public void setEnvHeatTemplateUUID(String envHeatTemplateUUID) { + this.envHeatTemplateUUID = envHeatTemplateUUID; + } + + public String getVolHeatEnvTemplateUUID() { + return volHeatEnvTemplateUUID; + } + + public void setVolHeatEnvTemplateUUID(String volHeatEnvTemplateUUID) { + this.volHeatEnvTemplateUUID = volHeatEnvTemplateUUID; + } + + public String getServiceVersion() { + return serviceVersion; + } + + public void setServiceVersion(String serviceVersion) { + this.serviceVersion = serviceVersion; + } + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java index d27819bb38..a93b065dbe 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java @@ -86,6 +86,8 @@ public final class VfResourceStructure { private Service catalogService; + private List vfArtifactUUIDList; + /** * The list of artifacts existing in this resource hashed by UUID. */ @@ -118,6 +120,13 @@ public final class VfResourceStructure { case ASDCConfiguration.VF_MODULES_METADATA: vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload()); + + for(IVfModuleData moduleData : vfModulesMetadataList){ + + } + + //vfArtifactUUIDList.add(artifactinfo.getArtifactUUID()); + //vfModulesMetadataList = distributionClient.decodeVfModuleArtifact(clientResult.getArtifactPayload()); break; default: diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java new file mode 100644 index 0000000000..eff3a7849b --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/ToscaResourceInstaller.java @@ -0,0 +1,1130 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.installer.heat; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.Collections; +import java.util.regex.Matcher; +import java.util.Comparator; + +import org.hibernate.exception.ConstraintViolationException; +import org.hibernate.exception.LockAcquisitionException; +//import org.openecomp.generic.tosca.parser.model.Metadata; +//import org.openecomp.generic.tosca.parser.model.NodeTemplate; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; +import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames; +import org.openecomp.sdc.toscaparser.api.Group; +import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.openecomp.sdc.toscaparser.api.Property; +import org.openecomp.sdc.toscaparser.api.elements.Metadata; +import org.openecomp.sdc.toscaparser.api.parameters.Input; +import org.openecomp.mso.asdc.client.ASDCConfiguration; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; +import org.openecomp.mso.asdc.installer.ASDCElementInfo; +import org.openecomp.mso.asdc.installer.BigDecimalVersion; +import org.openecomp.mso.asdc.installer.IVfModuleData; +import org.openecomp.mso.asdc.installer.IVfResourceInstaller; +import org.openecomp.mso.asdc.installer.ToscaResourceStructure; +import org.openecomp.mso.asdc.installer.VfModuleArtifact; +import org.openecomp.mso.asdc.installer.VfModuleStructure; +import org.openecomp.mso.asdc.installer.VfResourceStructure; +import org.openecomp.mso.asdc.util.YamlEditor; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.AllottedResource; +import org.openecomp.mso.db.catalog.beans.HeatEnvironment; +import org.openecomp.mso.db.catalog.beans.HeatFiles; +import org.openecomp.mso.db.catalog.beans.HeatTemplate; +import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; +import org.openecomp.mso.db.catalog.beans.NetworkResource; +import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; +import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; +import org.openecomp.mso.db.catalog.beans.Service; +import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources; +import org.openecomp.mso.db.catalog.beans.ServiceToNetworks; +import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization; +import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup; +import org.openecomp.mso.db.catalog.beans.ToscaCsar; +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.openecomp.mso.db.catalog.beans.VfModuleCustomization; +import org.openecomp.mso.db.catalog.beans.VfModuleToHeatFiles; +import org.openecomp.mso.db.catalog.beans.VnfResCustomToVfModuleCustom; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +public class ToscaResourceInstaller {// implements IVfResourceInstaller { + + private MsoLogger logger; + + private Service catalogService; + + private static final Pattern lastDigit = Pattern.compile("(\\d+)$"); + + public ToscaResourceInstaller() { + logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.ASDC); + } + + //@Override + public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) + throws ArtifactInstallerException { + CatalogDatabase db = CatalogDatabase.getInstance(); + boolean status = false; + VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct; + + try { + + String serviceUUID = vfResourceStruct.getNotification().getServiceUUID(); + + if (status) { + logger.info(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL, + vfResourceStructure.getResourceInstance().getResourceInstanceName(), + vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), + vfResourceStructure.getNotification().getServiceName(), + BigDecimalVersion.castAndCheckNotificationVersionToString( + vfResourceStructure.getNotification().getServiceVersion()), + vfResourceStructure.getNotification().getServiceUUID(), + vfResourceStructure.getResourceInstance().getResourceName(),"", ""); + } else { + logger.info(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, + vfResourceStructure.getResourceInstance().getResourceInstanceName(), + vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(), + vfResourceStructure.getNotification().getServiceName(), + BigDecimalVersion.castAndCheckNotificationVersionToString( + vfResourceStructure.getNotification().getServiceVersion()), + vfResourceStructure.getNotification().getServiceUUID(), + vfResourceStructure.getResourceInstance().getResourceName(),"", ""); + } + + return status; + + } catch (Exception e) { + logger.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception - isResourceAlreadyDeployed"); + throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e); + } + } + + //@Override + public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct) throws ArtifactInstallerException { + + logger.debug("installTheResource is called"); + + VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct; + + for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { + + switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) { + case ASDCConfiguration.HEAT: + case ASDCConfiguration.HEAT_VOL: + case ASDCConfiguration.HEAT_NESTED: + ToscaResourceInstaller.createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, vfModuleArtifact); + break; + case ASDCConfiguration.HEAT_ENV: + ToscaResourceInstaller.createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact); + break; + case ASDCConfiguration.HEAT_ARTIFACT: + ToscaResourceInstaller.createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact, toscaResourceStruct); + break; + case ASDCConfiguration.HEAT_NET: + case ASDCConfiguration.OTHER: + logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT, vfModuleArtifact.getArtifactInfo().getArtifactType()+"(Artifact Name:"+vfModuleArtifact.getArtifactInfo().getArtifactName()+")", "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported"); + break; + default: + break; + + } + } + // Those objects could be reused by different VfModule + + + + // PCLO: in case of deployment failure, use a string that will represent the type of artifact that failed... + List artifactListForLogging = new ArrayList<>(); + + CatalogDatabase catalogDB = CatalogDatabase.getInstance(); + // 2. Create the VFModules/VNFResource objects by linking them to the + // objects created before and store them in Resource/module structure + // Opening a DB transaction, starting from here + try { + + + String vfModuleModelUUID = null; + + createToscaCsar(toscaResourceStruct); + + catalogDB.saveToscaCsar(toscaResourceStruct.getCatalogToscaCsar()); + + ToscaResourceInstaller.createService(toscaResourceStruct); + + catalogDB.saveService(toscaResourceStruct.getCatalogService()); + + + /* VNF POPULATION + * ************************************************************************************************************ + */ + + // Ingest (VNF) Data - 1707 + List vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList(); + int outerLoop = 0; + logger.debug("**vfMondeTEmplatesList.size()=" + vfNodeTemplatesList.size()); + for (NodeTemplate nodeTemplate : vfNodeTemplatesList) { + logger.debug("nodeTemplate outerLoop=" + outerLoop++); + // extract VF metadata + + Metadata metadata = nodeTemplate.getMetaData(); + + String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID); + logger.debug("vfCustomizationUUID=" + vfCustomizationUUID); + + + /* HEAT TABLE POPULATION + * ******************************************************************************************************* + */ + + int nextLoop = 0; + for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { + logger.debug("vfResourceStructure.getVfMOduleStructure() loop, nextLoop = " + nextLoop++); + logger.debug("vfModuleStructure:" + vfModuleStructure.toString()); + + // Here we set the right db structure according to the Catalog + // DB + + // We expect only one MAIN HEAT per VFMODULE + // we can also obtain from it the Env ArtifactInfo, that's why + // we + // get the Main IArtifactInfo + + HeatTemplate heatMainTemplate = null; + HeatEnvironment heatEnv = null; + + HeatTemplate heatVolumeTemplate = null; + HeatEnvironment heatVolumeEnv = null; + + + IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata(); + + + if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT)) { + + List artifacts = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT); + logger.debug("there are " + artifacts.size() + " artifacts"); + IArtifactInfo mainEnvArtifactInfo = null; + for (VfModuleArtifact vfma : artifacts) { + logger.debug("vmfa=" + vfma.toString()); + mainEnvArtifactInfo = + vfma.getArtifactInfo().getGeneratedArtifact(); + + // MAIN HEAT + heatMainTemplate = (HeatTemplate) vfma.getCatalogObject(); + + // Set HeatTemplateArtifactUUID to use later when setting the VfModule and NetworkResource + toscaResourceStruct.setHeatTemplateUUID(heatMainTemplate.getArtifactUuid()); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo + .createElementFromVfArtifactInfo(vfma.getArtifactInfo())); + + catalogDB.saveHeatTemplate(heatMainTemplate, heatMainTemplate.getParameters()); + // Indicate we have deployed it in the DB + vfma.incrementDeployedInDB(); + } + + + // VOLUME HEAT + // We expect only one VOL HEAT per VFMODULE + // we can also obtain from it the Env ArtifactInfo, that's why + // we get the Volume IArtifactInfo + + if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_VOL)) { + IArtifactInfo volEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0) + .getArtifactInfo().getGeneratedArtifact(); + + heatVolumeTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap() + .get(ASDCConfiguration.HEAT_VOL).get(0).getCatalogObject(); + + // Set VolHeatTemplate ArtifactUUID to use later when setting the VfModule + toscaResourceStruct.setVolHeatTemplateUUID(heatVolumeTemplate.getArtifactUuid()); + + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo())); + + catalogDB.saveHeatTemplate(heatVolumeTemplate, heatVolumeTemplate.getParameters()); + // Indicate we have deployed it in the DB + vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).incrementDeployedInDB(); + + if (volEnvArtifactInfo != null) { + heatVolumeEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID() + .get(volEnvArtifactInfo.getArtifactUUID()).getCatalogObject(); + + // Set VolHeatTemplate ArtifactUUID to use later when setting the VfModule + toscaResourceStruct.setVolHeatEnvTemplateUUID(heatVolumeEnv.getArtifactUuid()); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(volEnvArtifactInfo)); + + catalogDB.saveHeatEnvironment(heatVolumeEnv); + // Indicate we have deployed it in the DB + vfResourceStructure.getArtifactsMapByUUID().get(volEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB(); + } + + } + + // NESTED HEAT + // Here we expect many HEAT_NESTED template to be there + // XXX FIX BY PCLO: Defect# -36643 -US666034 - check first if we really have nested heat templates + if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_NESTED)) { + for (VfModuleArtifact heatNestedArtifact : vfModuleStructure.getArtifactsMap() + .get(ASDCConfiguration.HEAT_NESTED)) { + + // Check if this nested is well referenced by the MAIN HEAT + String parentArtifactType = ToscaResourceInstaller.identifyParentOfNestedTemplate(vfModuleStructure,heatNestedArtifact); + HeatTemplate heatNestedTemplate = (HeatTemplate) heatNestedArtifact.getCatalogObject(); + + if (parentArtifactType != null) { + + switch (parentArtifactType) { + case ASDCConfiguration.HEAT: + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); + + catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); + // Indicate we have deployed it in the DB + heatNestedArtifact.incrementDeployedInDB(); + break; + case ASDCConfiguration.HEAT_VOL: + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); + catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); + // Indicate we have deployed it in the DB + heatNestedArtifact.incrementDeployedInDB(); + break; + + default: + break; + + } + } else { // Assume it belongs to HEAT MAIN + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); + + catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); + // Indicate we have deployed it in the DB + heatNestedArtifact.incrementDeployedInDB(); + } + } + } + + if (mainEnvArtifactInfo != null) { + heatEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID() + .get(mainEnvArtifactInfo.getArtifactUUID()).getCatalogObject(); + + // Set HeatEnvironmentArtifactUUID to use later when setting the VfModule + toscaResourceStruct.setEnvHeatTemplateUUID(heatEnv.getArtifactUuid()); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(mainEnvArtifactInfo)); + + catalogDB.saveHeatEnvironment(heatEnv); + // Indicate we have deployed it in the DB + vfResourceStructure.getArtifactsMapByUUID().get(mainEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB(); + } + + // here we expect one VFModule to be there + //VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv); + //VfModule vfModule = vfModuleStructure.getCatalogVfModule(); + + // Add this one for logging + //artifactListForLogging.add(ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure)); + + //catalogDB.saveOrUpdateVfModule(vfModule); + + + // extract VF metadata + createVnfResource(nodeTemplate, toscaResourceStruct); + + // check for duplicate record already in the database + VnfResource vnfResource = catalogDB.getVnfResource(toscaResourceStruct.getCatalogVnfResource().getModelName(), + BigDecimalVersion.castAndCheckNotificationVersionToString( + toscaResourceStruct.getCatalogVnfResource().getVersion())); + + if (vnfResource != null) { + toscaResourceStruct.setVnfAlreadyInstalled(true); + } + + + if(!toscaResourceStruct.isVnfAlreadyInstalled()) { + + catalogDB.saveOrUpdateVnfResource(toscaResourceStruct.getCatalogVnfResource()); + + } + + + boolean saveVnfCustomization = catalogDB.saveVnfResourceCustomization(toscaResourceStruct.getCatalogVnfResourceCustomization()); + + if(saveVnfCustomization){ + catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogVfServiceToResourceCustomization()); + } + + List vfGroups = toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID); + logger.debug("vfGroups:" + vfGroups.toString()); + + Collections.sort(vfGroups, new Comparator() { + @Override + public int compare(org.openecomp.sdc.toscaparser.api.Group group1, org.openecomp.sdc.toscaparser.api.Group group2) { + + //Field name1Field = group1.class.getDeclaredField("name"); + //name1Field.setAccessible(true); + String thisName = group1.getName(); //(String) name1Field.get(group1); + String thatName = group2.getName(); // (String) name1Field.get(group2); + + Matcher m = lastDigit.matcher(thisName); + Matcher m2 = lastDigit.matcher(thatName); + + String thisDigit = "0"; + String thatDigit = "0"; + if (m.find()) { + thisDigit = m.group(); + } else { + return -1; + } + if (m2.find()) { + thatDigit = m2.group(); + } else { + return 1; + } + + return new Integer(thisDigit).compareTo(new Integer(thatDigit)); + + } + }); + + logger.debug("vfGroupsAfter:" + vfGroups.toString()); + + + for(Group group : vfGroups){ + + + //boolean saveVFModule = createVFModule(group, nodeTemplate, toscaResourceStruct, vfMetadata); + if (vfMetadata.getVfModuleModelCustomizationUUID() == null) { + logger.debug("NULL 1"); + } else { + logger.debug("vfMetadata.getMCU=" + vfMetadata.getVfModuleModelCustomizationUUID()); + } + if (group.getMetadata() == null) { + logger.debug("NULL 3"); + } else { + logger.debug("group.getMetadata().getValue() = " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")); + } + if (vfMetadata.getVfModuleModelCustomizationUUID().equals(group.getMetadata().getValue("vfModuleModelCustomizationUUID"))) { + logger.debug("Found a match at " + vfMetadata.getVfModuleModelCustomizationUUID()); + createVFModule(group, nodeTemplate, toscaResourceStruct, vfResourceStructure, vfMetadata); + + catalogDB.saveOrUpdateVfModule(toscaResourceStruct.getCatalogVfModule()); + + catalogDB.saveOrUpdateVfModuleCustomization(toscaResourceStruct.getCatalogVfModuleCustomization()); + + catalogDB.saveVnfResourceToVfModuleCustomization(toscaResourceStruct.getCatalogVnfResourceCustomization(), toscaResourceStruct.getCatalogVfModuleCustomization()); + + + } else { + if(toscaResourceStruct.getCatalogVfModuleCustomization() != null){ + logger.debug("No match for " + toscaResourceStruct.getCatalogVfModuleCustomization().getModelCustomizationUuid()); + } else { + logger.debug("No match for vfModuleModelCustomizationUUID"); + } + } + + } + + } //Commented out to process VFModules each time + + + + // Here we expect many HEAT_TEMPLATE files to be there + if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_ARTIFACT)) { + for (VfModuleArtifact heatArtifact : vfModuleStructure.getArtifactsMap() + .get(ASDCConfiguration.HEAT_ARTIFACT)) { + + HeatFiles heatFile = (HeatFiles) heatArtifact.getCatalogObject(); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatArtifact.getArtifactInfo())); + + if(toscaResourceStruct.getCatalogVfModule() != null && heatFile != null){ + catalogDB.saveVfModuleToHeatFiles (toscaResourceStruct.getCatalogVfModule().getModelUUID(), heatFile); + } + // Indicate we will deploy it in the DB + heatArtifact.incrementDeployedInDB(); + } + } + + } + + } + + /* END OF HEAT TABLE POPULATION + * *************************************************************************************************** + */ + + + // throw new ArtifactInstallerException("TESTING"); + + + List allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources(); + + if(allottedResourceList != null){ + + for(NodeTemplate allottedNode : allottedResourceList){ + + createAllottedResource(allottedNode, toscaResourceStruct); + + catalogDB.saveAllottedResource(toscaResourceStruct.getAllottedResource()); + + catalogDB.saveAllottedResourceCustomization(toscaResourceStruct.getCatalogAllottedResourceCustomization()); + + catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogAllottedServiceToResourceCustomization()); + + } + } + + + List nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList(); + + if(nodeTemplatesVLList != null){ + + for(NodeTemplate vlNode : nodeTemplatesVLList){ + + String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim(); + + List networkHeatTemplateLookup = catalogDB.getTempNetworkHeatTemplateLookup(networkResourceModelName); + + if(networkHeatTemplateLookup != null && networkHeatTemplateLookup.size() > 0 ){ + + createNetworkResource(vlNode, toscaResourceStruct, networkHeatTemplateLookup.get(0)); + + } else { + throw new ArtifactInstallerException("No NetworkResourceName found in TempNetworkHeatTemplateLookup for " + networkResourceModelName); + } + + + catalogDB.saveNetworkResource(toscaResourceStruct.getCatalogNetworkResource()); + + catalogDB.saveNetworkResourceCustomization(toscaResourceStruct.getCatalogNetworkResourceCustomization()); + + catalogDB.saveServiceToResourceCustomization(toscaResourceStruct.getCatalogVlServiceToResourceCustomization()); + + } + } + + + //createServiceToResourceCustomization(toscaResourceStruct.getCatalogService(), toscaResourceStruct.getCatalogVnfResourceCustomization(), toscaResourceStruct); + + // catalogDB.saveToscaCsar(toscaResourceStruct.getCatalogToscaCsar()); + + + catalogDB.commit(); + vfResourceStructure.setSuccessfulDeployment(); + + }catch(Exception e){ + System.out.println("Exception" + e.getMessage()); + e.printStackTrace(); + + Throwable dbExceptionToCapture = e; + while (!(dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) + && (dbExceptionToCapture.getCause() != null)) { + dbExceptionToCapture = dbExceptionToCapture.getCause(); + } + + if (dbExceptionToCapture instanceof ConstraintViolationException || dbExceptionToCapture instanceof LockAcquisitionException) { + logger.warn(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED, vfResourceStructure.getResourceInstance().getResourceName(), + vfResourceStructure.getNotification().getServiceVersion(), "", "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e); + } else { + String endEvent = "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback."; + String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed"); + logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback", e); + catalogDB.rollback(); + throw new ArtifactInstallerException( + "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e); + } + + } + + } + + + public static String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure, List listTypes) { + String newFileBody = filebody; + for (VfModuleArtifact moduleArtifact:vfResourceStructure.getArtifactsMapByUUID().values()) { + + if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) { + + newFileBody = verifyTheFilePrefixInString(newFileBody,moduleArtifact.getArtifactInfo().getArtifactName()); + } + } + return newFileBody; + } + + public static String verifyTheFilePrefixInString(final String body, final String filenameToVerify) { + + String needlePrefix = "file:///"; + String prefixedFilenameToVerify = needlePrefix+filenameToVerify; + + if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) { + return body; + } + + StringBuffer sb = new StringBuffer(body.length()); + + int currentIndex = 0; + int startIndex = 0; + + while (currentIndex != -1) { + startIndex = currentIndex; + currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex); + + if (currentIndex == -1) { + break; + } + + // We append from the startIndex up to currentIndex (start of File Name) + sb.append(body.substring(startIndex, currentIndex)); + sb.append(filenameToVerify); + + currentIndex += prefixedFilenameToVerify.length(); + } + + sb.append(body.substring(startIndex)); + + return sb.toString(); + } + + + private static void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,ToscaResourceStructure toscaResourceStruct, + VfModuleArtifact vfModuleArtifact) { + HeatTemplate heatTemplate = new HeatTemplate(); + + // TODO Set the label +// heatTemplate.setAsdcLabel("label"); + // Use the ResourceName of the ASDC template because the HEAT could be + // reused +// heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); + heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + + List typeList = new ArrayList(); + typeList.add(ASDCConfiguration.HEAT_NESTED); + typeList.add(ASDCConfiguration.HEAT_ARTIFACT); + + heatTemplate.setTemplateBody(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList)); + heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName()); + + if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) { + heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout()); + } else { + heatTemplate.setTimeoutMinutes(240); + } + + //toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + + heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); + heatTemplate.setVersion(BigDecimalVersion + .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); + heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + + if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){ + heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); + } else { + heatTemplate.setArtifactChecksum("MANUAL_RECORD"); + } + + Set heatParam = ToscaResourceInstaller + .extractHeatTemplateParameters(vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + heatTemplate.setParameters(heatParam); + //heatTemplate.setCreated(getCurrentTimeStamp()); + + vfModuleArtifact.setCatalogObject(heatTemplate); + } + + private static void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure, + VfModuleArtifact vfModuleArtifact) { + HeatEnvironment heatEnvironment = new HeatEnvironment(); + + heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName()); + // TODO Set the label +// heatEnvironment.setAsdcLabel("Label"); + + List typeList = new ArrayList(); + typeList.add(ASDCConfiguration.HEAT); + typeList.add(ASDCConfiguration.HEAT_VOL); + + heatEnvironment.setEnvironment(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList)); +// heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); + heatEnvironment.setVersion(BigDecimalVersion + .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); +// heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure)); + heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + + if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){ + heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); + } else{ + heatEnvironment.setArtifactChecksum("MANUAL_RECORD"); + } + //heatEnvironment.setCreated(getCurrentTimeStamp()); + + vfModuleArtifact.setCatalogObject(heatEnvironment); + + } + + private static void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure, + VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) { + + HeatFiles heatFile = new HeatFiles(); + // TODO Set the label +// heatFile.setAsdcLabel("Label"); + heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); + heatFile.setFileBody(vfModuleArtifact.getResult()); + heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName()); + heatFile.setVersion(BigDecimalVersion + .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); + + toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + //heatFile.setCreated(getCurrentTimeStamp()); + +// heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); + + + if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){ + heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); + } else { + heatFile.setArtifactChecksum("MANUAL_RECORD"); + } + + vfModuleArtifact.setCatalogObject(heatFile); + + } + + private static void createService(ToscaResourceStructure toscaResourceStructure) { + + toscaResourceStructure.getServiceMetadata(); + + Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata(); + + Service service = new Service(); + + // Service + if(serviceMetadata != null){ + + if(toscaResourceStructure.getServiceVersion() != null){ + service.setVersion(toscaResourceStructure.getServiceVersion()); + } + + service.setServiceType(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(serviceMetadata, "serviceType")); + service.setServiceRole(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(serviceMetadata, "serviceRole")); + + service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)); + service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)); + service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)); + //service.setVersion(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)); + service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)); + service.setToscaCsarArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID()); + //service.setCreated(getCurrentTimeStamp()); + } + + toscaResourceStructure.setCatalogService(service); + } + + private static void createToscaCsar(ToscaResourceStructure toscaResourceStructure) { + + ToscaCsar toscaCsar = new ToscaCsar(); + if(toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null){ + toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum()); + } else { + toscaCsar.setArtifactChecksum("MANUAL_RECORD"); + } + toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID()); + toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName()); + toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion()); + toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription()); + toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL()); + + toscaResourceStructure.setCatalogToscaCsar(toscaCsar); + } + + private static void createNetworkResource(NodeTemplate networkNodeTemplate, ToscaResourceStructure toscaResourceStructure, TempNetworkHeatTemplateLookup networkHeatTemplateLookup) { + NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization(); + + NetworkResource networkResource = new NetworkResource(); + + String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK); + + if(providerNetwork != null && providerNetwork.equalsIgnoreCase("true")){ + networkResource.setNeutronNetworkType("PROVIDER"); + } else { + networkResource.setNeutronNetworkType("BASIC"); + } + + networkResource.setModelName(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim())); + + networkResource.setModelInvariantUUID(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + networkResource.setModelUUID(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + networkResource.setModelVersion(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + + networkResource.setAicVersionMax(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES))); + networkResource.setAicVersionMin(networkHeatTemplateLookup.getAicVersionMin()); + networkResource.setToscaNodeType(networkNodeTemplate.getType()); + networkResource.setDescription(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + networkResource.setOrchestrationMode("HEAT"); + networkResource.setHeatTemplateArtifactUUID(networkHeatTemplateLookup.getHeatTemplateArtifactUuid()); + + toscaResourceStructure.setCatalogNetworkResource(networkResource); + + networkResourceCustomization.setModelInstanceName(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim())); + networkResourceCustomization.setModelCustomizationUuid(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim())); + networkResourceCustomization.setNetworkResourceModelUuid(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim())); + + + networkResourceCustomization.setNetworkTechnology(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)).trim()); + networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)).trim()); + networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)).trim()); + networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)).trim()); + + toscaResourceStructure.setCatalogNetworkResourceCustomization(networkResourceCustomization); + + ServiceToResourceCustomization serviceToResourceCustomization = new ServiceToResourceCustomization(); + serviceToResourceCustomization.setServiceModelUUID(toscaResourceStructure.getCatalogService().getModelUUID()); + serviceToResourceCustomization.setResourceModelCustomizationUUID(testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim())); + serviceToResourceCustomization.setModelType("network"); + + toscaResourceStructure.setCatalogVlServiceToResourceCustomization(serviceToResourceCustomization); + + + } + + private static void createVFModule(Group group, NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure, IVfModuleData vfModuleData) { + VfModule vfModule = new VfModule(); + boolean isBase = false; + + Metadata vfMetadata = group.getMetadata(); + + String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID(); + + + if(vfModuleModelUUID != null && vfModuleModelUUID.indexOf(".") > -1){ + vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf(".")); + } + + + for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()){ + + String vfModelUUID = vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID(); + + if(vfModelUUID != null && vfModelUUID.equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))){ + + List artifacts = vfModuleStructure.getVfModuleMetadata().getArtifacts(); + + for(String artifact: artifacts){ + + + for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { + + + if(artifact.equals(vfModuleArtifact.getArtifactInfo().getArtifactUUID())){ + //if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)){ + if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)){ + vfModule.setHeatTemplateArtifactUUId(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + } + + if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)){ + vfModule.setVolHeatTemplateArtifactUUId(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + + } + } + + } + + + } + + + } + + + } + + vfModule.setModelInvariantUuid(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID))); + vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME))); + vfModule.setModelUUID(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID))); + vfModule.setVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION))); + vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + //vfModule.setHeatTemplateArtifactUUId(toscaResourceStructure.getHeatTemplateUUID()); + //vfModule.setVolHeatTemplateArtifactUUId(toscaResourceStructure.getVolHeatTemplateUUID()); + + vfModule.setVnfResourceModelUUId(toscaResourceStructure.getCatalogVnfResource().getModelUuid()); + + String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE); + if(vfModuleType != null && vfModuleType.equalsIgnoreCase("Base")){ + vfModule.setIsBase(1); + }else { + vfModule.setIsBase(0); + } + + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUuid(vfModuleData.getVfModuleModelCustomizationUUID()); + + + vfModuleCustomization.setVfModuleModelUuid(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)); + + vfModuleCustomization.setHeatEnvironmentArtifactUuid(toscaResourceStructure.getEnvHeatTemplateUUID()); + + + vfModuleCustomization.setVolEnvironmentArtifactUuid(toscaResourceStructure.getVolHeatEnvTemplateUUID()); + + String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT); + if(initialCount != null && initialCount.length() > 0){ + vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount)); + } + + vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT))); + + String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT); + if(availabilityZoneCount != null && availabilityZoneCount.length() > 0){ + vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount)); + } + + + vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL)); + + String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES); + if(maxInstances != null && maxInstances.length() > 0){ + vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances)); + } + + String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES); + if(minInstances != null && minInstances.length() > 0){ + vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances)); + } + + toscaResourceStructure.setCatalogVfModule(vfModule); + + toscaResourceStructure.setCatalogVfModuleCustomization(vfModuleCustomization); + + } + + private static void createVnfResourceToVfModuleCustomization(VnfResourceCustomization vnfResourceCustomization, + VfModuleCustomization vfModuleCustomization, + ToscaResourceStructure toscaResourceStructure) { + + VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom = new VnfResCustomToVfModuleCustom(); + + vnfResCustomToVfModuleCustom.setVfModuleCustModelCustomizationUuid(vfModuleCustomization.getModelCustomizationUuid()); + vnfResCustomToVfModuleCustom.setVnfResourceCustModelCustomizationUuid(vnfResourceCustomization.getModelCustomizationUuid()); + + toscaResourceStructure.setCatalogVnfResCustomToVfModuleCustom(vnfResCustomToVfModuleCustom); + + + + } + + + private static void createTempNetworkHeatTemplateLookup(NetworkResource networkResource, + VfModule vfModule, + ToscaResourceStructure toscaResourceStructure) { + + TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup(); + + tempNetworkHeatTemplateLookup.setNetworkResourceModelName(networkResource.getModelName()); + tempNetworkHeatTemplateLookup.setHeatTemplateArtifactUuid(vfModule.getHeatTemplateArtifactUUId()); + tempNetworkHeatTemplateLookup.setAicVersionMin("1"); + + toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(tempNetworkHeatTemplateLookup); + + + + } + + private static void createVnfResource(NodeTemplate vfNodeTemplate, ToscaResourceStructure toscaResourceStructure) { + VnfResource vnfResource = new VnfResource(); + + + //toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT) + + vnfResource.setModelInvariantUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim())); + vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim())); + vnfResource.setModelUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim())); + + vnfResource.setVersion(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim())); + vnfResource.setDescription(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION).trim())); + vnfResource.setOrchestrationMode("HEAT"); + vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType())); + vnfResource.setAicVersionMax(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES).trim())); + vnfResource.setAicVersionMin(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES).trim())); + //vnfResource.setHeatTemplateArtifactUUId(toscaResourceStructure.getHeatTemplateUUID()); + + // vfNodeTemplate.getProperties() + toscaResourceStructure.setCatalogVnfResource(vnfResource); + + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setModelCustomizationUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim())); + vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName()); + + vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)).trim()); + vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFCODE)).trim()); + vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)).trim()); + vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)).trim()); + + + vnfResourceCustomization.setVnfResourceModelUuid(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim())); + vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT).trim())); + + vnfResourceCustomization.setMaxInstances(Integer.getInteger(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES).trim())); + vnfResourceCustomization.setMinInstances(Integer.getInteger(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES).trim())); + + + + toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization); + + + ServiceToResourceCustomization serviceToResourceCustomization = new ServiceToResourceCustomization(); + serviceToResourceCustomization.setServiceModelUUID(toscaResourceStructure.getCatalogService().getModelUUID()); + serviceToResourceCustomization.setResourceModelCustomizationUUID(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim()); + serviceToResourceCustomization.setModelType("vnf"); + + toscaResourceStructure.setCatalogVfServiceToResourceCustomization(serviceToResourceCustomization); + + + } + + private static void createAllottedResource(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) { + AllottedResource allottedResource = new AllottedResource(); + + allottedResource.setModelUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim())); + allottedResource.setModelInvariantUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim())); + allottedResource.setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim())); + allottedResource.setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim())); + allottedResource.setToscaNodeType(testNull(nodeTemplate.getType())); + + toscaResourceStructure.setAllottedResource(allottedResource); + + AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization(); + allottedResourceCustomization.setModelCustomizationUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim())); + allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName()); + allottedResourceCustomization.setArModelUuid(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim())); + + allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)).trim()); + allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFCODE)).trim()); + allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)).trim()); + allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)).trim()); + + toscaResourceStructure.setCatalogAllottedResourceCustomization(allottedResourceCustomization); + + ServiceToResourceCustomization serviceToResourceCustomization = new ServiceToResourceCustomization(); + serviceToResourceCustomization.setServiceModelUUID(toscaResourceStructure.getCatalogService().getModelUUID()); + serviceToResourceCustomization.setResourceModelCustomizationUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim())); + serviceToResourceCustomization.setModelType("allottedResource"); + + toscaResourceStructure.setCatalogAllottedServiceToResourceCustomization(serviceToResourceCustomization); + + } + + private static Set extractHeatTemplateParameters(String yamlFile, String artifactUUID) { + + // Scan the payload downloadResult and extract the HeatTemplate + // parameters + YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes()); + return yamlEditor.getParameterList(artifactUUID); + + } + + private static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,VfModuleArtifact heatNestedArtifact) { + + if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null + && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) { + for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0) + .getArtifactInfo().getRelatedArtifacts()) { + if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) { + return ASDCConfiguration.HEAT; + } + + } + } + + if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null + && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts() != null) { + for (IArtifactInfo unknownArtifact:vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo().getRelatedArtifacts()) { + if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) { + return ASDCConfiguration.HEAT_VOL; + } + + } + } + + // Does not belong to anything + return null; + + } + + private static String testNull(Object object) { + if (object == null) { + return ""; + } else if (object.equals("null")) { + return null; + }else if (object instanceof Integer) { + return object.toString(); + } else if (object instanceof String) { + return (String)object; + } else { + return "Type not recognized"; + } + } + + private static String createVNFName(VfResourceStructure vfResourceStructure) { + + return vfResourceStructure.getNotification().getServiceName() + "/" + vfResourceStructure.getResourceInstance().getResourceInstanceName(); + } + + private static String createVfModuleName(VfModuleStructure vfModuleStructure) { + + return createVNFName(vfModuleStructure.getParentVfResource())+"::"+vfModuleStructure.getVfModuleMetadata().getVfModuleModelName(); + } + + + private static Timestamp getCurrentTimeStamp() { + + return new Timestamp(new Date().getTime()); + } + +} \ No newline at end of file diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java index 5f28cb48f2..63f5e3f04b 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java @@ -72,7 +72,7 @@ public class VfResourceInstaller implements IVfResourceInstaller { boolean status = false; VfResourceStructure vfResourceStructure = (VfResourceStructure)vfResourceStruct; - try(CatalogDatabase db = new CatalogDatabase()) { + try(CatalogDatabase db = CatalogDatabase.getInstance()) { String resourceType = vfResourceStruct.getResourceInstance().getResourceType(); String category = vfResourceStruct.getResourceInstance().getCategory(); @@ -209,7 +209,7 @@ public class VfResourceInstaller implements IVfResourceInstaller { // in case of deployment failure, use a string that will represent the type of artifact that failed... List artifactListForLogging = new ArrayList<>(); - CatalogDatabase catalogDB = new CatalogDatabase(); + CatalogDatabase catalogDB = CatalogDatabase.getInstance(); // 2. Create the VFModules/VNFResource objects by linking them to the // objects created before and store them in Resource/module structure // Opening a DB transaction, starting from here @@ -337,7 +337,7 @@ public class VfResourceInstaller implements IVfResourceInstaller { // Add this one for logging artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); - catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); + catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); // Indicate we have deployed it in the DB heatNestedArtifact.incrementDeployedInDB(); break; @@ -345,7 +345,7 @@ public class VfResourceInstaller implements IVfResourceInstaller { // Add this one for logging artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); - catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); + catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); // Indicate we have deployed it in the DB heatNestedArtifact.incrementDeployedInDB(); break; @@ -358,7 +358,7 @@ public class VfResourceInstaller implements IVfResourceInstaller { // Add this one for logging artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); - catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); + catalogDB.saveNestedHeatTemplate (heatMainTemplate.getArtifactUuid(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); // Indicate we have deployed it in the DB heatNestedArtifact.incrementDeployedInDB(); } @@ -381,7 +381,7 @@ public class VfResourceInstaller implements IVfResourceInstaller { // here we expect one VFModule to be there - VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv); +/* VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv); VfModule vfModule = vfModuleStructure.getCatalogVfModule(); // Add this one for logging @@ -400,11 +400,11 @@ public class VfResourceInstaller implements IVfResourceInstaller { artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatArtifact.getArtifactInfo())); - catalogDB.saveVfModuleToHeatFiles (vfModule.getId(), heatFile); + catalogDB.saveVfModuleToHeatFiles (vfModule.getArtifactUuid(), heatFile); // Indicate we will deploy it in the DB heatArtifact.incrementDeployedInDB(); } - } + } */ } @@ -470,22 +470,24 @@ public class VfResourceInstaller implements IVfResourceInstaller { private static void createVnfResource(VfResourceStructure vfResourceStructure) { VnfResource vnfResource = new VnfResource(); - vnfResource.setAsdcUuid(vfResourceStructure.getResourceInstance().getResourceUUID()); + vnfResource.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID()); vnfResource.setDescription(vfResourceStructure.getNotification().getServiceDescription()); vnfResource.setOrchestrationMode("HEAT"); // Set the version but Version is stored into ASDC_SERVICE_MODEL_VERSION vnfResource.setVersion(BigDecimalVersion .castAndCheckNotificationVersionToString(vfResourceStructure.getNotification().getServiceVersion())); - vnfResource.setVnfType(VfResourceInstaller.createVNFName(vfResourceStructure)); +// vnfResource.setVnfType(VfResourceInstaller.createVNFName(vfResourceStructure)); vnfResource.setModelVersion(BigDecimalVersion .castAndCheckNotificationVersionToString(vfResourceStructure.getResourceInstance().getResourceVersion())); vnfResource.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID()); - vnfResource.setModelCustomizationName(vfResourceStructure.getResourceInstance().getResourceInstanceName()); - vnfResource.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID()); + vnfResource.setModelVersion(vfResourceStructure.getResourceInstance().getResourceVersion()); +// vnfResource.setModelCustomizationName(vfResourceStructure.getResourceInstance().getResourceInstanceName()); +// vnfResource.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID()); vnfResource.setModelName(vfResourceStructure.getResourceInstance().getResourceName()); - vnfResource.setServiceModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID()); +// vnfResource.setServiceModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID()); + //vnfResource.setCreated(getCurrentTimeStamp()); vfResourceStructure.setCatalogVnfResource(vnfResource); @@ -495,11 +497,11 @@ public class VfResourceInstaller implements IVfResourceInstaller { NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization(); networkResourceCustomization.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID().trim()); - networkResourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim()); +// networkResourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim()); networkResourceCustomization.setModelInstanceName(vfResourceStructure.getResourceInstance().getResourceInstanceName().trim()); - networkResourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim()); - networkResourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim()); - networkResourceCustomization.setModelVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim()); +// networkResourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim()); +// networkResourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim()); +// networkResourceCustomization.setModelVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim()); //networkResourceCustomization.setCreated(getCurrentTimeStamp()); vfResourceStructure.setCatalogNetworkResourceCustomization(networkResourceCustomization); @@ -516,10 +518,10 @@ public class VfResourceInstaller implements IVfResourceInstaller { AllottedResourceCustomization resourceCustomization = new AllottedResourceCustomization(); resourceCustomization.setModelCustomizationUuid(vfResourceStructure.getResourceInstance().getResourceCustomizationUUID().trim()); - resourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim()); +// resourceCustomization.setModelName(vfResourceStructure.getResourceInstance().getResourceName().trim()); resourceCustomization.setModelInstanceName(vfResourceStructure.getResourceInstance().getResourceInstanceName().trim()); - resourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim()); - resourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim()); +// resourceCustomization.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID().trim()); +// resourceCustomization.setModelUuid(vfResourceStructure.getResourceInstance().getResourceUUID().trim()); resourceCustomization.setVersion(vfResourceStructure.getResourceInstance().getResourceVersion().trim()); //resourceCustomization.setCreated(getCurrentTimeStamp()); @@ -535,8 +537,8 @@ public class VfResourceInstaller implements IVfResourceInstaller { private static void createVfModule(VfModuleStructure vfModuleStructure,HeatTemplate heatMain, HeatTemplate heatVolume,HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) { VfModule vfModule = new VfModule(); - vfModule.setType(createVfModuleName(vfModuleStructure)); - vfModule.setAsdcUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID()); +// vfModule.setType(createVfModuleName(vfModuleStructure)); +// vfModule.setAsdcUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID()); vfModule.setDescription(vfModuleStructure.getVfModuleMetadata().getVfModuleModelDescription()); if (vfModuleStructure.getVfModuleMetadata().isBase()) { @@ -545,7 +547,7 @@ public class VfResourceInstaller implements IVfResourceInstaller { vfModule.setIsBase(0); } - vfModule.setModelCustomizationUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelCustomizationUUID()); +// vfModule.setModelCustomizationUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelCustomizationUUID()); vfModule.setModelInvariantUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelInvariantUUID()); vfModule.setModelName(vfModuleStructure.getVfModuleMetadata().getVfModuleModelName()); @@ -558,16 +560,16 @@ public class VfResourceInstaller implements IVfResourceInstaller { if(map != null){ if(map.get("vf_module_label") != null){ - vfModule.setLabel(map.get("vf_module_label")); +// vfModule.setLabel(map.get("vf_module_label")); } if(map.get("initial_count") != null && map.get("initial_count").length() > 0){ - vfModule.setInitialCount(Integer.parseInt(map.get("initial_count"))); +// vfModule.setInitialCount(Integer.parseInt(map.get("initial_count"))); } if(map.get("min_vf_module_instances") != null && map.get("min_vf_module_instances").length() > 0){ - vfModule.setMinInstances(Integer.parseInt(map.get("min_vf_module_instances"))); +// vfModule.setMinInstances(Integer.parseInt(map.get("min_vf_module_instances"))); } if(map.get("max_vf_module_instances") != null && map.get("max_vf_module_instances").length() > 0){ - vfModule.setMaxInstances(Integer.parseInt(map.get("max_vf_module_instances"))); +// vfModule.setMaxInstances(Integer.parseInt(map.get("max_vf_module_instances"))); } } @@ -581,28 +583,29 @@ public class VfResourceInstaller implements IVfResourceInstaller { HeatTemplate heatVolume, HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) { if (heatMain !=null) { - vfModule.setTemplateId(heatMain.getId()); +// vfModule.setTemplateId(heatMain.getId()); } if (heatEnv != null) { - vfModule.setEnvironmentId(heatEnv.getId()); +// vfModule.setEnvironmentId(heatEnv.getId()); } if (heatVolume != null) { - vfModule.setVolTemplateId(heatVolume.getId()); +// vfModule.setVolTemplateId(heatVolume.getId()); } if (heatVolumeEnv != null) { - vfModule.setVolEnvironmentId(heatVolumeEnv.getId()); +// vfModule.setVolEnvironmentId(heatVolumeEnv.getId()); } - vfModule.setVnfResourceId(vnfResource.getId()); +// vfModule.setVnfResourceId(vnfResource.getId()); } - private static Set extractHeatTemplateParameters(String yamlFile) { + + private static Set extractHeatTemplateParameters(String yamlFile, String artifactUUID) { // Scan the payload downloadResult and extract the HeatTemplate // parameters YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes()); - return yamlEditor.getParameterList(); + return yamlEditor.getParameterList(artifactUUID); } @@ -658,10 +661,10 @@ public class VfResourceInstaller implements IVfResourceInstaller { HeatTemplate heatTemplate = new HeatTemplate(); // TODO Set the label - heatTemplate.setAsdcLabel("label"); +// heatTemplate.setAsdcLabel("label"); // Use the ResourceName of the ASDC template because the HEAT could be // reused - heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); +// heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); List typeList = new ArrayList(); @@ -680,6 +683,7 @@ public class VfResourceInstaller implements IVfResourceInstaller { heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); heatTemplate.setVersion(BigDecimalVersion .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); + heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){ heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); @@ -688,8 +692,9 @@ public class VfResourceInstaller implements IVfResourceInstaller { } Set heatParam = VfResourceInstaller - .extractHeatTemplateParameters(vfModuleArtifact.getResult()); + .extractHeatTemplateParameters(vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID()); heatTemplate.setParameters(heatParam); + //heatTemplate.setCreated(getCurrentTimeStamp()); vfModuleArtifact.setCatalogObject(heatTemplate); } @@ -700,24 +705,26 @@ public class VfResourceInstaller implements IVfResourceInstaller { heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName()); // TODO Set the label - heatEnvironment.setAsdcLabel("Label"); +// heatEnvironment.setAsdcLabel("Label"); List typeList = new ArrayList(); typeList.add(ASDCConfiguration.HEAT); typeList.add(ASDCConfiguration.HEAT_VOL); heatEnvironment.setEnvironment(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList)); - heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); +// heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); heatEnvironment.setVersion(BigDecimalVersion .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); - heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure)); +// heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure)); + heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){ heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); } else{ heatEnvironment.setArtifactChecksum("MANUAL_RECORD"); } + //heatEnvironment.setCreated(getCurrentTimeStamp()); vfModuleArtifact.setCatalogObject(heatEnvironment); @@ -728,15 +735,16 @@ public class VfResourceInstaller implements IVfResourceInstaller { HeatFiles heatFile = new HeatFiles(); // TODO Set the label - heatFile.setAsdcLabel("Label"); +// heatFile.setAsdcLabel("Label"); heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); heatFile.setFileBody(vfModuleArtifact.getResult()); heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName()); heatFile.setVersion(BigDecimalVersion .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); + //heatFile.setCreated(getCurrentTimeStamp()); - heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); +// heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); if(vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null){ heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum()); @@ -752,10 +760,11 @@ public class VfResourceInstaller implements IVfResourceInstaller { Service service = new Service(); service.setDescription(vfResourceStructure.getNotification().getServiceDescription()); - service.setServiceName(vfResourceStructure.getNotification().getServiceName()); - service.setServiceNameVersionId(vfResourceStructure.getNotification().getServiceUUID()); + service.setModelName(vfResourceStructure.getNotification().getServiceName()); + service.setModelUUID(vfResourceStructure.getNotification().getServiceUUID()); service.setVersion(vfResourceStructure.getNotification().getServiceVersion()); service.setModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID()); + //service.setCreated(getCurrentTimeStamp()); vfResourceStructure.setCatalogService(service); } diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java index a355f0547a..085d761c0a 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java @@ -27,8 +27,13 @@ import java.util.Map; import org.openecomp.sdc.api.notification.IArtifactInfo; import org.openecomp.sdc.api.notification.INotificationData; import org.openecomp.sdc.api.notification.IResourceInstance; - +import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; +import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames; +import org.openecomp.sdc.toscaparser.api.Group; +import org.openecomp.sdc.toscaparser.api.NodeTemplate; +import org.openecomp.sdc.toscaparser.api.elements.Metadata; import org.openecomp.mso.asdc.installer.IVfModuleData; +import org.openecomp.mso.asdc.installer.ToscaResourceStructure; public class ASDCNotificationLogging { @@ -84,6 +89,198 @@ public class ASDCNotificationLogging { return buffer.toString(); } + public static String dumpCSARNotification(INotificationData asdcNotification, ToscaResourceStructure toscaResourceStructure) { + + if (asdcNotification == null) { + return "NULL"; + } + + + StringBuffer buffer = new StringBuffer("CSAR Notification:"); + buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); + + + ISdcCsarHelper csarHelper = toscaResourceStructure.getSdcCsarHelper(); + + + buffer.append("Service Level Properties:"); + buffer.append(System.lineSeparator()); + buffer.append("Name:"); + buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME))); + buffer.append(System.lineSeparator()); + buffer.append("Description:"); + buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION))); + buffer.append(System.lineSeparator()); + buffer.append("Model UUID:"); + buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID))); + buffer.append(System.lineSeparator()); + buffer.append("Model Version:"); + buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION))); + buffer.append(System.lineSeparator()); + buffer.append("Model InvariantUuid:"); + buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID))); + + buffer.append(System.lineSeparator()); + buffer.append(System.lineSeparator()); + buffer.append("VNF Level Properties:"); + buffer.append(System.lineSeparator()); + + List vfNodeTemplatesList = toscaResourceStructure.getSdcCsarHelper().getServiceVfList(); + for (NodeTemplate vfNodeTemplate : vfNodeTemplatesList) { + + buffer.append("Model Name:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Description:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Version:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Type:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE).trim())); + buffer.append(System.lineSeparator()); + buffer.append("InvariantUuid:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Max Instances:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Min Instances:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES).trim())); + buffer.append(System.lineSeparator()); + + buffer.append(System.lineSeparator()); + buffer.append("VNF Customization Properties:"); + buffer.append(System.lineSeparator()); + + buffer.append("Customization UUID:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim())); + buffer.append(System.lineSeparator()); + buffer.append("NFFunction:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION).trim())); + buffer.append(System.lineSeparator()); + buffer.append("NFCode:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NFCODE).trim())); + buffer.append(System.lineSeparator()); + buffer.append("NFRole:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NFROLE).trim())); + buffer.append(System.lineSeparator()); + buffer.append("NFType:"); + buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NFTYPE).trim())); + buffer.append(System.lineSeparator()); + + buffer.append(System.lineSeparator()); + buffer.append("VF Module Properties:"); + buffer.append(System.lineSeparator()); + List vfGroups = toscaResourceStructure.getSdcCsarHelper().getVfModulesByVf(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim())); + + for(Group group : vfGroups){ + + Metadata vfMetadata = group.getMetadata(); + + buffer.append("ModelInvariantUuid:"); + buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID).trim())); + buffer.append(System.lineSeparator()); + buffer.append("ModelName:"); + buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME).trim())); + buffer.append(System.lineSeparator()); + buffer.append("ModelUuid:"); + buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID).trim())); + buffer.append(System.lineSeparator()); + buffer.append("ModelVersion:"); + buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Description:"); + buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION).trim())); + buffer.append(System.lineSeparator()); + } + + } + + + List nodeTemplatesVLList = toscaResourceStructure.getSdcCsarHelper().getServiceVlList(); + + if(nodeTemplatesVLList != null){ + + buffer.append(System.lineSeparator()); + buffer.append("NETWORK Level Properties:"); + buffer.append(System.lineSeparator()); + + for(NodeTemplate vlNode : nodeTemplatesVLList){ + + buffer.append("Model Name:"); + buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Model InvariantUuid:"); + buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Model UUID:"); + buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Model Version:"); + buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim())); + buffer.append(System.lineSeparator()); + buffer.append("AIC Max Version:"); + buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES).trim())); + buffer.append(System.lineSeparator()); + buffer.append("AIC Min Version:"); + buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Tosca Node Type:"); + buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Description:"); + buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION).trim())); + buffer.append(System.lineSeparator()); + + } + + } + + List allottedResourceList = toscaResourceStructure.getSdcCsarHelper().getAllottedResources(); + + if(allottedResourceList != null){ + + buffer.append(System.lineSeparator()); + buffer.append("Allotted Resource Properties:"); + buffer.append(System.lineSeparator()); + + for(NodeTemplate allottedNode : allottedResourceList){ + + buffer.append("Model Name:"); + buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Model Name:"); + buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Model InvariantUuid:"); + buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Model Version:"); + buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION).trim())); + buffer.append(System.lineSeparator()); + buffer.append("Model UUID:"); + buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID).trim())); + buffer.append(System.lineSeparator()); + + + buffer.append("Allotted Resource Customization Properties:"); + buffer.append(System.lineSeparator()); + + buffer.append("Model Cutomization UUID:"); + buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).trim())); + buffer.append(System.lineSeparator()); + + + } + } + + + return buffer.toString(); + } + public static String dumpVfModuleMetaDataList(List moduleMetaDataList) { if (moduleMetaDataList == null ) { return null; diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java index 773ff86444..f7a0916f3b 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java @@ -96,7 +96,7 @@ public class YamlEditor { // Based on the email from Ella Kvetny: // Within Heat Template, under parameters catalog, it might indicate the default value of the parameter // If default value exist, the parameter is not mandatory, otherwise its value should be set - public synchronized Set getParameterList () { + public synchronized Set getParameterList (String artifactUUID) { Set paramSet = new HashSet (); @SuppressWarnings("unchecked") Map resourceMap = (Map ) yml.get ("parameters"); @@ -118,6 +118,8 @@ public class YamlEditor { // Now set the type String value = resourceEntry.get ("type"); param.setParamType (value); + + param.setHeatTemplateArtifactUuid(artifactUUID); paramSet.add (param); diff --git a/asdc-controller/src/main/resources/resource-examples/cloud-nimbus.sh b/asdc-controller/src/main/resources/resource-examples/cloud-nimbus.sh new file mode 100644 index 0000000000..8e5a486289 --- /dev/null +++ b/asdc-controller/src/main/resources/resource-examples/cloud-nimbus.sh @@ -0,0 +1,12 @@ +#!/bin/bash +echo "Running first-boot script" +FLAG="first-boot.sh" +echo "First boot run" > ${FLAG} +echo "$vm_name" >> ${FLAG} +touch /var/lib/cloud/instance/payload/launch-params +chmod 644 /var/lib/cloud/instance/payload/launch-params +#for i in $(ls /sys/class/net); do +# echo "Restart $i" >> ${FLAG} +# ifdown ${i} +# ifup ${i} +#done diff --git a/asdc-controller/src/main/resources/resource-examples/hot-nimbus-oam_v1.0.env b/asdc-controller/src/main/resources/resource-examples/hot-nimbus-oam_v1.0.env new file mode 100644 index 0000000000..138feb5822 --- /dev/null +++ b/asdc-controller/src/main/resources/resource-examples/hot-nimbus-oam_v1.0.env @@ -0,0 +1,18 @@ +parameters: + pcrf_oam_server_names: ZRDM1PCRF01OAM001,ZRDM1PCRF01OAM002 + pcrf_oam_image_name: PCRF_8.995-ATTM1.0.3.qcow2 + pcrf_oam_flavor_name: lc.4xlarge4 + availabilityzone_name: nova + pcrf_cps_net_name: Mobisupport-25193-I-INT1_int_pcrf_net_0 + pcrf_cps_net_ips: 172.26.16.111,172.26.16.112 + pcrf_arbiter_vip: 172.26.16.115 + pcrf_cps_net_mask: 255.255.255.0 + pcrf_oam_net_name: MNS-25180-L-01_oam_protected_net_0 + pcrf_oam_net_ips: 107.239.64.117,107.239.64.118 + pcrf_oam_net_gw: 107.239.64.1 + pcrf_oam_net_mask: 255.255.248.0 + pcrf_oam_volume_id_1: a4aa05fb-fcdc-457b-8077-6845fdfc3257 + pcrf_oam_volume_id_2: 93d8fc1f-f1c3-4933-86b2-039881ee910f + pcrf_security_group_name: nimbus_security_group + pcrf_vnf_id: 730797234b4a40aa99335157b02871cd + diff --git a/asdc-controller/src/main/resources/resource-examples/hot-nimbus-oam_v1.0.yaml b/asdc-controller/src/main/resources/resource-examples/hot-nimbus-oam_v1.0.yaml new file mode 100644 index 0000000000..2aa1235de2 --- /dev/null +++ b/asdc-controller/src/main/resources/resource-examples/hot-nimbus-oam_v1.0.yaml @@ -0,0 +1,109 @@ +heat_template_version: 2013-05-23 + +description: heat template that creates multiple PCRF OAM nodes stack + +parameters: + pcrf_oam_server_names: + type: comma_delimited_list + label: PCRF OAM server names + description: name of the PCRF OAM instance + pcrf_oam_image_name: + type: string + label: PCRF OAM image name + description: PCRF OAM image name + pcrf_oam_flavor_name: + type: string + label: PCRF OAM flavor name + description: flavor name of PCRF OAM instance + availabilityzone_name: + type: string + label: availabilityzone name + description: availabilityzone name + pcrf_cps_net_name: + type: string + label: CPS network name + description: CPS network name + pcrf_cps_net_ips: + type: comma_delimited_list + label: CPS network ips + description: CPS network ips + pcrf_cps_net_mask: + type: string + label: CPS network mask + description: CPS network mask + pcrf_arbiter_vip: + type: string + label: OAM Arbiter LB VIP + description: OAM Arbiter LB VIP + pcrf_oam_net_name: + type: string + label: OAM network name + description: OAM network name + pcrf_oam_net_ips: + type: comma_delimited_list + label: OAM network ips + description: OAM network ips + pcrf_oam_net_gw: + type: string + label: CPS network gateway + description: CPS network gateway + pcrf_oam_net_mask: + type: string + label: CPS network mask + description: CPS network mask + pcrf_oam_volume_id_1: + type: string + label: CPS OAM 001 Cinder Volume + description: CPS OAM 001 Cinder Volumes + pcrf_oam_volume_id_2: + type: string + label: CPS OAM 002 Cinder Volume + description: CPS OAM 002 Cinder Volumes + pcrf_security_group_name: + type: string + label: security group name + description: the name of security group + pcrf_vnf_id: + type: string + label: PCRF VNF Id + description: PCRF VNF Id + +resources: + server_pcrf_oam_001: + type: nested-oam_v1.0.yaml + properties: + pcrf_oam_server_name: { get_param: [pcrf_oam_server_names, 0] } + pcrf_oam_image_name: { get_param: pcrf_oam_image_name } + pcrf_oam_flavor_name: { get_param: pcrf_oam_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_oam_volume_id: { get_param: pcrf_oam_volume_id_1 } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 0] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_oam_net_name: { get_param: pcrf_oam_net_name } + pcrf_oam_net_ip: { get_param: [pcrf_oam_net_ips, 0] } + pcrf_oam_net_mask: { get_param: pcrf_oam_net_mask } + pcrf_oam_net_gw: { get_param: pcrf_oam_net_gw } + pcrf_arbiter_vip: { get_param: pcrf_arbiter_vip } + pcrf_vnf_id: {get_param: pcrf_vnf_id} + + server_pcrf_oam_002: + type: nested-oam_v1.0.yaml + depends_on: [server_pcrf_oam_001] + properties: + pcrf_oam_server_name: { get_param: [pcrf_oam_server_names, 1] } + pcrf_oam_image_name: { get_param: pcrf_oam_image_name } + pcrf_oam_flavor_name: { get_param: pcrf_oam_flavor_name } + availabilityzone_name: { get_param: availabilityzone_name } + pcrf_security_group_name: { get_param: pcrf_security_group_name } + pcrf_oam_volume_id: { get_param: pcrf_oam_volume_id_2 } + pcrf_cps_net_name: { get_param: pcrf_cps_net_name } + pcrf_cps_net_ip: { get_param: [pcrf_cps_net_ips, 1] } + pcrf_cps_net_mask: { get_param: pcrf_cps_net_mask } + pcrf_oam_net_name: { get_param: pcrf_oam_net_name } + pcrf_oam_net_ip: { get_param: [pcrf_oam_net_ips, 1] } + pcrf_oam_net_mask: { get_param: pcrf_oam_net_mask } + pcrf_oam_net_gw: { get_param: pcrf_oam_net_gw } + pcrf_arbiter_vip: { get_param: pcrf_arbiter_vip } + pcrf_vnf_id: {get_param: pcrf_vnf_id} diff --git a/asdc-controller/src/main/resources/resource-examples/nested-oam_v1.0.yaml b/asdc-controller/src/main/resources/resource-examples/nested-oam_v1.0.yaml new file mode 100644 index 0000000000..d3baf41da5 --- /dev/null +++ b/asdc-controller/src/main/resources/resource-examples/nested-oam_v1.0.yaml @@ -0,0 +1,156 @@ +heat_template_version: 2013-05-23 + +description: nested heat template that creates a PCRF OAM node stack + +parameters: + pcrf_oam_server_name: + type: string + label: PCRF OAM server name + description: PCRF OAM server name + pcrf_oam_image_name: + type: string + label: image name + description: PCRF OAM image name + pcrf_oam_flavor_name: + type: string + label: PCRF OAM flavor name + description: flavor name of PCRF OAM instance + availabilityzone_name: + type: string + label: availabilityzone name + description: availabilityzone name + pcrf_cps_net_name: + type: string + label: CPS network name + description: CPS network name + pcrf_cps_net_ip: + type: string + label: CPS network ip + description: CPS network ip + pcrf_cps_net_mask: + type: string + label: CPS network mask + description: CPS network mask + pcrf_arbiter_vip: + type: string + label: OAM Arbiter LB VIP + description: OAM Arbiter LB VIP + pcrf_oam_net_name: + type: string + label: OAM network name + description: OAM network name + pcrf_oam_net_ip: + type: string + label: OAM network ip + description: OAM network ip + pcrf_oam_net_gw: + type: string + label: CPS network gateway + description: CPS network gateway + pcrf_oam_net_mask: + type: string + label: CPS network mask + description: CPS network mask + pcrf_oam_volume_id: + type: string + label: CPS OAM Cinder Volume + description: CPS OAM Cinder Volume + pcrf_security_group_name: + type: string + label: security group name + description: the name of security group + pcrf_vnf_id: + type: string + label: PCRF VNF Id + description: PCRF VNF Id + +resources: + network: + type: OS::Heat::CloudConfig + properties: + cloud_config: + write_files: + - path: /etc/sysconfig/network-scripts/ifcfg-eth0 + permissions: "0644" + content: + str_replace: + template: { get_file: nimbus-ethernet } + params: + $dev: eth0 + $ip: { get_param: pcrf_cps_net_ip } + $netmask: { get_param: pcrf_cps_net_mask } + - path: /etc/sysconfig/network-scripts/ifcfg-eth1 + permissions: "0644" + content: + str_replace: + template: { get_file: nimbus-ethernet-gw } + params: + $dev: eth1 + $ip: { get_param: pcrf_oam_net_ip } + $netmask: { get_param: pcrf_oam_net_mask } + $gateway: { get_param: pcrf_oam_net_gw } + runcmd: + - ifdown eth0 && ifup eth0 + - ifdown eth1 && ifup eth1 + script_init: + type: OS::Heat::SoftwareConfig + properties: + group: ungrouped + config: + str_replace: + template: { get_file: cloud-nimbus.sh } + params: + $vm_name: { get_param: pcrf_oam_server_name } + pcrf_server_init: + type: OS::Heat::MultipartMime + properties: + parts: + - config: { get_resource: network} + - config: { get_resource: script_init} + + pcrf_server_oam: + type: OS::Nova::Server + properties: + config_drive: "True" + name: { get_param: pcrf_oam_server_name } + image: { get_param: pcrf_oam_image_name } + flavor: { get_param: pcrf_oam_flavor_name } + availability_zone: { get_param: availabilityzone_name } + networks: + - port: { get_resource: pcrf_oam_port_0} + - port: { get_resource: pcrf_oam_port_1} + user_data_format: RAW + user_data: + get_resource: pcrf_server_init + metadata: + vnf_id: {get_param: pcrf_vnf_id} + + pcrf_oam_port_0: + type: OS::Neutron::Port + properties: + network: { get_param: pcrf_cps_net_name } + fixed_ips: + - ip_address: { get_param: pcrf_cps_net_ip } + allowed_address_pairs: + - ip_address: { get_param: pcrf_arbiter_vip } + security_groups: [{ get_param: pcrf_security_group_name }] + + pcrf_oam_port_1: + type: OS::Neutron::Port + properties: + network: { get_param: pcrf_oam_net_name } + fixed_ips: + - ip_address: { get_param: pcrf_oam_net_ip } + security_groups: [{ get_param: pcrf_security_group_name }] + + pcrf_oam_vol_attachment: + type: OS::Cinder::VolumeAttachment + properties: + volume_id: { get_param: pcrf_oam_volume_id } + mountpoint: /dev/vdd + instance_uuid: { get_resource: pcrf_server_oam } + +outputs: + pcrf_oam_vol_attachment_id: + description: the pcrf_oam_vol_attachment_id id + value: { get_resource: pcrf_oam_vol_attachment } diff --git a/asdc-controller/src/main/resources/resource-examples/notif-structure.json b/asdc-controller/src/main/resources/resource-examples/notif-structure.json new file mode 100644 index 0000000000..103a799b9a --- /dev/null +++ b/asdc-controller/src/main/resources/resource-examples/notif-structure.json @@ -0,0 +1,138 @@ +{ + "serviceName": "test-service", + "serviceInvariantUUID": "585822c7-4027-4f84-ba50-e9248606f132", + "serviceUUID": "4be40491-e2e5-4a84-a7e5-57c83b5b95fc", + "serviceVersion": "2.0", + "serviceArtifacts": + [{ + "artifactName": "service_Rg516VmmscSrvc_csar.csar", + "artifactType": "TOSCA_CSAR", + "artifactURL": "service_Rg516VmmscSrvc_csar.csar", + "artifactChecksum": "ZDc1MTcxMzk4ODk4N2U5MzMxOTgwMzYzZTI0MTg5Y2U\u003d", + "artifactDescription": "TOSCA representation of the asset", + "artifactTimeout": 0, + "artifactUUID": "123456-35a8-467f-b440-d0f6226b3516", + "artifactVersion": "5" + } + + ], + + "resources": + [ + { + "resourceInstanceName": "resource-1", + "resourceInvariantUUID": "585822c7-4027-4f84-ba50-e9248606f134", + "resourceCustomizationUUID": "6402d92d-0050-46a9-8202-623a46680ba7", + "resourceName": "resourceName-1", + "resourceType": "VF", + "resourceUUID": "585822c7-4027-4f84-ba50-e9248606f136", + "resourceVersion": "2.0", + "category": "Resource", + "subcategory": "Resource", + "artifacts": + [ + { + "artifactChecksum": "ZDc1MTcxMzk4ODk4N2U5MzMxOTgwMzYzZTI0MTg5Y2U\u003d", + "artifactDescription": "Meta data for VFModule", + "artifactName": "vnf-module-artifact.json", + + "artifactType": "VF_MODULES_METADATA", + "artifactURL": "vnf-module-artifact.json", + "artifactUUID": "VfArtifact-UUID1", + "artifactVersion": "1.0" + + }, + { + "artifactChecksum": "ZDc1MTcxMzk4ODk4N2U5MzMxOTgwMzYzZTI0MTg5Y2U\u003d", + "artifactDescription": "Nimbus Heat OAM", + "artifactName": "hot-nimbus-oam_v1.0.yaml", + "artifactTimeout": 100, + "artifactType": "HEAT_ARTIFACT", + "artifactURL": "hot-nimbus-oam_v1.0.yaml", + "artifactUUID": "Heat-Artifact-Artifact-UUID1", + "artifactVersion": "1.0", + "generatedArtifact": "EnvArtifact-Artifact-UUID1" + + }, + + { + "artifactChecksum": "ZDc1MTcxMzk4ODk4N2U5MzMxOTgwMzYzZTI0MTg5Y2U\u003d", + "artifactDescription": "Nimbus Heat OAM Artifact", + "artifactName": "hot-nimbus-oam_v1.0.yaml", + "artifactTimeout": 100, + "artifactType": "HEAT", + "artifactURL": "hot-nimbus-oam_v1.0.yaml", + "artifactUUID": "Heat-Artifact-UUID1", + "artifactVersion": "1.0", + "generatedArtifact": "EnvArtifact-UUID1" + + }, + + { + "artifactChecksum": "ZDc1MTcxMzk4ODk4N2U5MzMxOTgwMzYzZTI0MTg5Y2U\u003d", + "artifactDescription": "Nimbus Heat ENV OAM", + "artifactName": "hot-nimbus-oam_v1.0.env", + + "artifactType": "HEAT_ENV", + "artifactURL": "hot-nimbus-oam_v1.0.env", + "artifactUUID": "EnvArtifact-UUID1", + "artifactVersion": "1.0" + + }, + + { + "artifactChecksum": "ZDc1MTcxMzk4ODk4N2U5MzMxOTgwMzYzZTI0MTg5Y2U\u003d", + "artifactDescription": "Nimbus Heat OAM", + "artifactName": "hot-nimbus-oam_v2.0.yaml", + "artifactTimeout": 100, + "artifactType": "HEAT_ARTIFACT", + "artifactURL": "hot-nimbus-oam_v1.0.yaml", + "artifactUUID": "Heat-Artifact-Artifact-UUID2", + "artifactVersion": "2.0", + "generatedArtifact": "EnvArtifact-Artifact-UUID2" + + }, + + { + "artifactChecksum": "ZDc1MTcxMzk4ODk4N2U5MzMxOTgwMzYzZTI0MTg5Y2U\u003d", + "artifactDescription": "Nimbus Heat OAM", + "artifactName": "hot-nimbus-oam_v2.0.yaml", + "artifactTimeout": 100, + "artifactType": "HEAT", + "artifactURL": "hot-nimbus-oam_v1.0.yaml", + "artifactUUID": "Heat-Artifact-UUID2", + "artifactVersion": "2.0", + "generatedArtifact": "EnvArtifact-UUID2" + + }, + + { + "artifactChecksum": "ZDc1MTcxMzk4ODk4N2U5MzMxOTgwMzYzZTI0MTg5Y2U\u003d", + "artifactDescription": "Nimbus Heat ENV OAM", + "artifactName": "hot-nimbus-oam_v2.0.env", + + "artifactType": "HEAT_ENV", + "artifactURL": "hot-nimbus-oam_v1.0.env", + "artifactUUID": "EnvArtifact-UUID2", + "artifactVersion": "2.0" + + }, + + { + "artifactChecksum": "ZDc1MTcxMzk4ODk4N2U5MzMxOTgwMzYzZTI0MTg5Y2U\u003d", + "artifactDescription": "Nested OAM", + "artifactName": "nested-oam_v1.0.yaml", + "artifactTimeout": 10, + "artifactType": "HEAT_NESTED", + "artifactURL": "nested-oam_v1.0.yaml", + "artifactUUID": "NestedArtifact-UUID3", + "artifactVersion": "1.0" + + } + ] + } + ], + + "serviceDescription": "test service for unit testing", + "distributionID": "35120a87-1f82-4276-9735-f6de5a244d65" +} \ No newline at end of file diff --git a/asdc-controller/src/main/resources/resource-examples/resource_Extvl.csar b/asdc-controller/src/main/resources/resource-examples/resource_Extvl.csar new file mode 100644 index 0000000000..7976e51d14 Binary files /dev/null and b/asdc-controller/src/main/resources/resource-examples/resource_Extvl.csar differ diff --git a/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-csar-0904-2.csar b/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-csar-0904-2.csar new file mode 100644 index 0000000000..fc21af334d Binary files /dev/null and b/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-csar-0904-2.csar differ diff --git a/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-with-allotted.csar b/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-with-allotted.csar new file mode 100644 index 0000000000..41ee2c7ce3 Binary files /dev/null and b/asdc-controller/src/main/resources/resource-examples/service-ServiceFdnt-with-allotted.csar differ diff --git a/asdc-controller/src/main/resources/resource-examples/service_Rg511NfmService.csar b/asdc-controller/src/main/resources/resource-examples/service_Rg511NfmService.csar new file mode 100644 index 0000000000..2686e4ba57 Binary files /dev/null and b/asdc-controller/src/main/resources/resource-examples/service_Rg511NfmService.csar differ diff --git a/asdc-controller/src/main/resources/resource-examples/service_Rg516VmmscSrvc_csar.csar b/asdc-controller/src/main/resources/resource-examples/service_Rg516VmmscSrvc_csar.csar new file mode 100644 index 0000000000..d2983ce609 Binary files /dev/null and b/asdc-controller/src/main/resources/resource-examples/service_Rg516VmmscSrvc_csar.csar differ diff --git a/asdc-controller/src/main/resources/resource-examples/vnf-module-artifact.json b/asdc-controller/src/main/resources/resource-examples/vnf-module-artifact.json new file mode 100644 index 0000000000..0608000441 --- /dev/null +++ b/asdc-controller/src/main/resources/resource-examples/vnf-module-artifact.json @@ -0,0 +1,45 @@ +[ + { + "vfModuleModelName": "VF_RI2_G6_withArtifacts::module-0", + "vfModuleModelInvariantUUID": "585822c7-4027-4f84-ba50-e9248606f131", + "vfModuleModelVersion": "1.0", + "vfModuleModelUUID": "ac53bd31-b2b1-42ce-826a-a9420712cbff.VF_RI2_G6_withArtifacts::module-0.group", + "vfModuleModelCustomizationUUID": "customization-uuid", + "isBase": true, + "properties": { + "vf_module_type": "Base", + "vf_module_label": "label1", + "min_vf_module_instances": "1", + "max_vf_module_instances": "2", + "initial_count": "3", + "vf_module_description": "description" + }, + "artifacts": [ + "Heat-Artifact-UUID1", + "Heat-Artifact-Artifact-UUID1", + "EnvArtifact-UUID1", + "NestedArtifact-UUID3" + ] + }, + { + "vfModuleModelName": "VF_RI2_G6_withArtifacts::module-1", + "vfModuleModelInvariantUUID": "585822c7-4027-4f84-ba50-e9248606f132", + "vfModuleModelVersion": "1.0", + "vfModuleModelUUID": "ac53bd31-b2b1-42ce-826a-a9420712cbff.VF_RI2_G6_withArtifacts::module-1.group", + "vfModuleModelCustomizationUUID": "customization-uuid2", + "isBase": true, + "properties": { + "vf_module_type": "Base", + "vf_module_label": "label1", + "min_vf_module_instances": "1", + "max_vf_module_instances": "2", + "initial_count": "3", + "vf_module_description": "description" + }, + "artifacts": [ + "Heat-Artifact-UUID2", + "Heat-Artifact-Artifact-UUID2", + "EnvArtifact-UUID2" + ] + } +] \ No newline at end of file diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTest.java deleted file mode 100644 index 9ca02e218a..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Fri Nov 25 13:38:29 GMT 2016 - */ - -package org.openecomp.mso.asdc; - -import org.junit.Test; -import static org.junit.Assert.*; - -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.evosuite.runtime.PrivateAccess; -import org.junit.runner.RunWith; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class ASDCControllerSingletonESTest extends ASDCControllerSingletonESTestscaffolding { - - @Test(timeout = 4000) - public void test0() throws Throwable { - ASDCControllerSingleton aSDCControllerSingleton0 = new ASDCControllerSingleton(); - PrivateAccess.callMethod((Class) ASDCControllerSingleton.class, aSDCControllerSingleton0, "setWorking", (Object) true, (Class) boolean.class); - aSDCControllerSingleton0.periodicControllerTask(); - } - - @Test(timeout = 4000) - public void test1() throws Throwable { - ASDCControllerSingleton aSDCControllerSingleton0 = new ASDCControllerSingleton(); - Object object0 = PrivateAccess.callMethod((Class) ASDCControllerSingleton.class, aSDCControllerSingleton0, "terminate"); - assertNull(object0); - } - - @Test(timeout = 4000) - public void test2() throws Throwable { - ASDCControllerSingleton aSDCControllerSingleton0 = new ASDCControllerSingleton(); - aSDCControllerSingleton0.periodicControllerTask(); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTestscaffolding.java deleted file mode 100644 index e099e9ceaf..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTestscaffolding.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Fri Nov 25 13:38:29 GMT 2016 - */ - -package org.openecomp.mso.asdc; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; - -@EvoSuiteClassExclude -public class ASDCControllerSingletonESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.ASDCControllerSingleton"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; - org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); - - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCControllerSingletonESTestscaffolding.class.getClassLoader() , - "org.openecomp.mso.properties.AbstractMsoProperties", - "org.openecomp.mso.properties.MsoPropertiesParameters$MsoPropertiesType", - "org.openecomp.mso.properties.MsoPropertiesParameters", - "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", - "org.openecomp.mso.logger.MsoLogger$ErrorCode", - "com.att.eelf.configuration.EELFLogger", - "org.openecomp.mso.properties.MsoJavaProperties", - "org.openecomp.mso.asdc.client.exceptions.ASDCParametersException", - "com.att.eelf.configuration.SLF4jWrapper", - "com.att.eelf.i18n.EELFResourceManager", - "org.openecomp.mso.properties.MsoPropertiesException", - "org.openecomp.mso.logger.MsoLogger", - "org.openecomp.mso.logger.MessageEnum", - "com.att.eelf.i18n.EELFResolvableErrorEnum", - "org.openecomp.mso.logger.MsoLogger$ResponseCode", - "org.openecomp.mso.properties.MsoJsonProperties", - "org.openecomp.mso.entity.MsoRequest", - "org.openecomp.mso.asdc.ASDCControllerSingleton", - "org.openecomp.mso.logger.MsoLogger$StatusCode", - "com.att.eelf.configuration.EELFManager", - "com.att.eelf.i18n.EELFMsgs", - "org.openecomp.mso.properties.MsoPropertiesFactory", - "org.openecomp.mso.asdc.client.ASDCGlobalController", - "com.att.eelf.configuration.EELFLogger$Level", - "org.openecomp.mso.logger.MsoLogger$Catalog", - "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException" - ); - } - - private static void resetClasses() { - org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCControllerSingletonESTestscaffolding.class.getClassLoader()); - - org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( - "org.openecomp.mso.logger.MsoLogger$Catalog", - "org.openecomp.mso.logger.MsoLogger", - "com.att.eelf.i18n.EELFResourceManager", - "com.att.eelf.i18n.EELFMsgs", - "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", - "com.att.eelf.configuration.EELFLogger$Level", - "com.att.eelf.configuration.EELFManager", - "org.openecomp.mso.logger.MessageEnum", - "org.openecomp.mso.asdc.ASDCControllerSingleton", - "org.openecomp.mso.asdc.client.ASDCGlobalController", - "org.openecomp.mso.properties.MsoPropertiesFactory", - "org.openecomp.mso.properties.MsoPropertiesParameters$MsoPropertiesType", - "org.openecomp.mso.properties.MsoPropertiesException", - "org.openecomp.mso.logger.MsoLogger$ErrorCode" - ); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java deleted file mode 100644 index e2112cee03..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Fri Nov 25 13:39:00 GMT 2016 - */ - -package org.openecomp.mso.asdc.client; - -import org.junit.Test; -import static org.junit.Assert.*; - -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.junit.runner.RunWith; -import org.openecomp.sdc.utils.DistributionStatusEnum; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class DistributionStatusMessageESTest extends DistributionStatusMessageESTestscaffolding { - - @Test(timeout = 4000) - public void test00() throws Throwable { - DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L); - long long0 = distributionStatusMessage0.getTimestamp(); - assertEquals(1L, long0); - } - - @Test(timeout = 4000) - public void test01() throws Throwable { - DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DEPLOYED; - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("n*lho0\"NQ4azb%8]KN", "n*lho0\"NQ4azb%8]KN", "BMWmXl2i-B", distributionStatusEnum0, (-58L)); - long long0 = distributionStatusMessage0.getTimestamp(); - assertEquals("BMWmXl2i-B", distributionStatusMessage0.getDistributionID()); - assertEquals((-58L), long0); - assertEquals("n*lho0\"NQ4azb%8]KN", distributionStatusMessage0.getConsumerID()); - assertEquals("n*lho0\"NQ4azb%8]KN", distributionStatusMessage0.getArtifactURL()); - } - - @Test(timeout = 4000) - public void test02() throws Throwable { - DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L); - DistributionStatusEnum distributionStatusEnum1 = distributionStatusMessage0.getStatus(); - DistributionStatusMessage distributionStatusMessage1 = new DistributionStatusMessage("", (String) null, "*? q^M(_q^3$ZQ", distributionStatusEnum1, (-833L)); - String string0 = distributionStatusMessage1.getDistributionID(); - assertNotNull(string0); - assertEquals((-833L), distributionStatusMessage1.getTimestamp()); - assertEquals("", distributionStatusMessage1.getArtifactURL()); - assertEquals("*? q^M(_q^3$ZQ", string0); - } - - @Test(timeout = 4000) - public void test03() throws Throwable { - DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("", "", "", distributionStatusEnum0, 1L); - distributionStatusMessage0.getDistributionID(); - assertEquals(1L, distributionStatusMessage0.getTimestamp()); - } - - @Test(timeout = 4000) - public void test04() throws Throwable { - DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("ALREADY_DEPLOYED", "ALREADY_DEPLOYED", "ALREADY_DEPLOYED", distributionStatusEnum0, 0L); - String string0 = distributionStatusMessage0.getConsumerID(); - assertEquals("ALREADY_DEPLOYED", string0); - } - - @Test(timeout = 4000) - public void test05() throws Throwable { - DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L); - DistributionStatusEnum distributionStatusEnum1 = distributionStatusMessage0.getStatus(); - DistributionStatusMessage distributionStatusMessage1 = new DistributionStatusMessage((String) null, "", "Qcuo3~gd})vsI*", distributionStatusEnum1, 0L); - String string0 = distributionStatusMessage1.getConsumerID(); - assertNotNull(string0); - assertEquals(1L, distributionStatusMessage0.getTimestamp()); - assertEquals("", string0); - assertEquals("Qcuo3~gd})vsI*", distributionStatusMessage1.getDistributionID()); - } - - @Test(timeout = 4000) - public void test06() throws Throwable { - DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("ALREADY_DEPLOYED", "ALREADY_DEPLOYED", "ALREADY_DEPLOYED", distributionStatusEnum0, 0L); - String string0 = distributionStatusMessage0.getArtifactURL(); - assertEquals("ALREADY_DEPLOYED", string0); - } - - @Test(timeout = 4000) - public void test07() throws Throwable { - DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L); - DistributionStatusEnum distributionStatusEnum1 = distributionStatusMessage0.getStatus(); - DistributionStatusMessage distributionStatusMessage1 = new DistributionStatusMessage("", (String) null, "*? q^M(_q^3$ZQ", distributionStatusEnum1, (-833L)); - String string0 = distributionStatusMessage1.getArtifactURL(); - assertEquals("", string0); - assertEquals("*? q^M(_q^3$ZQ", distributionStatusMessage1.getDistributionID()); - assertNotNull(string0); - assertEquals((-833L), distributionStatusMessage1.getTimestamp()); - } - - @Test(timeout = 4000) - public void test08() throws Throwable { - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); - long long0 = distributionStatusMessage0.getTimestamp(); - assertEquals(0L, long0); - } - - @Test(timeout = 4000) - public void test09() throws Throwable { - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); - String string0 = distributionStatusMessage0.getDistributionID(); - assertNull(string0); - } - - @Test(timeout = 4000) - public void test10() throws Throwable { - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); - distributionStatusMessage0.getStatus(); - } - - @Test(timeout = 4000) - public void test11() throws Throwable { - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); - String string0 = distributionStatusMessage0.getConsumerID(); - assertNull(string0); - } - - @Test(timeout = 4000) - public void test12() throws Throwable { - DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); - String string0 = distributionStatusMessage0.getArtifactURL(); - assertNull(string0); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java deleted file mode 100644 index f234ca64d5..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Fri Nov 25 13:39:00 GMT 2016 - */ - -package org.openecomp.mso.asdc.client; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; - -@EvoSuiteClassExclude -public class DistributionStatusMessageESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.DistributionStatusMessage"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; - org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); - - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DistributionStatusMessageESTestscaffolding.class.getClassLoader() , - "org.openecomp.sdc.utils.DistributionStatusEnum", - "org.openecomp.mso.asdc.client.DistributionStatusMessage", - "org.openecomp.sdc.api.consumer.IDistributionStatusMessage" - ); - } - - private static void resetClasses() { - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java deleted file mode 100644 index 37af59c639..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Fri Nov 25 13:39:27 GMT 2016 - */ - -package org.openecomp.mso.asdc.client.exceptions; - -import org.junit.Test; -import static org.junit.Assert.*; - -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.evosuite.runtime.mock.java.lang.MockThrowable; -import org.junit.runner.RunWith; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class ASDCControllerExceptionESTest extends ASDCControllerExceptionESTestscaffolding { - - @Test(timeout = 4000) - public void test0() throws Throwable { - ASDCControllerException aSDCControllerException0 = new ASDCControllerException("org.openecomp.mso.asdc.client.exceptions.ASDCControllerException"); - MockThrowable mockThrowable0 = new MockThrowable("B+;:\"w4^M(-Y:e~=", (Throwable) aSDCControllerException0); - ASDCControllerException aSDCControllerException1 = new ASDCControllerException("The list of prefixes must not be null", (Throwable) mockThrowable0); - assertFalse(aSDCControllerException1.equals((Object)aSDCControllerException0)); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java deleted file mode 100644 index d6041c2fb2..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Fri Nov 25 13:39:27 GMT 2016 - */ - -package org.openecomp.mso.asdc.client.exceptions; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; - -@EvoSuiteClassExclude -public class ASDCControllerExceptionESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; - org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); - - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCControllerExceptionESTestscaffolding.class.getClassLoader() , - "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException" - ); - } - - private static void resetClasses() { - org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCControllerExceptionESTestscaffolding.class.getClassLoader()); - - org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( - "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException" - ); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java deleted file mode 100644 index 75f4b5d27c..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Fri Nov 25 13:38:49 GMT 2016 - */ - -package org.openecomp.mso.asdc.client.exceptions; - -import org.junit.Test; -import static org.junit.Assert.*; - -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.junit.runner.RunWith; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class ASDCDownloadExceptionESTest extends ASDCDownloadExceptionESTestscaffolding { - - @Test(timeout = 4000) - public void test0() throws Throwable { - ASDCDownloadException aSDCDownloadException0 = new ASDCDownloadException(""); - ASDCDownloadException aSDCDownloadException1 = new ASDCDownloadException("", (Throwable) aSDCDownloadException0); - assertFalse(aSDCDownloadException1.equals((Object)aSDCDownloadException0)); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java deleted file mode 100644 index 5db3c2098f..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Fri Nov 25 13:38:49 GMT 2016 - */ - -package org.openecomp.mso.asdc.client.exceptions; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; - -@EvoSuiteClassExclude -public class ASDCDownloadExceptionESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; - org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); - - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCDownloadExceptionESTestscaffolding.class.getClassLoader() , - "org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException" - ); - } - - private static void resetClasses() { - org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCDownloadExceptionESTestscaffolding.class.getClassLoader()); - - org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( - "org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException" - ); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java deleted file mode 100644 index afc28346e3..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Fri Nov 25 13:39:10 GMT 2016 - */ - -package org.openecomp.mso.asdc.client.exceptions; - -import org.junit.Test; -import static org.junit.Assert.*; - -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.junit.runner.RunWith; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class ASDCParametersExceptionESTest extends ASDCParametersExceptionESTestscaffolding { - - @Test(timeout = 4000) - public void test0() throws Throwable { - ASDCParametersException aSDCParametersException0 = new ASDCParametersException("4vI_{2b paramSet = decoder.getParameterList(); + Set paramSet = decoder.getParameterList("123456"); assertTrue(paramSet.size() == 5); @@ -79,12 +79,12 @@ public class YamlTest { Set newParamSet = new HashSet (); HeatTemplateParam heatParam1 = new HeatTemplateParam(); - heatParam1.setId(1); + heatParam1.setHeatTemplateArtifactUuid("1"); heatParam1.setParamName("testos1"); heatParam1.setParamType("string"); HeatTemplateParam heatParam2 = new HeatTemplateParam(); - heatParam2.setId(2); + heatParam2.setHeatTemplateArtifactUuid("2"); heatParam2.setParamName("testos2"); heatParam2.setParamType("number"); @@ -93,7 +93,7 @@ public class YamlTest { decoder.addParameterList(newParamSet); - Set paramSet = decoder.getParameterList(); + Set paramSet = decoder.getParameterList("123456"); assertTrue(paramSet.size() == 2); assertTrue(decoder.encode().contains("testos1")); @@ -111,12 +111,12 @@ public class YamlTest { Set newParamSet = new HashSet (); HeatTemplateParam heatParam1 = new HeatTemplateParam(); - heatParam1.setId(1); + heatParam1.setHeatTemplateArtifactUuid("1"); heatParam1.setParamName("testos1"); heatParam1.setParamType("string"); HeatTemplateParam heatParam2 = new HeatTemplateParam(); - heatParam2.setId(2); + heatParam2.setHeatTemplateArtifactUuid("2"); heatParam2.setParamName("testos2"); heatParam2.setParamType("number"); @@ -125,7 +125,7 @@ public class YamlTest { decoder.addParameterList(newParamSet); - Set paramSet = decoder.getParameterList(); + Set paramSet = decoder.getParameterList("123456"); assertTrue(paramSet.size() == 7); diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTest.java deleted file mode 100644 index 4675f05477..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Fri Nov 25 13:37:47 GMT 2016 - */ - -package org.openecomp.mso.asdc.installer; - -import org.junit.Test; -import static org.junit.Assert.*; -import static org.evosuite.runtime.EvoAssertions.*; - -import java.math.BigDecimal; -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.junit.runner.RunWith; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class BigDecimalVersionESTest extends BigDecimalVersionESTestscaffolding { - - @Test(timeout = 4000) - public void test00() throws Throwable { - String string0 = BigDecimalVersion.castAndCheckNotificationVersionToString("9"); - assertEquals("9", string0); - } - - @Test(timeout = 4000) - public void test01() throws Throwable { - BigDecimal bigDecimal0 = BigDecimalVersion.castAndCheckNotificationVersion("0"); - assertEquals(0, bigDecimal0.shortValue()); - } - - @Test(timeout = 4000) - public void test02() throws Throwable { - BigDecimal bigDecimal0 = BigDecimalVersion.castAndCheckNotificationVersion("9"); - assertEquals(9, bigDecimal0.byteValue()); - } - - @Test(timeout = 4000) - public void test03() throws Throwable { - BigDecimal bigDecimal0 = BigDecimalVersion.castAndCheckNotificationVersion("-1"); - assertEquals(-1, bigDecimal0.byteValue()); - } - - @Test(timeout = 4000) - public void test04() throws Throwable { - // Undeclared exception! - try { - BigDecimalVersion.castAndCheckNotificationVersionToString("fgt+&6@pL9`5EE}.!.,"); - fail("Expecting exception: NumberFormatException"); - - } catch(NumberFormatException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("java.math.BigDecimal", e); - } - } - - @Test(timeout = 4000) - public void test05() throws Throwable { - // Undeclared exception! - try { - BigDecimalVersion.castAndCheckNotificationVersionToString((String) null); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.BigDecimalVersion", e); - } - } - - @Test(timeout = 4000) - public void test06() throws Throwable { - // Undeclared exception! - try { - BigDecimalVersion.castAndCheckNotificationVersion((String) null); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.BigDecimalVersion", e); - } - } - - @Test(timeout = 4000) - public void test07() throws Throwable { - // Undeclared exception! - try { - BigDecimalVersion.castAndCheckNotificationVersion("."); - fail("Expecting exception: ArrayIndexOutOfBoundsException"); - - } catch(ArrayIndexOutOfBoundsException e) { - // - // 0 - // - verifyException("org.openecomp.mso.asdc.installer.BigDecimalVersion", e); - } - } - - @Test(timeout = 4000) - public void test08() throws Throwable { - // Undeclared exception! - try { - BigDecimalVersion.castAndCheckNotificationVersion("Mf**K`5E.~Fu.,q"); - fail("Expecting exception: NumberFormatException"); - - } catch(NumberFormatException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("java.math.BigDecimal", e); - } - } - - @Test(timeout = 4000) - public void test09() throws Throwable { - BigDecimalVersion bigDecimalVersion0 = new BigDecimalVersion(); - } - - @Test(timeout = 4000) - public void test10() throws Throwable { - // Undeclared exception! - try { - BigDecimalVersion.castAndCheckNotificationVersionToString("."); - fail("Expecting exception: ArrayIndexOutOfBoundsException"); - - } catch(ArrayIndexOutOfBoundsException e) { - // - // 0 - // - verifyException("org.openecomp.mso.asdc.installer.BigDecimalVersion", e); - } - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTestscaffolding.java deleted file mode 100644 index c04ada8396..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTestscaffolding.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Fri Nov 25 13:37:47 GMT 2016 - */ - -package org.openecomp.mso.asdc.installer; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; - -@EvoSuiteClassExclude -public class BigDecimalVersionESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.installer.BigDecimalVersion"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; - org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); - - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(BigDecimalVersionESTestscaffolding.class.getClassLoader() , - "org.openecomp.mso.asdc.installer.BigDecimalVersion" - ); - } - - private static void resetClasses() { - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTest.java deleted file mode 100644 index c9b29ae57f..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Fri Nov 25 13:20:32 GMT 2016 - */ - -package org.openecomp.mso.asdc.installer; - -import org.junit.Test; -import static org.junit.Assert.*; -import static org.evosuite.shaded.org.mockito.Mockito.*; -import static org.evosuite.runtime.EvoAssertions.*; - -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.evosuite.runtime.PrivateAccess; -import org.evosuite.runtime.ViolatedAssumptionAnswer; -import org.junit.runner.RunWith; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; -import org.openecomp.sdc.impl.DistributionClientDownloadResultImpl; -import org.openecomp.sdc.utils.DistributionActionResultEnum; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class VfModuleArtifactESTest extends VfModuleArtifactESTestscaffolding { - - @Test(timeout = 4000) - public void test00() throws Throwable { - IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); - DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.CONF_MISSING_ARTIFACT_TYPES; - byte[] byteArray0 = new byte[1]; - DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "7pKd8", "7pKd8", byteArray0); - VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); - PrivateAccess.setVariable((Class) VfModuleArtifact.class, vfModuleArtifact0, "result", (Object) null); - vfModuleArtifact0.getResult(); - assertEquals(0, vfModuleArtifact0.getDeployedInDb()); - } - - @Test(timeout = 4000) - public void test01() throws Throwable { - IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); - DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.DISTRIBUTION_CLIENT_ALREADY_INITIALIZED; - byte[] byteArray0 = new byte[0]; - DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "o) VfModuleArtifact.class, vfModuleArtifact0, "deployedInDb", (Object) (-40)); - int int0 = vfModuleArtifact0.getDeployedInDb(); - assertEquals((-40), int0); - } - - @Test(timeout = 4000) - public void test04() throws Throwable { - IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); - DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.DISTRIBUTION_CLIENT_ALREADY_INITIALIZED; - byte[] byteArray0 = new byte[0]; - DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "o list0 = (List) mock(List.class, new ViolatedAssumptionAnswer()); - Integer integer0 = new Integer((-13)); - vfModuleMetaData0.setAttribute("", integer0); - vfModuleMetaData0.setAttribute("", ""); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn((Object) null).when(map0).put(any() , any()); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "attributesMap", (Object) map0); - List list1 = (List) mock(List.class, new ViolatedAssumptionAnswer()); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "artifacts", (Object) list1); - vfModuleMetaData0.setAttribute("kup1s\"/L_ ", "kup1s\"/L_ "); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "artifacts", (Object) list0); - Map map1 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "properties", (Object) map1); - Map map2 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "attributesMap", (Object) map2); - Map map3 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "attributesMap", (Object) map3); - VfModuleMetaData vfModuleMetaData1 = new VfModuleMetaData(); - List list2 = (List) mock(List.class, new ViolatedAssumptionAnswer()); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData1, "artifacts", (Object) list2); - vfModuleMetaData1.setAttribute((String) null, ""); - vfModuleMetaData1.setAttribute("", ""); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData1, "properties", (Object) null); - vfModuleMetaData1.getProperties(); - vfModuleMetaData0.setAttribute("", integer0); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "attributesMap", (Object) null); - // Undeclared exception! - try { - vfModuleMetaData1.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test01() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - Map map0 = vfModuleMetaData0.getProperties(); - List list0 = (List) mock(List.class, new ViolatedAssumptionAnswer()); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "artifacts", (Object) list0); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "attributesMap", (Object) map0); - vfModuleMetaData0.setAttribute(")aPjhY=.[,~@B5", ")aPjhY=.[,~@B5"); - vfModuleMetaData0.setAttribute(")aPjhY=.[,~@B5", ""); - vfModuleMetaData0.setAttribute(")aPjhY=.[,~@B5", ""); - Integer integer0 = new Integer((-6)); - vfModuleMetaData0.setAttribute(")aPjhY=.[,~@B5", integer0); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "properties", (Object) map0); - Map map1 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn((Object) null).when(map1).put(any() , any()); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "attributesMap", (Object) map1); - vfModuleMetaData0.setAttribute((String) null, integer0); - Integer integer1 = new Integer((-1)); - vfModuleMetaData0.setAttribute("&$*6wB^=VXY/.Gj`T", integer1); - Map map2 = vfModuleMetaData0.getProperties(); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "attributesMap", (Object) map2); - Map map3 = vfModuleMetaData0.getProperties(); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "attributesMap", (Object) map3); - List list1 = (List) mock(List.class, new ViolatedAssumptionAnswer()); - doReturn((String) null).when(list1).toString(); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "artifacts", (Object) list1); - List list2 = vfModuleMetaData0.getArtifacts(); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "properties", (Object) map3); - PrivateAccess.setVariable((Class) VfModuleMetaData.class, vfModuleMetaData0, "artifacts", (Object) list2); - // Undeclared exception! - try { - vfModuleMetaData0.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test02() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.getVfModuleModelUUID(); - vfModuleMetaData0.setAttribute("", ""); - vfModuleMetaData0.setAttribute("X0s-/&YT>", "X0s-/&YT>"); - vfModuleMetaData0.getArtifacts(); - vfModuleMetaData0.setAttribute("vfModuleModelUUID", ""); - vfModuleMetaData0.setAttribute("RHO{0R!FJsK+:s.q", ""); - vfModuleMetaData0.setAttribute((String) null, ""); - vfModuleMetaData0.setAttribute("", ""); - vfModuleMetaData0.getVfModuleModelUUID(); - vfModuleMetaData0.getArtifacts(); - vfModuleMetaData0.getProperties(); - vfModuleMetaData0.getVfModuleModelUUID(); - vfModuleMetaData0.getArtifacts(); - vfModuleMetaData0.setAttribute("", ""); - vfModuleMetaData0.getVfModuleModelUUID(); - vfModuleMetaData0.getArtifacts(); - // Undeclared exception! - try { - vfModuleMetaData0.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test03() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("6NJ#o #-{", "6NJ#o #-{"); - vfModuleMetaData0.setAttribute("", ""); - vfModuleMetaData0.setAttribute("", "3o(D\" map0 = vfModuleMetaData0.getProperties(); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.setAttribute("", ""); - vfModuleMetaData0.setAttribute("", "w(f2d"); - vfModuleMetaData0.setAttribute("", map0); - vfModuleMetaData0.setAttribute(" map0 = vfModuleMetaData0.getProperties(); - vfModuleMetaData0.setAttribute("vfModuleModelDescription", "vfModuleModelDescription"); - vfModuleMetaData0.setAttribute("vfModuleModelDescription", map0); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - vfModuleMetaData0.getArtifacts(); - vfModuleMetaData0.getProperties(); - // Undeclared exception! - try { - vfModuleMetaData0.getVfModuleModelDescription(); - fail("Expecting exception: ClassCastException"); - - } catch(ClassCastException e) { - // - // java.util.HashMap cannot be cast to java.lang.String - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test08() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("vfModuleModelDescription", "vfModuleModelDescription"); - vfModuleMetaData0.setAttribute("}U?", ""); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.setAttribute("f78C:y", (Object) null); - vfModuleMetaData0.getArtifacts(); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.getVfModuleModelUUID(); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.getVfModuleModelDescription(); - vfModuleMetaData0.setAttribute("", ""); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.getVfModuleModelDescription(); - vfModuleMetaData0.getVfModuleModelName(); - vfModuleMetaData0.getProperties(); - vfModuleMetaData0.getVfModuleModelVersion(); - // Undeclared exception! - try { - vfModuleMetaData0.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test09() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("Q> 'piXimPhE", "Q> 'piXimPhE"); - vfModuleMetaData0.setAttribute("Q> 'piXimPhE", "("); - vfModuleMetaData0.setAttribute("D0kbC~", "Q> 'piXimPhE"); - vfModuleMetaData0.setAttribute("", "D0kbC~"); - vfModuleMetaData0.setAttribute("(", ""); - vfModuleMetaData0.setAttribute("vfModuleModelVersion", "][,6>~[xc,"); - vfModuleMetaData0.setAttribute("", "("); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - vfModuleMetaData0.getVfModuleModelDescription(); - vfModuleMetaData0.getVfModuleModelDescription(); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.setAttribute("D0kbC~", "vfModuleModelVersion"); - // Undeclared exception! - try { - vfModuleMetaData0.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test10() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("vfModuleModelUUID", ""); - vfModuleMetaData0.setAttribute("vfModuleModelCustomizationUUID", ""); - vfModuleMetaData0.setAttribute("", ""); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - // Undeclared exception! - try { - vfModuleMetaData0.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test11() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("", ""); - vfModuleMetaData0.setAttribute("isBase", "isBase"); - vfModuleMetaData0.setAttribute("isBase", ""); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - vfModuleMetaData0.getArtifacts(); - // Undeclared exception! - try { - vfModuleMetaData0.isBase(); - fail("Expecting exception: ClassCastException"); - - } catch(ClassCastException e) { - // - // java.lang.String cannot be cast to java.lang.Boolean - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test12() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("vfModuleModelName", "vfModuleModelName"); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.setAttribute("mp+0S", (Object) null); - vfModuleMetaData0.setAttribute("EVNf'G}^Q", "mp+0S"); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.getVfModuleModelName(); - vfModuleMetaData0.getVfModuleModelName(); - vfModuleMetaData0.getArtifacts(); - vfModuleMetaData0.getVfModuleModelName(); - vfModuleMetaData0.setAttribute("Pw5`cyIph)xX&#zj~'", (Object) null); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.getVfModuleModelName(); - // Undeclared exception! - try { - vfModuleMetaData0.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test13() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("vfModuleModelName", "vfModuleModelName"); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.setAttribute("", (Object) null); - vfModuleMetaData0.setAttribute((String) null, "vfModuleModelName"); - vfModuleMetaData0.setAttribute("vfModuleModelName", ""); - vfModuleMetaData0.getVfModuleModelDescription(); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.getProperties(); - vfModuleMetaData0.getProperties(); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - vfModuleMetaData0.getVfModuleModelName(); - // Undeclared exception! - try { - vfModuleMetaData0.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test14() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("vfModuleModelInvariantUUID", "vfModuleModelInvariantUUID"); - vfModuleMetaData0.setAttribute("vfModuleModelInvariantUUID", "vfModuleModelInvariantUUID"); - vfModuleMetaData0.getVfModuleModelUUID(); - vfModuleMetaData0.getVfModuleModelName(); - vfModuleMetaData0.getProperties(); - vfModuleMetaData0.setAttribute("k", "k"); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.setAttribute("", (Object) null); - VfModuleMetaData vfModuleMetaData1 = new VfModuleMetaData(); - vfModuleMetaData1.getProperties(); - // Undeclared exception! - try { - vfModuleMetaData1.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test15() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("y&g B,yQlt!e=p`Q1", "y&g B,yQlt!e=p`Q1"); - vfModuleMetaData0.setAttribute("vfModuleModelCustomizationUUID", "vfModuleModelCustomizationUUID"); - vfModuleMetaData0.setAttribute("vfModuleModelCustomizationUUID", "vfModuleModelCustomizationUUID"); - vfModuleMetaData0.setAttribute("y&g B,yQlt!e=p`Q1", "vfModuleModelCustomizationUUID"); - vfModuleMetaData0.setAttribute("vfModuleModelCustomizationUUID", (Object) null); - vfModuleMetaData0.setAttribute("3m%.ng=pp5", "vfModuleModelCustomizationUUID"); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.setAttribute((String) null, (Object) null); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - vfModuleMetaData0.setAttribute((String) null, "vfModuleModelDescription"); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - vfModuleMetaData0.setAttribute("n8'>kSe2Hv:m| ", "vfModuleModelCustomizationUUID"); - vfModuleMetaData0.getVfModuleModelUUID(); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.getVfModuleModelName(); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - vfModuleMetaData0.getVfModuleModelVersion(); - String string0 = vfModuleMetaData0.getVfModuleModelVersion(); - assertNull(string0); - } - - @Test(timeout = 4000) - public void test16() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.getVfModuleModelDescription(); - vfModuleMetaData0.setAttribute((String) null, (Object) null); - vfModuleMetaData0.getVfModuleModelName(); - vfModuleMetaData0.getVfModuleModelVersion(); - vfModuleMetaData0.setAttribute(".+7u)hv;7kUOz", (Object) null); - vfModuleMetaData0.getVfModuleModelCustomizationUUID(); - vfModuleMetaData0.getVfModuleModelInvariantUUID(); - String string0 = vfModuleMetaData0.getVfModuleModelUUID(); - assertNull(string0); - } - - @Test(timeout = 4000) - public void test17() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - String string0 = "$"; - vfModuleMetaData0.setAttribute("$", "$"); - vfModuleMetaData0.setAttribute("$", ""); - vfModuleMetaData0.setAttribute("", "$"); - // Undeclared exception! - try { - vfModuleMetaData0.isBase(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test18() throws Throwable { - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.getArtifacts(); - Map map0 = vfModuleMetaData0.getProperties(); - assertEquals(0, map0.size()); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleMetaDataESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleMetaDataESTestscaffolding.java deleted file mode 100644 index 39bb3a7227..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleMetaDataESTestscaffolding.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Fri Feb 24 16:02:34 GMT 2017 - */ - -package org.openecomp.mso.asdc.installer; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; -import org.evosuite.runtime.sandbox.Sandbox.SandboxMode; - -@EvoSuiteClassExclude -public class VfModuleMetaDataESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.installer.VfModuleMetaData"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = SandboxMode.RECOMMENDED; - Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - Sandbox.goingToExecuteSUTCode(); - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VfModuleMetaDataESTestscaffolding.class.getClassLoader() , - "org.openecomp.mso.asdc.installer.VfModuleMetaData", - "org.openecomp.mso.asdc.installer.IVfModuleData" - ); - } - - private static void resetClasses() { - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTest.java deleted file mode 100644 index e63680b4c7..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Fri Feb 24 13:34:51 GMT 2017 - */ - -package org.openecomp.mso.asdc.installer; - -import org.junit.Test; -import static org.junit.Assert.*; -import static org.evosuite.shaded.org.mockito.Mockito.*; -import static org.evosuite.runtime.MockitoExtension.*; -import static org.evosuite.runtime.EvoAssertions.*; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.evosuite.runtime.ViolatedAssumptionAnswer; -import org.junit.runner.RunWith; -import org.openecomp.mso.asdc.installer.IVfModuleData; -import org.openecomp.mso.asdc.installer.VfModuleArtifact; -import org.openecomp.mso.asdc.installer.VfModuleStructure; -import org.openecomp.mso.asdc.installer.VfResourceStructure; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.api.notification.IResourceInstance; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class VfModuleStructureESTest extends VfModuleStructureESTestscaffolding { - - @Test(timeout = 4000) - public void test0() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - IVfModuleData iVfModuleData0 = mock(IVfModuleData.class, new ViolatedAssumptionAnswer()); - doReturn(linkedList0).when(iVfModuleData0).getArtifacts(); - VfModuleStructure vfModuleStructure0 = new VfModuleStructure((VfResourceStructure) null, iVfModuleData0); - VfModule vfModule0 = new VfModule(); - vfModule0.setIsBase(1); - vfModuleStructure0.setCatalogVfModule(vfModule0); - VfModule vfModule1 = vfModuleStructure0.getCatalogVfModule(); - assertNull(vfModule1.getModelInvariantUuid()); - } - - @Test(timeout = 4000) - public void test1() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - IVfModuleData iVfModuleData0 = mock(IVfModuleData.class, new ViolatedAssumptionAnswer()); - doReturn(linkedList0).when(iVfModuleData0).getArtifacts(); - VfModuleStructure vfModuleStructure0 = new VfModuleStructure((VfResourceStructure) null, iVfModuleData0); - VfModule vfModule0 = new VfModule(); - vfModuleStructure0.setCatalogVfModule(vfModule0); - VfModule vfModule1 = vfModuleStructure0.getCatalogVfModule(); - assertNull(vfModule1.getModelVersion()); - } - @Test(timeout = 4000) - public void test4() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - IVfModuleData iVfModuleData0 = mock(IVfModuleData.class, new ViolatedAssumptionAnswer()); - doReturn(linkedList0).when(iVfModuleData0).getArtifacts(); - VfModuleStructure vfModuleStructure0 = new VfModuleStructure((VfResourceStructure) null, iVfModuleData0); - Map> map0 = vfModuleStructure0.getArtifactsMap(); - assertTrue(map0.isEmpty()); - } - - @Test(timeout = 4000) - public void test5() throws Throwable { - INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); - IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); - VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); - IVfModuleData iVfModuleData0 = mock(IVfModuleData.class, new ViolatedAssumptionAnswer()); - doReturn((List) null).when(iVfModuleData0).getArtifacts(); - VfModuleStructure vfModuleStructure0 = null; - try { - vfModuleStructure0 = new VfModuleStructure(vfResourceStructure0, iVfModuleData0); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleStructure", e); - } - } - - @Test(timeout = 4000) - public void test6() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - IVfModuleData iVfModuleData0 = mock(IVfModuleData.class, new ViolatedAssumptionAnswer()); - doReturn(linkedList0).when(iVfModuleData0).getArtifacts(); - VfModuleStructure vfModuleStructure0 = new VfModuleStructure((VfResourceStructure) null, iVfModuleData0); - VfModule vfModule0 = vfModuleStructure0.getCatalogVfModule(); - assertNull(vfModule0); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTestscaffolding.java deleted file mode 100644 index f6aa2ab5f2..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTestscaffolding.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Fri Nov 25 13:37:00 GMT 2016 - */ - -package org.openecomp.mso.asdc.installer; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; - -@EvoSuiteClassExclude -public class VfModuleStructureESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.installer.VfModuleStructure"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; - org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); - - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VfModuleStructureESTestscaffolding.class.getClassLoader() , - "org.openecomp.sdc.api.IDistributionClient", - "org.openecomp.mso.db.catalog.utils.MavenLikeVersioning", - "org.openecomp.mso.asdc.installer.VfResourceStructure", - "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException", - "org.openecomp.mso.db.catalog.beans.VnfResource", - "org.openecomp.sdc.api.notification.IVfModuleMetadata", - "org.openecomp.mso.db.catalog.beans.VfModule", - "org.openecomp.sdc.api.results.IDistributionClientResult", - "org.openecomp.sdc.api.notification.IArtifactInfo", - "org.openecomp.mso.db.catalog.beans.Service", - "org.openecomp.mso.asdc.installer.VfModuleStructure", - "org.openecomp.sdc.api.notification.INotificationData", - "org.openecomp.mso.asdc.installer.VfModuleArtifact", - "org.openecomp.sdc.api.notification.IResourceInstance", - "org.openecomp.sdc.api.results.IDistributionClientDownloadResult" - ); - } - - private static void resetClasses() { - org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(VfModuleStructureESTestscaffolding.class.getClassLoader()); - - org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( - "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException" - ); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTest.java deleted file mode 100644 index 2e73096337..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTest.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Mon Mar 13 16:09:00 GMT 2017 - */ - -package org.openecomp.mso.asdc.util; - -import org.junit.Test; -import static org.junit.Assert.*; -import static org.evosuite.shaded.org.mockito.Mockito.*; -import static org.evosuite.runtime.MockitoExtension.*; -import static org.evosuite.runtime.EvoAssertions.*; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.function.UnaryOperator; -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.evosuite.runtime.PrivateAccess; -import org.evosuite.runtime.ViolatedAssumptionAnswer; -import org.junit.runner.RunWith; -import org.openecomp.mso.asdc.installer.IVfModuleData; -import org.openecomp.mso.asdc.installer.VfModuleMetaData; -import org.openecomp.mso.asdc.util.ASDCNotificationLogging; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.api.notification.IResourceInstance; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class ASDCNotificationLoggingESTest extends ASDCNotificationLoggingESTestscaffolding { - - @Test(timeout = 4000) - public void test00() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - vfModuleMetaData0.setAttribute("vfModuleModelInvariantUUID", vfModuleMetaData0); - linkedList0.add((IVfModuleData) vfModuleMetaData0); - // Undeclared exception! - try { - ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); - fail("Expecting exception: ClassCastException"); - - } catch(ClassCastException e) { - // - // org.openecomp.mso.asdc.installer.VfModuleMetaData cannot be cast to java.lang.String - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test01() throws Throwable { - List list0 = (List) mock(List.class, new ViolatedAssumptionAnswer()); - doReturn(false).when(list0).isEmpty(); - doReturn((Iterator) null).when(list0).iterator(); - doReturn(0).when(list0).size(); - INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); - doReturn("rGQA").when(iNotificationData0).getDistributionID(); - doReturn(list0).when(iNotificationData0).getServiceArtifacts(); - doReturn("rGQA").when(iNotificationData0).getServiceDescription(); - doReturn("").when(iNotificationData0).getServiceInvariantUUID(); - doReturn("").when(iNotificationData0).getServiceName(); - doReturn("rGQA").when(iNotificationData0).getServiceUUID(); - doReturn("").when(iNotificationData0).getServiceVersion(); - // Undeclared exception! - try { - ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.util.ASDCNotificationLogging", e); - } - } - - @Test(timeout = 4000) - public void test02() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - LinkedList linkedList1 = new LinkedList(); - linkedList0.offerFirst((IResourceInstance) null); - INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); - doReturn("").when(iNotificationData0).getDistributionID(); - doReturn(linkedList0, linkedList0).when(iNotificationData0).getResources(); - doReturn(linkedList1).when(iNotificationData0).getServiceArtifacts(); - doReturn("").when(iNotificationData0).getServiceDescription(); - doReturn("]U5JAkfdX0Cs").when(iNotificationData0).getServiceInvariantUUID(); - doReturn("jV13a").when(iNotificationData0).getServiceName(); - doReturn("").when(iNotificationData0).getServiceUUID(); - doReturn("jV13a").when(iNotificationData0).getServiceVersion(); - String string0 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); - assertEquals("ASDC Notification:\nDistributionID:\nServiceName:jV13a\nServiceVersion:jV13a\nServiceUUID:\nServiceInvariantUUID:]U5JAkfdX0Cs\nServiceDescription:\nService Artifacts List:\nNULL\nResource Instances List:\n{\nNULL\n\n}\n\n", string0); - } - - @Test(timeout = 4000) - public void test03() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - LinkedList linkedList1 = new LinkedList(); - IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); - doReturn((List) null).when(iResourceInstance0).getArtifacts(); - doReturn((String) null).when(iResourceInstance0).getCategory(); - doReturn((String) null).when(iResourceInstance0).getResourceCustomizationUUID(); - doReturn((String) null).when(iResourceInstance0).getResourceInstanceName(); - doReturn((String) null).when(iResourceInstance0).getResourceInvariantUUID(); - doReturn((String) null).when(iResourceInstance0).getResourceName(); - doReturn((String) null).when(iResourceInstance0).getResourceType(); - doReturn((String) null).when(iResourceInstance0).getResourceUUID(); - doReturn((String) null).when(iResourceInstance0).getResourceVersion(); - doReturn((String) null).when(iResourceInstance0).getSubcategory(); - linkedList0.add(iResourceInstance0); - INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); - doReturn("").when(iNotificationData0).getDistributionID(); - doReturn(linkedList0, linkedList0).when(iNotificationData0).getResources(); - doReturn(linkedList1).when(iNotificationData0).getServiceArtifacts(); - doReturn("").when(iNotificationData0).getServiceDescription(); - doReturn("").when(iNotificationData0).getServiceInvariantUUID(); - doReturn("36-s.n1@").when(iNotificationData0).getServiceName(); - doReturn("36-s.n1@").when(iNotificationData0).getServiceUUID(); - doReturn("").when(iNotificationData0).getServiceVersion(); - String string0 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); - assertEquals("ASDC Notification:\nDistributionID:\nServiceName:36-s.n1@\nServiceVersion:\nServiceUUID:36-s.n1@\nServiceInvariantUUID:\nServiceDescription:\nService Artifacts List:\nNULL\nResource Instances List:\n{\nResource Instance Info:\nResourceInstanceName:NULL\nResourceCustomizationUUID:NULL\nResourceInvariantUUID:NULL\nResourceName:NULL\nResourceType:NULL\nResourceUUID:NULL\nResourceVersion:NULL\nCategory:NULL\nSubCategory:NULL\nResource Artifacts List:\nNULL\n\n\n}\n\n", string0); - } - - @Test(timeout = 4000) - public void test04() throws Throwable { - INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); - doReturn((String) null).when(iNotificationData0).getDistributionID(); - doReturn((List) null).when(iNotificationData0).getResources(); - doReturn((List) null).when(iNotificationData0).getServiceArtifacts(); - doReturn((String) null).when(iNotificationData0).getServiceDescription(); - doReturn((String) null).when(iNotificationData0).getServiceInvariantUUID(); - doReturn((String) null).when(iNotificationData0).getServiceName(); - doReturn((String) null).when(iNotificationData0).getServiceUUID(); - doReturn((String) null).when(iNotificationData0).getServiceVersion(); - String string0 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); - assertEquals("ASDC Notification:\nDistributionID:NULL\nServiceName:NULL\nServiceVersion:NULL\nServiceUUID:NULL\nServiceInvariantUUID:NULL\nServiceDescription:NULL\nService Artifacts List:\nNULL\nResource Instances List:\nNULL\n", string0); - } - - @Test(timeout = 4000) - public void test05() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - Map map0 = vfModuleMetaData0.getProperties(); - IVfModuleData iVfModuleData0 = mock(IVfModuleData.class, new ViolatedAssumptionAnswer()); - doReturn((List) null, (List) null).when(iVfModuleData0).getArtifacts(); - doReturn(map0, map0, (Map) null).when(iVfModuleData0).getProperties(); - doReturn("vfModuleModelUUID", "isBase:").when(iVfModuleData0).getVfModuleModelDescription(); - doReturn((String) null, "vfModuleModelName").when(iVfModuleData0).getVfModuleModelInvariantUUID(); - doReturn("", "").when(iVfModuleData0).getVfModuleModelName(); - doReturn("vfModuleModelUUID", "isBase:").when(iVfModuleData0).getVfModuleModelUUID(); - doReturn("|:\\KD91", "vfModuleModelName").when(iVfModuleData0).getVfModuleModelVersion(); - doReturn(false, false).when(iVfModuleData0).isBase(); - linkedList0.add(iVfModuleData0); - String string0 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); - assertEquals("VfModuleMetaData List:\n{\nVfModuleMetaData:\nVfModuleModelName:\nVfModuleModelVersion:|:\\KD91\nVfModuleModelUUID:vfModuleModelUUID\nVfModuleModelInvariantUUID:NULL\nVfModuleModelDescription:vfModuleModelUUID\nArtifacts UUID List:NULLProperties List:\n}\n\nisBase:false\n\n\n}\n", string0); - - String string1 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); - assertEquals("VfModuleMetaData List:\n{\nVfModuleMetaData:\nVfModuleModelName:\nVfModuleModelVersion:vfModuleModelName\nVfModuleModelUUID:isBase:\nVfModuleModelInvariantUUID:vfModuleModelName\nVfModuleModelDescription:isBase:\nArtifacts UUID List:NULLNULL\nisBase:false\n\n\n}\n", string1); - } - - @Test(timeout = 4000) - public void test06() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - LinkedList linkedList1 = new LinkedList(); - IVfModuleData iVfModuleData0 = mock(IVfModuleData.class, new ViolatedAssumptionAnswer()); - doReturn((List) null, (List) null).when(iVfModuleData0).getArtifacts(); - doReturn((Map) null, (Map) null).when(iVfModuleData0).getProperties(); - doReturn((String) null, (String) null).when(iVfModuleData0).getVfModuleModelDescription(); - doReturn((String) null, (String) null).when(iVfModuleData0).getVfModuleModelInvariantUUID(); - doReturn((String) null, (String) null).when(iVfModuleData0).getVfModuleModelName(); - doReturn((String) null, (String) null).when(iVfModuleData0).getVfModuleModelUUID(); - doReturn((String) null, (String) null).when(iVfModuleData0).getVfModuleModelVersion(); - doReturn(false, false).when(iVfModuleData0).isBase(); - linkedList1.add(iVfModuleData0); - String string0 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList1); - String string1 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList1); - assertTrue(string1.equals((Object)string0)); - assertEquals("VfModuleMetaData List:\n{\nVfModuleMetaData:\nVfModuleModelName:NULL\nVfModuleModelVersion:NULL\nVfModuleModelUUID:NULL\nVfModuleModelInvariantUUID:NULL\nVfModuleModelDescription:NULL\nArtifacts UUID List:NULLNULL\nisBase:false\n\n\n}\n", string1); - } - - @Test(timeout = 4000) - public void test07() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - linkedList0.add((IVfModuleData) vfModuleMetaData0); - UnaryOperator unaryOperator0 = (UnaryOperator) mock(UnaryOperator.class, new ViolatedAssumptionAnswer()); - doReturn((Object) null).when(unaryOperator0).apply(any()); - linkedList0.replaceAll(unaryOperator0); - String string0 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); - assertEquals("VfModuleMetaData List:\n{\nNULL\n\n}\n", string0); - } - - @Test(timeout = 4000) - public void test08() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - VfModuleMetaData vfModuleMetaData0 = new VfModuleMetaData(); - linkedList0.add((IVfModuleData) vfModuleMetaData0); - // Undeclared exception! - try { - ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.installer.VfModuleMetaData", e); - } - } - - @Test(timeout = 4000) - public void test09() throws Throwable { - String string0 = ASDCNotificationLogging.dumpVfModuleMetaDataList((List) null); - assertNull(string0); - } - - @Test(timeout = 4000) - public void test10() throws Throwable { - String string0 = ASDCNotificationLogging.dumpASDCNotification((INotificationData) null); - assertEquals("NULL", string0); - } - - @Test(timeout = 4000) - public void test11() throws Throwable { - LinkedList linkedList0 = new LinkedList(); - INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); - doReturn("io7<{~.v|%").when(iNotificationData0).getDistributionID(); - doReturn((List) null).when(iNotificationData0).getResources(); - doReturn(linkedList0).when(iNotificationData0).getServiceArtifacts(); - doReturn("io7<{~.v|%").when(iNotificationData0).getServiceDescription(); - doReturn("io7<{~.v|%").when(iNotificationData0).getServiceInvariantUUID(); - doReturn("io7<{~.v|%").when(iNotificationData0).getServiceName(); - doReturn((String) null).when(iNotificationData0).getServiceUUID(); - doReturn("io7<{~.v|%").when(iNotificationData0).getServiceVersion(); - String string0 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); - assertEquals("ASDC Notification:\nDistributionID:io7<{~.v|%\nServiceName:io7<{~.v|%\nServiceVersion:io7<{~.v|%\nServiceUUID:NULL\nServiceInvariantUUID:io7<{~.v|%\nServiceDescription:io7<{~.v|%\nService Artifacts List:\nNULL\nResource Instances List:\nNULL\n", string0); - - ASDCNotificationLogging.dumpVfModuleMetaDataList((List) null); - IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); - doReturn((String) null).when(iArtifactInfo0).getArtifactChecksum(); - doReturn((String) null).when(iArtifactInfo0).getArtifactDescription(); - doReturn((String) null).when(iArtifactInfo0).getArtifactName(); - doReturn((Integer) null).when(iArtifactInfo0).getArtifactTimeout(); - doReturn((String) null).when(iArtifactInfo0).getArtifactType(); - doReturn((String) null).when(iArtifactInfo0).getArtifactURL(); - doReturn((String) null).when(iArtifactInfo0).getArtifactUUID(); - doReturn((String) null).when(iArtifactInfo0).getArtifactVersion(); - doReturn((IArtifactInfo) null).when(iArtifactInfo0).getGeneratedArtifact(); - doReturn((List) null).when(iArtifactInfo0).getRelatedArtifacts(); - linkedList0.push(iArtifactInfo0); - INotificationData iNotificationData1 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); - doReturn("t2J^4~*i|btm ib&").when(iNotificationData1).getDistributionID(); - doReturn((List) null).when(iNotificationData1).getResources(); - doReturn(linkedList0).when(iNotificationData1).getServiceArtifacts(); - doReturn("N~a W7").when(iNotificationData1).getServiceDescription(); - doReturn("N~a W7").when(iNotificationData1).getServiceInvariantUUID(); - doReturn("/&*/=").when(iNotificationData1).getServiceName(); - doReturn((String) null).when(iNotificationData1).getServiceUUID(); - doReturn("ASDC Notification:\nDistributionID:io7<{~.v|%\nServiceName:io7<{~.v|%\nServiceVersion:io7<{~.v|%\nServiceUUID:NULL\nServiceInvariantUUID:io7<{~.v|%\nServiceDescription:io7<{~.v|%\nService Artifacts List:\nNULL\nResource Instances List:\nNULL\n").when(iNotificationData1).getServiceVersion(); - String string1 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData1); - assertEquals("ASDC Notification:\nDistributionID:t2J^4~*i|btm ib&\nServiceName:/&*/=\nServiceVersion:ASDC Notification:\nDistributionID:io7<{~.v|%\nServiceName:io7<{~.v|%\nServiceVersion:io7<{~.v|%\nServiceUUID:NULL\nServiceInvariantUUID:io7<{~.v|%\nServiceDescription:io7<{~.v|%\nService Artifacts List:\nNULL\nResource Instances List:\nNULL\n\nServiceUUID:NULL\nServiceInvariantUUID:N~a W7\nServiceDescription:N~a W7\nService Artifacts List:\n{\nService Artifacts Info:\nArtifactName:NULL\nArtifactVersion:NULL\nArtifactType:NULL\nArtifactDescription:NULL\nArtifactTimeout:NULL\nArtifactURL:NULL\nArtifactUUID:NULL\nArtifactChecksum:NULL\nGeneratedArtifact:{NULL\n}\nRelatedArtifacts:NULL\n\n\n}\n\nResource Instances List:\nNULL\n", string1); - } - - @Test(timeout = 4000) - public void test12() throws Throwable { - ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); - Object object0 = PrivateAccess.callMethod((Class) ASDCNotificationLogging.class, aSDCNotificationLogging0, "dumpASDCResourcesList", (Object) null, (Class) INotificationData.class); - assertNull(object0); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTestscaffolding.java deleted file mode 100644 index 62663e7397..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTestscaffolding.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Mon Mar 13 15:55:23 GMT 2017 - */ - -package org.openecomp.mso.asdc.util; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; -import org.evosuite.runtime.sandbox.Sandbox.SandboxMode; - -@EvoSuiteClassExclude -public class ASDCNotificationLoggingESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.util.ASDCNotificationLogging"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = SandboxMode.RECOMMENDED; - Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - Sandbox.goingToExecuteSUTCode(); - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCNotificationLoggingESTestscaffolding.class.getClassLoader() , - "org.openecomp.sdc.api.notification.INotificationData", - "org.openecomp.mso.asdc.installer.VfModuleMetaData", - "org.openecomp.mso.asdc.installer.IVfModuleData", - "org.openecomp.sdc.api.notification.IResourceInstance", - "org.openecomp.sdc.api.notification.IArtifactInfo", - "org.openecomp.mso.asdc.util.ASDCNotificationLogging" - ); - } - - private static void resetClasses() { - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTest.java deleted file mode 100644 index c050a9cc20..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTest.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Fri Nov 25 13:17:51 GMT 2016 - */ - -package org.openecomp.mso.asdc.util; - -import org.junit.Test; -import static org.junit.Assert.*; -import static org.evosuite.shaded.org.mockito.Mockito.*; -import static org.evosuite.runtime.MockitoExtension.*; -import static org.evosuite.runtime.EvoAssertions.*; - -import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.evosuite.runtime.PrivateAccess; -import org.evosuite.runtime.ViolatedAssumptionAnswer; -import org.junit.runner.RunWith; -import org.yaml.snakeyaml.Yaml; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class YamlEditorESTest extends YamlEditorESTestscaffolding { - - @Test(timeout = 4000) - public void test00() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - boolean boolean0 = yamlEditor0.isParentTemplate("file:///"); - assertTrue(boolean0); - } - - @Test(timeout = 4000) - public void test01() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - HashMap hashMap0 = new HashMap(); - Yaml yaml0 = mock(Yaml.class, new ViolatedAssumptionAnswer()); - doReturn((String) null, (String) null).when(yaml0).dump(any()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yaml", (Object) yaml0); - yamlEditor0.encode((Map) hashMap0); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn((Object) null).when(map0).get(any()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yml", (Object) map0); - yamlEditor0.toString(); - // Undeclared exception! - try { - yamlEditor0.getYamlResourceTypeList(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test02() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - HashMap hashMap0 = new HashMap(); - Yaml yaml0 = mock(Yaml.class, new ViolatedAssumptionAnswer()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yaml", (Object) yaml0); - Object object0 = new Object(); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn(hashMap0, object0).when(map0).get(any()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yml", (Object) map0); - yamlEditor0.getParameterList(); - // Undeclared exception! - try { - yamlEditor0.getYamlResourceTypeList(); - fail("Expecting exception: ClassCastException"); - - } catch(ClassCastException e) { - // - // java.lang.Object cannot be cast to java.util.Map - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test03() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - // Undeclared exception! - try { - yamlEditor0.getYamlNestedFileResourceTypeList(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test04() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - HashMap hashMap0 = new HashMap(); - Yaml yaml0 = mock(Yaml.class, new ViolatedAssumptionAnswer()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yaml", (Object) yaml0); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn(hashMap0, (Object) null).when(map0).get(any()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yml", (Object) map0); - yamlEditor0.getYamlNestedFileResourceTypeList(); - // Undeclared exception! - try { - yamlEditor0.getParameterList(); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test05() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - HashMap hashMap0 = new HashMap(); - Set> set0 = (Set>)hashMap0.entrySet(); - hashMap0.put("null\n", set0); - // Undeclared exception! - try { - yamlEditor0.encode((Map) hashMap0); - fail("Expecting exception: StackOverflowError"); - - } catch(StackOverflowError e) { - // - // no message in exception (getMessage() returned null) - // - } - } - - @Test(timeout = 4000) - public void test06() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - Set> set0 = (Set>) mock(Set.class, new ViolatedAssumptionAnswer()); - doReturn((Iterator) null).when(set0).iterator(); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn(set0).when(map0).entrySet(); - doReturn(2655).when(map0).size(); - // Undeclared exception! - try { - yamlEditor0.encode(map0); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.yaml.snakeyaml.representer.BaseRepresenter", e); - } - } - - @Test(timeout = 4000) - public void test07() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn((-300)).when(map0).size(); - // Undeclared exception! - try { - yamlEditor0.encode(map0); - fail("Expecting exception: IllegalArgumentException"); - - } catch(IllegalArgumentException e) { - // - // Illegal Capacity: -300 - // - verifyException("java.util.ArrayList", e); - } - } - - @Test(timeout = 4000) - public void test08() throws Throwable { - byte[] byteArray0 = new byte[0]; - YamlEditor yamlEditor0 = new YamlEditor(byteArray0); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn("").when(map0).get(any()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yml", (Object) map0); - LinkedHashSet linkedHashSet0 = new LinkedHashSet(); - // Undeclared exception! - try { - yamlEditor0.addParameterList(linkedHashSet0); - fail("Expecting exception: ClassCastException"); - - } catch(ClassCastException e) { - // - // java.lang.String cannot be cast to java.util.Map - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test09() throws Throwable { - byte[] byteArray0 = new byte[1]; - YamlEditor yamlEditor0 = null; - try { - yamlEditor0 = new YamlEditor(byteArray0); - fail("Expecting exception: RuntimeException"); - - } catch(RuntimeException e) { - // - // special characters are not allowed - // - verifyException("org.yaml.snakeyaml.reader.StreamReader", e); - } - } - - @Test(timeout = 4000) - public void test10() throws Throwable { - byte[] byteArray0 = new byte[1]; - byteArray0[0] = (byte)37; - YamlEditor yamlEditor0 = null; - try { - yamlEditor0 = new YamlEditor(byteArray0); - fail("Expecting exception: RuntimeException"); - - } catch(RuntimeException e) { - // - // while scanning a directive - // in 'reader', line 1, column 1: - // % - // ^ - // expected alphabetic or numeric character, but found \u0000(0) - // in 'reader', line 1, column 2: - // % - // ^ - // - verifyException("org.yaml.snakeyaml.scanner.ScannerImpl", e); - } - } - - @Test(timeout = 4000) - public void test11() throws Throwable { - byte[] byteArray0 = new byte[2]; - byteArray0[1] = (byte) (-80); - YamlEditor yamlEditor0 = null; - try { - yamlEditor0 = new YamlEditor(byteArray0); - fail("Expecting exception: RuntimeException"); - - } catch(RuntimeException e) { - // - // java.nio.charset.MalformedInputException: Input length = 1 - // - verifyException("org.yaml.snakeyaml.reader.StreamReader", e); - } - } - - @Test(timeout = 4000) - public void test13() throws Throwable { - byte[] byteArray0 = new byte[1]; - byteArray0[0] = (byte)110; - YamlEditor yamlEditor0 = null; - try { - yamlEditor0 = new YamlEditor(byteArray0); - fail("Expecting exception: ClassCastException"); - - } catch(ClassCastException e) { - // - // java.lang.String cannot be cast to java.util.Map - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test14() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - String string0 = yamlEditor0.encode(); - assertEquals("null\n", string0); - } - - @Test(timeout = 4000) - public void test15() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - HashMap hashMap0 = new HashMap(); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn(hashMap0).when(map0).get(any()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yml", (Object) map0); - Set set0 = (Set) mock(Set.class, new ViolatedAssumptionAnswer()); - doReturn((Iterator) null).when(set0).iterator(); - // Undeclared exception! - try { - yamlEditor0.addParameterList(set0); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test16() throws Throwable { - byte[] byteArray0 = new byte[0]; - YamlEditor yamlEditor0 = new YamlEditor(byteArray0); - HashMap hashMap0 = new HashMap(); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yml", (Object) hashMap0); - LinkedHashSet linkedHashSet0 = new LinkedHashSet(); - HeatTemplateParam heatTemplateParam0 = mock(HeatTemplateParam.class, new ViolatedAssumptionAnswer()); - doReturn(">!=_`7`2d(").when(heatTemplateParam0).getParamName(); - doReturn(">!=_`7`2d(").when(heatTemplateParam0).getParamType(); - linkedHashSet0.add(heatTemplateParam0); - yamlEditor0.addParameterList(linkedHashSet0); - Set set0 = yamlEditor0.getParameterList(); - assertFalse(set0.isEmpty()); - } - - @Test(timeout = 4000) - public void test17() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - HashMap hashMap0 = new HashMap(); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn(hashMap0).when(map0).get(any()); - hashMap0.put(yamlEditor0, "V28"); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yml", (Object) map0); - // Undeclared exception! - try { - yamlEditor0.getParameterList(); - fail("Expecting exception: ClassCastException"); - - } catch(ClassCastException e) { - // - // java.lang.String cannot be cast to java.util.Map - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test18() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - HashMap hashMap0 = new HashMap(); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn(hashMap0).when(map0).get(any()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yml", (Object) map0); - List list0 = yamlEditor0.getYamlResourceTypeList(); - assertEquals(0, list0.size()); - } - - @Test(timeout = 4000) - public void test19() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - // Undeclared exception! - try { - yamlEditor0.isParentTemplate((String) null); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test20() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - yamlEditor0.verifyTemplate(); - yamlEditor0.isParentTemplate("\""); - Map map0 = (Map) mock(Map.class, new ViolatedAssumptionAnswer()); - doReturn(yamlEditor0).when(map0).get(any()); - PrivateAccess.setVariable((Class) YamlEditor.class, yamlEditor0, "yml", (Object) map0); - // Undeclared exception! - try { - yamlEditor0.getYamlNestedFileResourceTypeList(); - fail("Expecting exception: ClassCastException"); - - } catch(ClassCastException e) { - // - // org.openecomp.mso.asdc.util.YamlEditor cannot be cast to java.util.Map - // - verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); - } - } - - @Test(timeout = 4000) - public void test21() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - HashMap hashMap0 = new HashMap(); - String string0 = yamlEditor0.encode((Map) hashMap0); - assertEquals("{}\n", string0); - } - - @Test(timeout = 4000) - public void test22() throws Throwable { - YamlEditor yamlEditor0 = null; - try { - yamlEditor0 = new YamlEditor((byte[]) null); - fail("Expecting exception: NullPointerException"); - - } catch(NullPointerException e) { - // - // no message in exception (getMessage() returned null) - // - } - } - - @Test(timeout = 4000) - public void test23() throws Throwable { - YamlEditor yamlEditor0 = new YamlEditor(); - String string0 = yamlEditor0.toString(); - assertEquals("null\n", string0); - } -} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTestscaffolding.java deleted file mode 100644 index dca8696ef2..0000000000 --- a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTestscaffolding.java +++ /dev/null @@ -1,255 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Fri Nov 25 13:17:51 GMT 2016 - */ - -package org.openecomp.mso.asdc.util; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; - -@EvoSuiteClassExclude -public class YamlEditorESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.util.YamlEditor"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; - org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); - - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(YamlEditorESTestscaffolding.class.getClassLoader() , - "org.yaml.snakeyaml.parser.ParserImpl", - "org.yaml.snakeyaml.nodes.SequenceNode", - "org.yaml.snakeyaml.composer.ComposerException", - "org.yaml.snakeyaml.introspector.BeanAccess", - "org.yaml.snakeyaml.representer.Representer$RepresentJavaBean", - "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.PercentEscaper", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentNumber", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentBoolean", - "org.yaml.snakeyaml.scanner.ScannerImpl$Chomping", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlPairs", - "org.yaml.snakeyaml.emitter.Emitter$ExpectNothing", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentList", - "org.yaml.snakeyaml.events.Event", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlInt", - "org.yaml.snakeyaml.nodes.Node", - "org.yaml.snakeyaml.introspector.MissingProperty", - "org.yaml.snakeyaml.emitter.Emitable", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlTimestamp", - "org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject", - "org.yaml.snakeyaml.composer.Composer", - "org.yaml.snakeyaml.tokens.FlowMappingStartToken", - "org.yaml.snakeyaml.emitter.Emitter$ExpectDocumentStart", - "org.yaml.snakeyaml.constructor.SafeConstructor", - "org.yaml.snakeyaml.nodes.NodeId", - "org.yaml.snakeyaml.events.SequenceEndEvent", - "org.yaml.snakeyaml.events.MappingStartEvent", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentArray", - "org.yaml.snakeyaml.parser.Parser", - "org.yaml.snakeyaml.tokens.AnchorToken", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentDate", - "org.yaml.snakeyaml.parser.Production", - "org.yaml.snakeyaml.introspector.Property", - "org.yaml.snakeyaml.tokens.StreamStartToken", - "org.yaml.snakeyaml.DumperOptions$Version", - "org.yaml.snakeyaml.constructor.ConstructorException", - "org.yaml.snakeyaml.emitter.EmitterException", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlBool", - "org.yaml.snakeyaml.error.MarkedYAMLException", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlFloat", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentNull", - "org.yaml.snakeyaml.events.DocumentEndEvent", - "org.yaml.snakeyaml.error.Mark", - "org.yaml.snakeyaml.emitter.Emitter$ExpectFirstFlowMappingKey", - "org.yaml.snakeyaml.tokens.DocumentEndToken", - "org.yaml.snakeyaml.introspector.PropertyUtils", - "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.Escaper", - "org.yaml.snakeyaml.events.StreamStartEvent", - "org.yaml.snakeyaml.error.YAMLException", - "org.yaml.snakeyaml.scanner.ScannerImpl", - "org.yaml.snakeyaml.reader.UnicodeReader", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlOmap", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentMap", - "org.yaml.snakeyaml.parser.ParserImpl$ParseBlockNode", - "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.UnicodeEscaper", - "org.yaml.snakeyaml.parser.ParserImpl$ParseDocumentStart", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlNull", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlStr", - "org.yaml.snakeyaml.events.CollectionEndEvent", - "org.yaml.snakeyaml.DumperOptions", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentSet", - "org.yaml.snakeyaml.resolver.Resolver", - "org.yaml.snakeyaml.tokens.Token", - "org.yaml.snakeyaml.events.SequenceStartEvent", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap", - "org.yaml.snakeyaml.constructor.Constructor$ConstructMapping", - "org.yaml.snakeyaml.serializer.Serializer$1", - "org.yaml.snakeyaml.constructor.Constructor", - "org.yaml.snakeyaml.scanner.ScannerException", - "org.yaml.snakeyaml.tokens.ScalarToken", - "org.yaml.snakeyaml.resolver.ResolverTuple", - "org.yaml.snakeyaml.constructor.AbstractConstruct", - "org.yaml.snakeyaml.tokens.TagToken", - "org.yaml.snakeyaml.nodes.CollectionNode", - "org.yaml.snakeyaml.nodes.ScalarNode", - "org.yaml.snakeyaml.TypeDescription", - "org.yaml.snakeyaml.events.AliasEvent", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlSet", - "org.yaml.snakeyaml.constructor.Constructor$ConstructSequence", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlSeq", - "org.yaml.snakeyaml.reader.ReaderException", - "org.yaml.snakeyaml.tokens.DocumentStartToken", - "org.yaml.snakeyaml.util.UriEncoder", - "org.yaml.snakeyaml.serializer.SerializerException", - "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.UnicodeEscaper$2", - "org.yaml.snakeyaml.events.MappingEndEvent", - "org.yaml.snakeyaml.parser.VersionTagsTuple", - "org.yaml.snakeyaml.DumperOptions$FlowStyle", - "org.yaml.snakeyaml.events.DocumentStartEvent", - "org.yaml.snakeyaml.tokens.FlowMappingEndToken", - "org.yaml.snakeyaml.emitter.Emitter$ExpectDocumentRoot", - "org.yaml.snakeyaml.representer.BaseRepresenter", - "org.yaml.snakeyaml.nodes.AnchorNode", - "org.yaml.snakeyaml.tokens.FlowSequenceStartToken", - "org.yaml.snakeyaml.tokens.FlowSequenceEndToken", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlBinary", - "org.openecomp.mso.asdc.util.YamlEditor", - "org.yaml.snakeyaml.emitter.EmitterState", - "org.yaml.snakeyaml.events.Event$ID", - "org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart", - "org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder", - "org.yaml.snakeyaml.DumperOptions$LineBreak", - "org.yaml.snakeyaml.constructor.Construct", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentEnum", - "org.yaml.snakeyaml.introspector.PropertyUtils$1", - "org.yaml.snakeyaml.serializer.Serializer", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentPrimitiveArray", - "org.yaml.snakeyaml.scanner.Constant", - "org.yaml.snakeyaml.representer.SafeRepresenter", - "org.openecomp.mso.db.catalog.beans.HeatTemplateParam", - "org.yaml.snakeyaml.parser.ParserException", - "org.yaml.snakeyaml.tokens.AliasToken", - "org.yaml.snakeyaml.emitter.ScalarAnalysis", - "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructUndefined", - "org.yaml.snakeyaml.events.CollectionStartEvent", - "org.yaml.snakeyaml.parser.ParserImpl$ParseStreamStart", - "org.yaml.snakeyaml.DumperOptions$ScalarStyle", - "org.yaml.snakeyaml.tokens.StreamEndToken", - "org.yaml.snakeyaml.constructor.BaseConstructor", - "org.yaml.snakeyaml.representer.BaseRepresenter$1", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentByteArray", - "org.yaml.snakeyaml.nodes.MappingNode", - "org.yaml.snakeyaml.Yaml", - "org.yaml.snakeyaml.constructor.Constructor$ConstructScalar", - "org.yaml.snakeyaml.scanner.SimpleKey", - "org.yaml.snakeyaml.resolver.Resolver$1", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentIterator", - "org.yaml.snakeyaml.emitter.Emitter$ExpectStreamStart", - "org.yaml.snakeyaml.tokens.DirectiveToken", - "org.yaml.snakeyaml.representer.Represent", - "org.yaml.snakeyaml.events.StreamEndEvent", - "org.yaml.snakeyaml.tokens.Token$ID", - "org.yaml.snakeyaml.parser.ParserImpl$ParseDocumentEnd", - "org.yaml.snakeyaml.nodes.Tag", - "org.yaml.snakeyaml.util.ArrayStack", - "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentString", - "org.yaml.snakeyaml.events.ImplicitTuple", - "org.yaml.snakeyaml.scanner.Scanner", - "org.yaml.snakeyaml.emitter.Emitter$ExpectFirstDocumentStart", - "org.yaml.snakeyaml.events.NodeEvent", - "org.yaml.snakeyaml.emitter.Emitter", - "org.yaml.snakeyaml.reader.StreamReader", - "org.yaml.snakeyaml.representer.Representer", - "org.yaml.snakeyaml.emitter.Emitter$ExpectDocumentEnd", - "org.yaml.snakeyaml.events.ScalarEvent" - ); - } - - private static void resetClasses() { - org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(YamlEditorESTestscaffolding.class.getClassLoader()); - - org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( - "org.yaml.snakeyaml.constructor.SafeConstructor", - "org.yaml.snakeyaml.nodes.NodeId", - "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.UnicodeEscaper", - "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.PercentEscaper", - "org.yaml.snakeyaml.util.UriEncoder", - "org.yaml.snakeyaml.nodes.Tag", - "org.yaml.snakeyaml.representer.SafeRepresenter", - "org.yaml.snakeyaml.DumperOptions$FlowStyle", - "org.yaml.snakeyaml.representer.BaseRepresenter$1", - "org.yaml.snakeyaml.DumperOptions$ScalarStyle", - "org.yaml.snakeyaml.DumperOptions$LineBreak", - "org.yaml.snakeyaml.resolver.Resolver", - "org.yaml.snakeyaml.introspector.BeanAccess", - "org.yaml.snakeyaml.reader.StreamReader", - "org.yaml.snakeyaml.reader.UnicodeReader", - "org.yaml.snakeyaml.error.YAMLException", - "org.yaml.snakeyaml.reader.ReaderException", - "org.yaml.snakeyaml.emitter.Emitter", - "org.yaml.snakeyaml.serializer.Serializer$1", - "org.yaml.snakeyaml.resolver.Resolver$1", - "org.yaml.snakeyaml.scanner.Constant", - "org.yaml.snakeyaml.introspector.PropertyUtils$1", - "org.yaml.snakeyaml.parser.ParserImpl", - "org.yaml.snakeyaml.scanner.ScannerImpl", - "org.yaml.snakeyaml.events.Event$ID", - "org.yaml.snakeyaml.tokens.Token$ID", - "org.yaml.snakeyaml.error.MarkedYAMLException", - "org.yaml.snakeyaml.scanner.ScannerException", - "org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder", - "org.yaml.snakeyaml.parser.ParserException", - "org.openecomp.mso.asdc.util.YamlEditor" - ); - } -} -- cgit