Address sonar issues in models
[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-2020 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 static org.junit.Assert.assertNotNull;
24
25 import org.junit.Test;
26 import org.onap.policy.sdnc.util.Serialization;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 public class DemoTest {
31     private static final Logger logger = LoggerFactory.getLogger(DemoTest.class);
32
33     @Test
34     public void test() {
35         SdncRequest request = new SdncRequest();
36
37         request.setNsInstanceId("100");
38         request.setHealRequest(new SdncHealRequest());
39
40         request.getHealRequest().setRequestHeaderInfo(new SdncHealRequestHeaderInfo());
41         request.getHealRequest().getRequestHeaderInfo().setSvcRequestId("service-req-01");
42         request.getHealRequest().getRequestHeaderInfo().setSvcAction("servive-action");
43
44         request.getHealRequest().setRequestInfo(new SdncHealRequestInfo());
45         request.getHealRequest().getRequestInfo().setRequestAction("request-action");
46
47         request.getHealRequest().setServiceInfo(new SdncHealServiceInfo());
48         request.getHealRequest().getServiceInfo().setServiceInstanceId("service-instance-01");
49
50         request.getHealRequest().setNetworkInfo(new SdncHealNetworkInfo());
51         request.getHealRequest().getNetworkInfo().setNetworkId("network-5555");
52
53
54         String body = Serialization.gsonPretty.toJson(request);
55         logger.info("{}", body);
56
57         SdncResponse response = new SdncResponse();
58
59         body = Serialization.gsonPretty.toJson(response);
60         logger.info("{}", body);
61
62         response.setRequestId("request-01");
63         response.setResponseOutput(new SdncResponseOutput());
64         response.getResponseOutput().setSvcRequestId("service-req-01");
65         response.getResponseOutput().setResponseCode("200");
66         response.getResponseOutput().setAckFinalIndicator("final-indicator-00");
67
68         body = Serialization.gsonPretty.toJson(response);
69         logger.info("{}", body);
70
71         response = Serialization.gsonPretty.fromJson(body, SdncResponse.class);
72         body = Serialization.gsonPretty.toJson(response);
73         logger.info("{}", body);
74
75         assertNotNull(body);
76     }
77 }