From e8d8a37da95c6fea435e0b3e93a477b5aa45b9b1 Mon Sep 17 00:00:00 2001 From: Yuli Shlosberg Date: Wed, 7 Mar 2018 16:29:57 +0200 Subject: update distribution-client package names Change-Id: Ic6f81bc8fdd3b021033c7c68e44f876a6ee1d21a Issue-ID: SDC-952 Signed-off-by: Yuli Shlosberg --- sdc-distribution-ci/log4j.properties | 2 +- sdc-distribution-ci/pom.xml | 12 +- .../main/java/org/onap/test/AdvanceCallBack.java | 70 +++ .../main/java/org/onap/test/ArtifactTypeEnum.java | 111 +++++ .../src/main/java/org/onap/test/ClientTest.java | 113 +++++ .../main/java/org/onap/test/CsarToscaTester.java | 121 +++++ .../src/main/java/org/onap/test/Decoder.java | 58 +++ .../java/org/onap/test/NotificationCallback.java | 39 ++ .../main/java/org/onap/test/SimpleCallback.java | 356 ++++++++++++++ .../java/org/onap/test/SimpleConfiguration.java | 204 ++++++++ .../java/org/openecomp/test/AdvanceCallBack.java | 70 --- .../java/org/openecomp/test/ArtifactTypeEnum.java | 111 ----- .../main/java/org/openecomp/test/ClientTest.java | 113 ----- .../java/org/openecomp/test/CsarToscaTester.java | 121 ----- .../src/main/java/org/openecomp/test/Decoder.java | 58 --- .../org/openecomp/test/NotificationCallback.java | 39 -- .../java/org/openecomp/test/SimpleCallback.java | 356 -------------- .../org/openecomp/test/SimpleConfiguration.java | 204 -------- .../main/resources/ci/conf/attsdc-packages.yaml | 18 +- .../src/main/resources/ci/conf/log4j.properties | 4 +- .../src/main/resources/ci/scripts/startTest.sh | 2 +- .../ClientDownloadArtifact.java | 511 +++++++++++++++++++++ .../ClientDownloadArtifact.java | 511 --------------------- 23 files changed, 1602 insertions(+), 1602 deletions(-) create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/AdvanceCallBack.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/ArtifactTypeEnum.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/ClientTest.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/NotificationCallback.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/SimpleCallback.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/SimpleConfiguration.java delete mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java delete mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java delete mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java delete mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java delete mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java delete mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java delete mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java delete mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java create mode 100644 sdc-distribution-ci/src/test/java/org/onap/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java delete mode 100644 sdc-distribution-ci/src/test/java/org/openecomp/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java (limited to 'sdc-distribution-ci') diff --git a/sdc-distribution-ci/log4j.properties b/sdc-distribution-ci/log4j.properties index 80b2ca8..f71e8ce 100644 --- a/sdc-distribution-ci/log4j.properties +++ b/sdc-distribution-ci/log4j.properties @@ -1,6 +1,6 @@ log4j.rootCategory=DEBUG, CONSOLE, LOGFILE -log4j.logger.org.openecomp.sdc=TRACE, CONSOLE, LOGFILE +log4j.logger.org.onap.sdc=TRACE, CONSOLE, LOGFILE # CONSOLE is set to be a ConsoleAppender using a PatternLayout. log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender diff --git a/sdc-distribution-ci/pom.xml b/sdc-distribution-ci/pom.xml index 326bdb9..1914d07 100644 --- a/sdc-distribution-ci/pom.xml +++ b/sdc-distribution-ci/pom.xml @@ -4,9 +4,9 @@ 4.0.0 - org.openecomp.sdc.sdc-distribution-client + org.onap.sdc.sdc-distribution-client sdc-main-distribution-client - 1.2.2-SNAPSHOT + 1.3.0-SNAPSHOT sdc-distribution-ci @@ -23,16 +23,16 @@ - org.openecomp.sdc.sdc-distribution-client + org.onap.sdc.sdc-distribution-client sdc-distribution-client ${project.version} compile - org.openecomp.sdc.sdc-tosca + org.onap.sdc.sdc-tosca sdc-tosca - 1.1.55-SNAPSHOT + 1.3.0-SNAPSHOT compile @@ -87,7 +87,7 @@ spring-boot - org.openecomp.test.ClientTest + org.onap.test.ClientTest diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/AdvanceCallBack.java b/sdc-distribution-ci/src/main/java/org/onap/test/AdvanceCallBack.java new file mode 100644 index 0000000..a122ca0 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/AdvanceCallBack.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * 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.onap.test; + +import java.io.FileOutputStream; +import java.io.IOException; + +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.results.IDistributionClientDownloadResult; +import org.onap.sdc.utils.DistributionActionResultEnum; + +/** + * + * @author tg851x + * This is class used in testing and run locally in the IDE + * logging not needed it is monitored through the IDE console. + */ +public class AdvanceCallBack extends SimpleCallback{ + + public AdvanceCallBack(IDistributionClient client) { + super(client); + } + + @Override + protected void postDownloadLogic( IDistributionClientDownloadResult downloadResult) { + if( downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ + saveArtifactPayloadToDisk(downloadResult); + } + + } + + protected void saveFile(byte[] bs, String fileName) { + String downloadPath = SimpleConfiguration.downloadPath(); + try(FileOutputStream fileOuputStream = new FileOutputStream(downloadPath + fileName);) { + fileOuputStream.write(bs); + fileOuputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + protected void saveArtifactPayloadToDisk(IDistributionClientDownloadResult downloadResult) { + System.out.println("################ Downloaded Artifact Payload Start ################"); + String fileName = downloadResult.getArtifactFilename(); + saveFile(downloadResult.getArtifactPayload(), fileName); + System.out.println("################ Downloaded Artifact Payload End ################"); + } + + + + +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/ArtifactTypeEnum.java b/sdc-distribution-ci/src/main/java/org/onap/test/ArtifactTypeEnum.java new file mode 100644 index 0000000..1f5e799 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/ArtifactTypeEnum.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * 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.onap.test; + +import java.util.ArrayList; +import java.util.List; + +/** + * Enum That Represents possible Artifacts Types. + * + */ +public enum ArtifactTypeEnum { + + CHEF("CHEF"), + PUPPET("PUPPET"), + YANG("YANG"), + SHELL_SCRIPT("SHELL_SCRIPT"), + ICON("ICON"), + UNKNOWN("UNKNOWN"), + HEAT("HEAT"), + DG_XML("DG_XML"), + MURANO_PKG("MURANO_PKG"), + HEAT_ENV("HEAT_ENV"), + YANG_XML("YANG_XML"), + HEAT_VOL("HEAT_VOL"), + HEAT_NET("HEAT_NET"), + OTHER("OTHER"), + WORKFLOW("WORKFLOW"), + NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"), + TOSCA_TEMPLATE("TOSCA_TEMPLATE"), + TOSCA_CSAR("TOSCA_CSAR"), + VNF_CATALOG("VNF_CATALOG"), + VF_LICENSE("VF_LICENSE"), + VENDOR_LICENSE("VENDOR_LICENSE"), + MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), + MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"), + APPC_CONFIG("APPC_CONFIG"), + HEAT_NESTED("HEAT_NESTED"), + HEAT_ARTIFACT("HEAT_ARTIFACT"), + VF_MODULES_METADATA("VF_MODULES_METADATA"), + + // DCAE Artifacts + DCAE_TOSCA("DCAE_TOSCA"), + DCAE_JSON("DCAE_JSON"), + DCAE_POLICY("DCAE_POLICY"), + DCAE_DOC("DCAE_DOC"), + DCAE_EVENT("DCAE_EVENT"), + DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"), + DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"), + DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), + DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), + DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), + DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"), + + // AAI Artifacts + AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), + AAI_VF_MODEL("AAI_VF_MODEL"), + AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"), + AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"), + + // MIB artifacts + SNMP_POLL("SNMP_POLL"), + SNMP_TRAP("SNMP_TRAP"), + GUIDE("GUIDE"); + + ArtifactTypeEnum(String type) { + this.type = type; + } + + private String type; + + public String getType() { + return type; + } + + public static ArtifactTypeEnum findType(final String type) { + for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { + // According to Pavel/Ella + if (ate.getType().equalsIgnoreCase(type)) { + return ate; + } + } + return null; + } + + public static List getAllTypes() { + List types = new ArrayList<>(); + for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { + types.add(ate.getType()); + } + return types; + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/ClientTest.java b/sdc-distribution-ci/src/main/java/org/onap/test/ClientTest.java new file mode 100644 index 0000000..24160b5 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/ClientTest.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * 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.onap.test; + +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.consumer.IComponentDoneStatusMessage; +import org.onap.sdc.api.consumer.IStatusCallback; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.notification.IStatusData; +import org.onap.sdc.api.results.IDistributionClientResult; +import org.onap.sdc.impl.DistributionClientFactory; +import org.onap.sdc.utils.DistributionStatusEnum; + +public class ClientTest { + public static void main(String[] args) throws Exception { + + soWdListner(); + clientSender(); + + } + + private static void clientSender() { + IDistributionClient client = DistributionClientFactory.createDistributionClient(); + IDistributionClientResult result = client.init(new SimpleConfiguration(), new SimpleCallback(client)); + System.err.println("Init Status: " + result.toString()); + + IDistributionClientResult start = client.start(); + + System.err.println("Start Status: " + start.toString()); + for( int i = 0; i < 2; i++ ){ + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + client.sendComponentDoneStatus(new IComponentDoneStatusMessage() { + + @Override + public long getTimestamp() { + return System.currentTimeMillis(); + } + + @Override + public DistributionStatusEnum getStatus() { + return DistributionStatusEnum.COMPONENT_DONE_OK; + } + + @Override + public String getDistributionID() { + // TODO Auto-generated method stub + return ""; + } + + @Override + public String getConsumerID() { + return client.getConfiguration().getConsumerID(); + } + + @Override + public String getComponentName() { + return "MSO"; + } + }); + } + + } + + private static void soWdListner() { + IDistributionClient client = DistributionClientFactory.createDistributionClient(); + IDistributionClientResult result = client.init(new SimpleConfiguration() { + @Override + public boolean isConsumeProduceStatusTopic() { + return true; + } + }, new SimpleCallback(client) { + @Override + public void activateCallback(INotificationData data) { + System.err.println("Monitor Recieved Notification: " + data.toString()); + + } + }, new IStatusCallback() { + + @Override + public void activateCallback(IStatusData data) { + System.err.println("Monitor Recieved Status: " + data.toString()); + + } + }); + System.err.println("Init Status: " + result.toString()); + IDistributionClientResult start = client.start(); + + System.err.println("Start Status: " + start.toString()); + } + +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java b/sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java new file mode 100644 index 0000000..1102150 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java @@ -0,0 +1,121 @@ +package org.onap.test; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; +import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; +import org.onap.sdc.tosca.parser.impl.SdcTypes; +import org.onap.sdc.toscaparser.api.Group; +import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.elements.Metadata; +import org.onap.sdc.toscaparser.api.parameters.Input; +import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder; + +public class CsarToscaTester { + public static void main(String[] args) throws Exception { + System.out.println("CsarToscaParser - path to CSAR's Directory is " + Arrays.toString(args)); + SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance(); + + File folder = new File(args[0]); + File[] listOfFiles = folder.listFiles(); + Date now = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("d-MM-y-HH_mm_ss"); + String time = dateFormat.format(now); + String csarsDir = args[1] + "/csar-reports-" + time; + File dir = new File(csarsDir); + dir.mkdir(); + + + for (File file : listOfFiles) { + if (file.isFile()) { + System.out.println("File " + file.getAbsolutePath()); + String name = file.getName(); + String currentCsarDir = csarsDir+"/"+name+"-"+time; + dir = new File(currentCsarDir); + dir.mkdir(); + try { + processCsar(factory, file); + } catch (SdcToscaParserException e){ + System.out.println("SdcToscaParserException caught. Code: "+e.getCode()+", message: "+ e.getMessage()); + } + List validationIssueReport = ThreadLocalsHolder.getCollector().getValidationIssueReport(); + System.out.println("Validation issues during CSAR parsing are: " + (validationIssueReport != null ? validationIssueReport.toString() : "none")); + + try { + generateReport(time, name, currentCsarDir, validationIssueReport, "validationIssues"); + + } catch (IOException ex) { + ex.printStackTrace(); + } + } + + } + } + + private static void processCsar(SdcToscaParserFactory factory, File file) throws SdcToscaParserException { + ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file.getAbsolutePath()); + //Service level + System.out.println("Invoking sdc-tosca methods on this CSAR...."); + String conformanceLevel = sdcCsarHelper.getConformanceLevel(); + System.out.println("getConformanceLevel() - conformance level is "+conformanceLevel); + String serviceSubstitutionMappingsTypeName = sdcCsarHelper.getServiceSubstitutionMappingsTypeName(); + System.out.println("serviceSubstitutionMappingsTypeName() - subst mappings type of service is "+serviceSubstitutionMappingsTypeName); + List serviceInputs = sdcCsarHelper.getServiceInputs(); + System.out.println("getServiceInputs() - service inputs are "+serviceInputs); + Metadata serviceMetadata = sdcCsarHelper.getServiceMetadata(); + System.out.println("getServiceMetadata() - service metadata is "+serviceMetadata); + Map serviceMetadataProperties = sdcCsarHelper.getServiceMetadataProperties(); + System.out.println("getServiceMetadataProperties() - service metadata properties is "+serviceMetadataProperties); + List allottedResources = sdcCsarHelper.getAllottedResources(); + System.out.println("getAllottedResources() - service allotted resources are "+allottedResources); + List serviceVfList = sdcCsarHelper.getServiceVfList(); + System.out.println("getServiceVfList() - VF list is "+serviceVfList); + List serviceNodeTemplateBySdcType = sdcCsarHelper.getServiceNodeTemplateBySdcType(SdcTypes.VF); + System.out.println("getServiceNodeTemplateBySdcType() - VF list is "+serviceNodeTemplateBySdcType); + List serviceNodeTemplates = sdcCsarHelper.getServiceNodeTemplates(); + System.out.println("getServiceNodeTemplates() - all node templates list of service is "+serviceNodeTemplates); + + serviceVfList.forEach(x -> { + String nodeTemplateCustomizationUuid = sdcCsarHelper.getNodeTemplateCustomizationUuid(x); + System.out.println("getNodeTemplateCustomizationUuid() - VF ID is "+nodeTemplateCustomizationUuid); + String typeOfNodeTemplate = sdcCsarHelper.getTypeOfNodeTemplate(x); + System.out.println("getTypeOfNodeTemplate() - VF tosca type is "+typeOfNodeTemplate); + List vfModulesByVf = sdcCsarHelper.getVfModulesByVf(nodeTemplateCustomizationUuid); + System.out.println("getVfModulesByVf() - VF modules list is "+vfModulesByVf); + vfModulesByVf.forEach(y -> { + List membersOfVfModule = sdcCsarHelper.getMembersOfVfModule(x, y); + System.out.println("getMembersOfVfModule() - members of VfModule are "+membersOfVfModule); + }); + List vfcListByVf = sdcCsarHelper.getVfcListByVf(nodeTemplateCustomizationUuid); + System.out.println("getVfcListByVf() - VFC list is "+vfcListByVf); + vfcListByVf.forEach(z -> { + List nodeTemplateBySdcType = sdcCsarHelper.getNodeTemplateBySdcType(z, SdcTypes.CP); + System.out.println("getNodeTemplateBySdcType() - CP children node templates of this VFC are "+nodeTemplateBySdcType); + Map> cpPropertiesFromVfcAsObject = sdcCsarHelper.getCpPropertiesFromVfcAsObject(z); + System.out.println("getCpPropertiesFromVfcAsObject() - consolidated CP properties for this VFC are "+cpPropertiesFromVfcAsObject); + boolean hasTopology = sdcCsarHelper.hasTopology(z); + System.out.println("hasTopology() - this VFC is "+(hasTopology ? "nested" : "not nested")); + }); + }); + + } + + private static void generateReport(String time, String name, String currentCsarDir, List criticalsReport, String type) + throws IOException { + FileWriter fw; + fw = new FileWriter(new File(currentCsarDir + "/" + criticalsReport.size() + "-"+type+"-" + name +"-"+time + ".txt")); + for (String exception : criticalsReport) { + fw.write(exception); + fw.write("\r\n"); + } + fw.close(); + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java b/sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java new file mode 100644 index 0000000..384d26d --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * 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.onap.test; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import org.apache.commons.codec.binary.Base64; + +public class Decoder { + + public static String encode(byte[] byteArrayToEncode) { + return new String(Base64.encodeBase64(byteArrayToEncode)); + } + + public static String decode(String strEncoded) { + return new String(Base64.decodeBase64(strEncoded)); + } + + public static String readFileToString(String file) throws IOException { + + try (FileReader fileReader = new FileReader(file); + BufferedReader reader = new BufferedReader(fileReader)) { + String line; + StringBuilder stringBuilder = new StringBuilder(); + String ls = System.getProperty("line.separator"); + + while ((line = reader.readLine()) != null) { + stringBuilder.append(line); + stringBuilder.append(ls); + } + + reader.close(); + fileReader.close(); + return stringBuilder.toString(); + } catch (IOException e) { + throw new IOException(e); + } + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/NotificationCallback.java b/sdc-distribution-ci/src/main/java/org/onap/test/NotificationCallback.java new file mode 100644 index 0000000..48fda0a --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/NotificationCallback.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * 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.onap.test; + +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.notification.INotificationData; + +public class NotificationCallback extends SimpleCallback{ + INotificationData latestCallbackData; + public INotificationData getData() { + return latestCallbackData; + } + public NotificationCallback(IDistributionClient client) { + super(client); + } + + public void activateCallback(INotificationData data) { + this.latestCallbackData = data; + super.activateCallback(data); + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/SimpleCallback.java b/sdc-distribution-ci/src/main/java/org/onap/test/SimpleCallback.java new file mode 100644 index 0000000..547dde2 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/SimpleCallback.java @@ -0,0 +1,356 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * 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.onap.test; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.consumer.IDistributionStatusMessage; +import org.onap.sdc.api.consumer.INotificationCallback; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.notification.IResourceInstance; +import org.onap.sdc.api.notification.IVfModuleMetadata; +import org.onap.sdc.api.results.IDistributionClientDownloadResult; +import org.onap.sdc.api.results.IDistributionClientResult; +import org.onap.sdc.utils.ArtifactTypeEnum; +import org.onap.sdc.utils.DistributionActionResultEnum; +import org.onap.sdc.utils.DistributionStatusEnum; + +/** + * + * @author tg851x + * This is class used in testing and run locally in the IDE + * logging not needed it is monitored through the IDE console. + */ +public class SimpleCallback implements INotificationCallback { + protected IDistributionClient client; + public List iArtifactInfo; + + public final Map simpleCallbackResults = new HashMap(); + + public Map getSimpleCallbackResults() { + return simpleCallbackResults; + } + + public List getIArtifactInfo(){ + return iArtifactInfo; + } + public SimpleCallback(IDistributionClient client) { + this.client = client; + } + + + + + + public void activateCallback(INotificationData data) { + + List artifacts = getArtifacts(data); + + + for (IArtifactInfo iArtifactInfo : artifacts) { + + IArtifactInfo artifactMetadataByUUID = data.getArtifactMetadataByUUID(iArtifactInfo.getArtifactUUID()); + assertEquals("check artifact checksum", iArtifactInfo.getArtifactChecksum(), artifactMetadataByUUID.getArtifactChecksum()); + System.out.println(artifactMetadataByUUID.getArtifactURL()); + if (artifactMetadataByUUID.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA)){ + IDistributionClientDownloadResult download = client.download(iArtifactInfo); + if (download.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ + List decodeVfModuleArtifact = client.decodeVfModuleArtifact(download.getArtifactPayload()); +// assertEquals("decoded not equal to actual group amount ", decodeVfModuleArtifact.size(), 2); + if (!decodeVfModuleArtifact.isEmpty()){ + for (IVfModuleMetadata moduleMetadata : decodeVfModuleArtifact) { + List moduleArtifacts = moduleMetadata.getArtifacts(); + if (moduleArtifacts != null) { + + for (String artifactId : moduleArtifacts) { + + IArtifactInfo artifactInfo = data.getArtifactMetadataByUUID(artifactId); + IDistributionClientDownloadResult downloadArt = client.download(artifactInfo); + assertEquals(downloadArt.getDistributionActionResult(), DistributionActionResultEnum.SUCCESS); + + } + + } + } + } + } + } + } + + + for (IArtifactInfo relevantArtifact : artifacts){ + // Download Artifact + IDistributionClientDownloadResult downloadResult = client.download(relevantArtifact); + + postDownloadLogic(downloadResult); + + + + simpleCallbackResults.put("downloadResult", downloadResult); + System.out.println("downloadResult: " + downloadResult.toString()); + System.out.println("<<<<<<<<<<< Artifact content >>>>>>>>>>"); + System.out.println(Decoder.encode(downloadResult.getArtifactPayload())); + + /////Print artifact content to console/////// + +// byte[] contentInBytes = BaseEncoding.base64().decode(Decoder.encode(downloadResult.getArtifactPayload())); +// try { +// System.out.println("Source content: " + new String(contentInBytes, "UTF-8")); +// } catch (UnsupportedEncodingException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + System.out.println("ArtInfo_timeout: "+ relevantArtifact.getArtifactTimeout()); + System.out.println("ArtInfo_Art_description: "+ relevantArtifact.getArtifactDescription()); + System.out.println("ArtInfo_Art_CheckSum: "+ relevantArtifact.getArtifactChecksum()); + System.out.println("ArtInfo_Art_Url: "+ relevantArtifact.getArtifactURL()); + System.out.println("ArtInfo_Art_Type: "+ relevantArtifact.getArtifactType()); + System.out.println("ArtInfo_Art_Name: "+ relevantArtifact.getArtifactName()); + System.out.println("ArtInfo_UUID: " + relevantArtifact.getArtifactUUID()); + System.out.println("ArtInfo_Version: " + relevantArtifact.getArtifactVersion()); + System.out.println("ArtInfo_RelatedArtifacts: "+ relevantArtifact.getRelatedArtifacts()); + + System.out.println("ArtInfo_Serv_description: " + data.getServiceDescription()); + System.out.println("ArtInfo_Serv_Name: " + data.getServiceName()); + System.out.println("Get_serviceVersion: " + data.getServiceVersion()); + System.out.println("Get_Service_UUID: " + data.getServiceUUID()); + System.out.println("ArtInfo_DistributionId: " + data.getDistributionID()); + System.out.println("ArtInfo_ServiceInvariantUUID: " + data.getServiceInvariantUUID()); + + + // assertTrue("response code is not 200, returned :" + downloadResult.getDistributionActionResult(), downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); + + try { + String payload = new String(downloadResult.getArtifactPayload()); +// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); +// System.out.println(payload); +// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); + + } catch (Exception e) { + System.out.println("catch"); +// break; + // TODO: handle exception + } + + + + + if (downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { + handleSuccessfullDownload(data, relevantArtifact, downloadResult.getArtifactPayload()); + } else { + handleFailedDownload(data, relevantArtifact); + } + } +// if (data != null){ +// iArtifactInfo.addAll(artifacts); +// } + + } + + private List getArtifacts(INotificationData data) { + List ret = new ArrayList(); + List resources = data.getResources(); +// data.getArtifactMetadataByUUID(arg0) + List relevantArtifactTypes = client.getConfiguration().getRelevantArtifactTypes(); + + List collect = resources.stream().flatMap( e -> e.getArtifacts().stream()).filter(p -> relevantArtifactTypes.contains(p.getArtifactType() )).collect(Collectors.toList()); +// if( resources != null ){ +// for( IResourceInstance resourceInstance : resources){ +// if( resourceInstance.getArtifacts() != null ){ +// +// +// +// ret.addAll(resourceInstance.getArtifacts()); +// +// +// } +// } +// } + ret.addAll(collect); + + List servicesArt = data.getServiceArtifacts(); + if( servicesArt != null ){ + ret.addAll(servicesArt); + } + + System.out.println("I am here: " + ret.toString()); + return ret; + } + + + + private void handleFailedDownload(INotificationData data, + IArtifactInfo relevantArtifact) { + // Send Download Status + IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_ERROR)); + postDownloadStatusSendLogic(sendDownloadStatus); + } + + private void handleSuccessfullDownload(INotificationData data, IArtifactInfo relevantArtifact, byte[] payload) { + // Send Download Status + IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_OK)); + + simpleCallbackResults.put("sendDownloadStatus", sendDownloadStatus); +// assertTrue("response code is not 200, returned :" + sendDownloadStatus.getDistributionActionResult(), sendDownloadStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); + + // Doing deployment ... + postDownloadStatusSendLogic(sendDownloadStatus); + boolean isDeployedSuccessfully = handleDeployment(data, relevantArtifact, payload); + IDistributionClientResult deploymentStatus; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (isDeployedSuccessfully) { + deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_OK)); + + simpleCallbackResults.put("sendDeploymentStatus", deploymentStatus); +// assertTrue("response code is not 200, returned :" + deploymentStatus.getDistributionActionResult(), deploymentStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); + + } else { + deploymentStatus = handleFailedDeployment(data, relevantArtifact); + } + + postDeploymentStatusSendLogic(deploymentStatus); + } + + private IDistributionClientResult handleFailedDeployment(INotificationData data, IArtifactInfo relevantArtifact) { + IDistributionClientResult deploymentStatus; + boolean isAlreadyDeployed = checkIsDeployed(); + if (isAlreadyDeployed) { + deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.ALREADY_DEPLOYED)); + } else { + deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_ERROR)); + } + return deploymentStatus; + } + + protected void postDownloadLogic(IDistributionClientDownloadResult downloadResult) { + // TODO Auto-generated method stub + + } + + private void postDownloadStatusSendLogic( + IDistributionClientResult sendDownloadStatus) { + // TODO Auto-generated method stub + + } + + private void postDeploymentStatusSendLogic( + IDistributionClientResult deploymentStatus) { + // TODO Auto-generated method stub + + } + + private boolean checkIsDeployed() { + return false; + } + + private boolean handleDeployment(INotificationData data, IArtifactInfo relevantArtifact, byte[] payload) { + if (relevantArtifact.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.name())) { + + try { + List serviceArtifacts = data.getServiceArtifacts(); + List resourcesArtifacts = data.getResources(); + + JSONArray jsonData = new JSONArray(new String(payload)); + boolean artifactIsFound = true; + for (int index = 0 ; index < jsonData.length(); index++) { + + JSONObject jsonObject = (JSONObject) jsonData.get(index); + JSONArray artifacts = (JSONArray) jsonObject.get("artifacts"); + for (int i = 0 ; i < artifacts.length(); i++) { + String artifact = artifacts.getString(i).toString(); + + Optional serviceArtifactFound = serviceArtifacts.stream().filter(x -> x.getArtifactUUID().equals(artifact)).findFirst(); + + boolean isResourceFound = false; + for (int j = 0 ; j < resourcesArtifacts.size(); j++) { + Optional resourceArtifactFound = resourcesArtifacts.get(j).getArtifacts().stream().filter(x -> x.getArtifactUUID().equals(artifact)).findFirst(); + isResourceFound = resourceArtifactFound.isPresent() || isResourceFound; + } + + if (!serviceArtifactFound.isPresent() && !isResourceFound) { + artifactIsFound = false; + System.out.println("################ Artifact: " + artifact + " NOT FOUND in Notification Data ################"); + } + } + } + return artifactIsFound; + + } catch (Exception e) { + System.out.println("################ Couldn't convert vf_modules_metadata.json to json : " + e.getMessage()); + return false; + } + } + else { + return true; + } + +// to return deploy_error use return false +// return false; + } + + public static IDistributionStatusMessage buildStatusMessage( + final IDistributionClient client, final INotificationData data, + final IArtifactInfo relevantArtifact, + final DistributionStatusEnum status) { + IDistributionStatusMessage statusMessage = new IDistributionStatusMessage() { + + public long getTimestamp() { + long currentTimeMillis = System.currentTimeMillis(); + return currentTimeMillis; + } + + public DistributionStatusEnum getStatus() { + return status; + } + + public String getDistributionID() { + return data.getDistributionID(); + } + + public String getConsumerID() { + return client.getConfiguration().getConsumerID(); + } + + public String getArtifactURL() { + return relevantArtifact.getArtifactURL(); + } + }; + return statusMessage; + } + + +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/SimpleConfiguration.java b/sdc-distribution-ci/src/main/java/org/onap/test/SimpleConfiguration.java new file mode 100644 index 0000000..d22bcf2 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/SimpleConfiguration.java @@ -0,0 +1,204 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * 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.onap.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.onap.sdc.api.consumer.IConfiguration; + +public class SimpleConfiguration implements IConfiguration{ + + /*public String getUser() + { + return System.getProperty("user"); + } + + public List getRelevantArtifactTypes() { + return ArtifactTypeEnum.getAllTypes(); + } + + public int getPollingTimeout() + { + return 20; + } + + public int getPollingInterval() + { + return 20; + } + + public String getPassword() + { + return System.getProperty("password"); + } + + public String getEnvironmentName() + { + return System.getProperty("env"); + } + + public String getConsumerID() + { + return System.getProperty("consumerID"); + } + + public String getConsumerGroup() + { + return System.getProperty("groupID"); + } + + public String getAsdcAddress() + { + return System.getProperty("beAddress"); + } + + public String getKeyStorePath() + { + return ""; + } + + public String getKeyStorePassword() + { + return "Aa123456"; + } + + public boolean activateServerTLSAuth() + { + return Boolean.parseBoolean(System.getProperty("auth")); +// res.add(ArtifactTypeEnum.HEAT_ARTIFACT); +// res.add(ArtifactTypeEnum.HEAT_ENV); +// res.add(ArtifactTypeEnum.MURANO_PKG); +// res.add(ArtifactTypeEnum.VF_LICENSE); +// res.add(ArtifactTypeEnum.APPC_CONFIG); +// res.add(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE); +// res.add(ArtifactTypeEnum.VNF_CATALOG); +// res.add(ArtifactTypeEnum.APPC_CONFIG); +// res.add(ArtifactTypeEnum.VF_MODULES_METADATA); +// return "PROD-Tedy-Only"; +// return "A-AI"; +// return "A-AI"; + } + + @Override + public boolean isFilterInEmptyResources() { + return false; + } + + public static String downloadPath() { + return "c:\\temp\\"; + } + + public static Boolean toDownload() { + return false; + }*/ + + public String getUser() { + return "ci"; + } + + public List getRelevantArtifactTypes() { + +// List res = new ArrayList(); +// for (ArtifactTypeEnum type : AssetTypeEnum.values()){ +// res.add(type.name()); +// } + return ArtifactTypeEnum.getAllTypes(); + } + + + public int getPollingTimeout() { + return 20; + } + + public int getPollingInterval() { + return 20; + } + + public String getPassword() { + return "123456"; + } + + public String getEnvironmentName() { + return "PROD"; + } + + public String getConsumerID() { + return "consumerVasya"; + } + + public String getConsumerGroup() { + return "groupVasya"; + + } + + public static Boolean toDownload() { + return true; + } + + public static String downloadPath() { + return "c:\\temp\\"; + } + + public String getAsdcAddress() { + return "127.0.0.1:8443"; + } + + @Override + public List getMsgBusAddress() { + return new ArrayList<>(); + } + + @Override + public String getKeyStorePath() { + return StringUtils.EMPTY; + } + + @Override + public String getKeyStorePassword() { + + return "Aa123456"; + } + + @Override + public boolean activateServerTLSAuth() { + + return false; + } + + @Override + public boolean isFilterInEmptyResources() { + return false; + } + + @Override + public Boolean isUseHttpsWithDmaap() { + return true; + } + + @Override + public boolean isConsumeProduceStatusTopic() { + return false; + } + +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java deleted file mode 100644 index faabaeb..0000000 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * 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.test; - -import java.io.FileOutputStream; -import java.io.IOException; - -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; -import org.openecomp.sdc.utils.DistributionActionResultEnum; - -/** - * - * @author tg851x - * This is class used in testing and run locally in the IDE - * logging not needed it is monitored through the IDE console. - */ -public class AdvanceCallBack extends SimpleCallback{ - - public AdvanceCallBack(IDistributionClient client) { - super(client); - } - - @Override - protected void postDownloadLogic( IDistributionClientDownloadResult downloadResult) { - if( downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ - saveArtifactPayloadToDisk(downloadResult); - } - - } - - protected void saveFile(byte[] bs, String fileName) { - String downloadPath = SimpleConfiguration.downloadPath(); - try(FileOutputStream fileOuputStream = new FileOutputStream(downloadPath + fileName);) { - fileOuputStream.write(bs); - fileOuputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - protected void saveArtifactPayloadToDisk(IDistributionClientDownloadResult downloadResult) { - System.out.println("################ Downloaded Artifact Payload Start ################"); - String fileName = downloadResult.getArtifactFilename(); - saveFile(downloadResult.getArtifactPayload(), fileName); - System.out.println("################ Downloaded Artifact Payload End ################"); - } - - - - -} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java deleted file mode 100644 index 5c4c9e2..0000000 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * 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.test; - -import java.util.ArrayList; -import java.util.List; - -/** - * Enum That Represents possible Artifacts Types. - * - */ -public enum ArtifactTypeEnum { - - CHEF("CHEF"), - PUPPET("PUPPET"), - YANG("YANG"), - SHELL_SCRIPT("SHELL_SCRIPT"), - ICON("ICON"), - UNKNOWN("UNKNOWN"), - HEAT("HEAT"), - DG_XML("DG_XML"), - MURANO_PKG("MURANO_PKG"), - HEAT_ENV("HEAT_ENV"), - YANG_XML("YANG_XML"), - HEAT_VOL("HEAT_VOL"), - HEAT_NET("HEAT_NET"), - OTHER("OTHER"), - WORKFLOW("WORKFLOW"), - NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"), - TOSCA_TEMPLATE("TOSCA_TEMPLATE"), - TOSCA_CSAR("TOSCA_CSAR"), - VNF_CATALOG("VNF_CATALOG"), - VF_LICENSE("VF_LICENSE"), - VENDOR_LICENSE("VENDOR_LICENSE"), - MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), - MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"), - APPC_CONFIG("APPC_CONFIG"), - HEAT_NESTED("HEAT_NESTED"), - HEAT_ARTIFACT("HEAT_ARTIFACT"), - VF_MODULES_METADATA("VF_MODULES_METADATA"), - - // DCAE Artifacts - DCAE_TOSCA("DCAE_TOSCA"), - DCAE_JSON("DCAE_JSON"), - DCAE_POLICY("DCAE_POLICY"), - DCAE_DOC("DCAE_DOC"), - DCAE_EVENT("DCAE_EVENT"), - DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"), - DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"), - DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), - DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), - DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), - DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"), - - // AAI Artifacts - AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), - AAI_VF_MODEL("AAI_VF_MODEL"), - AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"), - AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"), - - // MIB artifacts - SNMP_POLL("SNMP_POLL"), - SNMP_TRAP("SNMP_TRAP"), - GUIDE("GUIDE"); - - ArtifactTypeEnum(String type) { - this.type = type; - } - - private String type; - - public String getType() { - return type; - } - - public static ArtifactTypeEnum findType(final String type) { - for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { - // According to Pavel/Ella - if (ate.getType().equalsIgnoreCase(type)) { - return ate; - } - } - return null; - } - - public static List getAllTypes() { - List types = new ArrayList<>(); - for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { - types.add(ate.getType()); - } - return types; - } -} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java deleted file mode 100644 index 872240b..0000000 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * 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.test; - -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.consumer.IComponentDoneStatusMessage; -import org.openecomp.sdc.api.consumer.IStatusCallback; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.api.notification.IStatusData; -import org.openecomp.sdc.api.results.IDistributionClientResult; -import org.openecomp.sdc.impl.DistributionClientFactory; -import org.openecomp.sdc.utils.DistributionStatusEnum; - -public class ClientTest { - public static void main(String[] args) throws Exception { - - soWdListner(); - clientSender(); - - } - - private static void clientSender() { - IDistributionClient client = DistributionClientFactory.createDistributionClient(); - IDistributionClientResult result = client.init(new SimpleConfiguration(), new SimpleCallback(client)); - System.err.println("Init Status: " + result.toString()); - - IDistributionClientResult start = client.start(); - - System.err.println("Start Status: " + start.toString()); - for( int i = 0; i < 2; i++ ){ - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - client.sendComponentDoneStatus(new IComponentDoneStatusMessage() { - - @Override - public long getTimestamp() { - return System.currentTimeMillis(); - } - - @Override - public DistributionStatusEnum getStatus() { - return DistributionStatusEnum.COMPONENT_DONE_OK; - } - - @Override - public String getDistributionID() { - // TODO Auto-generated method stub - return ""; - } - - @Override - public String getConsumerID() { - return client.getConfiguration().getConsumerID(); - } - - @Override - public String getComponentName() { - return "MSO"; - } - }); - } - - } - - private static void soWdListner() { - IDistributionClient client = DistributionClientFactory.createDistributionClient(); - IDistributionClientResult result = client.init(new SimpleConfiguration() { - @Override - public boolean isConsumeProduceStatusTopic() { - return true; - } - }, new SimpleCallback(client) { - @Override - public void activateCallback(INotificationData data) { - System.err.println("Monitor Recieved Notification: " + data.toString()); - - } - }, new IStatusCallback() { - - @Override - public void activateCallback(IStatusData data) { - System.err.println("Monitor Recieved Status: " + data.toString()); - - } - }); - System.err.println("Init Status: " + result.toString()); - IDistributionClientResult start = client.start(); - - System.err.println("Start Status: " + start.toString()); - } - -} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java deleted file mode 100644 index 98072fa..0000000 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.openecomp.test; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; -import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException; -import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.openecomp.sdc.tosca.parser.impl.SdcTypes; -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.sdc.toscaparser.api.parameters.Input; -import org.openecomp.sdc.toscaparser.api.utils.ThreadLocalsHolder; - -public class CsarToscaTester { - public static void main(String[] args) throws Exception { - System.out.println("CsarToscaParser - path to CSAR's Directory is " + Arrays.toString(args)); - SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance(); - - File folder = new File(args[0]); - File[] listOfFiles = folder.listFiles(); - Date now = new Date(); - SimpleDateFormat dateFormat = new SimpleDateFormat("d-MM-y-HH_mm_ss"); - String time = dateFormat.format(now); - String csarsDir = args[1] + "/csar-reports-" + time; - File dir = new File(csarsDir); - dir.mkdir(); - - - for (File file : listOfFiles) { - if (file.isFile()) { - System.out.println("File " + file.getAbsolutePath()); - String name = file.getName(); - String currentCsarDir = csarsDir+"/"+name+"-"+time; - dir = new File(currentCsarDir); - dir.mkdir(); - try { - processCsar(factory, file); - } catch (SdcToscaParserException e){ - System.out.println("SdcToscaParserException caught. Code: "+e.getCode()+", message: "+ e.getMessage()); - } - List validationIssueReport = ThreadLocalsHolder.getCollector().getValidationIssueReport(); - System.out.println("Validation issues during CSAR parsing are: " + (validationIssueReport != null ? validationIssueReport.toString() : "none")); - - try { - generateReport(time, name, currentCsarDir, validationIssueReport, "validationIssues"); - - } catch (IOException ex) { - ex.printStackTrace(); - } - } - - } - } - - private static void processCsar(SdcToscaParserFactory factory, File file) throws SdcToscaParserException { - ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper(file.getAbsolutePath()); - //Service level - System.out.println("Invoking sdc-tosca methods on this CSAR...."); - String conformanceLevel = sdcCsarHelper.getConformanceLevel(); - System.out.println("getConformanceLevel() - conformance level is "+conformanceLevel); - String serviceSubstitutionMappingsTypeName = sdcCsarHelper.getServiceSubstitutionMappingsTypeName(); - System.out.println("serviceSubstitutionMappingsTypeName() - subst mappings type of service is "+serviceSubstitutionMappingsTypeName); - List serviceInputs = sdcCsarHelper.getServiceInputs(); - System.out.println("getServiceInputs() - service inputs are "+serviceInputs); - Metadata serviceMetadata = sdcCsarHelper.getServiceMetadata(); - System.out.println("getServiceMetadata() - service metadata is "+serviceMetadata); - Map serviceMetadataProperties = sdcCsarHelper.getServiceMetadataProperties(); - System.out.println("getServiceMetadataProperties() - service metadata properties is "+serviceMetadataProperties); - List allottedResources = sdcCsarHelper.getAllottedResources(); - System.out.println("getAllottedResources() - service allotted resources are "+allottedResources); - List serviceVfList = sdcCsarHelper.getServiceVfList(); - System.out.println("getServiceVfList() - VF list is "+serviceVfList); - List serviceNodeTemplateBySdcType = sdcCsarHelper.getServiceNodeTemplateBySdcType(SdcTypes.VF); - System.out.println("getServiceNodeTemplateBySdcType() - VF list is "+serviceNodeTemplateBySdcType); - List serviceNodeTemplates = sdcCsarHelper.getServiceNodeTemplates(); - System.out.println("getServiceNodeTemplates() - all node templates list of service is "+serviceNodeTemplates); - - serviceVfList.forEach(x -> { - String nodeTemplateCustomizationUuid = sdcCsarHelper.getNodeTemplateCustomizationUuid(x); - System.out.println("getNodeTemplateCustomizationUuid() - VF ID is "+nodeTemplateCustomizationUuid); - String typeOfNodeTemplate = sdcCsarHelper.getTypeOfNodeTemplate(x); - System.out.println("getTypeOfNodeTemplate() - VF tosca type is "+typeOfNodeTemplate); - List vfModulesByVf = sdcCsarHelper.getVfModulesByVf(nodeTemplateCustomizationUuid); - System.out.println("getVfModulesByVf() - VF modules list is "+vfModulesByVf); - vfModulesByVf.forEach(y -> { - List membersOfVfModule = sdcCsarHelper.getMembersOfVfModule(x, y); - System.out.println("getMembersOfVfModule() - members of VfModule are "+membersOfVfModule); - }); - List vfcListByVf = sdcCsarHelper.getVfcListByVf(nodeTemplateCustomizationUuid); - System.out.println("getVfcListByVf() - VFC list is "+vfcListByVf); - vfcListByVf.forEach(z -> { - List nodeTemplateBySdcType = sdcCsarHelper.getNodeTemplateBySdcType(z, SdcTypes.CP); - System.out.println("getNodeTemplateBySdcType() - CP children node templates of this VFC are "+nodeTemplateBySdcType); - Map> cpPropertiesFromVfcAsObject = sdcCsarHelper.getCpPropertiesFromVfcAsObject(z); - System.out.println("getCpPropertiesFromVfcAsObject() - consolidated CP properties for this VFC are "+cpPropertiesFromVfcAsObject); - boolean hasTopology = sdcCsarHelper.hasTopology(z); - System.out.println("hasTopology() - this VFC is "+(hasTopology ? "nested" : "not nested")); - }); - }); - - } - - private static void generateReport(String time, String name, String currentCsarDir, List criticalsReport, String type) - throws IOException { - FileWriter fw; - fw = new FileWriter(new File(currentCsarDir + "/" + criticalsReport.size() + "-"+type+"-" + name +"-"+time + ".txt")); - for (String exception : criticalsReport) { - fw.write(exception); - fw.write("\r\n"); - } - fw.close(); - } -} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java deleted file mode 100644 index 434952b..0000000 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * 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.test; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import org.apache.commons.codec.binary.Base64; - -public class Decoder { - - public static String encode(byte[] byteArrayToEncode) { - return new String(Base64.encodeBase64(byteArrayToEncode)); - } - - public static String decode(String strEncoded) { - return new String(Base64.decodeBase64(strEncoded)); - } - - public static String readFileToString(String file) throws IOException { - - try (FileReader fileReader = new FileReader(file); - BufferedReader reader = new BufferedReader(fileReader)) { - String line; - StringBuilder stringBuilder = new StringBuilder(); - String ls = System.getProperty("line.separator"); - - while ((line = reader.readLine()) != null) { - stringBuilder.append(line); - stringBuilder.append(ls); - } - - reader.close(); - fileReader.close(); - return stringBuilder.toString(); - } catch (IOException e) { - throw new IOException(e); - } - } -} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java deleted file mode 100644 index 3b2d772..0000000 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * 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.test; - -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.notification.INotificationData; - -public class NotificationCallback extends SimpleCallback{ - INotificationData latestCallbackData; - public INotificationData getData() { - return latestCallbackData; - } - public NotificationCallback(IDistributionClient client) { - super(client); - } - - public void activateCallback(INotificationData data) { - this.latestCallbackData = data; - super.activateCallback(data); - } -} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java deleted file mode 100644 index 0c03bb0..0000000 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java +++ /dev/null @@ -1,356 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * 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.test; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; -import org.openecomp.sdc.api.consumer.INotificationCallback; -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.api.notification.IVfModuleMetadata; -import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; -import org.openecomp.sdc.api.results.IDistributionClientResult; -import org.openecomp.sdc.utils.ArtifactTypeEnum; -import org.openecomp.sdc.utils.DistributionActionResultEnum; -import org.openecomp.sdc.utils.DistributionStatusEnum; - -/** - * - * @author tg851x - * This is class used in testing and run locally in the IDE - * logging not needed it is monitored through the IDE console. - */ -public class SimpleCallback implements INotificationCallback { - protected IDistributionClient client; - public List iArtifactInfo; - - public final Map simpleCallbackResults = new HashMap(); - - public Map getSimpleCallbackResults() { - return simpleCallbackResults; - } - - public List getIArtifactInfo(){ - return iArtifactInfo; - } - public SimpleCallback(IDistributionClient client) { - this.client = client; - } - - - - - - public void activateCallback(INotificationData data) { - - List artifacts = getArtifacts(data); - - - for (IArtifactInfo iArtifactInfo : artifacts) { - - IArtifactInfo artifactMetadataByUUID = data.getArtifactMetadataByUUID(iArtifactInfo.getArtifactUUID()); - assertEquals("check artifact checksum", iArtifactInfo.getArtifactChecksum(), artifactMetadataByUUID.getArtifactChecksum()); - System.out.println(artifactMetadataByUUID.getArtifactURL()); - if (artifactMetadataByUUID.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA)){ - IDistributionClientDownloadResult download = client.download(iArtifactInfo); - if (download.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ - List decodeVfModuleArtifact = client.decodeVfModuleArtifact(download.getArtifactPayload()); -// assertEquals("decoded not equal to actual group amount ", decodeVfModuleArtifact.size(), 2); - if (!decodeVfModuleArtifact.isEmpty()){ - for (IVfModuleMetadata moduleMetadata : decodeVfModuleArtifact) { - List moduleArtifacts = moduleMetadata.getArtifacts(); - if (moduleArtifacts != null) { - - for (String artifactId : moduleArtifacts) { - - IArtifactInfo artifactInfo = data.getArtifactMetadataByUUID(artifactId); - IDistributionClientDownloadResult downloadArt = client.download(artifactInfo); - assertEquals(downloadArt.getDistributionActionResult(), DistributionActionResultEnum.SUCCESS); - - } - - } - } - } - } - } - } - - - for (IArtifactInfo relevantArtifact : artifacts){ - // Download Artifact - IDistributionClientDownloadResult downloadResult = client.download(relevantArtifact); - - postDownloadLogic(downloadResult); - - - - simpleCallbackResults.put("downloadResult", downloadResult); - System.out.println("downloadResult: " + downloadResult.toString()); - System.out.println("<<<<<<<<<<< Artifact content >>>>>>>>>>"); - System.out.println(Decoder.encode(downloadResult.getArtifactPayload())); - - /////Print artifact content to console/////// - -// byte[] contentInBytes = BaseEncoding.base64().decode(Decoder.encode(downloadResult.getArtifactPayload())); -// try { -// System.out.println("Source content: " + new String(contentInBytes, "UTF-8")); -// } catch (UnsupportedEncodingException e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } - System.out.println("ArtInfo_timeout: "+ relevantArtifact.getArtifactTimeout()); - System.out.println("ArtInfo_Art_description: "+ relevantArtifact.getArtifactDescription()); - System.out.println("ArtInfo_Art_CheckSum: "+ relevantArtifact.getArtifactChecksum()); - System.out.println("ArtInfo_Art_Url: "+ relevantArtifact.getArtifactURL()); - System.out.println("ArtInfo_Art_Type: "+ relevantArtifact.getArtifactType()); - System.out.println("ArtInfo_Art_Name: "+ relevantArtifact.getArtifactName()); - System.out.println("ArtInfo_UUID: " + relevantArtifact.getArtifactUUID()); - System.out.println("ArtInfo_Version: " + relevantArtifact.getArtifactVersion()); - System.out.println("ArtInfo_RelatedArtifacts: "+ relevantArtifact.getRelatedArtifacts()); - - System.out.println("ArtInfo_Serv_description: " + data.getServiceDescription()); - System.out.println("ArtInfo_Serv_Name: " + data.getServiceName()); - System.out.println("Get_serviceVersion: " + data.getServiceVersion()); - System.out.println("Get_Service_UUID: " + data.getServiceUUID()); - System.out.println("ArtInfo_DistributionId: " + data.getDistributionID()); - System.out.println("ArtInfo_ServiceInvariantUUID: " + data.getServiceInvariantUUID()); - - - // assertTrue("response code is not 200, returned :" + downloadResult.getDistributionActionResult(), downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); - - try { - String payload = new String(downloadResult.getArtifactPayload()); -// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); -// System.out.println(payload); -// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); - - } catch (Exception e) { - System.out.println("catch"); -// break; - // TODO: handle exception - } - - - - - if (downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { - handleSuccessfullDownload(data, relevantArtifact, downloadResult.getArtifactPayload()); - } else { - handleFailedDownload(data, relevantArtifact); - } - } -// if (data != null){ -// iArtifactInfo.addAll(artifacts); -// } - - } - - private List getArtifacts(INotificationData data) { - List ret = new ArrayList(); - List resources = data.getResources(); -// data.getArtifactMetadataByUUID(arg0) - List relevantArtifactTypes = client.getConfiguration().getRelevantArtifactTypes(); - - List collect = resources.stream().flatMap( e -> e.getArtifacts().stream()).filter(p -> relevantArtifactTypes.contains(p.getArtifactType() )).collect(Collectors.toList()); -// if( resources != null ){ -// for( IResourceInstance resourceInstance : resources){ -// if( resourceInstance.getArtifacts() != null ){ -// -// -// -// ret.addAll(resourceInstance.getArtifacts()); -// -// -// } -// } -// } - ret.addAll(collect); - - List servicesArt = data.getServiceArtifacts(); - if( servicesArt != null ){ - ret.addAll(servicesArt); - } - - System.out.println("I am here: " + ret.toString()); - return ret; - } - - - - private void handleFailedDownload(INotificationData data, - IArtifactInfo relevantArtifact) { - // Send Download Status - IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_ERROR)); - postDownloadStatusSendLogic(sendDownloadStatus); - } - - private void handleSuccessfullDownload(INotificationData data, IArtifactInfo relevantArtifact, byte[] payload) { - // Send Download Status - IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_OK)); - - simpleCallbackResults.put("sendDownloadStatus", sendDownloadStatus); -// assertTrue("response code is not 200, returned :" + sendDownloadStatus.getDistributionActionResult(), sendDownloadStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); - - // Doing deployment ... - postDownloadStatusSendLogic(sendDownloadStatus); - boolean isDeployedSuccessfully = handleDeployment(data, relevantArtifact, payload); - IDistributionClientResult deploymentStatus; - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if (isDeployedSuccessfully) { - deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_OK)); - - simpleCallbackResults.put("sendDeploymentStatus", deploymentStatus); -// assertTrue("response code is not 200, returned :" + deploymentStatus.getDistributionActionResult(), deploymentStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); - - } else { - deploymentStatus = handleFailedDeployment(data, relevantArtifact); - } - - postDeploymentStatusSendLogic(deploymentStatus); - } - - private IDistributionClientResult handleFailedDeployment(INotificationData data, IArtifactInfo relevantArtifact) { - IDistributionClientResult deploymentStatus; - boolean isAlreadyDeployed = checkIsDeployed(); - if (isAlreadyDeployed) { - deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.ALREADY_DEPLOYED)); - } else { - deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_ERROR)); - } - return deploymentStatus; - } - - protected void postDownloadLogic(IDistributionClientDownloadResult downloadResult) { - // TODO Auto-generated method stub - - } - - private void postDownloadStatusSendLogic( - IDistributionClientResult sendDownloadStatus) { - // TODO Auto-generated method stub - - } - - private void postDeploymentStatusSendLogic( - IDistributionClientResult deploymentStatus) { - // TODO Auto-generated method stub - - } - - private boolean checkIsDeployed() { - return false; - } - - private boolean handleDeployment(INotificationData data, IArtifactInfo relevantArtifact, byte[] payload) { - if (relevantArtifact.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA.name())) { - - try { - List serviceArtifacts = data.getServiceArtifacts(); - List resourcesArtifacts = data.getResources(); - - JSONArray jsonData = new JSONArray(new String(payload)); - boolean artifactIsFound = true; - for (int index = 0 ; index < jsonData.length(); index++) { - - JSONObject jsonObject = (JSONObject) jsonData.get(index); - JSONArray artifacts = (JSONArray) jsonObject.get("artifacts"); - for (int i = 0 ; i < artifacts.length(); i++) { - String artifact = artifacts.getString(i).toString(); - - Optional serviceArtifactFound = serviceArtifacts.stream().filter(x -> x.getArtifactUUID().equals(artifact)).findFirst(); - - boolean isResourceFound = false; - for (int j = 0 ; j < resourcesArtifacts.size(); j++) { - Optional resourceArtifactFound = resourcesArtifacts.get(j).getArtifacts().stream().filter(x -> x.getArtifactUUID().equals(artifact)).findFirst(); - isResourceFound = resourceArtifactFound.isPresent() || isResourceFound; - } - - if (!serviceArtifactFound.isPresent() && !isResourceFound) { - artifactIsFound = false; - System.out.println("################ Artifact: " + artifact + " NOT FOUND in Notification Data ################"); - } - } - } - return artifactIsFound; - - } catch (Exception e) { - System.out.println("################ Couldn't convert vf_modules_metadata.json to json : " + e.getMessage()); - return false; - } - } - else { - return true; - } - -// to return deploy_error use return false -// return false; - } - - public static IDistributionStatusMessage buildStatusMessage( - final IDistributionClient client, final INotificationData data, - final IArtifactInfo relevantArtifact, - final DistributionStatusEnum status) { - IDistributionStatusMessage statusMessage = new IDistributionStatusMessage() { - - public long getTimestamp() { - long currentTimeMillis = System.currentTimeMillis(); - return currentTimeMillis; - } - - public DistributionStatusEnum getStatus() { - return status; - } - - public String getDistributionID() { - return data.getDistributionID(); - } - - public String getConsumerID() { - return client.getConfiguration().getConsumerID(); - } - - public String getArtifactURL() { - return relevantArtifact.getArtifactURL(); - } - }; - return statusMessage; - } - - -} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java deleted file mode 100644 index 417f564..0000000 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java +++ /dev/null @@ -1,204 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * 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.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.openecomp.sdc.api.consumer.IConfiguration; - -public class SimpleConfiguration implements IConfiguration{ - - /*public String getUser() - { - return System.getProperty("user"); - } - - public List getRelevantArtifactTypes() { - return ArtifactTypeEnum.getAllTypes(); - } - - public int getPollingTimeout() - { - return 20; - } - - public int getPollingInterval() - { - return 20; - } - - public String getPassword() - { - return System.getProperty("password"); - } - - public String getEnvironmentName() - { - return System.getProperty("env"); - } - - public String getConsumerID() - { - return System.getProperty("consumerID"); - } - - public String getConsumerGroup() - { - return System.getProperty("groupID"); - } - - public String getAsdcAddress() - { - return System.getProperty("beAddress"); - } - - public String getKeyStorePath() - { - return ""; - } - - public String getKeyStorePassword() - { - return "Aa123456"; - } - - public boolean activateServerTLSAuth() - { - return Boolean.parseBoolean(System.getProperty("auth")); -// res.add(ArtifactTypeEnum.HEAT_ARTIFACT); -// res.add(ArtifactTypeEnum.HEAT_ENV); -// res.add(ArtifactTypeEnum.MURANO_PKG); -// res.add(ArtifactTypeEnum.VF_LICENSE); -// res.add(ArtifactTypeEnum.APPC_CONFIG); -// res.add(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE); -// res.add(ArtifactTypeEnum.VNF_CATALOG); -// res.add(ArtifactTypeEnum.APPC_CONFIG); -// res.add(ArtifactTypeEnum.VF_MODULES_METADATA); -// return "PROD-Tedy-Only"; -// return "A-AI"; -// return "A-AI"; - } - - @Override - public boolean isFilterInEmptyResources() { - return false; - } - - public static String downloadPath() { - return "c:\\temp\\"; - } - - public static Boolean toDownload() { - return false; - }*/ - - public String getUser() { - return "ci"; - } - - public List getRelevantArtifactTypes() { - -// List res = new ArrayList(); -// for (ArtifactTypeEnum type : AssetTypeEnum.values()){ -// res.add(type.name()); -// } - return ArtifactTypeEnum.getAllTypes(); - } - - - public int getPollingTimeout() { - return 20; - } - - public int getPollingInterval() { - return 20; - } - - public String getPassword() { - return "123456"; - } - - public String getEnvironmentName() { - return "PROD"; - } - - public String getConsumerID() { - return "consumerVasya"; - } - - public String getConsumerGroup() { - return "groupVasya"; - - } - - public static Boolean toDownload() { - return true; - } - - public static String downloadPath() { - return "c:\\temp\\"; - } - - public String getAsdcAddress() { - return "127.0.0.1:8443"; - } - - @Override - public List getMsgBusAddress() { - return new ArrayList<>(); - } - - @Override - public String getKeyStorePath() { - return StringUtils.EMPTY; - } - - @Override - public String getKeyStorePassword() { - - return "Aa123456"; - } - - @Override - public boolean activateServerTLSAuth() { - - return false; - } - - @Override - public boolean isFilterInEmptyResources() { - return false; - } - - @Override - public Boolean isUseHttpsWithDmaap() { - return true; - } - - @Override - public boolean isConsumeProduceStatusTopic() { - return false; - } - -} diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml b/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml index 34a78d9..65a38fa 100644 --- a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml +++ b/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml @@ -1,10 +1,10 @@ packages: - - org.openecomp.sdc.ci.tests.execute.general - - org.openecomp.sdc.ci.tests.execute.user - - org.openecomp.sdc.ci.tests.execute.property - - org.openecomp.sdc.ci.tests.execute.lifecycle - - org.openecomp.sdc.ci.tests.execute.resource - - org.openecomp.sdc.ci.tests.execute.service - - org.openecomp.sdc.ci.tests.execute.artifacts - - org.openecomp.sdc.ci.tests.execute.imports - - org.openecomp.sdc.ci.tests.execute.category \ No newline at end of file + - org.onap.sdc.ci.tests.execute.general + - org.onap.sdc.ci.tests.execute.user + - org.onap.sdc.ci.tests.execute.property + - org.onap.sdc.ci.tests.execute.lifecycle + - org.onap.sdc.ci.tests.execute.resource + - org.onap.sdc.ci.tests.execute.service + - org.onap.sdc.ci.tests.execute.artifacts + - org.onap.sdc.ci.tests.execute.imports + - org.onap.sdc.ci.tests.execute.category \ No newline at end of file diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties b/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties index 3e159ec..bef72a9 100644 --- a/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties +++ b/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties @@ -28,7 +28,7 @@ log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %10c: log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG log4j.logger.com.thinkaurelius.titan.diskstorage.cassandra.CassandraTransaction=INFO, FILE, stdout -log4j.logger.org.openecomp.sdc.ci.tests.utils=TRACE, FILE, stdout -log4j.additivity.org.openecomp.sdc.ci.tests.utils=false +log4j.logger.org.onap.sdc.ci.tests.utils=TRACE, FILE, stdout +log4j.additivity.org.onap.sdc.ci.tests.utils=false diff --git a/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh b/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh index 604903a..7fa5323 100644 --- a/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh +++ b/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh @@ -33,7 +33,7 @@ LOGS_PROP_FILE=file:${FULL_PATH}/conf/log4j.properties TARGET_DIR=${FULL_PATH}/target CONF_FILE=${FULL_PATH}/conf/attsdc.yaml DEBUG=true -MainClass=org.openecomp.sdc.ci.tests.run.StartTest +MainClass=org.onap.sdc.ci.tests.run.StartTest JAR_FILE=$1 diff --git a/sdc-distribution-ci/src/test/java/org/onap/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java b/sdc-distribution-ci/src/test/java/org/onap/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java new file mode 100644 index 0000000..22b1607 --- /dev/null +++ b/sdc-distribution-ci/src/test/java/org/onap/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java @@ -0,0 +1,511 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * 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.onap.sdc.ci.tests.execute.downloadArtifactUGN; + +import org.junit.Test; + +/** + * + * @author al714h + * US510007 - Story : ASDC Distr Client - Download Artifact + * following test set partially cover the US451327 - Story : API to download the specific artifact, cover the audit message. + */ + +//public class ClientDownloadArtifact extends AttSdcTest{ + public class ClientDownloadArtifact { + +// Logger logger = null; +// +// DistributionUtils distributionUtils = new DistributionUtils(); +// DownloadArtifactDetails downloadArtifactDetails = new DownloadArtifactDetails(); +// Utils utils = new Utils(); +// DbUtils dbUtils = new DbUtils(); +// UserUtils userUtils = new UserUtils(); +// ResourceUtils resourceUtils = new ResourceUtils(); +// ServiceUtils serviceUtils = new ServiceUtils(); +// ArtifactUtils artifactUtils = new ArtifactUtils(); +// private JSONParser jsonParser = new JSONParser(); +// + String serviceBaseVersion = "0.1"; +// +// @Before +// public void before() throws Exception { +// +// distributionUtils.resetInit(); +// dbUtils.cleanAllAudits(); +// } +// @Rule +// public static TestName name = new TestName(); +// +// } +// +// @Rule +// public static TestName name = new TestName(); +// +//// public ClientDownloadArtifact() { +//// super(name, ClientDownloadArtifact.class.getName()); +//// } +// +// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); +//// get default artifact info to upload +// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +//// set artifact info for download +// downloadArtifactDetails.setArtifactName(uploadedResourceArtifactInfo.getArtifactName()); +// String artifactName = downloadArtifactDetails.getArtifactName(); +//// Andrey TODO String resourceArtifactUrl = String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT,); +// +// int numOfResourcArtifacts = 1; +// RestResponse createCertifiedResourceWithArtifacts = resourceUtils.createCertifiedResourceWithArtifacts(resourceDetails, uploadedResourceArtifactInfo, numOfResourcArtifacts); +// +// +// +// try{ +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedResourceArtifactInfo); +// +// // validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// }finally{ +//// delete created resource +// resourceUtils.deleteResource_allVersions(resourceDetails, UserUtils.getAdminDetails()); +// } + +// } + +// send all mandatory headers only + @Test + public void downloadServiceArtifactSuccess() throws Exception{ + +//// ServiceReqDetails serviceDetails = serviceUtils.createDefaultDetailsService(); +// ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); +// Service service = new Service(); +// try{ +//// get default artifact info to upload +// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +// uploadedResourceArtifactInfo.setArtifactType(ArtifactTypeEnum.HEAT.getType()); +// ArtifactDefinition uploadedServiceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +// uploadedServiceArtifactInfo.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); +// +//// set artifact info for download +// downloadArtifactDetails.setArtifactName(uploadedServiceArtifactInfo.getArtifactName()); +// downloadArtifactDetails.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); +// String artifactName = downloadArtifactDetails.getArtifactName(); +// +//// create default resource details +// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); +// +// int numOfResourcArtifacts = 1; +// service = serviceUtils.createCertifiedServiceWithResourceInstanceAndArtifacts(serviceDetails, resourceDetails, uploadedResourceArtifactInfo, uploadedServiceArtifactInfo , numOfResourcArtifacts); +// logger.debug("service version = " + service.getVersion()); +// logger.debug("service distribution status = " + service.getDistributionStatus()); +// RestResponse changeDistributionStateToApprove = serviceUtils.changeDistributionStateToApprove(service, UserUtils.getGovernorDetails1()); +// +// int status = changeDistributionStateToApprove.getErrorCode(); +// assertTrue("response code is not 200, returned :" + status, status == 200); +// +// serviceDetails.setVersion(service.getVersion()); +// serviceDetails.setUniqueId(service.getUniqueId()); +// +// String responseString = changeDistributionStateToApprove.getResponse(); +// Gson gson = new Gson(); +// service = gson.fromJson(responseString, Service.class); +// ServiceMetadataDataDefinition serviceMetadataDataDefinition = gson.fromJson(responseString, ServiceMetadataDataDefinition.class); +// service.setDistributionStatus(DistributionStatusEnum.findState(serviceMetadataDataDefinition.getDistributionStatus())); +// DistributionStatusEnum distributionStatus = service.getDistributionStatus(); +// assertNotNull("distribution state is null",distributionStatus.name()); +// assertTrue("the default distribution state is invalid", DistributionStatusEnum.DISTRIBUTION_APPROVED.equals(distributionStatus)); +// +// String serviceArtifactUrl = String.format(Urls.DISTRIBUTION_DOWNLOAD_ARTIFACT,service.getName(), service.getVersion(), artifactName); +// logger.debug("download service artifact url: "+ serviceArtifactUrl+ " serviceName = " + service.getName() + " service version = " + service.getVersion() + "service artifact name = " + artifactName); +// +// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedArtifactInfo); +//// +//// // validate audit message server side +//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +//// String action = "ArtifactDownload"; +//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// }finally{ +//// delete created service +// serviceUtils.deleteService_allVersions(serviceDetails, UserUtils.getAdminDetails()); +// } + +// @Test +// public void downloadServiceArtifactSuccess() throws Exception{ +// +//// ServiceReqDetails serviceDetails = serviceUtils.createDefaultDetailsService(); +// ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); +// Service service = new Service(); +// try{ +//// get default artifact info to upload +// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +// uploadedResourceArtifactInfo.setArtifactType(ArtifactTypeEnum.HEAT.getType()); +// ArtifactDefinition uploadedServiceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +// uploadedServiceArtifactInfo.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); +// +//// set artifact info for download +// downloadArtifactDetails.setArtifactName(uploadedServiceArtifactInfo.getArtifactName()); +// downloadArtifactDetails.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); +// String artifactName = downloadArtifactDetails.getArtifactName(); +// +//// create default resource details +// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); +// +// int numOfResourcArtifacts = 1; +// service = serviceUtils.createCertifiedServiceWithResourceInstanceAndArtifacts(serviceDetails, resourceDetails, uploadedResourceArtifactInfo, uploadedServiceArtifactInfo , numOfResourcArtifacts); +// logger.debug("service version = " + service.getVersion()); +// logger.debug("service distribution status = " + service.getDistributionStatus()); +// RestResponse changeDistributionStateToApprove = serviceUtils.changeDistributionStateToApprove(service, UserUtils.getGovernorDetails1()); +// +// int status = changeDistributionStateToApprove.getErrorCode(); +// assertTrue("response code is not 200, returned :" + status, status == 200); +// +// serviceDetails.setVersion(service.getVersion()); +// serviceDetails.setUniqueId(service.getUniqueId()); +// +// String responseString = changeDistributionStateToApprove.getResponse(); +// Gson gson = new Gson(); +// service = gson.fromJson(responseString, Service.class); +// ServiceMetadataDataDefinition serviceMetadataDataDefinition = gson.fromJson(responseString, ServiceMetadataDataDefinition.class); +// service.setDistributionStatus(DistributionStatusEnum.findState(serviceMetadataDataDefinition.getDistributionStatus())); +// DistributionStatusEnum distributionStatus = service.getDistributionStatus(); +// assertNotNull("distribution state is null",distributionStatus.name()); +// assertTrue("the default distribution state is invalid", DistributionStatusEnum.DISTRIBUTION_APPROVED.equals(distributionStatus)); +// +// String serviceArtifactUrl = String.format(Urls.DISTRIBUTION_DOWNLOAD_ARTIFACT,service.getName(), service.getVersion(), artifactName); +// logger.debug("download service artifact url: "+ serviceArtifactUrl+ " serviceName = " + service.getName() + " service version = " + service.getVersion() + "service artifact name = " + artifactName); +// +// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedArtifactInfo); +//// +//// // validate audit message server side +//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +//// String action = "ArtifactDownload"; +//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// }finally{ +//// delete created service +// serviceUtils.deleteService_allVersions(serviceDetails, UserUtils.getAdminDetails()); +// } +// +// } +// +//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers +////// send all headers mandatory and not mandatory +//// @Test +//// public void downloadArtifactSuccessMandatoryAndNotMandatoryHeaders() throws Exception{ +//// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// +//// Map headersMap = new HashMap(); +//// headersMap.put(HttpHeaderEnum.X_ECOMP_InstanceID.getValue(), "instar_name"); // mandatory +//// headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), "usernamePassword"); // mandatory +//// headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/octet-stream"); // not mandatory +//// headersMap.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(),downloadArtifactDetails.getResourceUUID());// not mandatory +//// Log.debug("headers detailes: "+ headersMap.toString()); +//// +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); +//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse); +//// +////// validate audit message server side +//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +//// String action = "ArtifactDownload"; +//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +//// +//// } +// +// +////---------------------------------Failure scenario-------------------------------------------------------------------------------- +// +//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers +////// missing InstanceID mandatory header +//// @Test +//// public void downloadArtifactMissingInstanceIdHeader() throws Exception, JSONException{ +//// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// +//// Map headersMap = new HashMap(); +//// headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), "usernamePassword"); // mandatory +//// Log.debug("headers detailes: "+ headersMap.toString()); +//// +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); +//// +//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID.name()); +//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +//// +//// List variables = Arrays.asList(); +//// utils.checkBodyResponseOnError(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID.name(), variables, downloadArtifactRestResponse.getResponse())); +//// +//// } +// +//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers +////// missing Authorization mandatory header +//// @Test +//// public void downloadArtifactMissingAuthorizationHeader() throws Exception, JSONException{ +//// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// +//// Map headersMap = new HashMap(); +//// headersMap.put(HttpHeaderEnum.X_ECOMP_InstanceID.getValue(), "usernamePassword"); // mandatory +//// Log.debug("headers detailes: "+ headersMap.toString()); +//// +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); +//// +//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS.name()); +//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +//// +//// List variables = Arrays.asList(); +//// utils.checkBodyResponseOnError(ActionStatus.ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS.name(), variables, downloadArtifactRestResponse.getResponse())); +//// +//// } +// +// +//// artifact not found +// @Test +// public void downloadArtifactArtifactNotFound() throws Exception, JSONException{ +// +// downloadArtifactDetails.setArtifactName("artifactNotExist"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// +// } +// +//// service not found +// @Test +// public void downloadArtifactServiceNameNotFound() throws Exception, JSONException{ +// +// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceNotExist/0.1/artifacts/aaa.hh"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +//// TODO Andrey, change desc message +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// +// } +// +// +//// service version not found +// @Test +// public void downloadArtifactServiceVersionNotFound() throws Exception, JSONException{ +// +// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceName/0.888/artifacts/aaa.hh"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +//// TODO Andrey, change desc message +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// +// } +// +//// invalid HTTP method, PUT HTTP method +// @Test +// public void downloadArtifactByPutMethod() throws Exception, JSONException{ +// +// String method = "PUT"; +// +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); +// +// } +// +//// invalid HTTP method, DELETE HTTP method +// @Test +// public void downloadArtifactByDeleteMethod() throws Exception, JSONException{ +// +// String method = "DELETE"; +// downloadArtifactDetails.setArtifactName("artifactNotExist"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// +// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceNotExist/0.1/artifacts/aaa.hh"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +//// TODO Andrey, change desc message +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceName/0.888/artifacts/aaa.hh"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +//// TODO Andrey, change desc message +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); +// downloadArtifactDetails.setArtifactChecksum("invalidChecksum"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +//// TODO +// +//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name()); +//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +//// +//// List variables = Arrays.asList(); +//// utils.checkBodyResponseOnError(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse())); +// +// downloadArtifactDetails.setArtifactChecksum("invalidChecksum"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +//// TODO +// +//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name()); +//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +//// +//// List variables = Arrays.asList(); +//// utils.checkBodyResponseOnError(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse())); +// +// } +// +// +// +// + + } + +} diff --git a/sdc-distribution-ci/src/test/java/org/openecomp/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java b/sdc-distribution-ci/src/test/java/org/openecomp/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java deleted file mode 100644 index e52223d..0000000 --- a/sdc-distribution-ci/src/test/java/org/openecomp/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java +++ /dev/null @@ -1,511 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * 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.sdc.ci.tests.execute.downloadArtifactUGN; - -import org.junit.Test; - -/** - * - * @author al714h - * US510007 - Story : ASDC Distr Client - Download Artifact - * following test set partially cover the US451327 - Story : API to download the specific artifact, cover the audit message. - */ - -//public class ClientDownloadArtifact extends AttSdcTest{ - public class ClientDownloadArtifact { - -// Logger logger = null; -// -// DistributionUtils distributionUtils = new DistributionUtils(); -// DownloadArtifactDetails downloadArtifactDetails = new DownloadArtifactDetails(); -// Utils utils = new Utils(); -// DbUtils dbUtils = new DbUtils(); -// UserUtils userUtils = new UserUtils(); -// ResourceUtils resourceUtils = new ResourceUtils(); -// ServiceUtils serviceUtils = new ServiceUtils(); -// ArtifactUtils artifactUtils = new ArtifactUtils(); -// private JSONParser jsonParser = new JSONParser(); -// - String serviceBaseVersion = "0.1"; -// -// @Before -// public void before() throws Exception { -// -// distributionUtils.resetInit(); -// dbUtils.cleanAllAudits(); -// } -// @Rule -// public static TestName name = new TestName(); -// -// } -// -// @Rule -// public static TestName name = new TestName(); -// -//// public ClientDownloadArtifact() { -//// super(name, ClientDownloadArtifact.class.getName()); -//// } -// -// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); -//// get default artifact info to upload -// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -//// set artifact info for download -// downloadArtifactDetails.setArtifactName(uploadedResourceArtifactInfo.getArtifactName()); -// String artifactName = downloadArtifactDetails.getArtifactName(); -//// Andrey TODO String resourceArtifactUrl = String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT,); -// -// int numOfResourcArtifacts = 1; -// RestResponse createCertifiedResourceWithArtifacts = resourceUtils.createCertifiedResourceWithArtifacts(resourceDetails, uploadedResourceArtifactInfo, numOfResourcArtifacts); -// -// -// -// try{ -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedResourceArtifactInfo); -// -// // validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// }finally{ -//// delete created resource -// resourceUtils.deleteResource_allVersions(resourceDetails, UserUtils.getAdminDetails()); -// } - -// } - -// send all mandatory headers only - @Test - public void downloadServiceArtifactSuccess() throws Exception{ - -//// ServiceReqDetails serviceDetails = serviceUtils.createDefaultDetailsService(); -// ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); -// Service service = new Service(); -// try{ -//// get default artifact info to upload -// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -// uploadedResourceArtifactInfo.setArtifactType(ArtifactTypeEnum.HEAT.getType()); -// ArtifactDefinition uploadedServiceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -// uploadedServiceArtifactInfo.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); -// -//// set artifact info for download -// downloadArtifactDetails.setArtifactName(uploadedServiceArtifactInfo.getArtifactName()); -// downloadArtifactDetails.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); -// String artifactName = downloadArtifactDetails.getArtifactName(); -// -//// create default resource details -// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); -// -// int numOfResourcArtifacts = 1; -// service = serviceUtils.createCertifiedServiceWithResourceInstanceAndArtifacts(serviceDetails, resourceDetails, uploadedResourceArtifactInfo, uploadedServiceArtifactInfo , numOfResourcArtifacts); -// logger.debug("service version = " + service.getVersion()); -// logger.debug("service distribution status = " + service.getDistributionStatus()); -// RestResponse changeDistributionStateToApprove = serviceUtils.changeDistributionStateToApprove(service, UserUtils.getGovernorDetails1()); -// -// int status = changeDistributionStateToApprove.getErrorCode(); -// assertTrue("response code is not 200, returned :" + status, status == 200); -// -// serviceDetails.setVersion(service.getVersion()); -// serviceDetails.setUniqueId(service.getUniqueId()); -// -// String responseString = changeDistributionStateToApprove.getResponse(); -// Gson gson = new Gson(); -// service = gson.fromJson(responseString, Service.class); -// ServiceMetadataDataDefinition serviceMetadataDataDefinition = gson.fromJson(responseString, ServiceMetadataDataDefinition.class); -// service.setDistributionStatus(DistributionStatusEnum.findState(serviceMetadataDataDefinition.getDistributionStatus())); -// DistributionStatusEnum distributionStatus = service.getDistributionStatus(); -// assertNotNull("distribution state is null",distributionStatus.name()); -// assertTrue("the default distribution state is invalid", DistributionStatusEnum.DISTRIBUTION_APPROVED.equals(distributionStatus)); -// -// String serviceArtifactUrl = String.format(Urls.DISTRIBUTION_DOWNLOAD_ARTIFACT,service.getName(), service.getVersion(), artifactName); -// logger.debug("download service artifact url: "+ serviceArtifactUrl+ " serviceName = " + service.getName() + " service version = " + service.getVersion() + "service artifact name = " + artifactName); -// -// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedArtifactInfo); -//// -//// // validate audit message server side -//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -//// String action = "ArtifactDownload"; -//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// }finally{ -//// delete created service -// serviceUtils.deleteService_allVersions(serviceDetails, UserUtils.getAdminDetails()); -// } - -// @Test -// public void downloadServiceArtifactSuccess() throws Exception{ -// -//// ServiceReqDetails serviceDetails = serviceUtils.createDefaultDetailsService(); -// ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); -// Service service = new Service(); -// try{ -//// get default artifact info to upload -// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -// uploadedResourceArtifactInfo.setArtifactType(ArtifactTypeEnum.HEAT.getType()); -// ArtifactDefinition uploadedServiceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); -// uploadedServiceArtifactInfo.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); -// -//// set artifact info for download -// downloadArtifactDetails.setArtifactName(uploadedServiceArtifactInfo.getArtifactName()); -// downloadArtifactDetails.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); -// String artifactName = downloadArtifactDetails.getArtifactName(); -// -//// create default resource details -// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); -// -// int numOfResourcArtifacts = 1; -// service = serviceUtils.createCertifiedServiceWithResourceInstanceAndArtifacts(serviceDetails, resourceDetails, uploadedResourceArtifactInfo, uploadedServiceArtifactInfo , numOfResourcArtifacts); -// logger.debug("service version = " + service.getVersion()); -// logger.debug("service distribution status = " + service.getDistributionStatus()); -// RestResponse changeDistributionStateToApprove = serviceUtils.changeDistributionStateToApprove(service, UserUtils.getGovernorDetails1()); -// -// int status = changeDistributionStateToApprove.getErrorCode(); -// assertTrue("response code is not 200, returned :" + status, status == 200); -// -// serviceDetails.setVersion(service.getVersion()); -// serviceDetails.setUniqueId(service.getUniqueId()); -// -// String responseString = changeDistributionStateToApprove.getResponse(); -// Gson gson = new Gson(); -// service = gson.fromJson(responseString, Service.class); -// ServiceMetadataDataDefinition serviceMetadataDataDefinition = gson.fromJson(responseString, ServiceMetadataDataDefinition.class); -// service.setDistributionStatus(DistributionStatusEnum.findState(serviceMetadataDataDefinition.getDistributionStatus())); -// DistributionStatusEnum distributionStatus = service.getDistributionStatus(); -// assertNotNull("distribution state is null",distributionStatus.name()); -// assertTrue("the default distribution state is invalid", DistributionStatusEnum.DISTRIBUTION_APPROVED.equals(distributionStatus)); -// -// String serviceArtifactUrl = String.format(Urls.DISTRIBUTION_DOWNLOAD_ARTIFACT,service.getName(), service.getVersion(), artifactName); -// logger.debug("download service artifact url: "+ serviceArtifactUrl+ " serviceName = " + service.getName() + " service version = " + service.getVersion() + "service artifact name = " + artifactName); -// -// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedArtifactInfo); -//// -//// // validate audit message server side -//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -//// String action = "ArtifactDownload"; -//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// }finally{ -//// delete created service -// serviceUtils.deleteService_allVersions(serviceDetails, UserUtils.getAdminDetails()); -// } -// -// } -// -//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers -////// send all headers mandatory and not mandatory -//// @Test -//// public void downloadArtifactSuccessMandatoryAndNotMandatoryHeaders() throws Exception{ -//// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// -//// Map headersMap = new HashMap(); -//// headersMap.put(HttpHeaderEnum.X_ECOMP_InstanceID.getValue(), "instar_name"); // mandatory -//// headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), "usernamePassword"); // mandatory -//// headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/octet-stream"); // not mandatory -//// headersMap.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(),downloadArtifactDetails.getResourceUUID());// not mandatory -//// Log.debug("headers detailes: "+ headersMap.toString()); -//// -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); -//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse); -//// -////// validate audit message server side -//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -//// String action = "ArtifactDownload"; -//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -//// -//// } -// -// -////---------------------------------Failure scenario-------------------------------------------------------------------------------- -// -//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers -////// missing InstanceID mandatory header -//// @Test -//// public void downloadArtifactMissingInstanceIdHeader() throws Exception, JSONException{ -//// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// -//// Map headersMap = new HashMap(); -//// headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), "usernamePassword"); // mandatory -//// Log.debug("headers detailes: "+ headersMap.toString()); -//// -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); -//// -//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID.name()); -//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -//// -//// List variables = Arrays.asList(); -//// utils.checkBodyResponseOnError(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID.name(), variables, downloadArtifactRestResponse.getResponse())); -//// -//// } -// -//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers -////// missing Authorization mandatory header -//// @Test -//// public void downloadArtifactMissingAuthorizationHeader() throws Exception, JSONException{ -//// -//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -//// -//// Map headersMap = new HashMap(); -//// headersMap.put(HttpHeaderEnum.X_ECOMP_InstanceID.getValue(), "usernamePassword"); // mandatory -//// Log.debug("headers detailes: "+ headersMap.toString()); -//// -//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); -//// -//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS.name()); -//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -//// -//// List variables = Arrays.asList(); -//// utils.checkBodyResponseOnError(ActionStatus.ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS.name(), variables, downloadArtifactRestResponse.getResponse())); -//// -//// } -// -// -//// artifact not found -// @Test -// public void downloadArtifactArtifactNotFound() throws Exception, JSONException{ -// -// downloadArtifactDetails.setArtifactName("artifactNotExist"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// -// } -// -//// service not found -// @Test -// public void downloadArtifactServiceNameNotFound() throws Exception, JSONException{ -// -// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceNotExist/0.1/artifacts/aaa.hh"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -//// TODO Andrey, change desc message -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// -// } -// -// -//// service version not found -// @Test -// public void downloadArtifactServiceVersionNotFound() throws Exception, JSONException{ -// -// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceName/0.888/artifacts/aaa.hh"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -//// TODO Andrey, change desc message -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// -// } -// -//// invalid HTTP method, PUT HTTP method -// @Test -// public void downloadArtifactByPutMethod() throws Exception, JSONException{ -// -// String method = "PUT"; -// -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); -// -// } -// -//// invalid HTTP method, DELETE HTTP method -// @Test -// public void downloadArtifactByDeleteMethod() throws Exception, JSONException{ -// -// String method = "DELETE"; -// downloadArtifactDetails.setArtifactName("artifactNotExist"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// -// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceNotExist/0.1/artifacts/aaa.hh"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -//// TODO Andrey, change desc message -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceName/0.888/artifacts/aaa.hh"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); -// -//// validate audit message server side -// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); -// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); -//// TODO Andrey, change desc message -// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; -// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); -// -// String action = "ArtifactDownload"; -// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); -// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); -// -// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); -// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -// -// List variables = Arrays.asList(); -// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); -// downloadArtifactDetails.setArtifactChecksum("invalidChecksum"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -//// TODO -// -//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name()); -//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -//// -//// List variables = Arrays.asList(); -//// utils.checkBodyResponseOnError(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse())); -// -// downloadArtifactDetails.setArtifactChecksum("invalidChecksum"); -// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); -// -// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); -//// TODO -// -//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name()); -//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); -//// -//// List variables = Arrays.asList(); -//// utils.checkBodyResponseOnError(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse())); -// -// } -// -// -// -// - - } - -} -- cgit 1.2.3-korg