2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
 
   7  * ================================================================================
 
   8  * Licensed under the Apache License, Version 2.0 (the "License");
 
   9  * you may not use this file except in compliance with the License.
 
  10  * You may obtain a copy of the License at
 
  12  *      http://www.apache.org/licenses/LICENSE-2.0
 
  14  * Unless required by applicable law or agreed to in writing, software
 
  15  * distributed under the License is distributed on an "AS IS" BASIS,
 
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  17  * See the License for the specific language governing permissions and
 
  18  * limitations under the License.
 
  19  * ============LICENSE_END=========================================================
 
  22 package jtest.org.onap.ccsdk.sli.plugins.restapicall;
 
  24 import java.util.HashMap;
 
  27 import org.junit.Test;
 
  28 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 
  29 import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
 
  30 import org.slf4j.Logger;
 
  31 import org.slf4j.LoggerFactory;
 
  33 public class TestRestapiCallNode {
 
  35     private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class);
 
  39     public void testDelete() throws Exception {
 
  40         SvcLogicContext ctx = new SvcLogicContext();
 
  42         Map<String, String> p = new HashMap<String, String>();
 
  43         p.put("restapiUrl", "https://echo.getpostman.com/delete");
 
  44         p.put("restapiUser", "user1");
 
  45         p.put("restapiPassword", "pwd1");
 
  46         p.put("httpMethod", "delete");
 
  47         p.put("skipSending", "true");
 
  49         RestapiCallNode rcn = new RestapiCallNode();
 
  50         rcn.sendRequest(p, ctx);
 
  54     public void testJsonTemplate() throws Exception {
 
  55         SvcLogicContext ctx = new SvcLogicContext();
 
  56         ctx.setAttribute("tmp.sdn-circuit-req-row_length", "3");
 
  57         ctx.setAttribute("tmp.sdn-circuit-req-row[0].source-uid", "APIDOC-123");
 
  58         ctx.setAttribute("tmp.sdn-circuit-req-row[0].action", "delete");
 
  59         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-timestamp", "2016-09-09 16:30:35.0");
 
  60         ctx.setAttribute("tmp.sdn-circuit-req-row[0].request-status", "New");
 
  61         ctx.setAttribute("tmp.sdn-circuit-req-row[0].processing-status", "New");
 
  62         ctx.setAttribute("tmp.sdn-circuit-req-row[0].service-clfi", "testClfi1");
 
  63         ctx.setAttribute("tmp.sdn-circuit-req-row[0].clci", "clci");
 
  64         ctx.setAttribute("tmp.sdn-circuit-req-row[1].source-uid", "APIDOC-123");
 
  65         ctx.setAttribute("tmp.sdn-circuit-req-row[1].action", "delete");
 
  66         ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-timestamp", "2016-09-09 16:30:35.0");
 
  67         ctx.setAttribute("tmp.sdn-circuit-req-row[1].request-status", "New");
 
  68         ctx.setAttribute("tmp.sdn-circuit-req-row[1].processing-status", "New");
 
  69         ctx.setAttribute("tmp.sdn-circuit-req-row[1].service-clfi", "testClfi1");
 
  70         ctx.setAttribute("tmp.sdn-circuit-req-row[1].clci", "clci");
 
  71         ctx.setAttribute("tmp.sdn-circuit-req-row[2].source-uid", "APIDOC-123");
 
  72         ctx.setAttribute("tmp.sdn-circuit-req-row[2].action", "delete");
 
  73         ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-timestamp", "2016-09-09 16:30:35.0");
 
  74         ctx.setAttribute("tmp.sdn-circuit-req-row[2].request-status", "New");
 
  75         ctx.setAttribute("tmp.sdn-circuit-req-row[2].processing-status", "New");
 
  76         ctx.setAttribute("tmp.sdn-circuit-req-row[2].service-clfi", "testClfi1");
 
  77         ctx.setAttribute("tmp.sdn-circuit-req-row[2].clci", "clci");
 
  79         Map<String, String> p = new HashMap<String, String>();
 
  80         p.put("templateFileName", "src/test/resources/test-template.json");
 
  81         p.put("restapiUrl", "http://echo.getpostman.com");
 
  82         p.put("restapiUser", "user1");
 
  83         p.put("restapiPassword", "abc123");
 
  84         p.put("format", "json");
 
  85         p.put("httpMethod", "post");
 
  86         p.put("responsePrefix", "response");
 
  87         p.put("skipSending", "true");
 
  89         RestapiCallNode rcn = new RestapiCallNode();
 
  90         rcn.sendRequest(p, ctx);