summaryrefslogtreecommitdiffstats
path: root/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-12 08:58:56 +0900
committerGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-12 09:00:38 +0900
commit13f987af48136ab3a3a24434782e984b7c0d25e8 (patch)
tree0dac113082d837839b0ebc9581fb50ac6bc12cc4 /saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java
parent67c775f8adfce8b0e139ce9e6b70386047090c69 (diff)
saltstack reqExecSlsFile API implemented
Issue-ID: CCSDK-356 Change-Id: Ib9e7a7c147992505e85d1f2f195cb7f52930057f Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
Diffstat (limited to 'saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java')
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java210
1 files changed, 200 insertions, 10 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 c8776fb8..d60059e4 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
@@ -80,10 +80,10 @@ public class TestSaltstackAdapterImpl {
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.Id");
- assertEquals("101", status);
+ adapter.reqExecCommand(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("101", status);
}
@Test(expected = SvcLogicException.class)
@@ -322,7 +322,6 @@ public class TestSaltstackAdapterImpl {
params.put("slsExec", "true");
adapter.reqExecCommand(params, svcContext);
- String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
assertEquals(TestId, "test1");
}
@@ -432,7 +431,7 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test.json");
+ params.put("slsFile", "src/test/resources/test.sls");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
params.put("cmd", "test");
@@ -453,7 +452,26 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test-none.json");
+ params.put("slsFile", "src/test/resources/test-none.sls");
+ params.put("fileName", "src/test/resources/test-sls.json");
+ params.put("Id", "test1");
+
+ adapter.reqExecSLSFile(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals(TestId, "test1");
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecSLSFile_NoExtn() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("slsFile", "src/test/resources/test-none");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
@@ -482,8 +500,8 @@ public class TestSaltstackAdapterImpl {
assertEquals(TestId, "test1");
}
- @Test
- public void reqExecSLSFile_WithMinionSetSuccessJson() throws SvcLogicException,
+ @Test(expected = SvcLogicException.class)
+ public void reqExecSLSFile_WithMinionSetNotSLSType() throws SvcLogicException,
IllegalStateException, IllegalArgumentException {
params.put("HostName", "test");
@@ -504,6 +522,28 @@ public class TestSaltstackAdapterImpl {
assertEquals(TestId, "test1");
}
+ @Test
+ public void reqExecSLSFile_WithMinionSetSuccessSls() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("slsFile", "src/test/resources/test.sls");
+ params.put("fileName", "src/test/resources/test-sls.json");
+ params.put("Id", "test1");
+ params.put("cmd", "test");
+ params.put("applyTo", "minion1");
+
+ adapter.reqExecSLSFile(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ }
+
@Test(expected = SvcLogicException.class)
public void reqExecSLSFile_WithMinionNoSLSfile() throws SvcLogicException,
IllegalStateException, IllegalArgumentException {
@@ -553,7 +593,7 @@ public class TestSaltstackAdapterImpl {
params.put("User", "test");
params.put("Password", "test");
params.put("Test", "success");
- params.put("slsFile", "src/test/resources/test.json");
+ params.put("slsFile", "src/test/resources/test.sls");
params.put("fileName", "src/test/resources/test-sls.json");
params.put("Id", "test1");
params.put("cmd", "test");
@@ -606,6 +646,156 @@ public class TestSaltstackAdapterImpl {
assertEquals(TestId, "test1");
}
+
+ @Test
+ public void reqExecSLS_shouldSetSuccessJson() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("slsName", "src/test.sls");
+ params.put("fileName", "src/test/resources/test-sls.json");
+ params.put("Id", "test1");
+ params.put("cmd", "test");
+
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ }
+
+ @Test
+ public void reqExecSLS_shouldSetNoExtn() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("slsName", "src/test");
+ params.put("fileName", "src/test/resources/test-sls.json");
+ params.put("Id", "test1");
+ params.put("cmd", "test");
+
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecSLS_NoResponsefile() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("slsName", "src/test/resources/test.json");
+ params.put("fileName", "src/test/resources/test-none.json");
+ params.put("Id", "test1");
+
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals(TestId, "test1");
+ }
+
+
+ @Test
+ public void reqExecSLS_WithMinionSetSuccessSls() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("slsName", "src/test/resources/test.sls");
+ params.put("fileName", "src/test/resources/test-sls.json");
+ params.put("Id", "test1");
+ params.put("cmd", "test");
+ params.put("applyTo", "minion1");
+
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ }
+
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecSLS_WithMinionNoResponsefile() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("slsName", "src/test/resources/test.json");
+ params.put("fileName", "src/test/resources/test-none.json");
+ params.put("Id", "test1");
+ params.put("applyTo", "minion1");
+
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals(TestId, "test1");
+ }
+
+ @Test
+ public void reqExecSLS_WithAllMinionSetSuccessJson() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("slsName", "src/test/resources/test.sls");
+ params.put("fileName", "src/test/resources/test-sls.json");
+ params.put("Id", "test1");
+ params.put("cmd", "test");
+ params.put("applyTo", "*");
+
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals("200", status);
+ assertEquals(TestId, "test1");
+ }
+
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecSLS_WithAllMinionNoResponsefile() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+
+ params.put("HostName", "test");
+ params.put("Port", "10");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Test", "success");
+ params.put("slsName", "src/test/resources/test.json");
+ params.put("fileName", "src/test/resources/test-none.json");
+ params.put("Id", "test1");
+ params.put("applyTo", "*");
+
+ adapter.reqExecSLS(params, svcContext);
+ String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
+ TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
+ assertEquals(TestId, "test1");
+ }
+
+
@Test
public void reqExecLog_shouldSetMessage() throws IllegalStateException, IllegalArgumentException {