added asserts statements in 5 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 import static org.junit.Assert.assertNotNull;
32
33 public class TestParsingNode {
34
35     @Test
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);
46         }
47         assertNotNull(ctx);
48         
49     }
50     
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);
59                 
60     }
61 }