summaryrefslogtreecommitdiffstats
path: root/sdc-distribution-ci
diff options
context:
space:
mode:
authorEdyta Krukowska <edyta.krukowska@nokia.com>2020-12-15 13:45:37 +0100
committerEdyta Krukowska <edyta.krukowska@nokia.com>2020-12-17 12:04:05 +0100
commit26c6238bd7e5a48363b86122b9b40f013ed29f1a (patch)
tree329736e49b1fca0f9dd54dcc36f5b30f626c3186 /sdc-distribution-ci
parent64079b27bdfff509fe610b1d46e09bdf1e43e4c6 (diff)
Remove old content of CI project and create integration tests
Issue-ID: SDC-3400 Signed-off-by: Edyta Krukowska <edyta.krukowska@nokia.com> Change-Id: I1b46858cfae199aefcdeb8dfc14a33f50f4da7d6
Diffstat (limited to 'sdc-distribution-ci')
-rw-r--r--sdc-distribution-ci/log4j.properties17
-rw-r--r--sdc-distribution-ci/pom.xml198
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/AdvanceCallBack.java70
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/ClientTest.java113
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/CsarToscaTester.java121
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/Decoder.java58
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/SimpleCallback.java356
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/SimpleConfiguration.java204
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/config/ArtifactTypeEnum.java (renamed from sdc-distribution-ci/src/main/java/org/onap/test/ArtifactTypeEnum.java)3
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/config/DistributionClientConfig.java343
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsDownloader.java86
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsValidator.java (renamed from sdc-distribution-ci/src/main/java/org/onap/test/NotificationCallback.java)27
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientInitializer.java53
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/service/ClientNotifyCallback.java101
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/service/DistributionStatusMessage.java66
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationMessage.java25
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/core/service/ValidationResult.java42
-rw-r--r--sdc-distribution-ci/src/main/java/org/onap/test/it/RegisterToAsdcTopicIT.java51
-rw-r--r--sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml10
-rw-r--r--sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml35
-rw-r--r--sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties34
-rw-r--r--sdc-distribution-ci/src/main/resources/ci/conf/titan.properties5
-rw-r--r--sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh87
-rw-r--r--sdc-distribution-ci/src/main/resources/log4j2.properties44
-rw-r--r--sdc-distribution-ci/src/test/java/org/onap/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java511
-rw-r--r--sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java78
26 files changed, 1014 insertions, 1724 deletions
diff --git a/sdc-distribution-ci/log4j.properties b/sdc-distribution-ci/log4j.properties
deleted file mode 100644
index f71e8ce..0000000
--- a/sdc-distribution-ci/log4j.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-log4j.rootCategory=DEBUG, 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
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
-
-# LOGFILE is set to be a File appender using a PatternLayout.
-log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
-log4j.appender.LOGFILE.File=logs/wordnik.log
-log4j.appender.LOGFILE.Append=true
-log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
-log4j.appender.LOGFILE.MaxFileSize=10MB
-log4j.appender.LOGFILE.MaxBackupIndex=10
diff --git a/sdc-distribution-ci/pom.xml b/sdc-distribution-ci/pom.xml
index 7b32b37..fb5c2f1 100644
--- a/sdc-distribution-ci/pom.xml
+++ b/sdc-distribution-ci/pom.xml
@@ -1,93 +1,127 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.sdc.sdc-distribution-client</groupId>
- <artifactId>sdc-main-distribution-client</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.onap.sdc.sdc-distribution-client</groupId>
+ <artifactId>sdc-main-distribution-client</artifactId>
+ <version>1.4.1-SNAPSHOT</version>
+ </parent>
- <artifactId>sdc-distribution-ci</artifactId>
- <name>SdcDistributionCI</name>
- <description>Distribution CI for testing distribution client</description>
+ <artifactId>sdc-distribution-ci</artifactId>
+ <name>sdc-distribution-ci</name>
+ <description>Distribution CI for testing distribution client</description>
- <dependencies>
+ <properties>
+ <slf4j-api.version>1.7.30</slf4j-api.version>
+ <mockito-core.version>3.5.0</mockito-core.version>
+ <mockito-junit-jupiter.version>2.23.0</mockito-junit-jupiter.version>
+ <assertj-core.version>3.18.1</assertj-core.version>
+ <junit-jupiter.version>1.15.1</junit-jupiter.version>
+ <testcontainers.version>1.15.1</testcontainers.version>
+ <junit-jupiter-engine.version>5.4.2</junit-jupiter-engine.version>
+ <junit-jupiter-params.version>5.4.2</junit-jupiter-params.version>
+ <junit-jupiter-api.version>5.4.2</junit-jupiter-api.version>
+ </properties>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20131018</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.sdc.sdc-distribution-client</groupId>
- <artifactId>sdc-distribution-client</artifactId>
- <version>${project.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.onap.sdc.sdc-tosca</groupId>
- <artifactId>sdc-tosca</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <scope>compile</scope>
- </dependency>
-
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.sdc.sdc-distribution-client</groupId>
+ <artifactId>sdc-distribution-client</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${logback.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j-api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>${logback.version}</version>
+ <scope>compile</scope>
+ </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.5</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>${logback.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>${logback.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>compile</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- <configuration>
- <classifier>spring-boot</classifier>
- <mainClass>
- org.onap.test.ClientTest
- </mainClass>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>${junit-jupiter-api.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <version>${junit-jupiter-params.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>${junit-jupiter-engine.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>${testcontainers.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <version>${junit-jupiter.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>${mockito-core.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>${assertj-core.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <version>${mockito-junit-jupiter.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>client-initialization</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>lib</classpathPrefix>
+ <mainClass>org.onap.test.it.RegisterToAsdcTopicIT</mainClass>
+ </manifest>
+ <manifestEntries>
+ <Class-Path>lib/</Class-Path>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
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/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<String> 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<Input> serviceInputs = sdcCsarHelper.getServiceInputs();
- System.out.println("getServiceInputs() - service inputs are "+serviceInputs);
- Metadata serviceMetadata = sdcCsarHelper.getServiceMetadata();
- System.out.println("getServiceMetadata() - service metadata is "+serviceMetadata);
- Map<String, Object> serviceMetadataProperties = sdcCsarHelper.getServiceMetadataProperties();
- System.out.println("getServiceMetadataProperties() - service metadata properties is "+serviceMetadataProperties);
- List<NodeTemplate> allottedResources = sdcCsarHelper.getAllottedResources();
- System.out.println("getAllottedResources() - service allotted resources are "+allottedResources);
- List<NodeTemplate> serviceVfList = sdcCsarHelper.getServiceVfList();
- System.out.println("getServiceVfList() - VF list is "+serviceVfList);
- List<NodeTemplate> serviceNodeTemplateBySdcType = sdcCsarHelper.getServiceNodeTemplateBySdcType(SdcTypes.VF);
- System.out.println("getServiceNodeTemplateBySdcType() - VF list is "+serviceNodeTemplateBySdcType);
- List<NodeTemplate> 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<Group> vfModulesByVf = sdcCsarHelper.getVfModulesByVf(nodeTemplateCustomizationUuid);
- System.out.println("getVfModulesByVf() - VF modules list is "+vfModulesByVf);
- vfModulesByVf.forEach(y -> {
- List<NodeTemplate> membersOfVfModule = sdcCsarHelper.getMembersOfVfModule(x, y);
- System.out.println("getMembersOfVfModule() - members of VfModule are "+membersOfVfModule);
- });
- List<NodeTemplate> vfcListByVf = sdcCsarHelper.getVfcListByVf(nodeTemplateCustomizationUuid);
- System.out.println("getVfcListByVf() - VFC list is "+vfcListByVf);
- vfcListByVf.forEach(z -> {
- List<NodeTemplate> nodeTemplateBySdcType = sdcCsarHelper.getNodeTemplateBySdcType(z, SdcTypes.CP);
- System.out.println("getNodeTemplateBySdcType() - CP children node templates of this VFC are "+nodeTemplateBySdcType);
- Map<String, Map<String, Object>> 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<String> 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/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> iArtifactInfo;
-
- public final Map<String, IDistributionClientResult> simpleCallbackResults = new HashMap<String, IDistributionClientResult>();
-
- public Map<String, IDistributionClientResult> getSimpleCallbackResults() {
- return simpleCallbackResults;
- }
-
- public List<IArtifactInfo> getIArtifactInfo(){
- return iArtifactInfo;
- }
- public SimpleCallback(IDistributionClient client) {
- this.client = client;
- }
-
-
-
-
-
- public void activateCallback(INotificationData data) {
-
- List<IArtifactInfo> 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<IVfModuleMetadata> decodeVfModuleArtifact = client.decodeVfModuleArtifact(download.getArtifactPayload());
-// assertEquals("decoded not equal to actual group amount ", decodeVfModuleArtifact.size(), 2);
- if (!decodeVfModuleArtifact.isEmpty()){
- for (IVfModuleMetadata moduleMetadata : decodeVfModuleArtifact) {
- List<String> 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<IArtifactInfo> getArtifacts(INotificationData data) {
- List<IArtifactInfo> ret = new ArrayList<IArtifactInfo>();
- List<IResourceInstance> resources = data.getResources();
-// data.getArtifactMetadataByUUID(arg0)
- List<String> relevantArtifactTypes = client.getConfiguration().getRelevantArtifactTypes();
-
- List<IArtifactInfo> 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<IArtifactInfo> 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<IArtifactInfo> serviceArtifacts = data.getServiceArtifacts();
- List<IResourceInstance> 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<IArtifactInfo> serviceArtifactFound = serviceArtifacts.stream().filter(x -> x.getArtifactUUID().equals(artifact)).findFirst();
-
- boolean isResourceFound = false;
- for (int j = 0 ; j < resourcesArtifacts.size(); j++) {
- Optional<IArtifactInfo> 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<String> 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<String> getRelevantArtifactTypes() {
-
-// List<String> res = new ArrayList<String>();
-// 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<String> 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/ArtifactTypeEnum.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/ArtifactTypeEnum.java
index 1f5e799..64923c5 100644
--- a/sdc-distribution-ci/src/main/java/org/onap/test/ArtifactTypeEnum.java
+++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/config/ArtifactTypeEnum.java
@@ -17,8 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
-package org.onap.test;
+package org.onap.test.core.config;
import java.util.ArrayList;
import java.util.List;
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<String> 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<String> 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<String> 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<String> 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<String> 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<DistributionClientDownloadResultImpl> pullArtifacts(INotificationData service) {
+ log.info("Downloading artifacts...");
+ return service.getResources().stream()
+ .flatMap(this::getArtifactsStream)
+ .map(sdcConnectorClient::downloadArtifact)
+ .collect(Collectors.toList());
+ }
+
+ public void saveArtifacts(List<DistributionClientDownloadResultImpl> 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<IArtifactInfo> 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/NotificationCallback.java b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsValidator.java
index 48fda0a..2972777 100644
--- a/sdc-distribution-ci/src/main/java/org/onap/test/NotificationCallback.java
+++ b/sdc-distribution-ci/src/main/java/org/onap/test/core/service/ArtifactsValidator.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* sdc-distribution-client
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * 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.
@@ -17,23 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+package org.onap.test.core.service;
-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);
- }
+import java.util.List;
+
+public interface ArtifactsValidator {
+ List<ValidationResult> 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<ArtifactsValidator> 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<ArtifactsValidator> 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<IResourceInstance> 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<ArtifactsValidator> 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 !");
+ }
+ });
+
+ }
+}
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
deleted file mode 100644
index 65a38fa..0000000
--- a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-packages:
- - 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/attsdc.yaml b/sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml
deleted file mode 100644
index a9c449e..0000000
--- a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml
+++ /dev/null
@@ -1,35 +0,0 @@
-outputFolder: target
-reportName: index.html
-catalogBeHost: behost
-catalogFeHost: fehost
-esHost: eshost
-disributionClientHost: disClient
-catalogFePort: 8181
-catalogBePort: 8080
-disributionClientPort: 8181
-esPort: 9200
-neoHost: neoHost
-neoPort: 7474
-neoDBusername: neo4j
-neoDBpassword: 123456
-
-resourceConfigDir: src/test/resources/CI/tests
-componentsConfigDir: src/test/resources/CI/components
-importResourceConfigDir: src/test/resources/CI/importResource
-importResourceTestsConfigDir: src/test/resources/CI/importResourceTests
-errorConfigurationFile: ../catalog-be/src/main/resources/config/error-configuration.yaml
-
-titanPropertiesFile: src/main/resources/ci/conf/titan.properties
-
-stopOnClassFailure: false
-
-#List of non-abstract resources to keep during titan cleanup between tests
-#Only 1.0 version will be kept
-resourcesNotToDelete:
- - tosca.nodes.Compute
- - tosca.nodes.Database
- - tosca.nodes.ObjectStorage
- - tosca.nodes.BlockStorage
- - tosca.nodes.LoadBalancer
- - org.openecomp.resource.cp.Port
- - org.openecomp.resource.vl.Network \ 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
deleted file mode 100644
index bef72a9..0000000
--- a/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-# Define the root logger with appender file
-log4j.rootLogger = DEBUG, FILE, stdout
-
-# Define the file appender
-log4j.appender.FILE=org.apache.log4j.RollingFileAppender
-log4j.appender.FILE.File=${targetlog}logs/ci-log.out
-
-# Define the layout for file appender
-log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.FILE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p [%10c] : %m%n
-
-# Set the maximum file size before rollover
-log4j.appender.FILE.maxFileSize=5MB
-
-# Set the the backup index
-log4j.appender.FILE.maxBackupIndex=10
-
-
-#############################################################
-
-# Direct log messages to stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-#log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %10c:%L - %m%n
-
-log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG
-log4j.logger.com.thinkaurelius.titan.diskstorage.cassandra.CassandraTransaction=INFO, FILE, stdout
-
-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/conf/titan.properties b/sdc-distribution-ci/src/main/resources/ci/conf/titan.properties
deleted file mode 100644
index 691f4d6..0000000
--- a/sdc-distribution-ci/src/main/resources/ci/conf/titan.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-storage.backend=cassandra
-storage.hostname=cassandrahost
-storage.port=9160
-
-cache.db-cache = false \ No newline at end of file
diff --git a/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh b/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh
deleted file mode 100644
index 7fa5323..0000000
--- a/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/bash
-
-function usage {
- echo "Usage: $0 <jar file>"
-}
-
-function exitOnError() {
- if [ $1 -ne 0 ]
- then
- echo "Failed running task $2"
- exit 2
- fi
-}
-
-if [ $# -lt 1 ]
-then
- usage
- exit 2
-fi
-
-CURRENT_DIR=`pwd`
-BASEDIR=$(dirname $0)
-
-if [ ${BASEDIR:0:1} = "/" ]
-then
- FULL_PATH=$BASEDIR
-else
- FULL_PATH=$CURRENT_DIR/$BASEDIR
-fi
-
-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.onap.sdc.ci.tests.run.StartTest
-
-JAR_FILE=$1
-
-#TARGET_DIR=`echo ${TARGET_DIR} | sed 's/\//\//g'`
-#echo $TARGET_DIR
-
-TESTS_DIR=/opt/app/sdc/ci/resources/tests
-COMPONENTS_DIR=/opt/app/sdc/ci/resources/components
-
-#sed -i 's#\(outputFolder:\).*#\1 '${TARGET_DIR}'#g' $CONF_FILE
-#sed -i 's#\(resourceConfigDir:\).*#\1 '${TESTS_DIR}'#g' $CONF_FILE
-#sed -i 's#\(componentsConfigDir:\).*#\1 '${COMPONENTS_DIR}'#g' $CONF_FILE
-TARGET_LOG_DIR="${TARGET_DIR}/"
-
-mkdir -p ${TARGET_DIR}
-if [ -d ${TARGET_DIR} ]
-then
- rm -rf ${TARGET_DIR}/*
- exitOnError $? "Failed_to_delete_target_dir"
-fi
-
-debug_port=8800
-#JAVA_OPTION="-javaagent:/var/tmp/jacoco/lib/jacocoagent.jar=destfile=jacoco-it.exec"
-JAVA_OPTION=""
-case "$2" in
- -debug) echo "Debug mode, Listen on port $debug_port"; JAVA_OPTION="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debug_port}" ;;
- "") echo "Standard mode";;
- *) echo "USAGE: startTest.sh [-debug]";;
-esac
-
-cmd="java $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass}"
-
-#echo $cmd
-#console=`$cmd`
-
-if [ $DEBUG == "true" ]
-then
- $cmd
-else
- $cmd >> /dev/null
-fi
-status=`echo $?`
-
-
-
-echo "##################################################"
-echo "################# status is ${status} #################"
-echo "##################################################"
-
-exit $status
-
diff --git a/sdc-distribution-ci/src/main/resources/log4j2.properties b/sdc-distribution-ci/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..e94d551
--- /dev/null
+++ b/sdc-distribution-ci/src/main/resources/log4j2.properties
@@ -0,0 +1,44 @@
+# Copyright 2020 Huawei Technologies Co., Ltd.
+#
+# 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.
+# By default, log4j2 will look for a configuration file named log4j2.xml on the classpath.
+# reference: https://logging.apache.org/log4j/2.x/faq.html#troubleshooting
+rootLogger.level=ERROR
+rootLogger.appenderRefs=file
+rootLogger.appenderRef.file.ref=RollingFile
+logger.onap.name = org.onap
+logger.onap.level=ERROR
+logger.onap.additivity=false
+logger.onap.appenderRef.stdout.ref=STDOUT
+appenders=stdout, file
+# Direct log messages to stdout
+appender.stdout.type=Console
+appender.stdout.name=STDOUT
+appender.stdout.target=SYSTEM_OUT
+appender.stdout.layout.type=PatternLayout
+appender.stdout.layout.pattern=%d{yyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
+# Redirect log messages to a log file, support file rolling.
+appender.file.type = RollingFile
+appender.file.name = RollingFile
+appender.file.fileName=./csar-validate.log
+appender.file.filePattern=./csar-validate.%d{yyyy-MM-dd-HH:mm:ss}.log
+appender.file.append=true
+appender.file.policies.type=Policies
+appender.file.policies.size.type=SizeBasedTriggeringPolicy
+appender.file.policies.size.size=5MB
+appender.file.strategy.type=DefaultRolloverStrategy
+appender.file.strategy.max=10
+appender.file.layout.type=PatternLayout
+appender.file.layout.pattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
+
+
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
deleted file mode 100644
index 22b1607..0000000
--- a/sdc-distribution-ci/src/test/java/org/onap/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.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<String, String> headersMap = new HashMap<String,String>();
-//// 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<String, String> headersMap = new HashMap<String,String>();
-//// 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<String> 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<String, String> headersMap = new HashMap<String,String>();
-//// 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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/onap/test/core/service/ClientInitializerTest.java b/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java
new file mode 100644
index 0000000..e4c2241
--- /dev/null
+++ b/sdc-distribution-ci/src/test/java/org/onap/test/core/service/ClientInitializerTest.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.onap.sdc.impl.DistributionClientImpl;
+import org.onap.test.core.config.DistributionClientConfig;
+import org.slf4j.Logger;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.verify;
+
+@Testcontainers
+@ExtendWith(MockitoExtension.class)
+class ClientInitializerTest {
+
+
+ public static final int SUCCESSFUL_INIT_MSG_INDEX = 0;
+ public static final int SUCCESSFUL_DIST_MSG_INDEX = 3;
+ @Container
+ public GenericContainer mockDmaap = new GenericContainer("registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-dmaap:latest")
+ .withNetworkMode("host");
+
+ @Container
+ public GenericContainer mockSdc = new GenericContainer("registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdc:latest")
+ .dependsOn(mockDmaap)
+ .withNetworkMode("host");
+ @Mock
+ Logger log;
+
+ @Test
+ public void shouldRegisterToDmaapAfterClientInitialization() {
+ //given
+ DistributionClientConfig clientConfig = new DistributionClientConfig();
+ List<ArtifactsValidator> validators = new ArrayList<>();
+ DistributionClientImpl client = new DistributionClientImpl();
+ ClientNotifyCallback callback = new ClientNotifyCallback(validators, client);
+ ClientInitializer clientInitializer = new ClientInitializer(clientConfig, callback, client);
+ final ArgumentCaptor<String> exceptionCaptor = ArgumentCaptor.forClass(String.class);
+ //when
+ clientInitializer.log = log;
+ clientInitializer.initialize();
+ verify(log, Mockito.atLeastOnce()).info(exceptionCaptor.capture());
+ List<String> allValues = exceptionCaptor.getAllValues();
+ //then
+ assertThat(allValues.get(SUCCESSFUL_INIT_MSG_INDEX)).isEqualTo("distribution client initialized successfuly");
+ assertThat(allValues.get(SUCCESSFUL_DIST_MSG_INDEX)).isEqualTo("distribution client started successfuly");
+ }
+
+} \ No newline at end of file