2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Copyright (C) 2017 Amdocs
 
   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.
 
  21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
 
  22  * ============LICENSE_END=========================================================
 
  25 package org.onap.appc.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 final String PENDING = "100";
 
  45     private final String SUCCESS = "400";
 
  46     private String message = "{\"Results\":{\"192.168.1.10\":{\"Id\":\"101\",\"StatusCode\":200,\"StatusMessage\":\"SUCCESS\"}},\"StatusCode\":200,\"StatusMessage\":\"FINISHED\"}";
 
  48     private ConnectionBuilder connBuilder;
 
  49     private String TestId;
 
  50     private boolean testMode = true;
 
  51     private Map<String, String> params;
 
  52     private SvcLogicContext svcContext;
 
  56     public void setup() throws IllegalArgumentException {
 
  58         svcContext = new SvcLogicContext();
 
  59         String HostName = "test";
 
  62         String Password = "test";
 
  63         connBuilder = new ConnectionBuilder(HostName, Port, User, Password);
 
  65         params = new HashMap<>();
 
  66         params.put("AgentUrl", "https://192.168.1.1");
 
  67         params.put("User", "test");
 
  68         params.put("Password", "test");
 
  72     public void tearDown() {
 
  80     public void reqExecCommand_exitStatus255() {
 
  83         String errFilePath = "src/test/resources/test.json";
 
  84         String command = "test";
 
  86         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
  87         int status = result.getStatusCode();
 
  88         assertEquals(698, status);
 
  92     public void reqExecCommand_exitStatus1() {
 
  95         String errFilePath = "src/test/resources/test.json";
 
  96         String command = "test";
 
  98         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
  99         int status = result.getStatusCode();
 
 100         assertEquals(698, status);
 
 104     public void reqExecCommand_exitStatus5() {
 
 107         String errFilePath = "src/test/resources/test.json";
 
 108         String command = "test";
 
 110         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 111         int status = result.getStatusCode();
 
 112         assertEquals(613, status);
 
 116     public void reqExecCommand_exitStatus65() {
 
 119         String errFilePath = "src/test/resources/test.json";
 
 120         String command = "test";
 
 122         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 123         int status = result.getStatusCode();
 
 124         assertEquals(613, status);
 
 128     public void reqExecCommand_exitStatus67() {
 
 131         String errFilePath = "src/test/resources/test.json";
 
 132         String command = "test";
 
 134         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 135         int status = result.getStatusCode();
 
 136         assertEquals(613, status);
 
 140     public void reqExecCommand_exitStatus73() {
 
 143         String errFilePath = "src/test/resources/test.json";
 
 144         String command = "test";
 
 146         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 147         int status = result.getStatusCode();
 
 148         assertEquals(613, status);
 
 152     public void reqExecCommand_exitStatusUnknown() {
 
 154         int exitStatus = 5121;
 
 155         String errFilePath = "src/test/resources/test.json";
 
 156         String command = "test";
 
 158         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 159         int status = result.getStatusCode();
 
 160         assertEquals(699, status);
 
 164     public void reqExecCommand_exitStatusNoFile() {
 
 167         String errFilePath = "src/test/resource/test.json";
 
 168         String command = "test";
 
 170         SaltstackResult result = connBuilder.sortExitStatus(exitStatus, errFilePath, command);
 
 171         int status = result.getStatusCode();
 
 172         assertEquals(613, status);