aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java
blob: 41f07c3c7b16bbc694be9d78921d7cfbaca5be2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*-
 * ============LICENSE_START=======================================================
 * Copyright (C) 2018 Huawei. All rights reserved.
 * Modifications Copyright (C) 2019 Nordix Foundation.
 * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.policy.sdnc;

import org.junit.Test;
import org.onap.policy.sdnc.util.Serialization;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DemoTest {
    private static final Logger logger = LoggerFactory.getLogger(DemoTest.class);

    @Test
    public void test() {
        SdncRequest request = new SdncRequest();

        request.setNsInstanceId("100");
        request.setHealRequest(new SdncHealRequest());

        request.getHealRequest().setRequestHeaderInfo(new SdncHealRequestHeaderInfo());
        request.getHealRequest().getRequestHeaderInfo().setSvcRequestId("service-req-01");
        request.getHealRequest().getRequestHeaderInfo().setSvcAction("servive-action");

        request.getHealRequest().setRequestInfo(new SdncHealRequestInfo());
        request.getHealRequest().getRequestInfo().setRequestAction("request-action");

        request.getHealRequest().setServiceInfo(new SdncHealServiceInfo());
        request.getHealRequest().getServiceInfo().setServiceInstanceId("service-instance-01");

        request.getHealRequest().setNetworkInfo(new SdncHealNetworkInfo());
        request.getHealRequest().getNetworkInfo().setNetworkId("network-5555");


        String body = Serialization.gsonPretty.toJson(request);
        logger.info("{}", body);

        SdncResponse response = new SdncResponse();

        body = Serialization.gsonPretty.toJson(response);
        logger.info("{}", body);

        response.setRequestId("request-01");
        response.setResponseOutput(new SdncResponseOutput());
        response.getResponseOutput().setSvcRequestId("service-req-01");
        response.getResponseOutput().setResponseCode("200");
        response.getResponseOutput().setAckFinalIndicator("final-indicator-00");

        body = Serialization.gsonPretty.toJson(response);
        logger.info("{}", body);

        response = Serialization.gsonPretty.fromJson(body, SdncResponse.class);
        body = Serialization.gsonPretty.toJson(response);
        logger.info("{}", body);

    }
}