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