2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2017-2019 Intel Corp. All rights reserved.
4 * Modifications Copyright (C) 2019 Nordix Foundation.
5 * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.vfc;
23 import java.util.LinkedList;
25 import org.junit.Test;
26 import org.onap.policy.vfc.util.Serialization;
28 public class DemoTest {
32 VfcRequest request = new VfcRequest();
34 request.setNsInstanceId("100");
35 request.setHealRequest(new VfcHealRequest());
36 request.getHealRequest().setVnfInstanceId("1");
37 request.getHealRequest().setCause("vm is down");
39 request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams());
40 request.getHealRequest().getAdditionalParams().setAction("restartvm");
42 request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo());
43 request.getHealRequest().getAdditionalParams().getActionInfo().setVmid("33");
44 request.getHealRequest().getAdditionalParams().getActionInfo().setVmname("xgw-smp11");
46 String body = Serialization.gsonPretty.toJson(request);
47 System.out.println(body);
49 VfcResponse response = new VfcResponse();
50 response.setJobId("1");
52 body = Serialization.gsonPretty.toJson(response);
53 System.out.println(body);
55 response.setResponseDescriptor(new VfcResponseDescriptor());
56 response.getResponseDescriptor().setProgress("40");
57 response.getResponseDescriptor().setStatus("processing");
58 response.getResponseDescriptor().setStatusDescription("OMC VMs are decommissioned in VIM");
59 response.getResponseDescriptor().setErrorCode(null);
60 response.getResponseDescriptor().setResponseId("42");
61 body = Serialization.gsonPretty.toJson(response);
62 System.out.println(body);
64 VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor();
65 responseDescriptor.setProgress("20");
66 responseDescriptor.setStatus("processing");
67 responseDescriptor.setStatusDescription("OMC VMs are decommissioned in VIM");
68 responseDescriptor.setErrorCode(null);
69 responseDescriptor.setResponseId("11");
71 response.getResponseDescriptor().setResponseHistoryList(new LinkedList<>());
72 response.getResponseDescriptor().getResponseHistoryList().add(responseDescriptor);
74 body = Serialization.gsonPretty.toJson(response);
75 System.out.println(body);
77 response = Serialization.gsonPretty.fromJson(body, VfcResponse.class);
78 body = Serialization.gsonPretty.toJson(response);
79 System.out.println(body);