aboutsummaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-artifact-handler
diff options
context:
space:
mode:
Diffstat (limited to 'appc-inbound/appc-artifact-handler')
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java7
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java16
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/ArtifactHandlerProviderUtil.java282
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java2
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java42
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/MockArtifactHandlerNode.java65
6 files changed, 179 insertions, 235 deletions
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java
index 278808498..a337f0989 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java
@@ -26,6 +26,7 @@ package org.onap.appc.artifact.handler.dbservices;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import java.util.Optional;
import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
@@ -548,7 +549,7 @@ public class DBService {
return;
}
- public String getDownLoadDGReference(SvcLogicContext context) throws Exception {
+ public String getDownLoadDGReference(SvcLogicContext context) throws SvcLogicException, ConfigurationException {
String fn = "DBService.setDownLoadDGReference";
String downloadConfigDg = null;
log.info(fn + "Setting Download DG Reference from DB");
@@ -557,7 +558,7 @@ public class DBService {
String protocol = context.getAttribute(SdcArtifactHandlerConstants.DEVICE_PROTOCOL);
if (StringUtils.isBlank(protocol)) {
log.info(fn + " :: Protocol is Blank!! Returning without querying DB");
- throw new Exception(fn+":: Protocol is Blank!! Returning without querying DB");
+ throw new ConfigurationException(fn+":: Protocol is Blank!! Returning without querying DB");
}
key = "select download_config_dg from " + SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE
+ " where protocol = '" + protocol + "'";
@@ -569,7 +570,7 @@ public class DBService {
}
if (status == QueryStatus.NOT_FOUND) {
log.info(fn + ":: NOT_FOUND! No data found for download_config_dg!!");
- throw new Exception(fn + ":: NOT_FOUND! No data found for download_config_dg!");
+ throw new SvcLogicException(fn + ":: NOT_FOUND! No data found for download_config_dg!");
}
downloadConfigDg = localContext.getAttribute("download-config-dg");
log.info(fn + "download_config_dg::" + downloadConfigDg);
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java
index 455234296..0c0fa46b0 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java
@@ -75,7 +75,7 @@ import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.P
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.PORT_NUMBER;
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.REFERENCE;
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.REQUEST_INFORMATION;
-import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.REQUETS_ID;
+import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.REQUEST_ID;
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME;
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.RESOURCE_TYPE;
import static org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants.RESOURCE_UUID;
@@ -132,12 +132,12 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
} else
throw new Exception("Missing Artifact Name for Request : "
- + request_information.getString(REQUETS_ID));
+ + request_information.getString(REQUEST_ID));
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Error while processing Request ID : "
+ ((JSONObject) postDataJson.get(REQUEST_INFORMATION))
- .getString(REQUETS_ID)
+ .getString(REQUEST_ID)
+ e.getMessage());
}
return false;
@@ -443,7 +443,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
capabilities.put("vf-module", vfModuleActionList);
capabilities.put("vnfc", vnfcActionList);
capabilities.put("vm", vmActionVnfcFunctionCodesList);
- processAndStoreCapablitiesArtifact(dbservice, document_information, capabilities, capabilityArtifactName,
+ processAndStoreCapabilitiesArtifact(dbservice, document_information, capabilities, capabilityArtifactName,
vnfType);
}
@@ -471,9 +471,9 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
}
- private void processAndStoreCapablitiesArtifact(DBService dbservice, JSONObject document_information,
- JSONObject capabilities, String capabilityArtifactName, String vnfType) throws Exception {
- log.info("Begin-->processAndStoreCapablitiesArtifact ");
+ private void processAndStoreCapabilitiesArtifact(DBService dbservice, JSONObject document_information,
+ JSONObject capabilities, String capabilityArtifactName, String vnfType) throws Exception {
+ log.info("Begin-->processAndStoreCapabilitiesArtifact ");
try {
@@ -516,7 +516,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
log.error("Error saving capabilities artifact to DB: " + e.toString());
throw e;
} finally {
- log.info("End-->processAndStoreCapablitiesArtifact ");
+ log.info("End-->processAndStoreCapabilitiesArtifact ");
}
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/ArtifactHandlerProviderUtil.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/ArtifactHandlerProviderUtil.java
index ce825c553..7f10d2a84 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/ArtifactHandlerProviderUtil.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/ArtifactHandlerProviderUtil.java
@@ -40,152 +40,152 @@ import com.att.eelf.configuration.EELFManager;
public class ArtifactHandlerProviderUtil {
- public UploadartifactInput templateData ;
- SvcLogicContext context = null;
- private static final EELFLogger log = EELFManager.getInstance().getLogger(ArtifactHandlerProviderUtil.class);
- public static void loadProperties() {
- // TODO Auto-generated method stub
-
- }
- public enum DistributionStatusEnum {
- DOWNLOAD_OK,
- DOWNLOAD_ERROR,
- ALREADY_DOWNLOADED,
- DEPLOY_OK,
- DEPLOY_ERROR,
- ALREADY_DEPLOYED;
- }
+ public UploadartifactInput templateData ;
+ SvcLogicContext context = null;
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(ArtifactHandlerProviderUtil.class);
+ public static void loadProperties() {
+ // TODO Auto-generated method stub
+
+ }
+ public enum DistributionStatusEnum {
+ DOWNLOAD_OK,
+ DOWNLOAD_ERROR,
+ ALREADY_DOWNLOADED,
+ DEPLOY_OK,
+ DEPLOY_ERROR,
+ ALREADY_DEPLOYED;
+ }
- public ArtifactHandlerProviderUtil(){};
-
- public ArtifactHandlerProviderUtil(UploadartifactInput input) {
- this.templateData = input;
- log.info("templateData " + this.templateData);
- }
-
- public void processTemplate(String requestInfo) throws Exception {
- if(context == null)
- context = new SvcLogicContext();
-
- ArtifactHandlerNode node = new ArtifactHandlerNode();
- try {
-
- HashMap<String, String> processdata = new HashMap<String, String>();
- processdata.put("postData", requestInfo);
- log.info("Post data = " + requestInfo);
- node.processArtifact(processdata, context);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- log.error("Error: " + e.getMessage());
- e.printStackTrace();
- throw e;
- }
-
- }
- public String createDummyRequestData() throws JSONException, IOException{
+ public ArtifactHandlerProviderUtil(){};
+
+ public ArtifactHandlerProviderUtil(UploadartifactInput input) {
+ this.templateData = input;
+ log.info("templateData " + this.templateData);
+ }
+
+ public void processTemplate(String requestInfo) throws Exception {
+ if(context == null)
+ context = new SvcLogicContext();
+
+ ArtifactHandlerNode node = new ArtifactHandlerNode();
+ try {
+
+ HashMap<String, String> processdata = new HashMap<String, String>();
+ processdata.put("postData", requestInfo);
+ log.info("Post data = " + requestInfo);
+ node.processArtifact(processdata, context);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ log.error("Error: " + e.getMessage());
+ e.printStackTrace();
+ throw e;
+ }
+
+ }
+ public String createDummyRequestData() throws JSONException, IOException{
- JSONObject info = new JSONObject(this.templateData);
- log.info("INFO = " + info);
- String artifact_name = templateData.getDocumentParameters().getArtifactName();
- String artifact_version = templateData.getDocumentParameters().getArtifactVersion();
-
- JSONObject json = new JSONObject();
- JSONObject requestInfo = new JSONObject();
- String random = getRandom();
-
- requestInfo.put(SdcArtifactHandlerConstants.REQUETS_ID, "TLRID-" + random);
- requestInfo.put(SdcArtifactHandlerConstants.REQUEST_ACTION, "StoreSdcDocumentRequest");
- requestInfo.put(SdcArtifactHandlerConstants.SOURCE, "TemplateLoader");
-
- JSONObject docParams = new JSONObject();
- docParams.put(SdcArtifactHandlerConstants.SERVICE_UUID, "TLSUUID" + templateData.getRequestInformation().getRequestId());
- docParams.put(SdcArtifactHandlerConstants.DISTRIBUTION_ID, "TLDID" + random);
- docParams.put(SdcArtifactHandlerConstants.SERVICE_NAME, "TLServiceName");
- docParams.put(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION, "Template Loader Test");
- docParams.put(SdcArtifactHandlerConstants.SERVICE_ARTIFACTS, "[]");
- docParams.put(SdcArtifactHandlerConstants.RESOURCE_UUID, "TLRUID" + random);
- docParams.put(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME, "TLRIName");
- docParams.put(SdcArtifactHandlerConstants.REOURCE_NAME, "TLResourceName");
- docParams.put(SdcArtifactHandlerConstants.RESOURCE_VERSION, "TLResourceVersion");
- docParams.put(SdcArtifactHandlerConstants.RESOURCE_TYPE, "TLResourceType");
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_UUID, "TLAUUID" + random);
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, templateData.getDocumentParameters().getArtifactName());
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_TYPE, "APPC-CONFIG");
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_VERSION, templateData.getDocumentParameters().getArtifactVersion());
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, "SdcTestDescription");
- // String data = IOUtils.toString(TestartifactHandlerNode.class.getClassLoader().getResourceAsStream("template_msrp_msc_a_template.json"), "utf-8");
- // String data = IOUtils.toString(TemplateProcessor.class.getClassLoader().getResourceAsStream("referenceData.json"), "utf-8");
+ JSONObject info = new JSONObject(this.templateData);
+ log.info("INFO = " + info);
+ String artifact_name = templateData.getDocumentParameters().getArtifactName();
+ String artifact_version = templateData.getDocumentParameters().getArtifactVersion();
+
+ JSONObject json = new JSONObject();
+ JSONObject requestInfo = new JSONObject();
+ String random = getRandom();
+
+ requestInfo.put(SdcArtifactHandlerConstants.REQUEST_ID, "TLRID-" + random);
+ requestInfo.put(SdcArtifactHandlerConstants.REQUEST_ACTION, "StoreSdcDocumentRequest");
+ requestInfo.put(SdcArtifactHandlerConstants.SOURCE, "TemplateLoader");
+
+ JSONObject docParams = new JSONObject();
+ docParams.put(SdcArtifactHandlerConstants.SERVICE_UUID, "TLSUUID" + templateData.getRequestInformation().getRequestId());
+ docParams.put(SdcArtifactHandlerConstants.DISTRIBUTION_ID, "TLDID" + random);
+ docParams.put(SdcArtifactHandlerConstants.SERVICE_NAME, "TLServiceName");
+ docParams.put(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION, "Template Loader Test");
+ docParams.put(SdcArtifactHandlerConstants.SERVICE_ARTIFACTS, "[]");
+ docParams.put(SdcArtifactHandlerConstants.RESOURCE_UUID, "TLRUID" + random);
+ docParams.put(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME, "TLRIName");
+ docParams.put(SdcArtifactHandlerConstants.REOURCE_NAME, "TLResourceName");
+ docParams.put(SdcArtifactHandlerConstants.RESOURCE_VERSION, "TLResourceVersion");
+ docParams.put(SdcArtifactHandlerConstants.RESOURCE_TYPE, "TLResourceType");
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_UUID, "TLAUUID" + random);
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, templateData.getDocumentParameters().getArtifactName());
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_TYPE, "APPC-CONFIG");
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_VERSION, templateData.getDocumentParameters().getArtifactVersion());
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, "SdcTestDescription");
+ // String data = IOUtils.toString(TestartifactHandlerNode.class.getClassLoader().getResourceAsStream("template_msrp_msc_a_template.json"), "utf-8");
+ // String data = IOUtils.toString(TemplateProcessor.class.getClassLoader().getResourceAsStream("referenceData.json"), "utf-8");
- // this.templateData = this.templateData.substring(this.templateData.indexOf("}") + 1);
- docParams.put("artifact-contents", templateData.getDocumentParameters().getArtifactContents());
-
- json.put(SdcArtifactHandlerConstants.REQUEST_INFORMATION, requestInfo);
- json.put(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS, docParams);
- System.out.println("Final data =" + this.templateData);
- return String.format("{\"input\": %s}", json.toString());
- }
-
- private String getRandom() {
- SecureRandom random = new SecureRandom();
- int num = random.nextInt(100000);
- String formatted = String.format("%05d", num);
- return formatted;
- }
-
- public String escapeSql(String str) {
- if (str == null) {
- return null;
- }
- String searchList[] = new String[]{"'","\\"};
- String replacementList[] = new String[]{ "''","\\\\"};
- return StringUtils.replaceEach(str,searchList, replacementList);
- }
- public String createRequestData() throws JSONException, IOException{
+ // this.templateData = this.templateData.substring(this.templateData.indexOf("}") + 1);
+ docParams.put("artifact-contents", templateData.getDocumentParameters().getArtifactContents());
+
+ json.put(SdcArtifactHandlerConstants.REQUEST_INFORMATION, requestInfo);
+ json.put(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS, docParams);
+ System.out.println("Final data =" + this.templateData);
+ return String.format("{\"input\": %s}", json.toString());
+ }
+
+ private String getRandom() {
+ SecureRandom random = new SecureRandom();
+ int num = random.nextInt(100000);
+ String formatted = String.format("%05d", num);
+ return formatted;
+ }
+
+ public String escapeSql(String str) {
+ if (str == null) {
+ return null;
+ }
+ String searchList[] = new String[]{"'","\\"};
+ String replacementList[] = new String[]{ "''","\\\\"};
+ return StringUtils.replaceEach(str,searchList, replacementList);
+ }
+ public String createRequestData() throws JSONException, IOException{
- JSONObject info = new JSONObject(this.templateData);
- log.info("INFO = " + info);
-
- JSONObject json = new JSONObject();
- JSONObject requestInfo = new JSONObject();
- String random = getRandom();
-
- requestInfo.put(SdcArtifactHandlerConstants.REQUETS_ID, templateData.getRequestInformation().getRequestId());
- requestInfo.put(SdcArtifactHandlerConstants.REQUEST_ACTION, "StoreSdcDocumentRequest");
- requestInfo.put(SdcArtifactHandlerConstants.SOURCE, templateData.getRequestInformation().getSource());
-
- String serviceDescription = serviceDescriptionData(templateData.getDocumentParameters().getServiceDescription());
-
- JSONObject docParams = new JSONObject();
- docParams.put(SdcArtifactHandlerConstants.SERVICE_UUID, templateData.getDocumentParameters().getResourceUuid());
- docParams.put(SdcArtifactHandlerConstants.DISTRIBUTION_ID, templateData.getDocumentParameters().getDistributionId());
- docParams.put(SdcArtifactHandlerConstants.SERVICE_NAME, templateData.getDocumentParameters().getServiceName());
- docParams.put(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION,serviceDescription);
- docParams.put(SdcArtifactHandlerConstants.SERVICE_ARTIFACTS, templateData.getDocumentParameters().getServiceArtifacts());
- docParams.put(SdcArtifactHandlerConstants.RESOURCE_UUID, templateData.getDocumentParameters().getResourceUuid());
- docParams.put(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME, templateData.getDocumentParameters().getResourceInstanceName());
- docParams.put(SdcArtifactHandlerConstants.REOURCE_NAME, templateData.getDocumentParameters().getResourceName());
- docParams.put(SdcArtifactHandlerConstants.RESOURCE_VERSION, templateData.getDocumentParameters().getResourceVersion());
- docParams.put(SdcArtifactHandlerConstants.RESOURCE_TYPE, templateData.getDocumentParameters().getResourceType());
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_UUID, templateData.getDocumentParameters().getArtifactUuid());
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, templateData.getDocumentParameters().getArtifactName());
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_TYPE, templateData.getDocumentParameters().getArtifactType());
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_VERSION, templateData.getDocumentParameters().getArtifactVersion());
- docParams.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, templateData.getDocumentParameters().getArtifactDescription());
+ JSONObject info = new JSONObject(this.templateData);
+ log.info("INFO = " + info);
+
+ JSONObject json = new JSONObject();
+ JSONObject requestInfo = new JSONObject();
+ String random = getRandom();
+
+ requestInfo.put(SdcArtifactHandlerConstants.REQUEST_ID, templateData.getRequestInformation().getRequestId());
+ requestInfo.put(SdcArtifactHandlerConstants.REQUEST_ACTION, "StoreSdcDocumentRequest");
+ requestInfo.put(SdcArtifactHandlerConstants.SOURCE, templateData.getRequestInformation().getSource());
+
+ String serviceDescription = serviceDescriptionData(templateData.getDocumentParameters().getServiceDescription());
+
+ JSONObject docParams = new JSONObject();
+ docParams.put(SdcArtifactHandlerConstants.SERVICE_UUID, templateData.getDocumentParameters().getResourceUuid());
+ docParams.put(SdcArtifactHandlerConstants.DISTRIBUTION_ID, templateData.getDocumentParameters().getDistributionId());
+ docParams.put(SdcArtifactHandlerConstants.SERVICE_NAME, templateData.getDocumentParameters().getServiceName());
+ docParams.put(SdcArtifactHandlerConstants.SERVICE_DESCRIPTION,serviceDescription);
+ docParams.put(SdcArtifactHandlerConstants.SERVICE_ARTIFACTS, templateData.getDocumentParameters().getServiceArtifacts());
+ docParams.put(SdcArtifactHandlerConstants.RESOURCE_UUID, templateData.getDocumentParameters().getResourceUuid());
+ docParams.put(SdcArtifactHandlerConstants.RESOURCE_INSTANCE_NAME, templateData.getDocumentParameters().getResourceInstanceName());
+ docParams.put(SdcArtifactHandlerConstants.REOURCE_NAME, templateData.getDocumentParameters().getResourceName());
+ docParams.put(SdcArtifactHandlerConstants.RESOURCE_VERSION, templateData.getDocumentParameters().getResourceVersion());
+ docParams.put(SdcArtifactHandlerConstants.RESOURCE_TYPE, templateData.getDocumentParameters().getResourceType());
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_UUID, templateData.getDocumentParameters().getArtifactUuid());
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, templateData.getDocumentParameters().getArtifactName());
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_TYPE, templateData.getDocumentParameters().getArtifactType());
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_VERSION, templateData.getDocumentParameters().getArtifactVersion());
+ docParams.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, templateData.getDocumentParameters().getArtifactDescription());
- docParams.put("artifact-contents", templateData.getDocumentParameters().getArtifactContents());
-
- json.put(SdcArtifactHandlerConstants.REQUEST_INFORMATION, requestInfo);
- json.put(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS, docParams);
- System.out.println("Final data =" + this.templateData);
- return String.format("{\"input\": %s}", json.toString());
- }
-
- private String serviceDescriptionData(String serviceDescription){
- if(!StringUtils.isBlank(serviceDescription)&&serviceDescription.length()>255){
- serviceDescription = serviceDescription.substring(0, 255);
- }
- return serviceDescription;
- }
+ docParams.put("artifact-contents", templateData.getDocumentParameters().getArtifactContents());
+
+ json.put(SdcArtifactHandlerConstants.REQUEST_INFORMATION, requestInfo);
+ json.put(SdcArtifactHandlerConstants.DOCUMENT_PARAMETERS, docParams);
+ System.out.println("Final data =" + this.templateData);
+ return String.format("{\"input\": %s}", json.toString());
+ }
+
+ private String serviceDescriptionData(String serviceDescription){
+ if(!StringUtils.isBlank(serviceDescription)&&serviceDescription.length()>255){
+ serviceDescription = serviceDescription.substring(0, 255);
+ }
+ return serviceDescription;
+ }
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java
index 6bd15fba9..4f4525dd1 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/utils/SdcArtifactHandlerConstants.java
@@ -29,7 +29,7 @@ public class SdcArtifactHandlerConstants {
public static final String DOCUMENT_PARAMETERS = "document-parameters";
public static final String SERVICE_UUID = "service-uuid";
public static final String DISTRIBUTION_ID = "distribution-id";
- public static final String REQUETS_ID = "request-id";
+ public static final String REQUEST_ID = "request-id";
public static final String REQUEST_ACTION = "request-action";
public static final String SOURCE = "source";
public static final String SERVICE_NAME = "service-name";
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java
index 6a90a7e77..c7f18d777 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNodeTest.java
@@ -24,31 +24,43 @@
package org.onap.appc.artifact.handler.node;
-import java.nio.charset.Charset;
-
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.powermock.reflect.Whitebox;
-import static org.junit.Assert.assertTrue;
-
import org.onap.appc.artifact.handler.dbservices.MockDBService;
import org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
import org.onap.appc.artifact.handler.utils.ArtifactHandlerProviderUtilTest;
-
import java.util.Map;
import java.util.HashMap;
+import java.nio.charset.Charset;
+
+import static org.junit.Assert.assertTrue;
public class ArtifactHandlerNodeTest {
+ private ArtifactHandlerNode artifactHandlerNode;
+
+ @Before
+ public void setUp() throws Exception {
+ artifactHandlerNode = Mockito.spy(ArtifactHandlerNode.class);
+ Mockito.doReturn(true)
+ .when(artifactHandlerNode)
+ .updateStoreArtifacts(Mockito.any(JSONObject.class), Mockito.any(JSONObject.class));
+ Mockito.doReturn(true)
+ .when(artifactHandlerNode)
+ .storeReferenceData(Mockito.any(JSONObject.class), Mockito.any(JSONObject.class));
+ }
+
@Test
public void testProcessArtifact() throws Exception {
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("test", "test");
- MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
- Map<String, String> inParams = new HashMap<String, String>();
+ Map<String, String> inParams = new HashMap<>();
JSONObject postData = new JSONObject();
JSONObject input = new JSONObject();
inParams.put("response_prefix", "prefix");
@@ -63,13 +75,12 @@ public class ArtifactHandlerNodeTest {
input.put(SdcArtifactHandlerConstants.REQUEST_INFORMATION, requestInfo);
postData.put("input", input);
inParams.put("postData", postData.toString());
- ah.processArtifact(inParams, ctx);
+ artifactHandlerNode.processArtifact(inParams, ctx);
}
@Ignore("Test is taking 60 seconds")
@Test(expected = Exception.class)
public void testStoreReferenceData() throws Exception {
- MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
JSONObject documentInfo = new JSONObject();
String artifactContent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
.getResourceAsStream("templates/reference_template"), Charset.defaultCharset());
@@ -77,7 +88,7 @@ public class ArtifactHandlerNodeTest {
documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, "reference_Junit.json");
JSONObject requestInfo = new JSONObject();
requestInfo.put("RequestInfo", "testStoreReferenceData");
- ah.storeReferenceData(requestInfo, documentInfo);
+ artifactHandlerNode.storeReferenceData(requestInfo, documentInfo);
}
@Test
@@ -107,7 +118,7 @@ public class ArtifactHandlerNodeTest {
documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_UUID, "testArtifactUuid");
documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_VERSION, "testArtifactVers");
documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_DESRIPTION, "testArtifactDesc");
- Whitebox.invokeMethod(ah, "processAndStoreCapablitiesArtifact", dbService, documentInfo, capabilities,
+ Whitebox.invokeMethod(ah, "processAndStoreCapabilitiesArtifact", dbService, documentInfo, capabilities,
"artifactName", "someVnf");
}
@@ -140,7 +151,6 @@ public class ArtifactHandlerNodeTest {
@Ignore("Test is taking 60 seconds")
@Test(expected = Exception.class)
public void testUpdateStoreArtifacts() throws Exception {
- MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
JSONObject documentInfo = new JSONObject();
String artifactContent = IOUtils.toString(ArtifactHandlerProviderUtilTest.class.getClassLoader()
.getResourceAsStream("templates/reference_template"), Charset.defaultCharset());
@@ -148,23 +158,21 @@ public class ArtifactHandlerNodeTest {
documentInfo.put(SdcArtifactHandlerConstants.ARTIFACT_NAME, "reference_Junit.json");
JSONObject requestInfo = new JSONObject();
requestInfo.put("RequestInfo", "testupdateStoreArtifacts");
- ah.updateStoreArtifacts(requestInfo, documentInfo);
+ artifactHandlerNode.updateStoreArtifacts(requestInfo, documentInfo);
}
@Test
public void testCleanArtifactInstanceData() throws Exception {
- MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
SvcLogicContext ctx = new SvcLogicContext();
- Whitebox.invokeMethod(ah, "cleanArtifactInstanceData", ctx);
+ Whitebox.invokeMethod(artifactHandlerNode, "cleanArtifactInstanceData", ctx);
}
@Ignore("Test is taking 60 seconds")
@Test(expected = Exception.class)
public void testUpdateYangContents() throws Exception {
- MockArtifactHandlerNode ah = new MockArtifactHandlerNode();
String artifactId = "1";
String yangContents = "SomeContent";
- Whitebox.invokeMethod(ah, "updateYangContents", artifactId, yangContents);
+ Whitebox.invokeMethod(artifactHandlerNode, "updateYangContents", artifactId, yangContents);
}
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/MockArtifactHandlerNode.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/MockArtifactHandlerNode.java
deleted file mode 100644
index 39706a282..000000000
--- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/node/MockArtifactHandlerNode.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.artifact.handler.node;
-
-import org.json.JSONObject;
-import org.onap.appc.artifact.handler.dbservices.MockDBService;
-import org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
-public class MockArtifactHandlerNode extends ArtifactHandlerNode {
-
- @Override
- public boolean updateStoreArtifacts(JSONObject request_information, JSONObject document_information)
- throws Exception {
- if (request_information != null && request_information.get("RequestInfo").equals("testupdateStoreArtifacts")) {
- super.updateStoreArtifacts(request_information, document_information);
- }
- SvcLogicContext context = new SvcLogicContext();
- MockDBService dbservice = MockDBService.initialise();
- int intversion = 0;
- context.setAttribute("artifact_name",
- document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME));
- String internal_version = dbservice.getInternalVersionNumber(context,
- document_information.getString(SdcArtifactHandlerConstants.ARTIFACT_NAME), null);
- if (internal_version != null) {
- intversion = Integer.parseInt(internal_version);
- intversion++;
- }
-
- return true;
-
- }
-
- @Override
- public boolean storeReferenceData(JSONObject request_information, JSONObject document_information)
- throws Exception {
- if (request_information != null && request_information.get("RequestInfo").equals("testStoreReferenceData")) {
- super.storeReferenceData(request_information, document_information);
- }
- return true;
- }
-
-}