From 26c6238bd7e5a48363b86122b9b40f013ed29f1a Mon Sep 17 00:00:00 2001 From: Edyta Krukowska Date: Tue, 15 Dec 2020 13:45:37 +0100 Subject: Remove old content of CI project and create integration tests Issue-ID: SDC-3400 Signed-off-by: Edyta Krukowska Change-Id: I1b46858cfae199aefcdeb8dfc14a33f50f4da7d6 --- .../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 ------------ .../onap/test/core/config/ArtifactTypeEnum.java | 110 +++++++ .../test/core/config/DistributionClientConfig.java | 343 ++++++++++++++++++++ .../test/core/service/ArtifactsDownloader.java | 86 +++++ .../onap/test/core/service/ArtifactsValidator.java | 28 ++ .../onap/test/core/service/ClientInitializer.java | 53 +++ .../test/core/service/ClientNotifyCallback.java | 101 ++++++ .../core/service/DistributionStatusMessage.java | 66 ++++ .../onap/test/core/service/ValidationMessage.java | 25 ++ .../onap/test/core/service/ValidationResult.java | 42 +++ .../org/onap/test/it/RegisterToAsdcTopicIT.java | 51 +++ 18 files changed, 905 insertions(+), 1072 deletions(-) delete mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/AdvanceCallBack.java delete mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/ArtifactTypeEnum.java delete mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/ClientTest.java delete mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java delete mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java delete mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/NotificationCallback.java delete mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/SimpleCallback.java delete mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/SimpleConfiguration.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/core/config/ArtifactTypeEnum.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsDownloader.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsValidator.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/core/service/DistributionStatusMessage.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationMessage.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationResult.java create mode 100644 sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java (limited to 'sdc-distribution-ci/src/main/java/org/onap/test') 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 deleted file mode 100644 index a122ca0..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/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.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 deleted file mode 100644 index 1f5e799..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/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.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 deleted file mode 100644 index 24160b5..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/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.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 deleted file mode 100644 index 1102150..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java +++ /dev/null @@ -1,121 +0,0 @@ -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 deleted file mode 100644 index fc029ff..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc-distribution-client - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Modifications copyright (C) 2019 Nokia. 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 java.util.Base64; - -public class Decoder { - - public static String encode(byte[] byteArrayToEncode) { - return new String(Base64.getEncoder().encode(byteArrayToEncode)); - } - - public static String decode(String strEncoded) { - return new String(Base64.getDecoder().decode(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 deleted file mode 100644 index 48fda0a..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/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.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 deleted file mode 100644 index 547dde2..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/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.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 deleted file mode 100644 index d22bcf2..0000000 --- a/sdc-distribution-ci/src/main/java/org/onap/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.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/onap/test/core/config/ArtifactTypeEnum.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/ArtifactTypeEnum.java new file mode 100644 index 0000000..64923c5 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/ArtifactTypeEnum.java @@ -0,0 +1,110 @@ +/*- + * ============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.core.config; + +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/core/config/DistributionClientConfig.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java new file mode 100644 index 0000000..be6f6a6 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java @@ -0,0 +1,343 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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.core.config; + +import org.onap.sdc.api.consumer.IConfiguration; + +import java.util.ArrayList; +import java.util.List; + + +public class DistributionClientConfig implements IConfiguration { + + public static final String DEFAULT_ASDC_ADDRESS = "localhost:30206"; + public static final String DEFAULT_COMSUMER_ID = "dcae-openapi-manager"; + public static final String DEFAULT_CONSUMER_GROUP = "noapp"; + public static final String DEFAULT_ENVIRONMENT_NAME = "AUTO"; + public static final String DEFAULT_PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"; + public static final int DEFAULT_POLLING_INTERVAL = 20; + public static final int DEFAULT_POLLING_TIMEOUT = 20; + public static final String DEFAULT_USER = "dcae"; + public static final String DEFAULT_KEY_STORE_PATH = "etc/asdc-client.jks"; + public static final String DEFAULT_KEY_STORE_PASSWORD = "Aa123456"; + public static final boolean DEFAULT_ACTIVATE_SERVER_TLS_AUTH = false; + public static final boolean DEFAULT_IS_FILTER_IN_EMPTY_RESOURCES = false; + public static final boolean DEFAULT_USE_HTTPS_WITH_SDC = false; + public static final String DEFAULT_MSG_BUS_ADDRESS = "localhost"; + private String asdcAddress; + private String user; + private String password; + private int pollingInterval; + private int pollingTimeout; + private List relevantArtifactTypes; + private String consumerGroup; + private String environmentName; + private String comsumerID; + private String keyStorePath; + private String keyStorePassword; + private boolean activateServerTLSAuth; + private boolean isFilterInEmptyResources; + private boolean useHttpsWithDmaap; + private boolean useHttpsWithSDC; + private List msgBusAddress; + + public DistributionClientConfig(IConfiguration other) { + this.asdcAddress = other.getAsdcAddress(); + this.comsumerID = other.getConsumerID(); + this.consumerGroup = other.getConsumerGroup(); + this.environmentName = other.getEnvironmentName(); + this.password = other.getPassword(); + this.pollingInterval = other.getPollingInterval(); + this.pollingTimeout = other.getPollingTimeout(); + this.relevantArtifactTypes = other.getRelevantArtifactTypes(); + this.user = other.getUser(); + this.keyStorePath = other.getKeyStorePath(); + this.keyStorePassword = other.getKeyStorePassword(); + this.activateServerTLSAuth = other.activateServerTLSAuth(); + this.isFilterInEmptyResources = other.isFilterInEmptyResources(); + } + + public DistributionClientConfig() { + this.asdcAddress = DEFAULT_ASDC_ADDRESS; + this.comsumerID = DEFAULT_COMSUMER_ID; + this.consumerGroup = DEFAULT_CONSUMER_GROUP; + this.environmentName = DEFAULT_ENVIRONMENT_NAME; + this.password = DEFAULT_PASSWORD; + this.pollingInterval = DEFAULT_POLLING_INTERVAL; + this.pollingTimeout = DEFAULT_POLLING_TIMEOUT; + this.relevantArtifactTypes = new ArrayList<>(); + this.relevantArtifactTypes.add(ArtifactTypeEnum.HEAT.name()); + this.user = DEFAULT_USER; + this.keyStorePath = DEFAULT_KEY_STORE_PATH; + this.keyStorePassword = DEFAULT_KEY_STORE_PASSWORD; + this.activateServerTLSAuth = DEFAULT_ACTIVATE_SERVER_TLS_AUTH; + this.isFilterInEmptyResources = DEFAULT_IS_FILTER_IN_EMPTY_RESOURCES; + this.useHttpsWithSDC = DEFAULT_USE_HTTPS_WITH_SDC; + msgBusAddress = new ArrayList<>(); + msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); + msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); + msgBusAddress.add(DEFAULT_MSG_BUS_ADDRESS); + } + + @Override + public String getAsdcAddress() { + return asdcAddress; + } + + @Override + public List getMsgBusAddress() { + return msgBusAddress; + } + + @Override + public String getUser() { + return user; + } + + @Override + public String getPassword() { + return password; + } + + @Override + public int getPollingInterval() { + return pollingInterval; + } + + @Override + public int getPollingTimeout() { + return pollingTimeout; + } + + @Override + public List getRelevantArtifactTypes() { + return relevantArtifactTypes; + } + + @Override + public String getConsumerGroup() { + return consumerGroup; + } + + @Override + public String getEnvironmentName() { + return environmentName; + } + + @Override + public String getConsumerID() { + return comsumerID; + } + + @Override + public String getKeyStorePath() { + return keyStorePath; + } + + @Override + public String getKeyStorePassword() { + return keyStorePassword; + } + + public String getComsumerID() { + return comsumerID; + } + + public void setComsumerID(String comsumerID) { + this.comsumerID = comsumerID; + } + + public void setAsdcAddress(String asdcAddress) { + this.asdcAddress = asdcAddress; + } + + public void setUser(String user) { + this.user = user; + } + + public void setPassword(String password) { + this.password = password; + } + + public void setPollingInterval(int pollingInterval) { + this.pollingInterval = pollingInterval; + } + + public void setPollingTimeout(int pollingTimeout) { + this.pollingTimeout = pollingTimeout; + } + + public void setRelevantArtifactTypes(List relevantArtifactTypes) { + this.relevantArtifactTypes = relevantArtifactTypes; + } + + public void setConsumerGroup(String consumerGroup) { + this.consumerGroup = consumerGroup; + } + + public void setEnvironmentName(String environmentName) { + this.environmentName = environmentName; + } + + public void setKeyStorePath(String keyStorePath) { + this.keyStorePath = keyStorePath; + } + + public void setKeyStorePassword(String keyStorePassword) { + this.keyStorePassword = keyStorePassword; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((asdcAddress == null) ? 0 : asdcAddress.hashCode()); + result = prime * result + ((comsumerID == null) ? 0 : comsumerID.hashCode()); + result = prime * result + ((consumerGroup == null) ? 0 : consumerGroup.hashCode()); + result = prime * result + ((environmentName == null) ? 0 : environmentName.hashCode()); + result = prime * result + ((password == null) ? 0 : password.hashCode()); + result = prime * result + pollingInterval; + result = prime * result + pollingTimeout; + result = prime * result + ((relevantArtifactTypes == null) ? 0 : relevantArtifactTypes.hashCode()); + result = prime * result + ((user == null) ? 0 : user.hashCode()); + return result; + } + + @Override + public boolean activateServerTLSAuth() { + + return activateServerTLSAuth; + } + + public void setactivateServerTLSAuth(boolean activateServerTLSAuth) { + this.activateServerTLSAuth = activateServerTLSAuth; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + DistributionClientConfig other = (DistributionClientConfig) obj; + if (asdcAddress == null) { + if (other.asdcAddress != null) { + return false; + } + } else if (!asdcAddress.equals(other.asdcAddress)) { + return false; + } + if (comsumerID == null) { + if (other.comsumerID != null) { + return false; + } + } else if (!comsumerID.equals(other.comsumerID)) { + return false; + } + if (consumerGroup == null) { + if (other.consumerGroup != null) { + return false; + } + } else if (!consumerGroup.equals(other.consumerGroup)) { + return false; + } + if (environmentName == null) { + if (other.environmentName != null) { + return false; + } + } else if (!environmentName.equals(other.environmentName)) { + return false; + } + if (password == null) { + if (other.password != null) { + return false; + } + } else if (!password.equals(other.password)) { + return false; + } + if (pollingInterval != other.pollingInterval) { + return false; + } + if (pollingTimeout != other.pollingTimeout) { + return false; + } + if (relevantArtifactTypes == null) { + if (other.relevantArtifactTypes != null) { + return false; + } + } else if (!relevantArtifactTypes.equals(other.relevantArtifactTypes)) { + return false; + } + if (user == null) { + if (other.user != null) { + return false; + } + } else if (!user.equals(other.user)) { + return false; + } + if (keyStorePath == null) { + if (other.keyStorePath != null) { + return false; + } + } else if (!keyStorePath.equals(other.keyStorePath)) { + return false; + } + if (keyStorePassword == null) { + return other.keyStorePassword == null; + } else { + return keyStorePassword.equals(other.keyStorePassword); + } + } + + @Override + public String toString() { + return "TestConfiguration [asdcAddress=" + asdcAddress + ", user=" + user + ", password=" + password + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", relevantArtifactTypes=" + relevantArtifactTypes + + ", consumerGroup=" + consumerGroup + ", environmentName=" + environmentName + ", comsumerID=" + comsumerID + "]"; + } + + @Override + public boolean isFilterInEmptyResources() { + return isFilterInEmptyResources; + } + + + public void setFilterInEmptyResources(boolean isFilterInEmptyResources) { + this.isFilterInEmptyResources = isFilterInEmptyResources; + } + + @Override + public Boolean isUseHttpsWithDmaap() { + return this.useHttpsWithDmaap; + } + + + public Boolean isUseHttpsWithSDC() { + return this.useHttpsWithSDC; + } + + public void setUseHttpsWithSDC(Boolean useHttpsWithSDC) { + this.useHttpsWithSDC = useHttpsWithSDC; + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsDownloader.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsDownloader.java new file mode 100644 index 0000000..1e0623d --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsDownloader.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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.core.service; + +import org.apache.commons.io.FileUtils; +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.http.SdcConnectorClient; +import org.onap.sdc.impl.DistributionClientDownloadResultImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + + +public class ArtifactsDownloader { + + private static final Logger log = LoggerFactory.getLogger(ArtifactsDownloader.class); + + private final String artifactsDownloadPath; + private final SdcConnectorClient sdcConnectorClient; + + public ArtifactsDownloader(String artifactsDownloadPath, + SdcConnectorClient sdcConnectorClient) { + this.artifactsDownloadPath = artifactsDownloadPath; + this.sdcConnectorClient = sdcConnectorClient; + } + + public List pullArtifacts(INotificationData service) { + log.info("Downloading artifacts..."); + return service.getResources().stream() + .flatMap(this::getArtifactsStream) + .map(sdcConnectorClient::downloadArtifact) + .collect(Collectors.toList()); + } + + public void saveArtifacts(List artifacts, String serviceName) { + artifacts.forEach(artifact -> saveArtifact(artifact, serviceName)); + } + + public String parseArtifactName(DistributionClientDownloadResultImpl artifact) { + return artifact.getArtifactName().split("\"")[1]; + } + + private String getArtifactPath(String serviceName, String artifactName) { + return String.format("%s/%s/%s", artifactsDownloadPath, serviceName, artifactName); + } + + private Stream getArtifactsStream(IResourceInstance resourceInstance) { + return resourceInstance.getArtifacts().stream(); + } + + private void saveArtifact(DistributionClientDownloadResultImpl artifact, String serviceName) { + String artifactName = parseArtifactName(artifact); + String path = getArtifactPath(serviceName, artifactName); + + try { + File file = new File(path); + FileUtils.writeByteArrayToFile(file, artifact.getArtifactPayload()); + } catch (IOException e) { + log.error("Couldn't save an artifact: " + path, e); + } + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsValidator.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsValidator.java new file mode 100644 index 0000000..2972777 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsValidator.java @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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.core.service; + +import org.onap.sdc.api.notification.INotificationData; + +import java.util.List; + +public interface ArtifactsValidator { + List validate(INotificationData service); +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java new file mode 100644 index 0000000..64e6a6f --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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.core.service; + +import org.onap.sdc.api.results.IDistributionClientResult; +import org.onap.sdc.impl.DistributionClientImpl; +import org.onap.test.core.config.DistributionClientConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ClientInitializer { + + Logger log = LoggerFactory.getLogger(ClientInitializer.class); + public static final String SEPARATOR = "========================================"; + private final DistributionClientConfig clientConfig; + private final ClientNotifyCallback callback; + private final DistributionClientImpl client; + + + public ClientInitializer(DistributionClientConfig clientConfig, ClientNotifyCallback callback, DistributionClientImpl client) { + this.clientConfig = clientConfig; + this.callback = callback; + this.client = client; + } + + public void initialize() { + IDistributionClientResult initResult = client.init(clientConfig, callback); + log.info(initResult.getDistributionMessageResult()); + log.info(SEPARATOR); + log.info(SEPARATOR); + IDistributionClientResult startResult = client.start(); + log.info(startResult.getDistributionMessageResult()); + log.info(SEPARATOR); + } + +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java new file mode 100644 index 0000000..7737457 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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.core.service; + +import org.onap.sdc.api.consumer.IDistributionStatusMessage; +import org.onap.sdc.api.consumer.INotificationCallback; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.notification.IResourceInstance; +import org.onap.sdc.http.HttpAsdcClient; +import org.onap.sdc.http.SdcConnectorClient; +import org.onap.sdc.impl.DistributionClientImpl; +import org.onap.sdc.utils.DistributionStatusEnum; +import org.onap.test.core.config.DistributionClientConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.Collection; +import java.util.List; + +public class ClientNotifyCallback implements INotificationCallback { + + private static final Logger log = LoggerFactory.getLogger(ClientNotifyCallback.class); + + private final List validators; + private final DistributionClientImpl distributionClient; + DistributionClientConfig config = new DistributionClientConfig(); + HttpAsdcClient asdcClient = new HttpAsdcClient(config); + SdcConnectorClient sdcConnectorClient = new SdcConnectorClient(config,asdcClient); + ArtifactsDownloader artifactsDownloader = new ArtifactsDownloader("/app/path", sdcConnectorClient); + + public ClientNotifyCallback(List validators, DistributionClientImpl distributionClient) { + this.validators = validators; + this.distributionClient = distributionClient; + } + + @Override + public void activateCallback(INotificationData inotificationData) { + logServiceInfo(inotificationData); + artifactsDownloader.pullArtifacts(inotificationData); + } + + private void logServiceInfo(INotificationData service) { + log.info("================================================="); + log.info("Distrubuted service information"); + log.info("Service UUID: {}", service.getServiceUUID()); + log.info("Service name: {}", service.getServiceName()); + List resources = service.getResources(); + log.info("Service resources:"); + resources.forEach(resource -> { + log.info(" - Resource: {}", resource.getResourceName()); + log.info(" Artifacts:"); + resource.getArtifacts().forEach(artifact -> log.info(" - Name: {}", artifact.getArtifactName())); + }); + log.info("================================================="); + } + + private void validate(INotificationData service) { + validators.stream() + .map(validator -> validator.validate(service)) + .flatMap(Collection::stream) + .forEach(validationResult -> sendNotificationResponse(validationResult, service.getDistributionID())); + } + + private void sendNotificationResponse(ValidationResult validationResult, String distributionId) { + if (!validationResult.getMessage().equals(ValidationMessage.VALID)) { + log.warn("Artifact {} is invalid.", validationResult.getArtifact().getArtifactName()); + log.warn("Validation message: {}", validationResult.getMessage()); + + IDistributionStatusMessage message = getDistributionStatusMessage(validationResult, distributionId); + distributionClient.sendDeploymentStatus(message, "Schema reference is invalid."); + } + } + + private DistributionStatusMessage getDistributionStatusMessage(ValidationResult validationResult, String distributionId) { + return new DistributionStatusMessage( + validationResult.getArtifact().getArtifactURL(), + distributionId, + distributionClient.getConfiguration().getConsumerID(), + LocalDateTime.now().toEpochSecond(ZoneOffset.UTC), + DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR); + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/DistributionStatusMessage.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/DistributionStatusMessage.java new file mode 100644 index 0000000..42d54a4 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/DistributionStatusMessage.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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.core.service; + +import org.onap.sdc.api.consumer.IDistributionStatusMessage; +import org.onap.sdc.utils.DistributionStatusEnum; + + +public class DistributionStatusMessage implements IDistributionStatusMessage { + + private String artifactUrl; + private String distributionId; + private String consumerId; + private long timestamp; + private DistributionStatusEnum status; + + public DistributionStatusMessage(String artifactUrl, String distributionId, String consumerId, long timestamp, DistributionStatusEnum status) { + this.artifactUrl = artifactUrl; + this.distributionId = distributionId; + this.consumerId = consumerId; + this.timestamp = timestamp; + this.status = status; + } + + @Override + public String getArtifactURL() { + return artifactUrl; + } + + @Override + public String getDistributionID() { + return distributionId; + } + + @Override + public String getConsumerID() { + return consumerId; + } + + @Override + public long getTimestamp() { + return timestamp; + } + + @Override + public DistributionStatusEnum getStatus() { + return status; + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationMessage.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationMessage.java new file mode 100644 index 0000000..107d814 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationMessage.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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.core.service; + +public enum ValidationMessage { + VALID, + SCHEMA_REFERENCE_INVALID +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationResult.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationResult.java new file mode 100644 index 0000000..57c6fce --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationResult.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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.core.service; + + +import org.onap.sdc.api.notification.IArtifactInfo; + +public class ValidationResult { + private IArtifactInfo artifact; + private ValidationMessage message; + + + public ValidationResult(IArtifactInfo artifact, ValidationMessage message) { + this.artifact = artifact; + this.message = message; + } + + public IArtifactInfo getArtifact() { + return artifact; + } + + public ValidationMessage getMessage() { + return message; + } +} diff --git a/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java b/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java new file mode 100644 index 0000000..58baec7 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2020 Nokia. 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.it; + +import org.onap.sdc.impl.DistributionClientImpl; +import org.onap.test.core.config.DistributionClientConfig; +import org.onap.test.core.service.ArtifactsValidator; +import org.onap.test.core.service.ClientInitializer; +import org.onap.test.core.service.ClientNotifyCallback; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +public class RegisterToAsdcTopicIT { + + + public static void main(String[] args) { + DistributionClientConfig clientConfig = new DistributionClientConfig(); + List validators = new ArrayList<>(); + DistributionClientImpl client = new DistributionClientImpl(); + ClientNotifyCallback callback = new ClientNotifyCallback(validators, client); + ClientInitializer clientInitializer = new ClientInitializer(clientConfig, callback, client); + clientInitializer.initialize(); + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + client.stop(); + System.out.println("Shutdown Hook is running !"); + } + }); + + } +} -- cgit 1.2.3-korg