Add new LCM actions GetConfig, StartTraffic, StopTraffic, etc
[appc.git] / appc-dispatcher / appc-request-handler / appc-request-handler-core / src / test / java / org / onap / appc / requesthandler / ConverterTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * ================================================================================
9  * Modifications Copyright (C) 2018-2019 Orange
10  * =============================================================================
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.requesthandler;
26
27 import com.fasterxml.jackson.core.JsonProcessingException;
28 import org.junit.Assert;
29 import org.junit.Test;
30 import org.onap.appc.domainmodel.lcm.*;
31 import org.onap.appc.executor.objects.LCMCommandStatus;
32 import org.onap.appc.requesthandler.conv.Converter;
33
34 import java.text.ParseException;
35 import java.util.Date;
36 import java.util.HashMap;
37
38
39 public class ConverterTest {
40     private String expectedJsonBodyStr ="{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}}";
41     private String expectedDmaapOutgoingMessageJsonStringTest ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"test\",\"type\":\"response\"}";
42     private String expectedDmaapOutgoingMessageJsonStringRollback ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"rollback\",\"type\":\"response\"}";
43     private String expectedDmaapOutgoingMessageJsonStringSnapshot ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"snapshot\",\"type\":\"response\"}";
44     private String expectedDmaapOutgoingMessageJsonStringAudit ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"audit\",\"type\":\"response\"}";
45     private String expectedDmaapOutgoingMessageJsonStringHealthCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"health-check\",\"type\":\"response\"}";
46     private String expectedDmaapOutgoingMessageJsonStringLiveUpgrade ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"live-upgrade\",\"type\":\"response\"}";
47     private String expectedDmaapOutgoingMessageJsonStringLock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"lock\",\"type\":\"response\"}";
48     private String expectedDmaapOutgoingMessageJsonStringModifyConfig ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"config-modify\",\"type\":\"response\"}";
49     private String expectedDmaapOutgoingMessageJsonStringSoftwareUpload ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"software-upload\",\"type\":\"response\"}";
50     private String expectedDmaapOutgoingMessageJsonStringStop ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"stop\",\"type\":\"response\"}";
51     private String expectedDmaapOutgoingMessageJsonStringSync ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"sync\",\"type\":\"response\"}";
52     private String expectedDmaapOutgoingMessageJsonStringTerminate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"terminate\",\"type\":\"response\"}";
53     private String expectedDmaapOutgoingMessageJsonStringUnlock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"unlock\",\"type\":\"response\"}";
54     private String expectedDmaapOutgoingMessageJsonStringUpgradePreCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgrade-pre-check\",\"type\":\"response\"}";
55     private String expectedDmaapOutgoingMessageJsonStringUpgradePostCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgrade-post-check\",\"type\":\"response\"}";
56     private String expectedDmaapOutgoingMessageJsonStringUpgradeSoftware ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgradesoftware\",\"type\":\"response\"}";
57     private String expectedDmaapOutgoingMessageJsonStringUpgradeBackout ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgradebackout\",\"type\":\"response\"}";
58     private String expectedDmaapOutgoingMessageJsonStringUpgradeBackup ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgradebackup\",\"type\":\"response\"}";
59     private String expectedDmaapOutgoingMessageJsonStringReboot ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"reboot\",\"type\":\"response\"}";
60     private String expectedDmaapOutgoingMessageJsonStringPreConfigure ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"pre-configure\",\"type\":\"response\"}";
61     private String expectedDmaapOutgoingMessageJsonStringGetConfig ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"get-config\",\"type\":\"response\"}";
62     private String expectedJsonBodyStrwithPayload ="{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}}";
63     private String expectedDmaapOutgoingMessageJsonStringDistributeTraffic = "{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"distribute-traffic\",\"type\":\"response\"}";
64     private String expectedDmaapOutgoingMessageJsonStringDistributeTrafficCheck = "{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"distribute-traffic-check\",\"type\":\"response\"}";
65     private String expectedDmaapOutgoingMessageJsonStringPreRebuild ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"pre-rebuild\",\"type\":\"response\"}";
66     private String expectedDmaapOutgoingMessageJsonStringPostRebuild ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"post-rebuild\",\"type\":\"response\"}";
67     private String expectedDmaapOutgoingMessageJsonStringPreEvacuate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"pre-evacuate\",\"type\":\"response\"}";
68     private String expectedDmaapOutgoingMessageJsonStringPreMigrate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"pre-migrate\",\"type\":\"response\"}";
69     private String expectedDmaapOutgoingMessageJsonStringPostMigrate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"post-migrate\",\"type\":\"response\"}";
70     private String expectedDmaapOutgoingMessageJsonStringPostEvacuate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"post-evacuate\",\"type\":\"response\"}";
71     private String expectedDmaapOutgoingMessageJsonStringLicenseManagement ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"license-management\",\"type\":\"response\"}";
72     private String expectedDmaapOutgoingMessageJsonStringStartTraffic ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"start-traffic\",\"type\":\"response\"}";
73     private String expectedDmaapOutgoingMessageJsonStringStatusTraffic ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"status-traffic\",\"type\":\"response\"}";
74     private String expectedDmaapOutgoingMessageJsonStringStopTraffic ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"stop-traffic\",\"type\":\"response\"}";
75     private String expectedDmaapOutgoingMessageJsonStringProvisioning ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"provisioning\",\"type\":\"response\"}";
76  
77     @Test
78     public void convDateToZuluStringTest(){
79         String dateToZuluString = Converter.convDateToZuluString(new Date(0L));
80         Assert.assertEquals("1970-01-01T00:00:00.000Z", dateToZuluString);
81     }
82
83     @Test
84     public void convAsyncResponseToBuilderTestTest() throws JsonProcessingException {
85         ResponseContext asyncResponse = buildAsyncResponse();
86         VNFOperation action = VNFOperation.Test;
87         String rpcName = action.name().toLowerCase();
88         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
89         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
90     }
91
92     @Test
93     public void convAsyncResponseToDmaapOutgoingMessageJsonStringTestTest() throws JsonProcessingException {
94         ResponseContext asyncResponse = buildAsyncResponse();
95         VNFOperation action = VNFOperation.Test;
96         String rpcName = action.name().toLowerCase();
97         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
98         System.out.println("jsonStr = " + jsonStr);
99         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringTest, jsonStr);
100     }
101
102     @Test
103     public void convPayloadObjectToJsonStringTest() throws JsonProcessingException, ParseException {
104         String jsonString = Converter.convPayloadObjectToJsonString("any valid JSON string value");
105         Assert.assertEquals("any valid JSON string value", jsonString);
106
107         HashMap<String, String> hashMap = new HashMap<>();
108         hashMap.put("key","value");
109         jsonString = Converter.convPayloadObjectToJsonString(hashMap);
110         Assert.assertEquals("{\"key\":\"value\"}", jsonString);
111     }
112
113     @Test
114     public void convAsyncResponseToBuilderRollbackTest() throws JsonProcessingException {
115         ResponseContext asyncResponse = buildAsyncResponse();
116         VNFOperation action = VNFOperation.Rollback;
117         String rpcName = action.name().toLowerCase();
118         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
119         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
120     }
121
122     @Test
123     public void convAsyncResponseToDmaapOutgoingMessageJsonStringRollbackTest() throws JsonProcessingException {
124         ResponseContext asyncResponse = buildAsyncResponse();
125         VNFOperation action = VNFOperation.Rollback;
126         String rpcName = action.name().toLowerCase();
127         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
128         System.out.println("jsonStr = " + jsonStr);
129         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringRollback, jsonStr);
130     }
131
132     @Test
133     public void convAsyncResponseToBuilderSnapshotTest() throws JsonProcessingException {
134         ResponseContext asyncResponse = buildAsyncResponse();
135         VNFOperation action = VNFOperation.Snapshot;
136         String rpcName = action.name().toLowerCase();
137         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
138         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
139     }
140
141     @Test
142     public void convAsyncResponseToDmaapOutgoingMessageJsonStringSnapshotTest() throws JsonProcessingException {
143         ResponseContext asyncResponse = buildAsyncResponse();
144         VNFOperation action = VNFOperation.Snapshot;
145         String rpcName = action.name().toLowerCase();
146         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
147         System.out.println("jsonStr = " + jsonStr);
148         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringSnapshot, jsonStr);
149     }
150     @Test
151     public void convAsyncResponseToBuilderAuditTest() throws JsonProcessingException {
152         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
153         VNFOperation action = VNFOperation.Audit;
154         String rpcName = action.name().toLowerCase();
155         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
156         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
157     }
158
159     @Test
160     public void convAsyncResponseToDmaapOutgoingMessageJsonStringAuditTest() throws JsonProcessingException {
161         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
162         VNFOperation action = VNFOperation.Audit;
163         String rpcName = action.name().toLowerCase();
164         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
165         System.out.println("jsonStr = " + jsonStr);
166         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringAudit, jsonStr);
167     }
168     @Test
169     public void convAsyncResponseToBuilderHealthCheckTest() throws JsonProcessingException {
170         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
171         VNFOperation action = VNFOperation.HealthCheck;
172         String rpcName = convertActionNameToUrl(action.name());
173         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
174         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
175     }
176
177     @Test
178     public void convAsyncResponseToDmaapOutgoingMessageJsonStringHealthCheckTest() throws JsonProcessingException {
179         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
180         VNFOperation action = VNFOperation.HealthCheck;
181         String rpcName = convertActionNameToUrl(action.name());
182         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
183         System.out.println("jsonStr = " + jsonStr);
184         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringHealthCheck, jsonStr);
185     }
186     @Test
187     public void convAsyncResponseToBuilderLiveUpgradeTest() throws JsonProcessingException {
188         ResponseContext asyncResponse = buildAsyncResponse();
189         VNFOperation action = VNFOperation.LiveUpgrade;
190         String rpcName = convertActionNameToUrl(action.name());
191         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
192         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
193     }
194
195     @Test
196     public void convAsyncResponseToDmaapOutgoingMessageJsonStringLiveUpgradeTest() throws JsonProcessingException {
197         ResponseContext asyncResponse = buildAsyncResponse();
198         VNFOperation action = VNFOperation.LiveUpgrade;
199         String rpcName = convertActionNameToUrl(action.name());
200         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
201         System.out.println("jsonStr = " + jsonStr);
202         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringLiveUpgrade, jsonStr);
203     }
204     @Test
205     public void convAsyncResponseToBuilderLockTest() throws JsonProcessingException {
206         ResponseContext asyncResponse = buildAsyncResponse();
207         VNFOperation action = VNFOperation.Lock;
208         String rpcName = convertActionNameToUrl(action.name());
209
210         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
211         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
212     }
213
214     @Test
215     public void convAsyncResponseToDmaapOutgoingMessageJsonStringLockTest() throws JsonProcessingException {
216         ResponseContext asyncResponse = buildAsyncResponse();
217         VNFOperation action = VNFOperation.Lock;
218         String rpcName = convertActionNameToUrl(action.name());
219         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
220         System.out.println("jsonStr = " + jsonStr);
221         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringLock, jsonStr);
222     }
223     @Test
224     public void convAsyncResponseToBuilderModifyConfigTest() throws JsonProcessingException {
225         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
226         VNFOperation action = VNFOperation.ConfigModify;
227         String rpcName = convertActionNameToUrl(action.name());
228         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
229         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
230     }
231
232     @Test
233     public void convAsyncResponseToDmaapOutgoingMessageJsonStringModifyConfigTest() throws JsonProcessingException {
234         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
235         VNFOperation action = VNFOperation.ConfigModify;
236         String rpcName = convertActionNameToUrl(action.name());
237         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
238         System.out.println("jsonStr = " + jsonStr);
239         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringModifyConfig, jsonStr);
240     }
241     @Test
242     public void convAsyncResponseToBuilderSoftwareUploadTest() throws JsonProcessingException {
243         ResponseContext asyncResponse = buildAsyncResponse();
244         VNFOperation action = VNFOperation.SoftwareUpload;
245         String rpcName = convertActionNameToUrl(action.name());
246
247         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
248         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
249     }
250
251     @Test
252     public void convAsyncResponseToDmaapOutgoingMessageJsonStringSoftwareUploadTest() throws JsonProcessingException {
253         ResponseContext asyncResponse = buildAsyncResponse();
254         VNFOperation action = VNFOperation.SoftwareUpload;
255         String rpcName = convertActionNameToUrl(action.name());
256         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
257         System.out.println("jsonStr = " + jsonStr);
258         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringSoftwareUpload, jsonStr);
259     }
260
261     @Test
262     public void convAsyncResponseToBuilderStopTest() throws JsonProcessingException {
263         ResponseContext asyncResponse = buildAsyncResponse();
264         VNFOperation action = VNFOperation.Stop;
265         String rpcName = convertActionNameToUrl(action.name());
266         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
267         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
268     }
269
270     @Test
271     public void convAsyncResponseToDmaapOutgoingMessageJsonStringStopTest() throws JsonProcessingException {
272         ResponseContext asyncResponse = buildAsyncResponse();
273         VNFOperation action = VNFOperation.Stop;
274         String rpcName = convertActionNameToUrl(action.name());
275         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
276         System.out.println("jsonStr = " + jsonStr);
277         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringStop, jsonStr);
278     }
279
280     @Test
281     public void convAsyncResponseToBuilderSync() throws JsonProcessingException {
282         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
283         VNFOperation action = VNFOperation.Sync;
284         String rpcName = convertActionNameToUrl(action.name());
285
286         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
287         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
288     }
289
290     @Test
291     public void convAsyncResponseToDmaapOutgoingMessageJsonStringSync() throws JsonProcessingException {
292         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
293         VNFOperation action = VNFOperation.Sync;
294         String rpcName = convertActionNameToUrl(action.name());
295         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
296         System.out.println("jsonStr = " + jsonStr);
297         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringSync, jsonStr);
298     }
299     @Test
300     public void convAsyncResponseToBuilderTerminateTest() throws JsonProcessingException {
301         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
302         VNFOperation action = VNFOperation.Sync;
303         String rpcName = convertActionNameToUrl(action.name());
304         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
305         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
306     }
307
308     @Test
309     public void convAsyncResponseToDmaapOutgoingMessageJsonStringTerminateTest() throws JsonProcessingException {
310         ResponseContext asyncResponse = buildAsyncResponse();
311         VNFOperation action = VNFOperation.Terminate;
312         String rpcName = convertActionNameToUrl(action.name());
313         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
314         System.out.println("jsonStr = " + jsonStr);
315         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringTerminate, jsonStr);
316     }
317
318     @Test
319     public void convAsyncResponseToBuilderUnlockTest() throws JsonProcessingException {
320         ResponseContext asyncResponse = buildAsyncResponse();
321         VNFOperation action = VNFOperation.Unlock;
322         String rpcName = convertActionNameToUrl(action.name());
323         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
324         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
325     }
326
327     @Test
328     public void convAsyncResponseToDmaapOutgoingMessageJsonStringUnlockTest() throws JsonProcessingException {
329         ResponseContext asyncResponse = buildAsyncResponse();
330         VNFOperation action = VNFOperation.Unlock;
331         String rpcName = convertActionNameToUrl(action.name());
332         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
333         System.out.println("jsonStr = " + jsonStr);
334         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUnlock, jsonStr);
335     }
336
337     @Test
338     public void convAsyncResponseToBuilderRebootTest() throws JsonProcessingException {
339         ResponseContext asyncResponse = buildAsyncResponse();
340         VNFOperation action = VNFOperation.Reboot;
341         String rpcName = convertActionNameToUrl(action.name());
342
343         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
344         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
345     }
346
347     @Test
348     public void convAsyncResponseToDmaapOutgoingMessageJsonStringRebootTest() throws JsonProcessingException {
349         ResponseContext asyncResponse = buildAsyncResponse();
350         VNFOperation action = VNFOperation.Reboot;
351         String rpcName = convertActionNameToUrl(action.name());
352         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
353         System.out.println("jsonStr = " + jsonStr);
354         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringReboot, jsonStr);
355     }
356
357     @Test
358     public void convAsyncResponseToBuilderUpgradePreCheckTest() throws JsonProcessingException {
359         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
360         VNFOperation action = VNFOperation.UpgradePreCheck;
361         String rpcName = convertActionNameToUrl(action.name());
362         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
363         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
364     }
365
366     @Test
367     public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradePreCheckTest() throws JsonProcessingException {
368         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
369         VNFOperation action = VNFOperation.UpgradePreCheck;
370         String rpcName = convertActionNameToUrl(action.name());
371         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
372         System.out.println("jsonStr = " + jsonStr);
373         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradePreCheck, jsonStr);
374     }
375
376     @Test
377     public void convAsyncResponseToBuilderUpgradePostCheckTest() throws JsonProcessingException {
378         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
379         VNFOperation action = VNFOperation.UpgradePostCheck;
380         String rpcName = convertActionNameToUrl(action.name());
381         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
382         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
383     }
384
385     @Test
386     public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradePostCheckTest() throws JsonProcessingException {
387         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
388         VNFOperation action = VNFOperation.UpgradePostCheck;
389         String rpcName = convertActionNameToUrl(action.name());
390         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
391         System.out.println("jsonStr = " + jsonStr);
392         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradePostCheck, jsonStr);
393     }
394
395     @Test
396     public void convAsyncResponseToBuilderUpgradeSoftwareTest() throws JsonProcessingException {
397         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
398         VNFOperation action = VNFOperation.UpgradeSoftware;
399         String rpcName = action.name().toLowerCase();
400         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
401         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
402     }
403
404     @Test
405     public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradeSoftwareTest() throws JsonProcessingException {
406         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
407         VNFOperation action = VNFOperation.UpgradeSoftware;
408         String rpcName = action.name().toLowerCase();
409         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
410         System.out.println("jsonStr = " + jsonStr);
411         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradeSoftware, jsonStr);
412     }
413     @Test
414     public void convAsyncResponseToBuilderUpgradeBackoutTest() throws JsonProcessingException {
415         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
416         VNFOperation action = VNFOperation.UpgradeBackout;
417         String rpcName = action.name().toLowerCase();
418         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
419         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
420     }
421
422     @Test
423     public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradeBackoutTest() throws JsonProcessingException {
424         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
425         VNFOperation action = VNFOperation.UpgradeBackout;
426         String rpcName = action.name().toLowerCase();
427         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
428         System.out.println("jsonStr = " + jsonStr);
429         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradeBackout, jsonStr);
430     }
431     @Test
432     public void convAsyncResponseToBuilderUpgradeBackupTest() throws JsonProcessingException {
433         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
434         VNFOperation action = VNFOperation.UpgradeBackup;
435         String rpcName = action.name().toLowerCase();
436         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
437         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
438     }
439
440     @Test
441     public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradeBackupTest() throws JsonProcessingException {
442         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
443         VNFOperation action = VNFOperation.UpgradeBackup;
444         String rpcName = action.name().toLowerCase();
445         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
446         System.out.println("jsonStr = " + jsonStr);
447         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradeBackup, jsonStr);
448     }
449     @Test
450     public void convAsyncResponseToBuilderPreConfigureTest() throws JsonProcessingException {
451         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
452         VNFOperation action = VNFOperation.PreConfigure;
453         String rpcName = convertActionNameToUrl(action.name());
454
455         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
456         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
457     }
458
459     @Test
460     public void convAsyncResponseToDmaapOutgoingMessageJsonStringPreConfigureTest() throws JsonProcessingException {
461         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
462         VNFOperation action = VNFOperation.PreConfigure;
463         String rpcName = convertActionNameToUrl(action.name());
464         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
465         System.out.println("jsonStr = " + jsonStr);
466         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPreConfigure, jsonStr);
467     }
468
469     @Test
470     public void convAsyncResponseToBuilderGetConfigTest() throws JsonProcessingException {
471         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
472         VNFOperation action = VNFOperation.GetConfig;
473         String rpcName = convertActionNameToUrl(action.name());
474
475         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
476         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
477     }
478
479     @Test
480     public void convAsyncResponseToDmaapOutgoingMessageJsonStringGetConfigTest() throws JsonProcessingException {
481         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
482         VNFOperation action = VNFOperation.GetConfig;
483         String rpcName = convertActionNameToUrl(action.name());
484         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
485         System.out.println("jsonStr = " + jsonStr);
486         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringGetConfig, jsonStr);
487     }
488
489     @Test
490     public void convAsyncResponseToBuilderDistributeTrafficTest() throws JsonProcessingException {
491         ResponseContext asyncResponse = buildAsyncResponse();
492         VNFOperation action = VNFOperation.DistributeTraffic;
493         String rpcName = convertActionNameToUrl(action.name());
494         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
495         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
496     }
497
498     @Test
499     public void convAsyncResponseToDmaapOutgoingMessageJsonStringDistributeTrafficTest()
500             throws JsonProcessingException {
501         ResponseContext asyncResponse = buildAsyncResponse();
502         VNFOperation action = VNFOperation.DistributeTraffic;
503         String rpcName = convertActionNameToUrl(action.name());
504         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
505         System.out.println("jsonStr = " + jsonStr);
506         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringDistributeTraffic, jsonStr);
507     }
508
509     @Test
510     public void convAsyncResponseToBuilderDistributeTrafficCheckTest() throws JsonProcessingException {
511         ResponseContext asyncResponse = buildAsyncResponse();
512         VNFOperation action = VNFOperation.DistributeTrafficCheck;
513         String rpcName = convertActionNameToUrl(action.name());
514         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
515         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
516     }
517
518     @Test
519     public void convAsyncResponseToDmaapOutgoingMessageJsonStringDistributeTrafficCheckTest()
520             throws JsonProcessingException {
521         ResponseContext asyncResponse = buildAsyncResponse();
522         VNFOperation action = VNFOperation.DistributeTrafficCheck;
523         String rpcName = convertActionNameToUrl(action.name());
524         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
525         System.out.println("jsonStr = " + jsonStr);
526         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringDistributeTrafficCheck, jsonStr);
527     }
528
529     @Test
530     public void convAsyncResponseToBuilderPreRebuildTest() throws JsonProcessingException {
531         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
532         VNFOperation action = VNFOperation.PreRebuild;
533         String rpcName = convertActionNameToUrl(action.name());
534
535         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
536         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
537     }
538
539     @Test
540     public void convAsyncResponseToDmaapOutgoingMessageJsonStringPreRebuildTest() throws JsonProcessingException {
541         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
542         VNFOperation action = VNFOperation.PreRebuild;
543         String rpcName = convertActionNameToUrl(action.name());
544         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
545         System.out.println("jsonStr = " + jsonStr);
546         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPreRebuild, jsonStr);
547     }
548
549     @Test
550     public void convAsyncResponseToBuilderPostRebuildTest() throws JsonProcessingException {
551         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
552         VNFOperation action = VNFOperation.PostRebuild;
553         String rpcName = convertActionNameToUrl(action.name());
554
555         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
556         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
557     }
558
559     @Test
560     public void convAsyncResponseToDmaapOutgoingMessageJsonStringPostRebuildTest() throws JsonProcessingException {
561         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
562         VNFOperation action = VNFOperation.PostRebuild;
563         String rpcName = convertActionNameToUrl(action.name());
564         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
565         System.out.println("jsonStr = " + jsonStr);
566         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPostRebuild, jsonStr);
567     }
568
569     @Test
570     public void convAsyncResponseToBuilderPreEvacuateTest() throws JsonProcessingException {
571         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
572         VNFOperation action = VNFOperation.PreEvacuate;
573         String rpcName = convertActionNameToUrl(action.name());
574         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
575         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
576     }
577
578     @Test
579     public void convAsyncResponseToDmaapOutgoingMessageJsonStringPreEvacuateTest() throws JsonProcessingException {
580         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
581         VNFOperation action = VNFOperation.PreEvacuate;
582         String rpcName = convertActionNameToUrl(action.name());
583         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
584         System.out.println("jsonStr = " + jsonStr);
585         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPreEvacuate, jsonStr);
586     }
587
588     @Test
589     public void convAsyncResponseToBuilderPreMigrateTest() throws JsonProcessingException {
590         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
591         VNFOperation action = VNFOperation.PreMigrate;
592         String rpcName = convertActionNameToUrl(action.name());
593
594         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
595         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
596     }
597
598     @Test
599     public void convAsyncResponseToDmaapOutgoingMessageJsonStringPreMigrateTest() throws JsonProcessingException {
600         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
601         VNFOperation action = VNFOperation.PreMigrate;
602         String rpcName = convertActionNameToUrl(action.name());
603         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
604         System.out.println("jsonStr = " + jsonStr);
605         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPreMigrate, jsonStr);
606     }
607
608     @Test
609     public void convAsyncResponseToBuilderPostMigrateTest() throws JsonProcessingException {
610         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
611         VNFOperation action = VNFOperation.PostMigrate;
612         String rpcName = convertActionNameToUrl(action.name());
613
614         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
615         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
616     }
617
618     @Test
619     public void convAsyncResponseToDmaapOutgoingMessageJsonStringPostMigrateTest() throws JsonProcessingException {
620         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
621         VNFOperation action = VNFOperation.PostMigrate;
622         String rpcName = convertActionNameToUrl(action.name());
623         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
624         System.out.println("jsonStr = " + jsonStr);
625         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPostMigrate, jsonStr);
626     }
627
628     @Test
629     public void convAsyncResponseToBuilderPostEvacuateTest() throws JsonProcessingException {
630         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
631         VNFOperation action = VNFOperation.PostEvacuate;
632         String rpcName = convertActionNameToUrl(action.name());
633
634         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
635         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
636     }
637
638     @Test
639     public void convAsyncResponseToDmaapOutgoingMessageJsonStringPostEvacuateTest() throws JsonProcessingException {
640         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
641         VNFOperation action = VNFOperation.PostEvacuate;
642         String rpcName = convertActionNameToUrl(action.name());
643         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
644         System.out.println("jsonStr = " + jsonStr);
645         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPostEvacuate, jsonStr);
646     }
647
648     @Test
649     public void convAsyncResponseToBuilderStartTrafficTest() throws JsonProcessingException {
650         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
651         VNFOperation action = VNFOperation.StartTraffic;
652         String rpcName = convertActionNameToUrl(action.name());
653
654         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
655         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
656     }
657
658     @Test
659     public void convAsyncResponseToDmaapOutgoingMessageJsonStringStartTrafficTest() throws JsonProcessingException {
660         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
661         VNFOperation action = VNFOperation.StartTraffic;
662         String rpcName = convertActionNameToUrl(action.name());
663         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
664         System.out.println("jsonStr = " + jsonStr);
665         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringStartTraffic, jsonStr);
666     }
667
668     @Test
669     public void convAsyncResponseToBuilderStatusTrafficTest() throws JsonProcessingException {
670         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
671         VNFOperation action = VNFOperation.StatusTraffic;
672         String rpcName = convertActionNameToUrl(action.name());
673         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
674         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
675     }
676
677     @Test
678     public void convAsyncResponseToDmaapOutgoingMessageJsonStringStatusTrafficTest() throws JsonProcessingException {
679         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
680         VNFOperation action = VNFOperation.StatusTraffic;
681         String rpcName = convertActionNameToUrl(action.name());
682         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
683         System.out.println("jsonStr = " + jsonStr);
684         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringStatusTraffic, jsonStr);
685     }
686   
687     @Test
688     public void convAsyncResponseToDmaapOutgoingMessageJsonStringLicenseManagementTest()
689             throws JsonProcessingException {
690         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
691         VNFOperation action = VNFOperation.LicenseManagement;
692         String rpcName = convertActionNameToUrl(action.name());
693         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
694         System.out.println("jsonStr = " + jsonStr);
695         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringLicenseManagement,jsonStr);
696     }
697
698     @Test
699     public void convAsyncResponseToBuilderLicenseManagementTest() throws JsonProcessingException {
700         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
701         VNFOperation action = VNFOperation.LicenseManagement;
702         String rpcName = convertActionNameToUrl(action.name());
703         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
704         Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
705     }
706    @Test
707     public void convAsyncResponseToDmaapOutgoingMessageJsonStringProvisioningTest() throws JsonProcessingException {
708         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
709         VNFOperation action = VNFOperation.Provisioning;
710         String rpcName = convertActionNameToUrl(action.name());
711         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
712         System.out.println("jsonStr = " + jsonStr);
713         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringProvisioning,jsonStr);
714     }
715
716     @Test
717     public void convAsyncResponseToBuilderProvisioningTest() throws JsonProcessingException {
718         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
719         VNFOperation action = VNFOperation.Provisioning;
720         String rpcName = convertActionNameToUrl(action.name());
721         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
722         Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
723     }
724     @Test
725     public void convAsyncResponseToBuilderStopTrafficTest() throws JsonProcessingException {
726         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
727         VNFOperation action = VNFOperation.StopTraffic;
728         String rpcName = convertActionNameToUrl(action.name());
729         String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
730         Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
731     }
732
733     @Test
734     public void convAsyncResponseToDmaapOutgoingMessageJsonStringStopTrafficTest() throws JsonProcessingException {
735         ResponseContext asyncResponse = buildAsyncResponsewithPayload();
736         VNFOperation action = VNFOperation.StopTraffic;
737         String rpcName = convertActionNameToUrl(action.name());
738         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
739         System.out.println("jsonStr = " + jsonStr);
740         Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringStopTraffic, jsonStr);
741     }
742
743     /*@Test
744     public void convAsyncResponseToBuilderTest() throws JsonProcessingException {
745         AsyncResponse asyncResponse = buildAsyncResponse();
746         String jsonStr = Converter.convAsyncResponseToJsonStringBody(asyncResponse);
747         Assert.assertEquals(expectedJsonBodyStr, jsonStr);
748     }
749
750     @Test
751     public void convAsyncResponseToDmaapOutgoingMessageJsonStringTest() throws JsonProcessingException {
752         AsyncResponse asyncResponse = buildAsyncResponse();
753         String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(asyncResponse);
754         System.out.println("jsonStr = " + jsonStr);
755         Assert.assertEquals(expectedDmaapOutgoingMessageJsonString, jsonStr);
756     }*/
757
758
759     private ResponseContext buildAsyncResponse() {
760         ResponseContext asyncResponse = createResponseContextWithSubObjects();
761         asyncResponse.getStatus().setCode(LCMCommandStatus.SUCCESS.getResponseCode());
762         asyncResponse.getStatus().setMessage(LCMCommandStatus.SUCCESS.getResponseMessage());
763         asyncResponse.getCommonHeader().setOriginatorId("oid");
764         asyncResponse.getCommonHeader().setApiVer("2.0.0");
765         asyncResponse.getCommonHeader().setRequestId("reqid");
766         asyncResponse.getCommonHeader().setTimestamp(new Date(1000L));
767         asyncResponse.setPayload(
768                 "any valid JSON string value. Json escape characters need to be added to make it a valid json string value");
769         return asyncResponse;
770     }
771
772     private ResponseContext buildAsyncResponsewithPayload() {
773         ResponseContext asyncResponse = createResponseContextWithSubObjects();
774         asyncResponse.getStatus().setCode(LCMCommandStatus.SUCCESS.getResponseCode());
775         asyncResponse.getStatus().setMessage(LCMCommandStatus.SUCCESS.getResponseMessage());
776         asyncResponse.getCommonHeader().setOriginatorId("oid");
777         asyncResponse.getCommonHeader().setApiVer("2.0.0");
778         asyncResponse.getCommonHeader().setRequestId("reqid");
779         asyncResponse.getCommonHeader().setTimestamp(new Date(1000L));
780         asyncResponse.setPayload("{}");
781         return asyncResponse;
782     }
783
784     private ResponseContext createResponseContextWithSubObjects() {
785
786         ResponseContext responseContext = new ResponseContext();
787         CommonHeader commonHeader = new CommonHeader();
788         Flags flags = new Flags();
789         Status status = new Status();
790         responseContext.setCommonHeader(commonHeader);
791         responseContext.setStatus(status);
792         commonHeader.setFlags(flags);
793         return responseContext;
794     }
795
796     private String convertActionNameToUrl(String action) {
797         String regex = "([a-z])([A-Z]+)";
798         String replacement = "$1-$2";
799         return action.replaceAll(regex, replacement)
800                 .toLowerCase();
801     }
802
803
804 }