aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-data-services/provider/src/main
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-27 19:27:19 +0000
committerTakamune Cho <takamune.cho@att.com>2019-02-27 22:48:13 +0000
commitd1a56a7bef30e17462ded7bd9e14449985a32db4 (patch)
tree158beaca3c074f5cc513b5cc34a74cbe6af4fd22 /appc-config/appc-data-services/provider/src/main
parentde4fcf5171fcc7713b83722906ca4364d253abe8 (diff)
Test coverage in ConfigResourceNode
Add >100 lines of coverage and increase from 71% to 99% Increase branch coverage to fix Sonar major issue Extract repeated strings to constants Issue-ID: APPC-1504 Change-Id: Ib3b1e83d39f02befaede035b84a0ebef96b36cfd Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
Diffstat (limited to 'appc-config/appc-data-services/provider/src/main')
-rw-r--r--appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/AppcDataServiceConstant.java6
-rw-r--r--appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/node/ConfigResourceNode.java23
2 files changed, 15 insertions, 14 deletions
diff --git a/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/AppcDataServiceConstant.java b/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/AppcDataServiceConstant.java
index a17c257c3..ff2d8cdd0 100644
--- a/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/AppcDataServiceConstant.java
+++ b/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/AppcDataServiceConstant.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.
@@ -36,13 +38,13 @@ public class AppcDataServiceConstant {
public static final String INPUT_PARAM_SDC_ARTIFACT_IND = "asdcArtifactInd";
public static final String INPUT_PARAM_VNF_ID = "vnfId";
public static final String INPUT_PARAM_VM_NAME = "vmName";
-
public static final String INPUT_PARAM_FILE_ID = "fileId";
-
public static final String INPUT_PARAM_UPLOAD_CONFIG_ID= "uploadConfigId";
public static final String CAPABILITY_VM_LEVEL="vm";
public static final String KEY_VSERVER_ID = "vserver-id";
public static final String KEY_VNFC_FUNCTION_CODE = "vnfc-function-code";
+ public static final String TEMPLATE_NAME = "template-name";
+ public static final String TEMPLATE_MODEL_ID = "template-model-id";
public enum ACTIONS
{
diff --git a/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/node/ConfigResourceNode.java b/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/node/ConfigResourceNode.java
index 13d7d2874..219bb0a2e 100644
--- a/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/node/ConfigResourceNode.java
+++ b/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/node/ConfigResourceNode.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.
@@ -188,8 +190,8 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin {
String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
String fileCategory = inParams.get(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY);
- String templateName = ctx.getAttribute("template-name");
- String templateModelId = ctx.getAttribute("template-model-id");
+ String templateName = ctx.getAttribute(AppcDataServiceConstant.TEMPLATE_NAME);
+ String templateModelId = ctx.getAttribute(AppcDataServiceConstant.TEMPLATE_MODEL_ID);
QueryStatus status;
String responsePrefix1 = "";
@@ -201,7 +203,7 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin {
if (StringUtils.isBlank(templateName)) {
if (StringUtils.isNotBlank(templateModelId)) {
- status = db.getTemplateWithTemplateModelId(ctx, responsePrefix, fileCategory,templateModelId);
+ status = db.getTemplateWithTemplateModelId(ctx, responsePrefix, fileCategory, templateModelId);
if (status == QueryStatus.FAILURE) {
throw new QueryException(UNABLE_TO_READ_STR + fileCategory);
}
@@ -219,7 +221,7 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin {
if (status == QueryStatus.NOT_FOUND) {
if (StringUtils.isNotBlank(templateModelId)) {
- status = db.getTemplateByVnfTypeNActionWithTemplateModelId(ctx, responsePrefix, fileCategory,templateModelId);
+ status = db.getTemplateByVnfTypeNActionWithTemplateModelId(ctx, responsePrefix, fileCategory, templateModelId);
if (status == QueryStatus.FAILURE) {
throw new QueryException(UNABLE_TO_READ_STR + fileCategory);
}
@@ -553,7 +555,7 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin {
saveConfigFiles(inParams, ctx);
}
- private void saveConfigurationData(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
+ protected void saveConfigurationData(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
ctx.setAttribute(DATA_SOURCE, ctx.getAttribute("originator-id"));
ctx.setAttribute(FILE_CONTENT, ctx.getAttribute(CONFIG_PARAMS));
ctx.setAttribute(FILE_CATEGORY_PARAM, "config_data");
@@ -571,7 +573,6 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin {
String vmName = inParams.get(AppcDataServiceConstant.INPUT_PARAM_VM_NAME);
try {
QueryStatus status = db.getConfigFilesByVnfVmNCategory(ctx, responsePrefix, fileCategory, vnfId, vmName);
-
if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE) {
throw new QueryException("Unable to get " + ctx.getAttribute("fileCategory") + " from configfiles");
}
@@ -658,25 +659,23 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin {
log.info("Received getVnfcReference call with params : " + inParams);
String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
- String templateModelId = ctx.getAttribute("template-model-id");
- log.info("getVnfcReference():::"+templateModelId);
+ String templateModelId = ctx.getAttribute(AppcDataServiceConstant.TEMPLATE_MODEL_ID);
+ log.info("getVnfcReference():::" + templateModelId);
QueryStatus status = null;
try {
if (!StringUtils.isBlank(ctx.getAttribute("vnfc-type"))) {
-
status = db.getVnfcReferenceByVnfcTypeNAction(ctx, responsePrefix);
-
if (status == QueryStatus.FAILURE) {
throw new QueryException("Unable to Read vnfc-reference");
}
}
if (StringUtils.isNotBlank(templateModelId)) {
- status = db.getVnfcReferenceByVnfTypeNActionWithTemplateModelId(ctx, responsePrefix,templateModelId);
+ status = db.getVnfcReferenceByVnfTypeNActionWithTemplateModelId(ctx, responsePrefix, templateModelId);
if (status == QueryStatus.FAILURE) {
- throw new QueryException("Unable to Read vnfc-reference with template-model-id");
+ throw new QueryException("Unable to Read vnfc-reference with " + AppcDataServiceConstant.TEMPLATE_MODEL_ID);
}
}
if (StringUtils.isBlank(templateModelId) || (StringUtils.isNotBlank(templateModelId) && (status == QueryStatus.NOT_FOUND))) {