summaryrefslogtreecommitdiffstats
path: root/saltstack-adapter/saltstack-adapter-provider/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'saltstack-adapter/saltstack-adapter-provider/src/test/java/org')
-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
2 files changed, 523 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();
+ }
+}