aboutsummaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-artifact-handler/provider/src/main
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-01-22 14:16:57 +0000
committerTakamune Cho <takamune.cho@att.com>2019-01-22 20:36:40 +0000
commitbe51f642321d0e79a5b97936c40fae448bf9881a (patch)
treef2cb298087357c8ec64f7b8c5ffcfd00dbecec81 /appc-inbound/appc-artifact-handler/provider/src/main
parent27543757355a584901f8d2cb5ca0b2dffe31a628 (diff)
Increase coverage in artifact-handler-node package
Increased coverage from 56% to 93% Issue-ID: APPC-1335 Change-Id: I65ed7979141a035444ff45e7540d7fb022d24355 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-inbound/appc-artifact-handler/provider/src/main')
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/dbservices/DBService.java6
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerInternalException.java21
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerNode.java26
3 files changed, 39 insertions, 14 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 cf45bc32e..758869f24 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
@@ -224,7 +224,7 @@ public class DBService {
if( db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE) && StringUtils.isNotBlank(modelId)) {
log.info("ModelId is sent!!");
String queryPart = createQueryListForTemplateIds(modelId);
- log.info("Querypart is = "+queryPart);
+ log.info("Querypart is = " + queryPart);
if (isUpdateRequiredForTemplates(queryPart, context, db)) {
log.info("Update is Required!!");
return true;
@@ -370,7 +370,7 @@ public class DBService {
}
log.info("Starting DB operation for Device authentication " + isUpdate);
- log.info("credentials"+user + "user" + "port" + port +"protocol"+protocol+"action"+action+"vnftype"+vnftype);
+ log.info("credentials"+user + "user" + "port" + port +"protocol" + protocol + "action" + action + "vnftype" + vnftype);
String key;
QueryStatus status;
if (isUpdate) {
@@ -712,7 +712,7 @@ public class DBService {
}
public String createQueryListForTemplateIds(String modelId) {
- String queryPart = " AND ARTIFACT_NAME like '%_" + modelId+".%'";
+ String queryPart = " AND ARTIFACT_NAME like '%_" + modelId + ".%'";
return queryPart;
}
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerInternalException.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerInternalException.java
index e79bcc15d..9f3b6d55d 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerInternalException.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/node/ArtifactHandlerInternalException.java
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 Ericsson
+ * ================================================================================
+ * 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.appc.artifact.handler.node;
class ArtifactHandlerInternalException extends Exception{
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 4118d6822..0b8aa5f81 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
@@ -5,6 +5,8 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -137,7 +139,6 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
JSONObject requestInfo = (JSONObject) postDataJson.get(REQUEST_INFORMATION);
JSONObject documentInfo = (JSONObject) postDataJson.get(DOCUMENT_PARAMETERS);
String artifactName = documentInfo.getString(ARTIFACT_NAME);
-
if (artifactName != null) {
updateStoreArtifacts(requestInfo, documentInfo);
if (artifactName.toLowerCase().startsWith(REFERENCE)) {
@@ -165,7 +166,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
String fn = "ArtifactHandlerNode.createReferenceDataForPD";
String artifactName = documentInfo.getString(ARTIFACT_NAME);
- log.info(fn + "Received PD File Name: " + artifactName + " and suffix lenght "
+ log.info(fn + "Received PD File Name: " + artifactName + " and suffix length "
+ PD.length());
try {
@@ -190,7 +191,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
// Tosca generation
OutputStream toscaStream = new ByteArrayOutputStream();
String toscaContents;
- ArtifactProcessorImpl toscaGenerator = new ArtifactProcessorImpl();
+ ArtifactProcessorImpl toscaGenerator = getArtifactProcessorImpl();
toscaGenerator.generateArtifact(pdFileContents, toscaStream);
toscaContents = toscaStream.toString();
log.info("Generated Tosca File : " + toscaContents);
@@ -242,7 +243,6 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
protected boolean updateStoreArtifacts(JSONObject requestInfo, JSONObject documentInfo)
throws SvcLogicException {
log.info("UpdateStoreArtifactsStarted storing of SDC Artifacs ");
-
SvcLogicContext context = new SvcLogicContext();
DBService dbservice = DBService.initialise();
ArtifactHandlerProviderUtil ahpUtil = new ArtifactHandlerProviderUtil();
@@ -277,6 +277,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
public boolean storeReferenceData(JSONObject requestInfo, JSONObject documentInfo)
throws ArtifactHandlerInternalException {
+
log.info("Started storing of SDC Artifacs into Handler");
try {
DBService dbservice = DBService.initialise();
@@ -297,7 +298,6 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
JSONObject contentObject = new JSONObject(contentString);
JSONArray contentArray = contentObject.getJSONArray("reference_data");
boolean storeCapabilityArtifact = true;
-
for (int a = 0; a < contentArray.length(); a++) {
JSONObject content = (JSONObject) contentArray.get(a);
log.info("contentString =" + content.toString());
@@ -460,10 +460,10 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
log.info("artifact is " + artifact);
//Get Model details
- if (null != templateIdList && i>0 && i%2==0) {//Should this be changed to 3 to account for 3 artifacts
+ if (null != templateIdList && i>0 && i%2 == 0) {//Should this be changed to 3 to account for 3 artifacts
modelInd++;
}
- if (null != vnfcTypeList && i>0 && i%3==0) {
+ if (null != vnfcTypeList && i>0 && i%3 == 0) {
//TDP 517180 - CD tool has made changes to send 3 artifacts instead of 2
vnfcRefInd++;
}
@@ -482,18 +482,18 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
if (null != templateIdList && modelInd < templateIdList.length()) {
model = templateIdList.getString(modelInd);
- log.info("Model is ::: "+model+" ,modelInd = "+modelInd);
+ log.info("Model is ::: "+model+" ,modelInd = " + modelInd);
}
if (null != vnfcTypeList && vnfcRefInd < vnfcTypeList.length() ) {
String vnfcType = vnfcTypeList.getString(vnfcRefInd);
if (StringUtils.isNotBlank(vnfcType)) {
context.setAttribute(VNFC_TYPE, vnfcType);
}
- log.info("Setting vnfc type from vnfc-type-list ::"+vnfcType);
+ log.info("Setting vnfc type from vnfc-type-list ::" + vnfcType);
}
if (StringUtils.isNotBlank(model)) {
dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context,
- DB_SDC_REFERENCE, model),model);
+ DB_SDC_REFERENCE, model), model);
}
else {
dbservice.processSdcReferences(context, dbservice.isArtifactUpdateRequired(context,
@@ -505,7 +505,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
if (pdFile) {
log.info("Sending information related to pdfile Artifact");
tryUpdateContext(dbservice, context, pdFile, suffix, model);
- pdFile=false;//set to false afterprocessing yang and Tosca
+ pdFile = false;//set to false afterprocessing yang and Tosca
}
}
@@ -754,4 +754,8 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
}
return null;
}
+
+ protected ArtifactProcessorImpl getArtifactProcessorImpl() {
+ return new ArtifactProcessorImpl();
+ }
}