From fe8c4ae15a2301db06f1a1b217b8db82f4716211 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Mon, 7 Oct 2019 11:38:20 +0900 Subject: Test cases fix Change-Id: I2de47d5c7c8b41a2e2536f9f9ffaec1193d8f5ba Signed-off-by: Ganesh Chandrasekaran Issue-ID: CCSDK-1806 Signed-off-by: Ganesh Chandrasekaran --- .../adaptors/saltstack/impl/ConnectionBuilder.java | 3 +++ .../ccsdk/adapter/impl/TestConnectionBuilder.java | 28 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'saltstack-adapter') diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java index 9f1799821..48469fdd5 100644 --- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java @@ -134,6 +134,9 @@ public class ConnectionBuilder { return result; } + /** + * Print Reasonable error messages based on SSH Exit status code + * */ public SaltstackResult sortExitStatus(int exitStatus, String errMess, String cmd) { SaltstackResult result = new SaltstackResult(); if (exitStatus == 255 || exitStatus == 1) { diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestConnectionBuilder.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestConnectionBuilder.java index 8cd7af25e..71fcf3454 100644 --- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestConnectionBuilder.java +++ b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestConnectionBuilder.java @@ -86,6 +86,30 @@ public class TestConnectionBuilder { assertEquals(698, status); } + @Test + public void reqExecCommand_exitStatus67() { + + int exitStatus = 67; + String errFilePath = "src/test/resources/test.json"; + String command = "test"; + + SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command); + int status = result.getStatusCode(); + assertEquals(610, status); + } + + @Test + public void reqExecCommand_exitStatus73() { + + int exitStatus = 73; + String errFilePath = "src/test/resources/test.json"; + String command = "test"; + + SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command); + int status = result.getStatusCode(); + assertEquals(610, status); + } + @Test public void reqExecCommand_exitStatus5() { @@ -111,7 +135,7 @@ public class TestConnectionBuilder { } @Test - public void reqExecCommand_exitStatus67() { + public void reqExecCommand_exitStatus67613() { int exitStatus = 5; String errFilePath = "src/test/resources/test.json"; @@ -123,7 +147,7 @@ public class TestConnectionBuilder { } @Test - public void reqExecCommand_exitStatus73() { + public void reqExecCommand_exitStatus65613() { int exitStatus = 65; String errFilePath = "src/test/resources/test.json"; -- cgit 1.2.3-korg