20c69fafe394b87d164b26e071df5965d919b91c
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / onap / so / bpmn / appc / payload / PayloadClientTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
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.so.bpmn.appc.payload;
22
23 import static org.junit.Assert.assertEquals;
24
25 import java.util.Optional;
26
27 import org.json.JSONObject;
28 import org.junit.Test;
29
30 public class PayloadClientTest {
31
32         @Test
33         public void upgradeFormatTest()  throws Exception {
34                 String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"existing_software_version\":\"existingVersion\",\"new_software_version\":\"newVersion\"}}";
35                 JSONObject jsonObject = new JSONObject();
36                 jsonObject.put("existing_software_version", "existingVersion");
37                 jsonObject.put("new_software_version", "newVersion");
38                 Optional<String> payload = Optional.of(jsonObject.toString());
39                 Optional<String> payloadClient = PayloadClient.upgradeFormat(payload, "vnfName1"); 
40                 assertEquals(payloadResult, payloadClient.get());
41         }
42
43         @Test
44         public void resumeTrafficFormatTest()  throws Exception {
45                 String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\"}}";
46                 Optional<String> payloadClient = PayloadClient.resumeTrafficFormat("vnfName1"); 
47                 assertEquals(payloadResult, payloadClient.get());
48         }       
49         
50         @Test
51         public void quiesceTrafficFormatTest()  throws Exception {
52                 String payloadResult = "{\"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());
58         }       
59         
60         @Test
61         public void startStopFormatTest()  throws Exception {
62                 String payloadResult = "{\" AICIdentity \":\"aicIdentity1\"}";
63                 Optional<String> payloadClient = PayloadClient.startStopFormat("aicIdentity1"); 
64                 assertEquals(payloadResult, payloadClient.get());
65         }       
66         
67         @Test
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());
72         }       
73         
74         @Test
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());
79         }       
80         
81 }