summaryrefslogtreecommitdiffstats
path: root/distribution-ci/src/main/java/org/openecomp/test
diff options
context:
space:
mode:
Diffstat (limited to 'distribution-ci/src/main/java/org/openecomp/test')
-rw-r--r--distribution-ci/src/main/java/org/openecomp/test/BaseInit.java122
-rw-r--r--distribution-ci/src/main/java/org/openecomp/test/CallableTask.java57
-rw-r--r--distribution-ci/src/main/java/org/openecomp/test/ClientTest.java33
-rw-r--r--distribution-ci/src/main/java/org/openecomp/test/E2eFlows.java108
-rw-r--r--distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java19
-rw-r--r--distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java275
-rw-r--r--distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java149
7 files changed, 763 insertions, 0 deletions
diff --git a/distribution-ci/src/main/java/org/openecomp/test/BaseInit.java b/distribution-ci/src/main/java/org/openecomp/test/BaseInit.java
new file mode 100644
index 0000000000..b056b35b75
--- /dev/null
+++ b/distribution-ci/src/main/java/org/openecomp/test/BaseInit.java
@@ -0,0 +1,122 @@
+package org.openecomp.test;
+
+//import static org.junit.Assert.assertNotNull;
+//import static org.junit.Assert.assertTrue;
+//
+//import java.io.IOException;
+//
+//import org.junit.Before;
+//import org.junit.rules.TestName;
+//
+//import org.openecomp.sdc.be.model.User;
+//import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
+//import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
+//import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
+//import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
+//import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
+//import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+////import org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest;
+//import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+//import org.openecomp.sdc.ci.tests.datatypes.ComponentInstanceReqDetails;
+//import org.openecomp.sdc.ci.tests.utils.ArtifactUtils;
+//import org.openecomp.sdc.ci.tests.utils.DbUtils;
+////import org.openecomp.sdc.ci.tests.utils.ResourceUtils;
+////import org.openecomp.sdc.ci.tests.utils.ServiceUtils;
+//import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+//import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
+//import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
+//import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
+//import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
+//import org.openecomp.sdc.common.api.ArtifactTypeEnum;
+
+public abstract class BaseInit {
+
+
+// protected ResourceReqDetails resourceDetails;
+// protected ResourceReqDetails resourceDetails1;
+// protected ServiceReqDetails serviceDetails;
+// protected ServiceReqDetails serviceDetails2;
+// protected ComponentInstanceReqDetails resourceInstanceReqDetails;
+// protected ComponentInstanceReqDetails resourceInstanceReqDetails2;
+// protected User sdncDesignerDetails1;
+// protected User sdncTesterDeatails1;
+// protected User sdncAdminDetails1;
+// protected ArtifactReqDetails heatArtifactDetails;
+//
+// protected ArtifactReqDetails defaultArtifactDetails;
+// //protected ResourceUtils resourceUtils;
+// protected ArtifactUtils artifactUtils;
+//
+//
+// //static ServiceUtils serviceUtils = new ServiceUtils();
+// public BaseInit(TestName testName, String className) {
+// super(testName, className);
+// }
+// @Before
+// public void before() throws Exception{
+//
+// initializeMembers();
+//
+// createComponents();
+//
+// }
+// public void initializeMembers() throws IOException, Exception {
+//
+// resourceDetails = ElementFactory.getDefaultResource();
+// resourceDetails1 = ElementFactory.getDefaultResource("secondResource", NormativeTypesEnum.ROOT);
+// serviceDetails = ElementFactory.getDefaultService();
+// serviceDetails2 = ElementFactory.getDefaultService("newTestService2", ServiceCategoriesEnum.MOBILITY, "al1976");
+// sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
+// sdncTesterDeatails1 = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
+// sdncAdminDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
+// heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
+// resourceInstanceReqDetails = ElementFactory.getDefaultComponentInstance();
+// resourceInstanceReqDetails2 = ElementFactory.getDefaultComponentInstance();
+//
+// }
+// protected void createComponents() throws Exception{
+//
+//// Create resources
+// RestResponse response = ResourceRestUtils.createResource(resourceDetails, sdncDesignerDetails1);
+// assertTrue("create request returned status:" + response.getErrorCode(),response.getErrorCode() == 201);
+// assertNotNull("resource uniqueId is null:", resourceDetails.getUniqueId());
+//
+// response = ResourceRestUtils.createResource(resourceDetails1, sdncDesignerDetails1);
+// assertTrue("create request returned status:" + response.getErrorCode(),response.getErrorCode() == 201);
+// assertNotNull("resource uniqueId is null:", resourceDetails1.getUniqueId());
+//
+//// Create services
+// response = ServiceRestUtils.createService(serviceDetails, sdncDesignerDetails1);
+// assertTrue("create request returned status:" + response.getErrorCode(),response.getErrorCode() == 201);
+// assertNotNull("service uniqueId is null:", serviceDetails.getUniqueId());
+//
+// response = ServiceRestUtils.createService(serviceDetails2, sdncDesignerDetails1);
+// assertTrue("create request returned status:" + response.getErrorCode(),response.getErrorCode() == 201);
+// assertNotNull("service uniqueId is null:", serviceDetails2.getUniqueId());
+//
+// ArtifactReqDetails heatArtifactDetails = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
+// response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails, sdncDesignerDetails1, resourceDetails.getUniqueId());
+// assertTrue("add HEAT artifact to resource request returned status:" + response.getErrorCode(),response.getErrorCode() == 200);
+//
+// ArtifactReqDetails heatArtifactDetails1 = ElementFactory.getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
+// response = ArtifactRestUtils.addInformationalArtifactToResource(heatArtifactDetails1, sdncDesignerDetails1, resourceDetails1.getUniqueId());
+// assertTrue("add HEAT artifact to resource request returned status:" + response.getErrorCode(),response.getErrorCode() == 200);
+//
+// // certified resources
+//// response = LCSbaseTest.certifyResource(resourceDetails);
+//// assertTrue("certify resource request returned status:" + response.getErrorCode(),response.getErrorCode() == 200);
+////
+//// response = LCSbaseTest.certifyResource(resourceDetails1);
+//// assertTrue("certify resource request returned status:" + response.getErrorCode(),response.getErrorCode() == 200);
+////
+//// add resource instance with HEAT deployment artifact to the service
+// resourceInstanceReqDetails.setUniqueId(resourceDetails.getUniqueId());
+//// response = ServiceUtils.createResourceInstance(resourceInstanceReqDetails, sdncDesignerDetails1, serviceDetails.getUniqueId());
+//// assertTrue("response code is not 200, returned: " + response.getErrorCode(),response.getErrorCode() == 200);
+//
+// DbUtils.cleanAllAudits();
+//
+//
+// }
+
+}
diff --git a/distribution-ci/src/main/java/org/openecomp/test/CallableTask.java b/distribution-ci/src/main/java/org/openecomp/test/CallableTask.java
new file mode 100644
index 0000000000..814fe9ae46
--- /dev/null
+++ b/distribution-ci/src/main/java/org/openecomp/test/CallableTask.java
@@ -0,0 +1,57 @@
+package org.openecomp.test;
+
+//import java.util.concurrent.Callable;
+//
+//import org.openecomp.sdc.api.IDistributionClient;
+//import org.openecomp.sdc.api.results.IDistributionClientResult;
+//import org.openecomp.sdc.impl.DistributionClientFactory;
+//import org.openecomp.sdc.be.model.Service;
+//import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
+
+public class CallableTask {
+
+// NotificationCallback notifCallback = null;
+// //private ServiceUtils serviceUtils;
+// private Service service;
+//
+// //public CallableTask(ServiceUtils serviceUtils, Service service) {
+// public CallableTask(Service service) {
+// //this.serviceUtils = serviceUtils;
+// this.service = service;
+// }
+//
+// public NotificationCallback getNotifCallback() {
+// return notifCallback;
+// }
+//
+// @Override
+// public Boolean call() throws Exception {
+//
+// IDistributionClient client = DistributionClientFactory.createDistributionClient();
+//
+// notifCallback = new NotificationCallback(client);
+// IDistributionClientResult result = client.init(new SimpleConfiguration(), notifCallback);
+//
+// System.out.println("result.getDistributionMessageResult: " + result.getDistributionMessageResult());
+//
+// System.out.println("Starting client...");
+// IDistributionClientResult start = client.start();
+// System.out.println(start.getDistributionMessageResult());
+//
+//// RestResponse changeStateToDISTRIBUTED = serviceUtils.changeStateToDISTRIBUTED(service, UserUtils.getGovernorDetails1());
+// ServiceReqDetails serviceDetails = new ServiceReqDetails();
+// serviceDetails.setUniqueId(service.getUniqueId());
+// //RestResponse changeStateToDISTRIBUTED = serviceUtils.changeDistributionStatus(serviceDetails, "1.0", UserUtils.getGovernorDetails1(), "change", DistributionStatusEnum.DISTRIBUTED);
+// //assertTrue("response code is not 200, returned :" + changeStateToDISTRIBUTED.getErrorCode(), changeStateToDISTRIBUTED.getErrorCode() == 200);
+//
+//
+//// while (simpleCallback.getSimpleCallbackResults().size()<3){
+// System.err.println("Sleeping...");
+// Thread.sleep(5000);
+// System.err.println("Finished Sleeping...");
+//// }
+//
+// return true;
+// }
+
+}
diff --git a/distribution-ci/src/main/java/org/openecomp/test/ClientTest.java b/distribution-ci/src/main/java/org/openecomp/test/ClientTest.java
new file mode 100644
index 0000000000..1a10860828
--- /dev/null
+++ b/distribution-ci/src/main/java/org/openecomp/test/ClientTest.java
@@ -0,0 +1,33 @@
+package org.openecomp.test;
+
+import org.slf4j.LoggerFactory;
+
+import org.openecomp.sdc.api.IDistributionClient;
+import org.openecomp.sdc.api.results.IDistributionClientResult;
+import org.openecomp.sdc.impl.DistributionClientFactory;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.LoggerContext;
+
+public class ClientTest {
+ public static void main(String[] args) throws InterruptedException {
+
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ lc.getLogger("org.apache.http").setLevel(Level.INFO);
+
+ IDistributionClient client = DistributionClientFactory.createDistributionClient();
+
+ IDistributionClientResult result = client.init(new SimpleConfiguration(), new NotificationCallback(client));
+ System.out.println(result.getDistributionMessageResult());
+
+ System.out.println("Starting client...");
+ IDistributionClientResult startResult = client.start();
+
+ // Thread.sleep(10000);
+ // client.stop();
+
+ System.out.println(startResult.getDistributionMessageResult());
+
+ }
+
+}
diff --git a/distribution-ci/src/main/java/org/openecomp/test/E2eFlows.java b/distribution-ci/src/main/java/org/openecomp/test/E2eFlows.java
new file mode 100644
index 0000000000..521fc21312
--- /dev/null
+++ b/distribution-ci/src/main/java/org/openecomp/test/E2eFlows.java
@@ -0,0 +1,108 @@
+package org.openecomp.test;
+
+import org.junit.rules.TestName;
+
+//import static org.junit.Assert.assertTrue;
+//
+//import java.util.concurrent.ExecutorService;
+//import java.util.concurrent.Executors;
+//import java.util.concurrent.Future;
+//import java.util.concurrent.TimeUnit;
+//
+//import org.junit.After;
+//import org.junit.Test;
+//import org.junit.rules.TestName;
+//
+//import org.openecomp.sdc.api.IDistributionClient;
+//import org.openecomp.sdc.api.notification.IArtifactInfo;
+//import org.openecomp.sdc.api.notification.INotificationData;
+//import org.openecomp.sdc.api.results.IDistributionClientResult;
+//import org.openecomp.sdc.impl.DistributionClientFactory;
+//import org.openecomp.sdc.utils.DistributionActionResultEnum;
+//import org.openecomp.sdc.be.model.DistributionStatusEnum;
+//import org.openecomp.sdc.be.model.Service;
+//import org.openecomp.sdc.ci.tests.execute.lifecycle.LCSbaseTest;
+//import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+////import org.openecomp.sdc.ci.tests.users.UserUtils;
+//import org.openecomp.sdc.ci.tests.utils.DbUtils;
+//import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
+
+public class E2eFlows {
+
+
+
+// private IDistributionClient client = DistributionClientFactory.createDistributionClient();
+// private ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
+//
+// private CallableTask callableTask;
+// private NotificationCallback notifCallback;
+// private IArtifactInfo iArtifactInfo;
+//
+
+
+//
+// @After
+// public void after() throws Exception {
+// client.stop();
+// Thread.sleep(5000);
+// }
+//
+// // ---------------------------------Success
+// // scenario--------------------------------------------------------------------------------
+//
+// @Test
+// public void distributeService() throws Exception{
+// createServiceReadyForDistribution();
+// //RestResponse changeStateToDISTRIBUTED = serviceUtils.changeDistributionStatus(serviceDetails, "1.0", UserUtils.getGovernorDetails1(), "change", DistributionStatusEnum.DISTRIBUTED);
+// //assertTrue("response code is not 200, returned :" + changeStateToDISTRIBUTED.getErrorCode(), changeStateToDISTRIBUTED.getErrorCode() == 200);
+//
+// }
+// @Test
+// public void E2E_Success() throws Exception {
+// Service service = createServiceReadyForDistribution();
+//
+//// clean audit
+// DbUtils.cleanAllAudits();
+//
+// //Create task to run in BG
+// callableTask = new CallableTask(service);
+//
+// //Run the task in BG
+// System.err.println("Executing Task...");
+// Future<Boolean> f = newSingleThreadExecutor.submit(callableTask);
+//
+// //Wait for task to complete and return with result
+//
+//// while (!f.isDone()){
+// System.err.println("Waiting for result...");
+// // Thread.sleep(30000);
+//// }
+// Boolean result = f.get(15, TimeUnit.SECONDS);
+//
+// System.out.println("future:" + result);
+//
+// //Check Results
+// notifCallback = callableTask.getNotifCallback();
+//
+// INotificationData data = notifCallback.getData();
+//
+// System.out.println("result map size = "+ notifCallback.getSimpleCallbackResults().size());
+// IDistributionClientResult downloadResult = notifCallback.getSimpleCallbackResults().get("downloadResult");
+// assertTrue("response code is not SUCCESS, returned :"+ downloadResult.getDistributionActionResult(),downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS);
+//
+// }
+//
+//
+// private Service createServiceReadyForDistribution() throws Exception {
+//// RestResponse response = LCSbaseTest.certifyService(serviceDetails);
+//// assertTrue("response code is not 200, returned :" + response.getErrorCode(), response.getErrorCode() == 200);
+//// Service service = ResponseParser.convertServiceResponseToJavaObject(response.getResponse());
+////
+//// RestResponse changeDistributionStateToApprove = serviceUtils.changeDistributionStateToApprove(service,UserUtils.getGovernorDetails1());
+//// assertTrue("response code is not 200, returned :" + changeDistributionStateToApprove.getErrorCode(), changeDistributionStateToApprove.getErrorCode() == 200);
+//// service = ResponseParser.convertServiceResponseToJavaObject(changeDistributionStateToApprove.getResponse());
+//// return service;
+// return null;
+// }
+
+}
diff --git a/distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java b/distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java
new file mode 100644
index 0000000000..247b9a9984
--- /dev/null
+++ b/distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java
@@ -0,0 +1,19 @@
+package org.openecomp.test;
+
+import org.openecomp.sdc.api.IDistributionClient;
+import org.openecomp.sdc.api.notification.INotificationData;
+
+public class NotificationCallback extends SimpleCallback{
+ INotificationData latestCallbackData;
+ public INotificationData getData() {
+ return latestCallbackData;
+ }
+ public NotificationCallback(IDistributionClient client) {
+ super(client);
+ }
+
+ public void activateCallback(INotificationData data) {
+ this.latestCallbackData = data;
+ super.activateCallback(data);
+ }
+}
diff --git a/distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java b/distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java
new file mode 100644
index 0000000000..a7b2311867
--- /dev/null
+++ b/distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java
@@ -0,0 +1,275 @@
+package org.openecomp.test;
+
+import static org.junit.Assert.*;
+
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.apache.commons.codec.binary.Base64;
+
+import org.openecomp.sdc.api.IDistributionClient;
+import org.openecomp.sdc.api.consumer.IDistributionStatusMessage;
+import org.openecomp.sdc.api.consumer.INotificationCallback;
+import org.openecomp.sdc.api.notification.IArtifactInfo;
+import org.openecomp.sdc.api.notification.INotificationData;
+import org.openecomp.sdc.api.notification.IResourceInstance;
+import org.openecomp.sdc.api.notification.IVfModuleMetadata;
+import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
+import org.openecomp.sdc.api.results.IDistributionClientResult;
+import org.openecomp.sdc.utils.ArtifactTypeEnum;
+import org.openecomp.sdc.utils.DistributionActionResultEnum;
+import org.openecomp.sdc.utils.DistributionStatusEnum;
+import org.openecomp.sdc.ci.tests.utils.Decoder;
+import org.openecomp.sdc.ci.tests.utils.general.FileUtils;
+import com.google.common.io.BaseEncoding;
+
+public class SimpleCallback implements INotificationCallback {
+ private 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);
+ } 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) {
+ // 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();
+ 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;
+ }
+
+ private 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() {
+ 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/distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java b/distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java
new file mode 100644
index 0000000000..7f2ff91906
--- /dev/null
+++ b/distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java
@@ -0,0 +1,149 @@
+package org.openecomp.test;
+
+import java.util.List;
+
+import org.openecomp.sdc.api.consumer.IConfiguration;
+import org.openecomp.sdc.common.api.ArtifactTypeEnum;
+
+public class SimpleConfiguration implements IConfiguration{
+
+// public String getUser()
+// {
+// return System.getProperty("user");
+// }
+//
+// public List<String> getRelevantArtifactTypes() {
+// List<String> res = new ArrayList<String>();
+// for (ArtifactTypeEnum type : ArtifactTypeEnum.values()){
+// res.add(type.name());
+// }
+// return res;
+// }
+//
+// 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";
+// }
+
+
+
+ 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-Rom";
+ }
+
+ public String getConsumerID() {
+ return "ys9693-groupVasya";
+ }
+
+ public String getConsumerGroup() {
+// return "mso-groupTedy";
+ return "ys9693-consumerVasya";
+ }
+
+ public String getAsdcAddress() {
+ return "127.0.0.1:8443";
+
+ }
+
+ @Override
+ public String getKeyStorePath() {
+ //return "";
+ return "etc/asdc-client.jks";
+ }
+
+ @Override
+ public String getKeyStorePassword() {
+
+ return "Aa123456";
+ }
+
+ @Override
+ public boolean activateServerTLSAuth() {
+
+ return false;
+ }
+
+}