Merge "Add debugging of REST call"
[policy/drools-applications.git] / controlloop / common / model-impl / sdnc / src / test / java / org / onap / policy / sdnc / DemoTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2018 Huawei. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END=========================================================
17  */
18
19 package org.onap.policy.sdnc;
20
21 import java.util.LinkedList;
22
23 import org.junit.Test;
24 import org.onap.policy.sdnc.util.Serialization;
25
26 public class DemoTest {
27
28     @Test
29     public void test() {
30         SdncRequest request = new SdncRequest();
31
32         request.setNsInstanceId("100");
33         request.setHealRequest(new SdncHealRequest());
34
35         request.getHealRequest().setRequestHeaderInfo(new SdncHealRequestHeaderInfo());
36         request.getHealRequest().getRequestHeaderInfo().setSvcRequestId("service-req-01");
37         request.getHealRequest().getRequestHeaderInfo().setSvcAction("servive-action");
38
39         request.getHealRequest().setRequestInfo(new SdncHealRequestInfo());
40         request.getHealRequest().getRequestInfo().setRequestAction("request-action");
41         
42         request.getHealRequest().setServiceInfo(new SdncHealServiceInfo());
43         request.getHealRequest().getServiceInfo().setServiceInstanceId("service-instance-01");
44         
45         request.getHealRequest().setNetworkInfo(new SdncHealNetworkInfo());
46         request.getHealRequest().getNetworkInfo().setNetworkId("network-5555");
47         
48
49         String body = Serialization.gsonPretty.toJson(request);
50         System.out.println(body);
51
52         SdncResponse response = new SdncResponse();
53
54         body = Serialization.gsonPretty.toJson(response);
55         System.out.println(body);
56
57         response.setRequestId("request-01");
58         response.setResponseOutput(new SdncResponseOutput());
59         response.getResponseOutput().setSvcRequestId("service-req-01");
60         response.getResponseOutput().setResponseCode("200");
61         response.getResponseOutput().setAckFinalIndicator("final-indicator-00");
62         
63         body = Serialization.gsonPretty.toJson(response);
64         System.out.println(body);
65
66         response = Serialization.gsonPretty.fromJson(body, SdncResponse.class);
67         body = Serialization.gsonPretty.toJson(response);
68         System.out.println(body);
69
70     }
71 }