2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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
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.so.bpmn.appc.payload;
23 import static org.junit.Assert.assertEquals;
24 import java.util.Optional;
25 import org.json.JSONObject;
26 import org.junit.Test;
28 public class PayloadClientTest {
31 public void upgradeFormatTest() throws Exception {
32 String payloadResult =
33 "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"existing_software_version\":\"existingVersion\",\"new_software_version\":\"newVersion\"}}";
34 JSONObject jsonObject = new JSONObject();
35 jsonObject.put("existing_software_version", "existingVersion");
36 jsonObject.put("new_software_version", "newVersion");
37 Optional<String> payload = Optional.of(jsonObject.toString());
38 Optional<String> payloadClient = PayloadClient.upgradeFormat(payload, "vnfName1");
39 assertEquals(payloadResult, payloadClient.get());
43 public void resumeTrafficFormatTest() throws Exception {
44 String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\"}}";
45 Optional<String> payloadClient = PayloadClient.resumeTrafficFormat("vnfName1");
46 assertEquals(payloadResult, payloadClient.get());
50 public void quiesceTrafficFormatTest() throws Exception {
51 String payloadResult =
52 "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"operations_timeout\":\"operationTimeout\"}}";
53 JSONObject jsonObject = new JSONObject();
54 jsonObject.put("operations_timeout", "operationTimeout");
55 Optional<String> payload = Optional.of(jsonObject.toString());
56 Optional<String> payloadClient = PayloadClient.quiesceTrafficFormat(payload, "vnfName1");
57 assertEquals(payloadResult, payloadClient.get());
61 public void startStopFormatTest() throws Exception {
62 String payloadResult = "{\" AICIdentity \":\"aicIdentity1\"}";
63 Optional<String> payloadClient = PayloadClient.startStopFormat("aicIdentity1");
64 assertEquals(payloadResult, payloadClient.get());
68 public void healthCheckFormatTest() throws Exception {
69 String payloadResult = "{\"request-parameters\":{\"host-ip-address\":\"hostIpAddress1\"}}";
70 Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "hostIpAddress1");
71 assertEquals(payloadResult, payloadClient.get());
75 public void snapshotFormatTest() throws Exception {
76 String payloadResult = "{\"vm-id\":\"vmId1\",\"identity-url\":\"identityUrl1\"}";
77 Optional<String> payloadClient = PayloadClient.snapshotFormat("vmId1", "identityUrl1");
78 assertEquals(payloadResult, payloadClient.get());