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