added assert statements in 4 jUnits
[appc.git] / appc-config / appc-flow-controller / provider / src / test / java / org / onap / appc / flow / executor / node / TestParsingNode.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  * ============LICENSE_END=========================================================
22  */
23 package org.onap.appc.flow.executor.node;
24
25 import java.util.HashMap;
26
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
32 public class TestParsingNode {
33
34     @Test
35     public void testRestServiceNode() throws Exception {
36         SvcLogicContext ctx = new SvcLogicContext();
37         HashMap<String, String> inParams = new HashMap<String, String>();
38         JsonParsingNode rsn = new JsonParsingNode();
39         inParams.put("data", "{\"identifier\": \"scope represented\",\"state\": \"healthy\",\"test\": \"passed\", \"time\": \"01-01-1000:0000\"}");
40         inParams.put("responsePrefix", "APPC.healthcheck");
41         rsn.parse(inParams, ctx);
42         for (Object key : ctx.getAttributeKeySet()) {
43             String parmName = (String) key;
44             String parmValue = ctx.getAttribute(parmName);
45         }
46         
47     }
48     
49     @Test(expected=SvcLogicException.class)
50     public void testRestServiceNodeForNonJsonData() throws Exception {
51         SvcLogicContext ctx = new SvcLogicContext();
52         HashMap<String, String> inParams = new HashMap<String, String>();
53         JsonParsingNode rsn = new JsonParsingNode();
54         inParams.put("data", "2");
55         inParams.put("responsePrefix", "APPC.healthcheck");
56         rsn.parse(inParams, ctx);
57                 
58     }
59 }