*/
 package org.onap.appc.data.services.node;
 
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 
 public class ConfigResourceNode implements SvcLogicJavaPlugin {
 
+    static final String DEVICE_CONF_PREFIX = "configfilereference-deviceconfig";
+    static final String DEVICE_CONF_FILE_TYPE = "device_configuration";
+
+    static final String SUCCESS_PREFIX = "configfilereference-success";
+    static final String SUCCESS_FILE_TYPE = "configuration_success";
+
+    static final String FAILURE_PREFIX = "configfilereference-failure";
+    static final String FAILURE_FILE_TYPE = "configuration_error";
+
+    static final String LOG_PREFIX = "configfilereference-log";
+    static final String LOG_FILE_TYPE = "log";
+
     private static final EELFLogger log = EELFManager.getInstance().getLogger(ConfigResourceNode.class);
+    private final DGGeneralDBService db;
+
+    /**
+     * Constructor which provide default DB service
+     */
+    public ConfigResourceNode() {
+       db = DGGeneralDBService.initialise();
+    }
+
+    /**
+     * Constructor which allow to provide custom DB service, prefer to use no-arg constructor
+     */
+    public ConfigResourceNode(DGGeneralDBService dbService) {
+        db = dbService;
+    }
 
     public void getConfigFileReference(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
 
         log.info("Received getConfigFiles call with params : " + inParams);
-
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
 
         try {
-
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
-            DGGeneralDBService db = DGGeneralDBService.initialise();
-            QueryStatus status = db.getConfigFileReferenceByFileTypeNVnfType(ctx, "configfilereference-deviceconfig",
-                    "device_configuration");
+            QueryStatus status = db.getConfigFileReferenceByFileTypeNVnfType(ctx, DEVICE_CONF_PREFIX, DEVICE_CONF_FILE_TYPE);
 
             if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE)
                 throw new Exception("Unable to Read ConfigFileReference:device-configuration");
 
-            status = db.getConfigFileReferenceByFileTypeNVnfType(ctx, "configfilereference-success",
-                    "configuration_success");
+            status = db.getConfigFileReferenceByFileTypeNVnfType(ctx, SUCCESS_PREFIX, SUCCESS_FILE_TYPE);
 
             if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE)
                 throw new Exception("Unable to Read ConfigFileReference:configuration_success");
 
-            status = db.getConfigFileReferenceByFileTypeNVnfType(ctx, "configfilereference-failure",
-                    "configuration_error");
+            status = db.getConfigFileReferenceByFileTypeNVnfType(ctx, FAILURE_PREFIX, FAILURE_FILE_TYPE);
 
             if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE)
                 throw new Exception("Unable to Read ConfigFileReference:configuration_error");
 
-            status = db.getConfigFileReferenceByFileTypeNVnfType(ctx, "configfilereference-log", "log");
+            status = db.getConfigFileReferenceByFileTypeNVnfType(ctx, LOG_PREFIX, LOG_FILE_TYPE);
 
             if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE)
                 throw new Exception("Unable to Read ConfigFileReference:configuration_log");
 
-
             ctx.setAttribute(responsePrefix + AppcDataServiceConstant.OUTPUT_PARAM_STATUS,
                     AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS);
             log.info("GetConfigFileReference Successful ");
     public void getCommonConfigInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
 
         log.info("Received getDeviceInfo call with params : " + inParams);
-
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
 
         try {
-
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
-            DGGeneralDBService db = DGGeneralDBService.initialise();
-
             QueryStatus status = db.getDeviceProtocolByVnfType(ctx, "tmp.deviceinterfaceprotocol");
 
             if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE)
                     throw new Exception("Unable to Read configure_action_dg");
             }
 
-
-
             ctx.setAttribute(responsePrefix + AppcDataServiceConstant.OUTPUT_PARAM_STATUS,
                     AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS);
             log.info("getCommonConfigInfo Successful ");
 
         log.info("Received getTemplate call with params : " + inParams);
 
-
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
         String fileCategory = inParams.get(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY);
         String templateName = ctx.getAttribute("template-name");
             log.info("RESPONSEPREFIX : " + responsePrefix);
             log.info("RESPONSEPREFIX1 : " + responsePrefix1);
 
-            DGGeneralDBService db = DGGeneralDBService.initialise();
-
             if (StringUtils.isBlank(templateName)) {
 
                 // if ( !StringUtils.isBlank(ctx.getAttribute("vnfc-type"))) {
 
-
                 status = db.getTemplate(ctx, responsePrefix, fileCategory);
                 if (status == QueryStatus.FAILURE)
                     throw new Exception("Unable to Read " + fileCategory);
                     throw new Exception("Unable to Read " + fileCategory + " template");
             }
 
