summaryrefslogtreecommitdiffstats
path: root/saltstack-adapter/saltstack-adapter-provider/src/test
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
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')
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java210
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java323
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/resources/test.sls30
3 files changed, 553 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 c8776fb8d..d60059e40 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 {
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java
new file mode 100644
index 000000000..927591830
--- /dev/null
+++ b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java
@@ -0,0 +1,323 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.impl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.sli.adaptors.saltstack.SaltstackAdapterPropertiesProvider;
+import org.onap.ccsdk.sli.adaptors.saltstack.impl.SaltstackAdapterImpl;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestSaltstackAdapterPropertiesProviderImpl {
+ private final String PENDING = "100";
+ private final String SUCCESS = "400";
+ private String message = "{\"Results\":{\"192.168.1.10\":{\"Id\":\"101\",\"StatusCode\":200,\"StatusMessage\":\"SUCCESS\"}},\"StatusCode\":200,\"StatusMessage\":\"FINISHED\"}";
+
+ private SaltstackAdapterImpl adapter;
+ private Properties params;
+ private SvcLogicContext svcContext;
+
+
+ @Before
+ public void setup() throws IllegalArgumentException {
+ params = new Properties();
+ }
+
+ @After
+ public void tearDown() {
+ adapter = null;
+ params = null;
+ svcContext = null;
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_setPropertiesBasicPortNull() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "BASIC");
+ params.put("User", "test");
+ params.put("Password", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_setPropertiesBasicPortString() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "BASIC");
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "test");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test
+ public void reqExecCommand_setPropertiesBasicSuccess() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "BASIC");
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "10");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_setPropertiesSSH_CERTPortNull() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "SSH_CERT");
+ params.put("User", "test");
+ params.put("Password", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_setPropertiesSSH_CERTPortString() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "SSH_CERT");
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "test");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test
+ public void reqExecCommand_setPropertiesSSH_CERTSuccess() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "SSH_CERT");
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "10");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_setPropertiesBOTHPortNull() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "BOTH");
+ params.put("User", "test");
+ params.put("Password", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test(expected = SvcLogicException.class)
+ public void reqExecCommand_setPropertiesBOTHPortString() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "BOTH");
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "test");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test
+ public void reqExecCommand_setPropertiesBOTHSuccess() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "BOTH");
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "10");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test
+ public void reqExecCommand_setPropertiesNonePortNull() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "NONE");
+ params.put("User", "test");
+ params.put("Password", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test
+ public void reqExecCommand_setPropertiesNonePortString() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "NONE");
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "test");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test
+ public void reqExecCommand_setPropertiesNoneSuccess() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.clientType", "NONE");
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "10");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+
+
+ @Test
+ public void reqExecCommand_setPropertiesElsePortNull() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("User", "test");
+ params.put("Password", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test
+ public void reqExecCommand_setPropertiesElsePortString() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "test");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ }
+
+ @Test
+ public void reqExecCommand_setPropertiesElseSuccess() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ params.put("org.onap.appc.adapter.saltstack.host", "test");
+ params.put("org.onap.appc.adapter.saltstack.port", "10");
+ params.put("org.onap.appc.adapter.saltstack.userName", "test");
+ params.put("org.onap.appc.adapter.saltstack.userPasswd", "test");
+ params.put("org.onap.appc.adapter.saltstack.sshKey", "test");
+ SaltstackAdapterPropertiesProvider propProvider = new SaltstackAdapterPropertiesProvider() {
+ @Override
+ public Properties getProperties() {
+ return params;
+ }
+ };
+ adapter = new SaltstackAdapterImpl(propProvider);
+ String adaptorName = adapter.getAdapterName();
+ assertEquals("Saltstack Adapter", adaptorName);
+ adapter.setExecTimeout(10);
+ }
+
+ @Test
+ public void reqExecCommand_setPropertiesDefault() throws SvcLogicException,
+ IllegalStateException, IllegalArgumentException {
+ adapter = new SaltstackAdapterImpl();
+ }
+}
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/resources/test.sls b/saltstack-adapter/saltstack-adapter-provider/src/test/resources/test.sls
new file mode 100644
index 000000000..cd76486aa
--- /dev/null
+++ b/saltstack-adapter/saltstack-adapter-provider/src/test/resources/test.sls
@@ -0,0 +1,30 @@
+{
+ "equipment-data": [
+ {
+ "server-count": "4",
+ "max-server-speed": "1600000",
+ "number-primary-servers": "2",
+ "equipment-id": "Server1",
+ "server-model": "Unknown",
+ "server-id": "Server1",
+ "test-node" : {
+ "test-inner-node" : "Test-Value"
+ }
+ }
+ ],
+ "resource-state": {
+ "threshold-value": "1600000",
+ "last-added": "1605000",
+ "used": "1605000",
+ "limit-value": "1920000"
+ },
+ "resource-rule": {
+ "endpoint-position": "VCE-Cust",
+ "soft-limit-expression": "0.6 * max-server-speed * number-primary-servers",
+ "resource-name": "Bandwidth",
+ "service-model": "DUMMY",
+ "hard-limit-expression": "max-server-speed * number-primary-servers",
+ "equipment-level": "Server"
+ },
+ "message": "The provisioned access bandwidth is at or exceeds 50% of the total server capacity."
+}