2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2018 Samsung Electronics. All rights reserved.
 
   6  * ================================================================================
 
   8  * =============================================================================
 
   9  * Licensed under the Apache License, Version 2.0 (the "License");
 
  10  * you may not use this file except in compliance with the License.
 
  11  * You may obtain a copy of the License at
 
  13  *      http://www.apache.org/licenses/LICENSE-2.0
 
  15  * Unless required by applicable law or agreed to in writing, software
 
  16  * distributed under the License is distributed on an "AS IS" BASIS,
 
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  18  * See the License for the specific language governing permissions and
 
  19  * limitations under the License.
 
  22  * ============LICENSE_END=========================================================
 
  25 package org.onap.ccsdk.adapter.impl;
 
  27 import org.junit.After;
 
  28 import org.junit.Before;
 
  29 import org.junit.Test;
 
  30 import org.onap.ccsdk.sli.adaptors.saltstack.impl.ConnectionBuilder;
 
  31 import org.onap.ccsdk.sli.adaptors.saltstack.model.SaltstackResult;
 
  32 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 
  33 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 
  35 import java.util.HashMap;
 
  38 import static org.junit.Assert.assertEquals;
 
  39 import static org.junit.Assert.fail;
 
  42 public class TestConnectionBuilder {
 
  44     private ConnectionBuilder connBuilder;
 
  45     private Map<String, String> params;
 
  49     public void setup() throws IllegalArgumentException {
 
  50         String HostName = "test";
 
  53         String Password = "test";
 
  54         connBuilder = new ConnectionBuilder(HostName, Port, User, Password);
 
  56         params = new HashMap<>();
 
  57         params.put("AgentUrl", "https://192.168.1.1");
 
  58         params.put("User", "test");
 
  59         params.put("Password", "test");
 
  63     public void tearDown() {
 
  69     public void reqExecCommand_exitStatus255() {
 
  72         String errFilePath = "src/test/resources/test.json";
 
  73         String command = "test";
 
  75         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
  76         int status = result.getStatusCode();
 
  77         assertEquals(698, status);
 
  81     public void reqExecCommand_exitStatus1() {
 
  84         String errFilePath = "src/test/resources/test.json";
 
  85         String command = "test";
 
  87         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
  88         int status = result.getStatusCode();
 
  89         assertEquals(698, status);
 
  93     public void reqExecCommand_exitStatus5() {
 
  96         String errFilePath = "src/test/resources/test.json";
 
  97         String command = "test";
 
  99         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 100         int status = result.getStatusCode();
 
 101         assertEquals(613, status);
 
 105     public void reqExecCommand_exitStatus65() {
 
 108         String errFilePath = "src/test/resources/test.json";
 
 109         String command = "test";
 
 111         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 112         int status = result.getStatusCode();
 
 113         assertEquals(613, status);
 
 117     public void reqExecCommand_exitStatus67() {
 
 120         String errFilePath = "src/test/resources/test.json";
 
 121         String command = "test";
 
 123         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 124         int status = result.getStatusCode();
 
 125         assertEquals(613, status);
 
 129     public void reqExecCommand_exitStatus73() {
 
 132         String errFilePath = "src/test/resources/test.json";
 
 133         String command = "test";
 
 135         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 136         int status = result.getStatusCode();
 
 137         assertEquals(613, status);
 
 141     public void reqExecCommand_exitStatusUnknown() {
 
 143         int exitStatus = 5121;
 
 144         String errFilePath = "src/test/resources/test.json";
 
 145         String command = "test";
 
 147         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 148         int status = result.getStatusCode();
 
 149         assertEquals(699, status);
 
 153     public void reqExecCommand_exitStatusNoFile() {
 
 156         String errFilePath = "src/test/resource/test.json";
 
 157         String command = "test";
 
 159         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 160         int status = result.getStatusCode();
 
 161         assertEquals(613, status);