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.SaltstackAdapterImpl;
 
  31 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 
  32 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 
  34 import java.util.HashMap;
 
  37 import static org.junit.Assert.assertEquals;
 
  38 import static org.junit.Assert.fail;
 
  41 public class TestSaltstackAdapterImpl {
 
  43     private final String PENDING = "100";
 
  44     private final String SUCCESS = "400";
 
  45     private String message = "{\"Results\":{\"192.168.1.10\":{\"Id\":\"101\",\"StatusCode\":200,\"StatusMessage\":\"SUCCESS\"}},\"StatusCode\":200,\"StatusMessage\":\"FINISHED\"}";
 
  47     private SaltstackAdapterImpl adapter;
 
  48     private String TestId;
 
  49     private boolean testMode = true;
 
  50     private Map<String, String> params;
 
  51     private SvcLogicContext svcContext;
 
  55     public void setup() throws IllegalArgumentException {
 
  57         svcContext = new SvcLogicContext();
 
  58         adapter = new SaltstackAdapterImpl(testMode);
 
  60         params = new HashMap<>();
 
  61         params.put("AgentUrl", "https://192.168.1.1");
 
  62         params.put("User", "test");
 
  63         params.put("Password", "test");
 
  67     public void tearDown() {
 
  74     @Test(expected = SvcLogicException.class)
 
  75     public void reqExecCommand_shouldSetFailed() throws SvcLogicException,
 
  76             IllegalStateException, IllegalArgumentException {
 
  78         params.put("HostName", "test");
 
  79         params.put("Port", "10");
 
  80         params.put("User", "test");
 
  81         params.put("Password", "test");
 
  82         params.put("Test", "fail");
 
  83         adapter.reqExecCommand(params, svcContext);
 
  84         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
  85         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
  86         assertEquals("101", status);
 
  89     @Test(expected = SvcLogicException.class)
 
  90     public void reqExecCommand_shouldSetUserFailed() throws SvcLogicException,
 
  91             IllegalStateException, IllegalArgumentException {
 
  93         params.put("HostName", "test");
 
  94         params.put("Port", "10");
 
  95         params.put("Password", "test");
 
  96         params.put("Test", "fail");
 
  97         adapter.reqExecCommand(params, svcContext);
 
  98         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
  99         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 100         assertEquals("101", status);
 
 103     @Test(expected = SvcLogicException.class)
 
 104     public void reqExecCommand_shouldSetHostFailed() throws SvcLogicException,
 
 105             IllegalStateException, IllegalArgumentException {
 
 107         params.put("Port", "10");
 
 108         params.put("User", "test");
 
 109         params.put("Password", "test");
 
 110         params.put("Test", "fail");
 
 111         adapter.reqExecCommand(params, svcContext);
 
 112         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 113         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 114         assertEquals("101", status);
 
 117     @Test(expected = SvcLogicException.class)
 
 118     public void reqExecCommand_shouldSetPortFailed() throws SvcLogicException,
 
 119             IllegalStateException, IllegalArgumentException {
 
 121         params.put("HostName", "test");
 
 122         params.put("User", "test");
 
 123         params.put("Password", "test");
 
 124         params.put("Test", "fail");
 
 125         adapter.reqExecCommand(params, svcContext);
 
 126         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 127         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 128         assertEquals("101", status);
 
 131     @Test(expected = SvcLogicException.class)
 
 132     public void reqExecCommand_shouldSetPasswordFailed() throws SvcLogicException,
 
 133             IllegalStateException, IllegalArgumentException {
 
 135         params.put("HostName", "test");
 
 136         params.put("Port", "10");
 
 137         params.put("User", "test");
 
 138         params.put("Test", "fail");
 
 139         adapter.reqExecCommand(params, svcContext);
 
 140         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 141         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 142         assertEquals("101", status);
 
 145     @Test(expected = SvcLogicException.class)
 
 146     public void reqExecCommand_shouldSetMandatoryFailed() throws SvcLogicException,
 
 147             IllegalStateException, IllegalArgumentException {
 
 149         params.put("Test", "fail");
 
 150         adapter.reqExecCommand(params, svcContext);
 
 151         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 152         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 153         assertEquals("101", status);
 
 156     @Test(expected = SvcLogicException.class)
 
 157     public void reqExecCommand_NoResponseFile() throws SvcLogicException,
 
 158             IllegalStateException, IllegalArgumentException {
 
 160         params.put("HostName", "test");
 
 161         params.put("Port", "10");
 
 162         params.put("User", "test");
 
 163         params.put("Password", "test");
 
 164         params.put("Test", "success");
 
 165         params.put("cmd", "test");
 
 166         params.put("slsExec", "false");
 
 168             adapter.reqExecCommand(params, svcContext);
 
 169             String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 170             TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 171             assertEquals("400", status);
 
 172         } catch (NullPointerException e) {
 
 173             fail(e.getMessage() + " Unknown exception encountered ");
 
 177     @Test(expected = SvcLogicException.class)
 
 178     public void reqExecCommand_NoResponseFileWithRetry() throws SvcLogicException,
 
 179             IllegalStateException, IllegalArgumentException {
 
 181         params.put("HostName", "test");
 
 182         params.put("Port", "10");
 
 183         params.put("User", "test");
 
 184         params.put("Password", "test");
 
 185         params.put("Test", "success");
 
 186         params.put("retryDelay", "10");
 
 187         params.put("retryCount", "10");
 
 188         params.put("cmd", "test");
 
 189         params.put("slsExec", "false");
 
 191             adapter.reqExecCommand(params, svcContext);
 
 192             String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 193             TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 194             assertEquals("400", status);
 
 195         } catch (NullPointerException e) {
 
 196             fail(e.getMessage() + " Unknown exception encountered ");
 
 200     @Test(expected = SvcLogicException.class)
 
 201     public void reqExecCommand_NoResponseFileWithRetryZero() throws SvcLogicException,
 
 202             IllegalStateException, IllegalArgumentException {
 
 204         params.put("HostName", "test");
 
 205         params.put("Port", "10");
 
 206         params.put("User", "test");
 
 207         params.put("Password", "test");
 
 208         params.put("Test", "success");
 
 209         params.put("retryDelay", "0");
 
 210         params.put("retryCount", "0");
 
 211         params.put("cmd", "test");
 
 212         params.put("slsExec", "false");
 
 214             adapter.reqExecCommand(params, svcContext);
 
 215             String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 216             TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 217             assertEquals("400", status);
 
 218         } catch (NullPointerException e) {
 
 219             fail(e.getMessage() + " Unknown exception encountered ");
 
 223     @Test(expected = SvcLogicException.class)
 
 224     public void reqExecCommand_NoResponseFileWithNoRetry() throws SvcLogicException,
 
 225             IllegalStateException, IllegalArgumentException {
 
 227         params.put("HostName", "test");
 
 228         params.put("Port", "10");
 
 229         params.put("User", "test");
 
 230         params.put("Password", "test");
 
 231         params.put("Test", "success");
 
 232         params.put("retryDelay", "-1");
 
 233         params.put("retryCount", "-1");
 
 234         params.put("cmd", "test");
 
 235         params.put("slsExec", "false");
 
 238             adapter.reqExecCommand(params, svcContext);
 
 239             String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 240             TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 241             assertEquals("400", status);
 
 242         } catch (NullPointerException e) {
 
 243             fail(e.getMessage() + " Unknown exception encountered ");
 
 247     @Test(expected = SvcLogicException.class)
 
 248     public void reqExecCommand_shouldSetFailure() throws SvcLogicException,
 
 249             IllegalStateException, IllegalArgumentException {
 
 251         params.put("HostName", "test");
 
 252         params.put("Port", "10");
 
 253         params.put("User", "test");
 
 254         params.put("Password", "test");
 
 255         params.put("cmd", "test");
 
 256         params.put("slsExec", "test");
 
 257         params.put("Test", "fail");
 
 259             adapter.reqExecCommand(params, svcContext);
 
 260             String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 261             TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 262             assertEquals("400", status);
 
 263         } catch (NullPointerException e) {
 
 264             fail(e.getMessage() + " Unknown exception encountered ");
 
 269     public void reqExecCommand_shouldSetSuccessNoSLS() throws SvcLogicException,
 
 270             IllegalStateException, IllegalArgumentException {
 
 272         params.put("HostName", "test");
 
 273         params.put("Port", "10");
 
 274         params.put("User", "test");
 
 275         params.put("Password", "test");
 
 276         params.put("Test", "success");
 
 277         params.put("fileName", "src/test/resources/test.json");
 
 278         params.put("Id", "test1");
 
 279         params.put("cmd", "test");
 
 280         params.put("slsExec", "false");
 
 282         adapter.reqExecCommand(params, svcContext);
 
 283         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 284         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 285         assertEquals("250", status);
 
 286         assertEquals(TestId, "test1");
 
 290     public void reqExecCommand_shouldSetSuccessExecSLS() throws SvcLogicException,
 
 291             IllegalStateException, IllegalArgumentException {
 
 293         params.put("HostName", "test");
 
 294         params.put("Port", "10");
 
 295         params.put("User", "test");
 
 296         params.put("Password", "test");
 
 297         params.put("Test", "success");
 
 298         params.put("fileName", "src/test/resources/test-sls.json");
 
 299         params.put("Id", "test1");
 
 300         params.put("cmd", "test");
 
 301         params.put("slsExec", "true");
 
 303         adapter.reqExecCommand(params, svcContext);
 
 304         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 305         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 306         assertEquals("200", status);
 
 307         assertEquals(TestId, "test1");
 
 310     @Test(expected = SvcLogicException.class)
 
 311     public void reqExecCommand_shouldSetFailExecSLS() throws SvcLogicException,
 
 312             IllegalStateException, IllegalArgumentException {
 
 314         params.put("HostName", "test");
 
 315         params.put("Port", "10");
 
 316         params.put("User", "test");
 
 317         params.put("Password", "test");
 
 318         params.put("Test", "success");
 
 319         params.put("fileName", "src/test/resources/test.json");
 
 320         params.put("Id", "test1");
 
 321         params.put("cmd", "test");
 
 322         params.put("slsExec", "true");
 
 324         adapter.reqExecCommand(params, svcContext);
 
 325         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 326         assertEquals(TestId, "test1");
 
 330     public void reqExecCommand_shouldSetSuccessFileTxt() throws SvcLogicException,
 
 331             IllegalStateException, IllegalArgumentException {
 
 333         params.put("HostName", "test");
 
 334         params.put("Port", "10");
 
 335         params.put("User", "test");
 
 336         params.put("Password", "test");
 
 337         params.put("Test", "success");
 
 338         params.put("fileName", "src/test/resources/test.txt");
 
 339         params.put("Id", "txt");
 
 340         params.put("cmd", "test");
 
 341         params.put("slsExec", "false");
 
 343         adapter.reqExecCommand(params, svcContext);
 
 344         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 345         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 346         assertEquals("250", status);
 
 347         assertEquals(TestId, "txt");
 
 351     public void reqExecCommand_shouldSetSuccessFileNoExtension() throws SvcLogicException,
 
 352             IllegalStateException, IllegalArgumentException {
 
 354         params.put("HostName", "test");
 
 355         params.put("Port", "10");
 
 356         params.put("User", "test");
 
 357         params.put("Password", "test");
 
 358         params.put("Test", "success");
 
 359         params.put("fileName", "src/test/resources/test");
 
 360         params.put("Id", "txt");
 
 361         params.put("cmd", "test");
 
 362         params.put("slsExec", "false");
 
 364         adapter.reqExecCommand(params, svcContext);
 
 365         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 366         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 367         assertEquals("250", status);
 
 368         assertEquals(TestId, "txt");
 
 372     public void reqExecCommand_shouldSetSuccessFileInvalidJson() throws SvcLogicException,
 
 373             IllegalStateException, IllegalArgumentException {
 
 375         params.put("HostName", "test");
 
 376         params.put("Port", "10");
 
 377         params.put("User", "test");
 
 378         params.put("Password", "test");
 
 379         params.put("Test", "success");
 
 380         params.put("fileName", "src/test/resources/test-invalid.json");
 
 381         params.put("Id", "test1");
 
 382         params.put("cmd", "test");
 
 383         params.put("slsExec", "false");
 
 385         adapter.reqExecCommand(params, svcContext);
 
 386         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 387         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 388         assertEquals("250", status);
 
 391     @Test(expected = SvcLogicException.class)
 
 392     public void reqExecCommand_shouldSetFailFileInvalidFile() throws SvcLogicException,
 
 393             IllegalStateException, IllegalArgumentException {
 
 395         params.put("HostName", "test");
 
 396         params.put("Port", "10");
 
 397         params.put("User", "test");
 
 398         params.put("Password", "test");
 
 399         params.put("Test", "success");
 
 400         params.put("fileName", "src/test/resources/test-none.json");
 
 401         params.put("Id", "test1");
 
 403         adapter.reqExecCommand(params, svcContext);
 
 407     public void reqExecCommand_shouldSetSuccessFileJsonNoReqID() throws SvcLogicException,
 
 408             IllegalStateException, IllegalArgumentException {
 
 410         params.put("HostName", "test");
 
 411         params.put("Port", "10");
 
 412         params.put("User", "test");
 
 413         params.put("Password", "test");
 
 414         params.put("Test", "success");
 
 415         params.put("fileName", "src/test/resources/test.json");
 
 416         params.put("cmd", "test");
 
 417         params.put("slsExec", "false");
 
 419         adapter.reqExecCommand(params, svcContext);
 
 420         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 421         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 422         assertEquals("250", status);
 
 426     public void reqExecSLSFile_shouldSetSuccessJson() throws SvcLogicException,
 
 427             IllegalStateException, IllegalArgumentException {
 
 429         params.put("HostName", "test");
 
 430         params.put("Port", "10");
 
 431         params.put("User", "test");
 
 432         params.put("Password", "test");
 
 433         params.put("Test", "success");
 
 434         params.put("slsFile", "src/test/resources/test.sls");
 
 435         params.put("fileName", "src/test/resources/test-sls.json");
 
 436         params.put("Id", "test1");
 
 437         params.put("cmd", "test");
 
 439         adapter.reqExecSLSFile(params, svcContext);
 
 440         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 441         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 442         assertEquals("200", status);
 
 443         assertEquals(TestId, "test1");
 
 446     @Test(expected = SvcLogicException.class)
 
 447     public void reqExecSLSFile_NoSLSfile() throws SvcLogicException,
 
 448             IllegalStateException, IllegalArgumentException {
 
 450         params.put("HostName", "test");
 
 451         params.put("Port", "10");
 
 452         params.put("User", "test");
 
 453         params.put("Password", "test");
 
 454         params.put("Test", "success");
 
 455         params.put("slsFile", "src/test/resources/test-none.sls");
 
 456         params.put("fileName", "src/test/resources/test-sls.json");
 
 457         params.put("Id", "test1");
 
 459         adapter.reqExecSLSFile(params, svcContext);
 
 460         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 461         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 462         assertEquals(TestId, "test1");
 
 465     @Test(expected = SvcLogicException.class)
 
 466     public void reqExecSLSFile_NoExtn() throws SvcLogicException,
 
 467             IllegalStateException, IllegalArgumentException {
 
 469         params.put("HostName", "test");
 
 470         params.put("Port", "10");
 
 471         params.put("User", "test");
 
 472         params.put("Password", "test");
 
 473         params.put("Test", "success");
 
 474         params.put("slsFile", "src/test/resources/test-none");
 
 475         params.put("fileName", "src/test/resources/test-sls.json");
 
 476         params.put("Id", "test1");
 
 478         adapter.reqExecSLSFile(params, svcContext);
 
 479         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 480         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 481         assertEquals(TestId, "test1");
 
 484     @Test(expected = SvcLogicException.class)
 
 485     public void reqExecSLSFile_NoResponsefile() throws SvcLogicException,
 
 486             IllegalStateException, IllegalArgumentException {
 
 488         params.put("HostName", "test");
 
 489         params.put("Port", "10");
 
 490         params.put("User", "test");
 
 491         params.put("Password", "test");
 
 492         params.put("Test", "success");
 
 493         params.put("slsFile", "src/test/resources/test.json");
 
 494         params.put("fileName", "src/test/resources/test-none.json");
 
 495         params.put("Id", "test1");
 
 497         adapter.reqExecSLSFile(params, svcContext);
 
 498         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 499         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 500         assertEquals(TestId, "test1");
 
 503     @Test(expected = SvcLogicException.class)
 
 504     public void reqExecSLSFile_WithMinionSetNotSLSType() throws SvcLogicException,
 
 505             IllegalStateException, IllegalArgumentException {
 
 507         params.put("HostName", "test");
 
 508         params.put("Port", "10");
 
 509         params.put("User", "test");
 
 510         params.put("Password", "test");
 
 511         params.put("Test", "success");
 
 512         params.put("slsFile", "src/test/resources/test.json");
 
 513         params.put("fileName", "src/test/resources/test-sls.json");
 
 514         params.put("Id", "test1");
 
 515         params.put("cmd", "test");
 
 516         params.put("applyTo", "minion1");
 
 518         adapter.reqExecSLSFile(params, svcContext);
 
 519         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 520         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 521         assertEquals("200", status);
 
 522         assertEquals(TestId, "test1");
 
 526     public void reqExecSLSFile_WithMinionSetSuccessSls() throws SvcLogicException,
 
 527             IllegalStateException, IllegalArgumentException {
 
 529         params.put("HostName", "test");
 
 530         params.put("Port", "10");
 
 531         params.put("User", "test");
 
 532         params.put("Password", "test");
 
 533         params.put("Test", "success");
 
 534         params.put("slsFile", "src/test/resources/test.sls");
 
 535         params.put("fileName", "src/test/resources/test-sls.json");
 
 536         params.put("Id", "test1");
 
 537         params.put("cmd", "test");
 
 538         params.put("applyTo", "minion1");
 
 540         adapter.reqExecSLSFile(params, svcContext);
 
 541         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 542         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 543         assertEquals("200", status);
 
 544         assertEquals(TestId, "test1");
 
 547     @Test(expected = SvcLogicException.class)
 
 548     public void reqExecSLSFile_WithMinionNoSLSfile() throws SvcLogicException,
 
 549             IllegalStateException, IllegalArgumentException {
 
 551         params.put("HostName", "test");
 
 552         params.put("Port", "10");
 
 553         params.put("User", "test");
 
 554         params.put("Password", "test");
 
 555         params.put("Test", "success");
 
 556         params.put("slsFile", "src/test/resources/test-none.json");
 
 557         params.put("fileName", "src/test/resources/test-sls.json");
 
 558         params.put("Id", "test1");
 
 559         params.put("applyTo", "minion1");
 
 561         adapter.reqExecSLSFile(params, svcContext);
 
 562         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 563         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 564         assertEquals(TestId, "test1");
 
 567     @Test(expected = SvcLogicException.class)
 
 568     public void reqExecSLSFile_WithMinionNoResponsefile() throws SvcLogicException,
 
 569             IllegalStateException, IllegalArgumentException {
 
 571         params.put("HostName", "test");
 
 572         params.put("Port", "10");
 
 573         params.put("User", "test");
 
 574         params.put("Password", "test");
 
 575         params.put("Test", "success");
 
 576         params.put("slsFile", "src/test/resources/test.json");
 
 577         params.put("fileName", "src/test/resources/test-none.json");
 
 578         params.put("Id", "test1");
 
 579         params.put("applyTo", "minion1");
 
 581         adapter.reqExecSLSFile(params, svcContext);
 
 582         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 583         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 584         assertEquals(TestId, "test1");
 
 588     public void reqExecSLSFile_WithAllMinionSetSuccessJson() throws SvcLogicException,
 
 589             IllegalStateException, IllegalArgumentException {
 
 591         params.put("HostName", "test");
 
 592         params.put("Port", "10");
 
 593         params.put("User", "test");
 
 594         params.put("Password", "test");
 
 595         params.put("Test", "success");
 
 596         params.put("slsFile", "src/test/resources/test.sls");
 
 597         params.put("fileName", "src/test/resources/test-sls.json");
 
 598         params.put("Id", "test1");
 
 599         params.put("cmd", "test");
 
 600         params.put("applyTo", "*");
 
 602         adapter.reqExecSLSFile(params, svcContext);
 
 603         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 604         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 605         assertEquals("200", status);
 
 606         assertEquals(TestId, "test1");
 
 609     @Test(expected = SvcLogicException.class)
 
 610     public void reqExecSLSFile_WithAllMinionNoSLSfile() throws SvcLogicException,
 
 611             IllegalStateException, IllegalArgumentException {
 
 613         params.put("HostName", "test");
 
 614         params.put("Port", "10");
 
 615         params.put("User", "test");
 
 616         params.put("Password", "test");
 
 617         params.put("Test", "success");
 
 618         params.put("slsFile", "src/test/resources/test-none.json");
 
 619         params.put("fileName", "src/test/resources/test-sls.json");
 
 620         params.put("Id", "test1");
 
 621         params.put("applyTo", "*");
 
 623         adapter.reqExecSLSFile(params, svcContext);
 
 624         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 625         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 626         assertEquals(TestId, "test1");
 
 629     @Test(expected = SvcLogicException.class)
 
 630     public void reqExecSLSFile_WithAllMinionNoResponsefile() throws SvcLogicException,
 
 631             IllegalStateException, IllegalArgumentException {
 
 633         params.put("HostName", "test");
 
 634         params.put("Port", "10");
 
 635         params.put("User", "test");
 
 636         params.put("Password", "test");
 
 637         params.put("Test", "success");
 
 638         params.put("slsFile", "src/test/resources/test.json");
 
 639         params.put("fileName", "src/test/resources/test-none.json");
 
 640         params.put("Id", "test1");
 
 641         params.put("applyTo", "*");
 
 643         adapter.reqExecSLSFile(params, svcContext);
 
 644         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 645         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 646         assertEquals(TestId, "test1");
 
 651     public void reqExecSLS_shouldSetSuccessJson() throws SvcLogicException,
 
 652             IllegalStateException, IllegalArgumentException {
 
 654         params.put("HostName", "test");
 
 655         params.put("Port", "10");
 
 656         params.put("User", "test");
 
 657         params.put("Password", "test");
 
 658         params.put("Test", "success");
 
 659         params.put("slsName", "src/test.sls");
 
 660         params.put("fileName", "src/test/resources/test-sls.json");
 
 661         params.put("Id", "test1");
 
 662         params.put("cmd", "test");
 
 664         adapter.reqExecSLS(params, svcContext);
 
 665         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 666         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 667         assertEquals("200", status);
 
 668         assertEquals(TestId, "test1");
 
 672     public void reqExecSLS_shouldSetNoExtn() throws SvcLogicException,
 
 673             IllegalStateException, IllegalArgumentException {
 
 675         params.put("HostName", "test");
 
 676         params.put("Port", "10");
 
 677         params.put("User", "test");
 
 678         params.put("Password", "test");
 
 679         params.put("Test", "success");
 
 680         params.put("slsName", "src/test");
 
 681         params.put("fileName", "src/test/resources/test-sls.json");
 
 682         params.put("Id", "test1");
 
 683         params.put("cmd", "test");
 
 685         adapter.reqExecSLS(params, svcContext);
 
 686         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 687         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 688         assertEquals("200", status);
 
 689         assertEquals(TestId, "test1");
 
 692     @Test(expected = SvcLogicException.class)
 
 693     public void reqExecSLS_NoResponsefile() throws SvcLogicException,
 
 694             IllegalStateException, IllegalArgumentException {
 
 696         params.put("HostName", "test");
 
 697         params.put("Port", "10");
 
 698         params.put("User", "test");
 
 699         params.put("Password", "test");
 
 700         params.put("Test", "success");
 
 701         params.put("slsName", "src/test/resources/test.json");
 
 702         params.put("fileName", "src/test/resources/test-none.json");
 
 703         params.put("Id", "test1");
 
 705         adapter.reqExecSLS(params, svcContext);
 
 706         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 707         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 708         assertEquals(TestId, "test1");
 
 713     public void reqExecSLS_WithMinionSetSuccessSls() throws SvcLogicException,
 
 714             IllegalStateException, IllegalArgumentException {
 
 716         params.put("HostName", "test");
 
 717         params.put("Port", "10");
 
 718         params.put("User", "test");
 
 719         params.put("Password", "test");
 
 720         params.put("Test", "success");
 
 721         params.put("slsName", "src/test/resources/test.sls");
 
 722         params.put("fileName", "src/test/resources/test-sls.json");
 
 723         params.put("Id", "test1");
 
 724         params.put("cmd", "test");
 
 725         params.put("applyTo", "minion1");
 
 727         adapter.reqExecSLS(params, svcContext);
 
 728         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 729         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 730         assertEquals("200", status);
 
 731         assertEquals(TestId, "test1");
 
 735     @Test(expected = SvcLogicException.class)
 
 736     public void reqExecSLS_WithMinionNoResponsefile() throws SvcLogicException,
 
 737             IllegalStateException, IllegalArgumentException {
 
 739         params.put("HostName", "test");
 
 740         params.put("Port", "10");
 
 741         params.put("User", "test");
 
 742         params.put("Password", "test");
 
 743         params.put("Test", "success");
 
 744         params.put("slsName", "src/test/resources/test.json");
 
 745         params.put("fileName", "src/test/resources/test-none.json");
 
 746         params.put("Id", "test1");
 
 747         params.put("applyTo", "minion1");
 
 749         adapter.reqExecSLS(params, svcContext);
 
 750         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 751         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 752         assertEquals(TestId, "test1");
 
 756     public void reqExecSLS_WithAllMinionSetSuccessJson() throws SvcLogicException,
 
 757             IllegalStateException, IllegalArgumentException {
 
 759         params.put("HostName", "test");
 
 760         params.put("Port", "10");
 
 761         params.put("User", "test");
 
 762         params.put("Password", "test");
 
 763         params.put("Test", "success");
 
 764         params.put("slsName", "src/test/resources/test.sls");
 
 765         params.put("fileName", "src/test/resources/test-sls.json");
 
 766         params.put("Id", "test1");
 
 767         params.put("cmd", "test");
 
 768         params.put("applyTo", "*");
 
 770         adapter.reqExecSLS(params, svcContext);
 
 771         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 772         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 773         assertEquals("200", status);
 
 774         assertEquals(TestId, "test1");
 
 778     @Test(expected = SvcLogicException.class)
 
 779     public void reqExecSLS_WithAllMinionNoResponsefile() throws SvcLogicException,
 
 780             IllegalStateException, IllegalArgumentException {
 
 782         params.put("HostName", "test");
 
 783         params.put("Port", "10");
 
 784         params.put("User", "test");
 
 785         params.put("Password", "test");
 
 786         params.put("Test", "success");
 
 787         params.put("slsName", "src/test/resources/test.json");
 
 788         params.put("fileName", "src/test/resources/test-none.json");
 
 789         params.put("Id", "test1");
 
 790         params.put("applyTo", "*");
 
 792         adapter.reqExecSLS(params, svcContext);
 
 793         String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code");
 
 794         TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id");
 
 795         assertEquals(TestId, "test1");
 
 800     public void reqExecLog_shouldSetMessage() throws IllegalStateException, IllegalArgumentException {
 
 802         params.put("Id", "101");
 
 805             adapter.reqExecLog(params, svcContext);
 
 806             String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.log");
 
 807             //assertEquals(message, status);
 
 808             assertEquals(null, status);
 
 809         } catch (SvcLogicException e) {
 
 810             String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.log");
 
 811             fail(e.getMessage() + " Code = " + status);
 
 812         } catch (Exception e) {
 
 813             fail(e.getMessage() + " Unknown exception encountered ");