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