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);
- }
-
}