aboutsummaryrefslogtreecommitdiffstats
path: root/sshapi-call-node/provider/src/test
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-08-03 18:06:37 +0900
committerGanesh Chandrasekaran <ganesh.c@samsung.com>2018-08-03 18:30:15 +0900
commitefd6f9e3d2f770f16a6cb93efc061fe502a56979 (patch)
treeba71d2eee33f01f43380cf717e127c87e096b07f /sshapi-call-node/provider/src/test
parent1476ff884265181b5934d71a7a0e59b705ee1aac (diff)
mocked testcases added
Issue-ID: CCSDK-433 Change-Id: I9961df9131b4672a99601b31ed2e9312d0840d6b Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
Diffstat (limited to 'sshapi-call-node/provider/src/test')
-rw-r--r--sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java
index 3992dffe..544057a6 100644
--- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java
+++ b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/sshapicall/TestSshApiCallNode.java
@@ -225,4 +225,111 @@ public class TestSshApiCallNode {
params.put("ResponseType", "json");
adapter.execWithStatusCheck(params, svcContext);
}
+
+ @Test
+ public void testExecCommandResponse_validJSON() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Cmd", "test");
+ params.put("AuthType", "basic");
+ params.put("ResponseType", "json");
+ params.put("TestOut", "{\"equipment-data\":\"boo\"}");
+ params.put("TestFail", "false");
+ adapter = new SshApiCallNode(true);
+ adapter.execWithStatusCheck(params, svcContext);
+ assertEquals("boo", svcContext.getAttribute("equipment-data"));
+ }
+
+ @Test
+ public void testExecCommandResponse_validXML() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Cmd", "test");
+ params.put("AuthType", "basic");
+ params.put("ResponseType", "xml");
+ params.put("TestOut", "<modelVersion>4.0.0</modelVersion>");
+ params.put("TestFail", "false");
+ adapter = new SshApiCallNode(true);
+ adapter.execWithStatusCheck(params, svcContext);
+ assertEquals("4.0.0", svcContext.getAttribute("modelVersion"));
+ }
+
+ @Test
+ public void testExecCommandResponse_validJSONPrefix() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Cmd", "test");
+ params.put("AuthType", "basic");
+ params.put("ResponseType", "json");
+ params.put("TestOut", "{\"equipment-data\":\"boo\"}");
+ params.put("ResponsePrefix", "test");
+ params.put("TestFail", "false");
+ adapter = new SshApiCallNode(true);
+ adapter.execWithStatusCheck(params, svcContext);
+ assertEquals("boo", svcContext.getAttribute("test.equipment-data"));
+ }
+
+ @Test
+ public void testExecCommandResponse_validXMLPrefix() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Cmd", "test");
+ params.put("AuthType", "basic");
+ params.put("ResponseType", "xml");
+ params.put("TestOut", "<modelVersion>4.0.0</modelVersion>");
+ params.put("ResponsePrefix", "test");
+ params.put("TestFail", "false");
+ adapter = new SshApiCallNode(true);
+ adapter.execWithStatusCheck(params, svcContext);
+ assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion"));
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandResponse_validXMLFail() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Cmd", "test");
+ params.put("AuthType", "basic");
+ params.put("ResponseType", "xml");
+ params.put("TestOut", "<modelVersion>4.0.0</modelVersion>");
+ params.put("TestFail", "true");
+ params.put("ResponsePrefix", "test");
+ adapter = new SshApiCallNode(true);
+ adapter.execWithStatusCheck(params, svcContext);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void testExecCommandResponse_validXMLPrefixKey() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params = new HashMap<>();
+ params.put("Url", "test");
+ params.put("Port", "10");
+ params.put("SshKey", "test");
+ params.put("Cmd", "test");
+ params.put("ResponseType", "xml");
+ params.put("TestOut", "<modelVersion>4.0.0</modelVersion>");
+ params.put("ResponsePrefix", "test");
+ adapter.execWithStatusCheck(params, svcContext);
+ assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion"));
+ }
}