-
             ctx.setAttribute(responsePrefix1 + AppcDataServiceConstant.OUTPUT_PARAM_STATUS,
                     AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS);
             log.info("GetTemplate Successful ");
         try {
 
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
-            DGGeneralDBService db = DGGeneralDBService.initialise();
             QueryStatus status = db.saveConfigFiles(ctx, "tmp.configFiles");
 
             if (status == QueryStatus.FAILURE)
         try {
 
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
-            DGGeneralDBService db = DGGeneralDBService.initialise();
 
             ctx.setAttribute("tmp.escaped.devicerunningconfig",
                     EscapeUtils.escapeSql(ctx.getAttribute("device-running-config")));
         try {
 
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
-            DGGeneralDBService db = DGGeneralDBService.initialise();
 
             QueryStatus status = db.savePrepareRelationship(ctx, "tmp.preparerel", fileId, sdcArtifactInd);
             if (status == QueryStatus.FAILURE)
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
 
         try {
-
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
             ctx.setAttribute("tmp.convertconfig.escapeData", EscapeUtils.escapeSql(ctx.getAttribute("configuration")));
-            DGGeneralDBService db = DGGeneralDBService.initialise();
 
             if (StringUtils.isBlank(ctx.getAttribute("configuration-params"))) {
                 saveDeviceConfiguration(inParams, ctx, "Request", ctx.getAttribute("tmp.convertconfig.escapeData"),
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
 
         try {
-
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
-            DGGeneralDBService db = DGGeneralDBService.initialise();
 
             if (StringUtils.isBlank(ctx.getAttribute("configuration-params"))) {
 
         }
     }
 
-
-
     public void saveStyleSheetConfig(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
 
-
         log.info("Received saveStyleSheet call with params : " + inParams);
 
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
             saveDeviceConfiguration(inParams, ctx, "StyleSheet", ctx.getAttribute("tmp.convertconfig.escapeData"),
                     ctx.getAttribute("tmp.merge.mergedData"));
 
-
             ctx.setAttribute(responsePrefix + AppcDataServiceConstant.OUTPUT_PARAM_STATUS,
                     AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS);
             log.info("saveStyleSheet Successful ");
         }
     }
 
-
     public void getSmmChainKeyFiles(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
 
-
         log.info("Received saveStyleSheet call with params : " + inParams);
 
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
 
         try {
 
-
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
-            DGGeneralDBService db = DGGeneralDBService.initialise();
-
-
 
             status = db.getTemplateByArtifactType(ctx, "smm", "smm", siteLocation);
 
             if (status == QueryStatus.FAILURE)
                 throw new Exception("Unable to Read smm file");
 
-
             status = db.getTemplateByArtifactType(ctx, "intermediate-ca-chain", "intermediate_ca_chain", siteLocation);
 
             if (status == QueryStatus.FAILURE)
                 throw new Exception("Unable to Read intermediate_ca_chain file");
 
-
-
             status = db.getTemplateByArtifactType(ctx, "server-certificate-and-key", "server_certificate_and_key",
                     siteLocation);
 
             if (status == QueryStatus.FAILURE)
                 throw new Exception("Unable to Read server_certificate_and_key file");
 
-
             ctx.setAttribute(responsePrefix + AppcDataServiceConstant.OUTPUT_PARAM_STATUS,
                     AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS);
             log.info("saveStyleSheet Successful ");
         }
     }
 
-
     public void saveDeviceConfiguration(Map<String, String> inParams, SvcLogicContext ctx, String dataSource,
             String fileContent, String deviceConfig) throws SvcLogicException {
         ctx.setAttribute("data-source", dataSource);
         saveConfigFiles(inParams, ctx);
     }
 
-
     public void getConfigFilesByVnfVmNCategory(Map<String, String> inParams, SvcLogicContext ctx)
             throws SvcLogicException {
 
         String vnfId = inParams.get(AppcDataServiceConstant.INPUT_PARAM_VNF_ID);
         String vmName = inParams.get(AppcDataServiceConstant.INPUT_PARAM_VM_NAME);
         try {
-
-
-            DGGeneralDBService db = DGGeneralDBService.initialise();
-
             QueryStatus status = db.getConfigFilesByVnfVmNCategory(ctx, responsePrefix, fileCategory, vnfId, vmName);
 
             if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE)
                 throw new Exception("Unable to get " + ctx.getAttribute("fileCategory") + " from configfiles");
 
-
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
             ctx.setAttribute(responsePrefix + AppcDataServiceConstant.OUTPUT_PARAM_STATUS,
                     AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS);
         }
     }
 
-
     public void getDownloadConfigTemplateByVnf(Map<String, String> inParams, SvcLogicContext ctx)
             throws SvcLogicException {
 
 
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
         try {
-            DGGeneralDBService db = DGGeneralDBService.initialise();
-
             QueryStatus status = db.getDownloadConfigTemplateByVnf(ctx, responsePrefix);
 
             if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE)
                 throw new Exception("Unable to get download config template.");
 
-
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
             ctx.setAttribute(responsePrefix + AppcDataServiceConstant.OUTPUT_PARAM_STATUS,
                     AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS);
         }
     }
 
-
     public void saveConfigTransactionLog(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
 
-
-
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
 
         String messageType = inParams.get(AppcDataServiceConstant.INPUT_PARAM_MESSAGE_TYPE);
         try {
 
             SvcLogicContext logctx = new SvcLogicContext();
-
             String escapedMessage = EscapeUtils.escapeSql(message);
 
-
             logctx.setAttribute("request-id", ctx.getAttribute("request-id"));
             logctx.setAttribute("log-message-type", messageType);
             logctx.setAttribute("log-message", escapedMessage);
 
-
             responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : "";
-            DGGeneralDBService db = DGGeneralDBService.initialise();
             QueryStatus status = db.saveConfigTransactionLog(logctx, responsePrefix);
 
             logctx.setAttribute("log-message", null);
             if (status == QueryStatus.FAILURE)
                 throw new Exception("Unable to insert into config_transaction_log");
 
-
         } catch (Exception e) {
             ctx.setAttribute(responsePrefix + AppcDataServiceConstant.OUTPUT_PARAM_STATUS,
                     AppcDataServiceConstant.OUTPUT_STATUS_FAILURE);
             ctx.setAttribute(responsePrefix + AppcDataServiceConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
 
-
             throw new SvcLogicException(e.getMessage());
         }
     }
 
-
-
     public void getVnfcReference(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
 
         log.info("Received getVnfcReference call with params : " + inParams);
 
         String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX);
-
-
         QueryStatus status = null;
 
         try {
-
-
-            DGGeneralDBService db = DGGeneralDBService.initialise();
-
             if (!StringUtils.isBlank(ctx.getAttribute("vnfc-type"))) {
                 status = db.getVnfcReferenceByVnfcTypeNAction(ctx, responsePrefix);
 
             return;
         }
         try {
-            DGGeneralDBService db = DGGeneralDBService.initialise();
             String cap = db.getCapability(ctx, inParams.get("vnf-type"));
             log.info("getCapability::returned from DB::+cap");
             if (StringUtils.isBlank(cap)) {
 
 
 package org.onap.appc.data.services.db;
 
-import java.util.ArrayList;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import java.util.HashMap;
 import java.util.Map;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
+@Deprecated // class must be rewritten
 public class TestConfigResourceNode {
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testgetConfigFileReferenc() throws SvcLogicException {
         SvcLogicContext ctx = new SvcLogicContext();
         ctx.setAttribute("test", "test");
-        ConfigResourceNode dbService = new ConfigResourceNode();
-        Map<String, String> map = new HashMap<String, String>();
+        ConfigResourceNode dbService = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> map = new HashMap<>();
         dbService.getConfigFileReference(map, ctx);
     }
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testgetTemplate() throws SvcLogicException {
         ctx.setAttribute(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
         ctx.setAttribute("template-name", "test.json");
 
-        ConfigResourceNode dbService = new ConfigResourceNode();
-        Map<String, String> map = new HashMap<String, String>();
+        ConfigResourceNode dbService = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> map = new HashMap<>();
         dbService.getTemplate(map, ctx);
 
     }
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testgetVnfcReference() throws SvcLogicException {
         SvcLogicContext ctx = new SvcLogicContext();
         ctx.setAttribute("test", "test");
-        ConfigResourceNode dbService = new ConfigResourceNode();
-        Map<String, String> map = new HashMap<String, String>();
+        ConfigResourceNode dbService = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> map = new HashMap<>();
         map.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
         dbService.getVnfcReference(map, ctx);
     }
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testgetSmmChainKeyFiles() throws SvcLogicException {
         SvcLogicContext ctx = new SvcLogicContext();
         ctx.setAttribute("test", "test");
         ctx.setAttribute("site-location","test/location");
-        ConfigResourceNode dbService = new ConfigResourceNode();
-        Map<String, String> map = new HashMap<String, String>();
+        ConfigResourceNode dbService = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> map = new HashMap<>();
         map.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
         dbService.getSmmChainKeyFiles(map, ctx);
     }
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testgetDownloadConfigTemplateByVnf() throws SvcLogicException {
         SvcLogicContext ctx = new SvcLogicContext();
         ctx.setAttribute("test", "test");    
-        ConfigResourceNode dbService = new ConfigResourceNode();
-        Map<String, String> map = new HashMap<String, String>();
+        ConfigResourceNode dbService = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> map = new HashMap<>();
         map.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp.test");
         dbService.getDownloadConfigTemplateByVnf(map, ctx);
 
     }
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testgetCommonConfigInfo() throws SvcLogicException {
         SvcLogicContext ctx = new SvcLogicContext();
         ctx.setAttribute("test", "test");
-        ConfigResourceNode dbService = new ConfigResourceNode();
-        Map<String, String> map = new HashMap<String, String>();
+        ConfigResourceNode dbService = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> map = new HashMap<>();
         dbService.getCommonConfigInfo(map, ctx);
 
     }
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testupdateUploadConfigss() throws SvcLogicException {
         SvcLogicContext ctx = new SvcLogicContext();
         ctx.setAttribute("test", "test");
-        ConfigResourceNode dbService = new ConfigResourceNode();
-        Map<String, String> map = new HashMap<String, String>();
+        ConfigResourceNode dbService = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> map = new HashMap<>();
         dbService.updateUploadConfig(map, ctx);
 
     }
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testgetConfigFilesByVnfVmNCategory() throws SvcLogicException {
         SvcLogicContext ctx = new SvcLogicContext();
-        ConfigResourceNode node = new ConfigResourceNode();
-        Map<String, String> inParams = new HashMap<String, String>();
+        ConfigResourceNode node = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> inParams = new HashMap<>();
         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "response-prefix");
         inParams.put(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY, "config_template");
         inParams.put((String) AppcDataServiceConstant.INPUT_PARAM_VNF_ID, "test");
         node.getConfigFilesByVnfVmNCategory(inParams, ctx);
     }
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testsaveConfigTransactionLog() throws SvcLogicException {
         SvcLogicContext ctx = new SvcLogicContext();
-        ConfigResourceNode node = new ConfigResourceNode();
-        Map<String, String> inParams = new HashMap<String, String>();
+        ConfigResourceNode node = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> inParams = new HashMap<>();
         inParams.put(AppcDataServiceConstant.INPUT_PARAM_MESSAGE, "testMessage");
         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "response-prefix");
         inParams.put(AppcDataServiceConstant.INPUT_PARAM_MESSAGE_TYPE, "testmessage");
 
     }
 
+    @Deprecated // timeout due NPE
     @Ignore("Test is taking 60 seconds")
     @Test(expected = Exception.class)
     public void testsaveConfigBlock() throws SvcLogicException {
         SvcLogicContext ctx = new SvcLogicContext();
-        ConfigResourceNode node = new ConfigResourceNode();
-        Map<String, String> inParams = new HashMap<String, String>();
+        ConfigResourceNode node = new ConfigResourceNode(DGGeneralDBService.initialise());
+        Map<String, String> inParams = new HashMap<>();
         inParams.put(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX, "tmp");
         ctx.setAttribute("configuration", "test");
         ctx.setAttribute("tmp.convertconfig.escapeData", "test");
         node.saveConfigBlock(inParams, ctx);
     }
 
-    @Test
-    public void testProcessCapabilitiesForVMLevel ()  throws Exception {
-        //{"capabilities":{"vnfc":[],"vm":[{"ConfigureTest":["SSC","MMSC"]}],"vf-module":[],"vnf":["ConfigModify","HealthCheck"]}}
-        SvcLogicContext ctx = new SvcLogicContext();
-        ConfigResourceNode node = new ConfigResourceNode();
-        String findCapability="Restart";
-        JsonNode subCapabilities = JsonNodeFactory.instance.objectNode();
-        String subCaps= "[{\"Restart\":[\"SSC\",\"MMC\"]},{\"Rebuild\":[\"SSC\"]},{\"Migrate\":[\"SSC\"]},{\"Snapshot\":[\"SSC\"]},{\"Start\":[\"SSC\"]},{\"Stop\":[\"SSC\"]}]";
-        ObjectMapper m = new ObjectMapper();
-        subCapabilities = m.readTree(subCaps);
-        String vServerId="testServer";
-        ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-function-code", "MMC");
-        ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-name","testVnfc")    ;
-        node.processCapabilitiesForVMLevel( vServerId,    ctx,
-                 findCapability,  subCapabilities);
-        String result=ctx.getAttribute("capabilities");
-        assertEquals(result,"Supported");
-    }
-
-    @Test
-    public void testcheckIfCapabilityCheckNeeded ()  throws Exception {
-        ConfigResourceNode node = new ConfigResourceNode();
-        String findCapability="Start";
-        String capLevel="vnf";
-        boolean result=node.checkIfCapabilityCheckNeeded(capLevel,findCapability);
-        assertFalse(result);
-    }
-
 }
 
--- /dev/null
+package org.onap.appc.data.services.node;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import java.util.HashMap;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import static org.mockito.Mockito.mock;
+import org.onap.appc.data.services.db.DGGeneralDBService;
+import static org.onap.appc.data.services.node.ConfigResourceNode.DEVICE_CONF_FILE_TYPE;
+import static org.onap.appc.data.services.node.ConfigResourceNode.DEVICE_CONF_PREFIX;
+import static org.onap.appc.data.services.node.ConfigResourceNode.FAILURE_FILE_TYPE;
+import static org.onap.appc.data.services.node.ConfigResourceNode.FAILURE_PREFIX;
+import static org.onap.appc.data.services.node.ConfigResourceNode.LOG_FILE_TYPE;
+import static org.onap.appc.data.services.node.ConfigResourceNode.LOG_PREFIX;
+import static org.onap.appc.data.services.node.ConfigResourceNode.SUCCESS_FILE_TYPE;
+import static org.onap.appc.data.services.node.ConfigResourceNode.SUCCESS_PREFIX;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+
+public class ConfigResourceNodeTest {
+
+    private HashMap<String, String> inParams;
+    private SvcLogicContext contextMock;
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Before
+    public void setUp() {
+        contextMock = mock(SvcLogicContext.class);
+        inParams = new HashMap<>();
+    }
+
+    /**
+     * Example data:
+     *
+     * {"capabilities":{"vnfc":[],"vm":[{"ConfigureTest":["SSC","MMSC"]}],"vf-module":[],"vnf":["ConfigModify","HealthCheck"]}}
+     *
+     */
+    @Test
+    public void shouldProcessCapabilitiesForVMLevel() throws Exception {
+        SvcLogicContext ctx = new SvcLogicContext();
+        ConfigResourceNode node = new ConfigResourceNode(DGGeneralDBService.initialise());
+        String findCapability = "Restart";
+        JsonNodeFactory.instance.objectNode();
+        String subCaps = "[{\"Restart\":[\"SSC\",\"MMC\"]},{\"Rebuild\":[\"SSC\"]},{\"Migrate\":[\"SSC\"]},{\"Snapshot\":[\"SSC\"]},{\"Start\":[\"SSC\"]},{\"Stop\":[\"SSC\"]}]";
+        ObjectMapper m = new ObjectMapper();
+        JsonNode subCapabilities = m.readTree(subCaps);
+        String vServerId = "testServer";
+        ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-function-code", "MMC");
+        ctx.setAttribute("tmp.vnfInfo.vm.vnfc.vnfc-name", "testVnfc");
+        node.processCapabilitiesForVMLevel(vServerId, ctx, findCapability, subCapabilities);
+        String result = ctx.getAttribute("capabilities");
+        assertEquals(result, "Supported");
+    }
+
+    @Test
+    public void shouldCheckIfCapabilityCheckNeeded() {
+        ConfigResourceNode node = new ConfigResourceNode(DGGeneralDBService.initialise());
+        String findCapability = "Start";
+        String capLevel = "vnf";
+        boolean result = node.checkIfCapabilityCheckNeeded(capLevel, findCapability);
+        assertFalse(result);
+    }
+
+    @Test
+    public void should_not_throw_if_all_db_params_return_success() throws SvcLogicException {
+        DGGeneralDBService dbServiceMock = new MockDbServiceBuilder().build();
+
+        ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
+        configResourceNode.getConfigFileReference(inParams, contextMock);
+    }
+
+    @Test
+    public void should_throw_exception_on_device_config_missing() throws Exception {
+        DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
+            .configFileReference(DEVICE_CONF_PREFIX, DEVICE_CONF_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
+            .build();
+
+        ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
+
+        expectedException.expect(SvcLogicException.class);
+        expectedException.expectMessage("Unable to Read ConfigFileReference:device-configuration");
+        configResourceNode.getConfigFileReference(inParams, contextMock);
+    }
+
+    @Test
+    public void should_throw_exception_on_device_config_failure() throws Exception {
+        DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
+            .configFileReference(DEVICE_CONF_PREFIX, DEVICE_CONF_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
+            .build();
+
+        ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
+
+        expectedException.expect(SvcLogicException.class);
+        expectedException.expectMessage("Unable to Read ConfigFileReference:device-configuration");
+        configResourceNode.getConfigFileReference(inParams, contextMock);
+    }
+
+    @Test
+    public void should_throw_exception_on_success_param_missing() throws Exception {
+
+        DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
+            .configFileReference(SUCCESS_PREFIX, SUCCESS_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
+            .build();
+
+        ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
+
+        expectedException.expect(SvcLogicException.class);
+        expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_success");
+        configResourceNode.getConfigFileReference(inParams, contextMock);
+    }
+
+    @Test
+    public void should_throw_exception_on_success_param_failure() throws Exception {
+        DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
+            .configFileReference(SUCCESS_PREFIX, SUCCESS_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
+            .build();
+
+        ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
+
+        expectedException.expect(SvcLogicException.class);
+        expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_success");
+        configResourceNode.getConfigFileReference(inParams, contextMock);
+    }
+
+    @Test
+    public void should_throw_exception_on_failure_param_missing() throws Exception {
+
+        DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
+            .configFileReference(FAILURE_PREFIX, FAILURE_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
+            .build();
+
+        ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
+
+        expectedException.expect(SvcLogicException.class);
+        expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_error");
+        configResourceNode.getConfigFileReference(inParams, contextMock);
+    }
+
+    @Test
+    public void should_throw_exception_on_failure_param_failure() throws Exception {
+        DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
+            .configFileReference(FAILURE_PREFIX, FAILURE_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
+            .build();
+
+        ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
+
+        expectedException.expect(SvcLogicException.class);
+        expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_error");
+        configResourceNode.getConfigFileReference(inParams, contextMock);
+    }
+
+    @Test
+    public void should_throw_exception_on_log_param_missing() throws Exception {
+
+        DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
+            .configFileReference(LOG_PREFIX, LOG_FILE_TYPE, SvcLogicResource.QueryStatus.NOT_FOUND)
+            .build();
+
+        ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
+
+        expectedException.expect(SvcLogicException.class);
+        expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_log");
+        configResourceNode.getConfigFileReference(inParams, contextMock);
+    }
+
+    @Test
+    public void should_throw_exception_on_log_param_failure() throws Exception {
+        DGGeneralDBService dbServiceMock = new MockDbServiceBuilder()
+            .configFileReference(LOG_PREFIX, LOG_FILE_TYPE, SvcLogicResource.QueryStatus.FAILURE)
+            .build();
+
+        ConfigResourceNode configResourceNode = new ConfigResourceNode(dbServiceMock);
+
+        expectedException.expect(SvcLogicException.class);
+        expectedException.expectMessage("Unable to Read ConfigFileReference:configuration_log");
+        configResourceNode.getConfigFileReference(inParams, contextMock);
+    }
+
+}
\ No newline at end of file
 
--- /dev/null
+package org.onap.appc.data.services.node;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import org.onap.appc.data.services.db.DGGeneralDBService;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+
+class MockDbServiceBuilder {
+
+    private final DGGeneralDBService dbServiceMock;
+
+    MockDbServiceBuilder() throws SvcLogicException {
+        dbServiceMock = mock(DGGeneralDBService.class);
+
+        doReturn(SvcLogicResource.QueryStatus.SUCCESS)
+            .when(dbServiceMock)
+            .getConfigFileReferenceByFileTypeNVnfType(any(SvcLogicContext.class), anyString(), anyString());
+    }
+
+    MockDbServiceBuilder configFileReference(String prefix, String fileType, SvcLogicResource.QueryStatus status) throws SvcLogicException {
+        doReturn(status)
+            .when(dbServiceMock)
+            .getConfigFileReferenceByFileTypeNVnfType(any(SvcLogicContext.class), eq(prefix), eq(fileType));
+
+        return this;
+    }
+
+    DGGeneralDBService build() {
+        return dbServiceMock;
+    }
+}