summaryrefslogtreecommitdiffstats
path: root/saltstack-adapter/saltstack-adapter-provider/src/test
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-04 14:10:57 +0900
committerGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-08 23:14:16 +0000
commit43090d8778d60ed62089927c1f6732140036791a (patch)
treee41cf85c64bbacbd8d5af32355ff506e7fa9899f /saltstack-adapter/saltstack-adapter-provider/src/test
parentccf87e9fe98de4be6d63f81aaa2b9034da27d039 (diff)
reqExec API implemented for saltstack
Issue-ID: CCSDK-320 Change-Id: I5c4eb36924f36ebc9a7786d2bd46c923d0c05ab0 Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
Diffstat (limited to 'saltstack-adapter/saltstack-adapter-provider/src/test')
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java163
1 files changed, 155 insertions, 8 deletions
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java
index 5ca6e6ea1..d7b330387 100644
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java
+++ b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java
@@ -71,26 +71,173 @@ public class TestSaltstackAdapterImpl {
svcContext = null;
}
- @Test
- public void reqExecCommand_shouldSetPending() throws IllegalStateException, IllegalArgumentException {
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
+ assertEquals("101", status);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetUserFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
+ assertEquals("101", status);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetHostFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
+ assertEquals("101", status);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetPortFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "fail");
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
+ assertEquals("101", status);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetPasswordFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Test", "fail");
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
+ assertEquals("101", status);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetMandatoryFailed() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("Test", "fail");
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
+ assertEquals("101", status);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetSuccess() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
params.put("PlaybookName", "test_playbook.yaml");
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ try {
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
+ assertEquals("400", status);
+ } catch (NullPointerException e) {
+ fail(e.getMessage() + " Unknown exception encountered ");
+ }
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetSuccessWithRetry() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("PlaybookName", "test_playbook.yaml");
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("retryDelay", "10");
+ params.put("retryCount", "10");
try {
adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
- // System.out.println("Comparing " + PENDING + " and " + status);
- //assertEquals(PENDING, status);
- assertEquals(null, status);
- } catch (SvcLogicException e) {
+ assertEquals("400", status);
+ } catch (NullPointerException e) {
+ fail(e.getMessage() + " Unknown exception encountered ");
+ }
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetSuccessWithRetryZero() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("PlaybookName", "test_playbook.yaml");
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("retryDelay", "0");
+ params.put("retryCount", "0");
+ try {
+ adapter.reqExecCommand(params, svcContext);
String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
- fail(e.getMessage() + " Code = " + status);
- } catch (Exception e) {
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
+ assertEquals("400", status);
+ } catch (NullPointerException e) {
fail(e.getMessage() + " Unknown exception encountered ");
}
}
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_shouldSetSuccessWithNoRetry() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("PlaybookName", "test_playbook.yaml");
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("retryDelay", "-1");
+ params.put("retryCount", "-1");
+ try {
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.Id");
+ assertEquals("400", status);
+ } catch (NullPointerException e) {
+ fail(e.getMessage() + " Unknown exception encountered ");
+ }
+ }
@Test
public void reqExecSLS_shouldSetSuccess() throws IllegalStateException, IllegalArgumentException {