summaryrefslogtreecommitdiffstats
path: root/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-13 09:41:32 +0900
committerGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-16 16:24:56 +0900
commit3323c0829fa0492a5c7b3544a83cc24412c9934c (patch)
tree421b5d254821a24d63869b8c6651ea74a562d1ea /saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc
parent3c36ac2ba101ec0cc596c15bfd45efcc731f442f (diff)
saltstack adaptor fixes from Sonar
Issue-ID: CCSDK-364 Change-Id: Ief9705370d84fcb99fcb718f03c31e6cbfd47363 Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
Diffstat (limited to 'saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc')
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestConnectionBuilder.java174
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java816
-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/java/org/onap/appc/adapter/model/TestJsonParser.java74
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/model/TestSaltstackAdapter.java80
5 files changed, 0 insertions, 1467 deletions
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestConnectionBuilder.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestConnectionBuilder.java
deleted file mode 100644
index d9a38414..00000000
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestConnectionBuilder.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*-
- * ============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.impl.ConnectionBuilder;
-import org.onap.ccsdk.sli.adaptors.saltstack.model.SaltstackResult;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-
-public class TestConnectionBuilder {
-
- 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 ConnectionBuilder connBuilder;
- private String TestId;
- private boolean testMode = true;
- private Map<String, String> params;
- private SvcLogicContext svcContext;
-
-
- @Before
- public void setup() throws IllegalArgumentException {
- testMode = true;
- svcContext = new SvcLogicContext();
- String HostName = "test";
- String Port = "10";
- String User = "test";
- String Password = "test";
- connBuilder = new ConnectionBuilder(HostName, Port, User, Password);
-
- params = new HashMap<>();
- params.put("AgentUrl", "https://192.168.1.1");
- params.put("User", "test");
- params.put("Password", "test");
- }
-
- @After
- public void tearDown() {
- testMode = false;
- connBuilder = null;
- params = null;
- svcContext = null;
- }
-
- @Test
- public void reqExecCommand_exitStatus255() {
-
- int exitStatus = 255;
- String errFilePath = "src/test/resources/test.json";
- String command = "test";
-
- SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
- int status = result.getStatusCode();
- assertEquals(698, status);
- }
-
- @Test
- public void reqExecCommand_exitStatus1() {
-
- int exitStatus = 1;
- String errFilePath = "src/test/resources/test.json";
- String command = "test";
-
- SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
- int status = result.getStatusCode();
- assertEquals(698, status);
- }
-
- @Test
- public void reqExecCommand_exitStatus5() {
-
- int exitStatus = 5;
- String errFilePath = "src/test/resources/test.json";
- String command = "test";
-
- SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
- int status = result.getStatusCode();
- assertEquals(613, status);
- }
-
- @Test
- public void reqExecCommand_exitStatus65() {
-
- int exitStatus = 65;
- String errFilePath = "src/test/resources/test.json";
- String command = "test";
-
- SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
- int status = result.getStatusCode();
- assertEquals(613, status);
- }
-
- @Test
- public void reqExecCommand_exitStatus67() {
-
- int exitStatus = 5;
- String errFilePath = "src/test/resources/test.json";
- String command = "test";
-
- SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
- int status = result.getStatusCode();
- assertEquals(613, status);
- }
-
- @Test
- public void reqExecCommand_exitStatus73() {
-
- int exitStatus = 65;
- String errFilePath = "src/test/resources/test.json";
- String command = "test";
-
- SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
- int status = result.getStatusCode();
- assertEquals(613, status);
- }
-
- @Test
- public void reqExecCommand_exitStatusUnknown() {
-
- int exitStatus = 5121;
- String errFilePath = "src/test/resources/test.json";
- String command = "test";
-
- SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
- int status = result.getStatusCode();
- assertEquals(699, status);
- }
-
- @Test
- public void reqExecCommand_exitStatusNoFile() {
-
- int exitStatus = 65;
- String errFilePath = "src/test/resource/test.json";
- String command = "test";
-
- SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
- int status = result.getStatusCode();
- assertEquals(613, status);
- }
-}
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
deleted file mode 100644
index d60059e4..00000000
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterImpl.java
+++ /dev/null
@@ -1,816 +0,0 @@
-/*-
- * ============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.impl.SaltstackAdapterImpl;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-
-public class TestSaltstackAdapterImpl {
-
- 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 String TestId;
- private boolean testMode = true;
- private Map<String, String> params;
- private SvcLogicContext svcContext;
-
-
- @Before
- public void setup() throws IllegalArgumentException {
- testMode = true;
- svcContext = new SvcLogicContext();
- adapter = new SaltstackAdapterImpl(testMode);
-
- params = new HashMap<>();
- params.put("AgentUrl", "https://192.168.1.1");
- params.put("User", "test");
- params.put("Password", "test");
- }
-
- @After
- public void tearDown() {
- testMode = false;
- adapter = null;
- params = null;
- svcContext = null;
- }
-
- @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.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.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.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.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.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.Id");
- assertEquals("101", status);
- }
-
- @Test(expected = SvcLogicException.class)
- public void reqExecCommand_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("cmd", "test");
- params.put("slsExec", "false");
- try {
- 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("400", status);
- } catch (NullPointerException e) {
- fail(e.getMessage() + " Unknown exception encountered ");
- }
- }
-
- @Test(expected = SvcLogicException.class)
- public void reqExecCommand_NoResponseFileWithRetry() 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("retryDelay", "10");
- params.put("retryCount", "10");
- params.put("cmd", "test");
- params.put("slsExec", "false");
- try {
- 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("400", status);
- } catch (NullPointerException e) {
- fail(e.getMessage() + " Unknown exception encountered ");
- }
- }
-
- @Test(expected = SvcLogicException.class)
- public void reqExecCommand_NoResponseFileWithRetryZero() 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("retryDelay", "0");
- params.put("retryCount", "0");
- params.put("cmd", "test");
- params.put("slsExec", "false");
- try {
- 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("400", status);
- } catch (NullPointerException e) {
- fail(e.getMessage() + " Unknown exception encountered ");
- }
- }
-
- @Test(expected = SvcLogicException.class)
- public void reqExecCommand_NoResponseFileWithNoRetry() 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("retryDelay", "-1");
- params.put("retryCount", "-1");
- params.put("cmd", "test");
- params.put("slsExec", "false");
-
- try {
- 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("400", status);
- } catch (NullPointerException e) {
- fail(e.getMessage() + " Unknown exception encountered ");
- }
- }
-
- @Test(expected = SvcLogicException.class)
- public void reqExecCommand_shouldSetFailure() throws SvcLogicException,
- IllegalStateException, IllegalArgumentException {
-
- params.put("HostName", "test");
- params.put("Port", "10");
- params.put("User", "test");
- params.put("Password", "test");
- params.put("cmd", "test");
- params.put("slsExec", "test");
- params.put("Test", "fail");
- try {
- 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("400", status);
- } catch (NullPointerException e) {
- fail(e.getMessage() + " Unknown exception encountered ");
- }
- }
-
- @Test
- public void reqExecCommand_shouldSetSuccessNoSLS() 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("fileName", "src/test/resources/test.json");
- params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("slsExec", "false");
-
- 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("250", status);
- assertEquals(TestId, "test1");
- }
-
- @Test
- public void reqExecCommand_shouldSetSuccessExecSLS() 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("fileName", "src/test/resources/test-sls.json");
- params.put("Id", "test1");
- params.put("cmd", "test");
- 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("200", status);
- assertEquals(TestId, "test1");
- }
-
- @Test(expected = SvcLogicException.class)
- public void reqExecCommand_shouldSetFailExecSLS() 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("fileName", "src/test/resources/test.json");
- params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("slsExec", "true");
-
- adapter.reqExecCommand(params, svcContext);
- TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
- assertEquals(TestId, "test1");
- }
-
- @Test
- public void reqExecCommand_shouldSetSuccessFileTxt() 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("fileName", "src/test/resources/test.txt");
- params.put("Id", "txt");
- params.put("cmd", "test");
- params.put("slsExec", "false");
-
- 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("250", status);
- assertEquals(TestId, "txt");
- }
-
- @Test
- public void reqExecCommand_shouldSetSuccessFileNoExtension() 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("fileName", "src/test/resources/test");
- params.put("Id", "txt");
- params.put("cmd", "test");
- params.put("slsExec", "false");
-
- 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("250", status);
- assertEquals(TestId, "txt");
- }
-
- @Test
- public void reqExecCommand_shouldSetSuccessFileInvalidJson() 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("fileName", "src/test/resources/test-invalid.json");
- params.put("Id", "test1");
- params.put("cmd", "test");
- params.put("slsExec", "false");
-
- 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("250", status);
- }
-
- @Test(expected = SvcLogicException.class)
- public void reqExecCommand_shouldSetFailFileInvalidFile() 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("fileName", "src/test/resources/test-none.json");
- params.put("Id", "test1");
-
- adapter.reqExecCommand(params, svcContext);
- }
-
- @Test
- public void reqExecCommand_shouldSetSuccessFileJsonNoReqID() 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("fileName", "src/test/resources/test.json");
- params.put("cmd", "test");
- params.put("slsExec", "false");
-
- 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("250", status);
- }
-
- @Test
- public void reqExecSLSFile_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("slsFile", "src/test/resources/test.sls");
- params.put("fileName", "src/test/resources/test-sls.json");
- params.put("Id", "test1");
- params.put("cmd", "test");
-
- 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_NoSLSfile() 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.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");
-
- 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_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("slsFile", "src/test/resources/test.json");
- params.put("fileName", "src/test/resources/test-none.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_WithMinionSetNotSLSType() 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.json");
- 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
- 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 {
-
- 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.json");
- params.put("fileName", "src/test/resources/test-sls.json");
- params.put("Id", "test1");
- 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(TestId, "test1");
- }
-
- @Test(expected = SvcLogicException.class)
- public void reqExecSLSFile_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("slsFile", "src/test/resources/test.json");
- params.put("fileName", "src/test/resources/test-none.json");
- params.put("Id", "test1");
- 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(TestId, "test1");
- }
-
- @Test
- public void reqExecSLSFile_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("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", "*");
-
- 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_WithAllMinionNoSLSfile() 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.json");
- params.put("fileName", "src/test/resources/test-sls.json");
- params.put("Id", "test1");
- params.put("applyTo", "*");
-
- 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_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("slsFile", "src/test/resources/test.json");
- params.put("fileName", "src/test/resources/test-none.json");
- params.put("Id", "test1");
- params.put("applyTo", "*");
-
- 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
- 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 {
-
- params.put("Id", "101");
-
- try {
- adapter.reqExecLog(params, svcContext);
- String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.log");
- //assertEquals(message, status);
- assertEquals(null, status);
- } catch (SvcLogicException e) {
- String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.log");
- fail(e.getMessage() + " Code = " + status);
- } catch (Exception e) {
- fail(e.getMessage() + " Unknown exception encountered ");
- }
- }
-}
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
deleted file mode 100644
index 92759183..00000000
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/impl/TestSaltstackAdapterPropertiesProviderImpl.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*-
- * ============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/java/org/onap/appc/adapter/model/TestJsonParser.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/model/TestJsonParser.java
deleted file mode 100644
index ae13da6c..00000000
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/model/TestJsonParser.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.model;
-
-import org.codehaus.jettison.json.JSONException;
-import org.junit.Test;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.adaptors.saltstack.model.JsonParser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-public class TestJsonParser {
-
- private static final Logger log = LoggerFactory.getLogger(TestJsonParser.class);
-
- @Test
- public void test() throws SvcLogicException, IOException, JSONException {
- BufferedReader in = new BufferedReader(
- new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json"))
- );
- StringBuilder b = new StringBuilder();
- String line;
- while ((line = in.readLine()) != null)
- b.append(line).append('\n');
-
- Map<String, String> mm = JsonParser.convertToProperties(b.toString());
-
- logProperties(mm);
-
- in.close();
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullString() throws SvcLogicException, JSONException {
- JsonParser.convertToProperties(null);
- }
-
- private void logProperties(Map<String, String> mm) {
- List<String> ll = new ArrayList<>();
- for (Object o : mm.keySet())
- ll.add((String) o);
- Collections.sort(ll);
- log.info("Properties:");
- for (String name : ll)
- log.info("--- {}: {}", name, mm.get(name));
- }
-}
diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/model/TestSaltstackAdapter.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/model/TestSaltstackAdapter.java
deleted file mode 100644
index 37b6502c..00000000
--- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/appc/adapter/model/TestSaltstackAdapter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * ============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.model;
-
-import org.junit.Test;
-import org.onap.ccsdk.sli.adaptors.saltstack.model.SaltstackMessageParser;
-import org.onap.ccsdk.sli.adaptors.saltstack.model.SaltstackResult;
-import org.onap.ccsdk.sli.adaptors.saltstack.model.SaltstackServerEmulator;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import static org.junit.Assert.assertNotNull;
-
-public class TestSaltstackAdapter {
-
- private Class[] parameterTypes;
- private SaltstackMessageParser saltstackMessageParser;
- private Method m;
- private String name;
-
- @Test
- public void callPrivateConstructorsMethodsForCodeCoverage() throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
-
- /* test constructors */
- Class<?>[] classesOne = {SaltstackMessageParser.class};
- for(Class<?> clazz : classesOne) {
- Constructor<?> constructor = clazz.getDeclaredConstructor();
- name = constructor.getName();
- constructor.setAccessible(true);
- assertNotNull(constructor.newInstance());
- }
- Class<?>[] classesTwo = {SaltstackServerEmulator.class};
- for(Class<?> clazz : classesTwo) {
- Constructor<?> constructor = clazz.getDeclaredConstructor();
- name = constructor.getName();
- constructor.setAccessible(true);
- assertNotNull(constructor.newInstance());
- }
- Class<?>[] classesThree = {SaltstackResult.class};
- for(Class<?> clazz : classesThree) {
- Constructor<?> constructor = clazz.getDeclaredConstructor();
- name = constructor.getName();
- constructor.setAccessible(true);
- assertNotNull(constructor.newInstance());
- }
-
- /* test methods */
- saltstackMessageParser = new SaltstackMessageParser();
- parameterTypes = new Class[1];
- parameterTypes[0] = String.class;
-
- m = saltstackMessageParser.getClass().getDeclaredMethod("getFilePayload", parameterTypes);
- m.setAccessible(true);
- assertNotNull(m.invoke(saltstackMessageParser,"{\"test\": test}"));
-
- }
-}