2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * =============================================================================
7 * Modifications Copyright (C) 2018 IBM.
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 * ============LICENSE_END=========================================================
23 package org.onap.appc.flow.executor.node;
25 import java.util.HashMap;
27 import org.junit.Test;
28 import org.onap.appc.flow.controller.node.JsonParsingNode;
29 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
31 import static org.junit.Assert.assertNotNull;
33 public class TestParsingNode {
36 public void testRestServiceNode() throws Exception {
37 SvcLogicContext ctx = new SvcLogicContext();
38 HashMap<String, String> inParams = new HashMap<String, String>();
39 JsonParsingNode rsn = new JsonParsingNode();
40 inParams.put("data", "{\"identifier\": \"scope represented\",\"state\": \"healthy\",\"test\": \"passed\", \"time\": \"01-01-1000:0000\"}");
41 inParams.put("responsePrefix", "APPC.healthcheck");
42 rsn.parse(inParams, ctx);
43 for (Object key : ctx.getAttributeKeySet()) {
44 String parmName = (String) key;
45 String parmValue = ctx.getAttribute(parmName);
51 @Test(expected=SvcLogicException.class)
52 public void testRestServiceNodeForNonJsonData() throws Exception {
53 SvcLogicContext ctx = new SvcLogicContext();
54 HashMap<String, String> inParams = new HashMap<String, String>();
55 JsonParsingNode rsn = new JsonParsingNode();
56 inParams.put("data", "2");
57 inParams.put("responsePrefix", "APPC.healthcheck");
58 rsn.parse(inParams, ctx);