Merge of new rebased code
[appc.git] / appc-dispatcher / appc-request-handler / appc-request-handler-core / src / test / java / org / openecomp / appc / requesthandler / TestConverter.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.requesthandler;
23
24 import com.fasterxml.jackson.core.JsonProcessingException;
25 import org.junit.Assert;
26 import org.junit.Test;
27 import org.openecomp.appc.domainmodel.lcm.*;
28 import org.openecomp.appc.executor.objects.LCMCommandStatus;
29 import org.openecomp.appc.requesthandler.conv.Converter;
30
31 import java.text.ParseException;
32 import java.time.Instant;
33 import java.util.Date;
34 import java.util.HashMap;
35
36
37 public class TestConverter {
38         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\"}}}";
39         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\"}";
40         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\"}";
41         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\"}";
42         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\"}";
43         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\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"health-check\",\"type\":\"response\"}";
44         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\"}";
45         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\"}";
46         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\"}";
47         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\"}";
48         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\"}";
49         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\"}";
50         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\"}";
51         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\"}";
52         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\"}}}";
53
54         @Test
55         public void convDateToZuluStringTest(){
56                 String dateToZuluString = Converter.convDateToZuluString(new Date(0L));
57                 Assert.assertEquals("1970-01-01T00:00:00.000Z", dateToZuluString);
58         }
59
60         @Test
61         public void convAsyncResponseToBuilderTestTest() throws JsonProcessingException {
62                 ResponseContext asyncResponse = buildAsyncResponse();
63                 VNFOperation action = VNFOperation.Test;
64                 String rpcName = action.name().toLowerCase();
65                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
66                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
67         }
68
69         @Test
70         public void convAsyncResponseToDmaapOutgoingMessageJsonStringTestTest() throws JsonProcessingException {
71                 ResponseContext asyncResponse = buildAsyncResponse();
72                 VNFOperation action = VNFOperation.Test;
73                 String rpcName = action.name().toLowerCase();
74                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
75                 System.out.println("jsonStr = " + jsonStr);
76                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringTest,jsonStr);
77         }
78
79         @Test
80         public void convPayloadObjectToJsonStringTest() throws JsonProcessingException, ParseException {
81                 String jsonString = Converter.convPayloadObjectToJsonString("any valid JSON string value");
82                 Assert.assertEquals("any valid JSON string value", jsonString);
83
84                 HashMap<String, String> hashMap = new HashMap<>();
85                 hashMap.put("key","value");
86                 jsonString = Converter.convPayloadObjectToJsonString(hashMap);
87                 Assert.assertEquals("{\"key\":\"value\"}", jsonString);
88         }
89
90         @Test
91         public void convAsyncResponseToBuilderRollbackTest() throws JsonProcessingException {
92                 ResponseContext asyncResponse = buildAsyncResponse();
93                 VNFOperation action = VNFOperation.Rollback;
94                 String rpcName = action.name().toLowerCase();
95                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
96                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
97         }
98
99         @Test
100         public void convAsyncResponseToDmaapOutgoingMessageJsonStringRollbackTest() throws JsonProcessingException {
101                 ResponseContext asyncResponse = buildAsyncResponse();
102                 VNFOperation action = VNFOperation.Rollback;
103                 String rpcName = action.name().toLowerCase();
104                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
105                 System.out.println("jsonStr = " + jsonStr);
106                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringRollback,jsonStr);
107         }
108
109         @Test
110         public void convAsyncResponseToBuilderSnapshotTest() throws JsonProcessingException {
111                 ResponseContext asyncResponse = buildAsyncResponse();
112                 VNFOperation action = VNFOperation.Snapshot;
113                 String rpcName = action.name().toLowerCase();
114                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
115                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
116         }
117
118         @Test
119         public void convAsyncResponseToDmaapOutgoingMessageJsonStringSnapshotTest() throws JsonProcessingException {
120                 ResponseContext asyncResponse = buildAsyncResponse();
121                 VNFOperation action = VNFOperation.Snapshot;
122                 String rpcName = action.name().toLowerCase();
123                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
124                 System.out.println("jsonStr = " + jsonStr);
125                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringSnapshot,jsonStr);
126         }
127         @Test
128         public void convAsyncResponseToBuilderAuditTest() throws JsonProcessingException {
129                 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
130                 VNFOperation action = VNFOperation.Audit;
131                 String rpcName = action.name().toLowerCase();
132                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
133                 Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
134         }
135
136         @Test
137         public void convAsyncResponseToDmaapOutgoingMessageJsonStringAuditTest() throws JsonProcessingException {
138                 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
139                 VNFOperation action = VNFOperation.Audit;
140                 String rpcName = action.name().toLowerCase();
141                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
142                 System.out.println("jsonStr = " + jsonStr);
143                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringAudit,jsonStr);
144         }
145         @Test
146         public void convAsyncResponseToBuilderHealthCheckTest() throws JsonProcessingException {
147                 ResponseContext asyncResponse = buildAsyncResponse();
148                 VNFOperation action = VNFOperation.HealthCheck;
149                 String rpcName = convertActionNameToUrl(action.name());
150                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
151                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
152         }
153
154         @Test
155         public void convAsyncResponseToDmaapOutgoingMessageJsonStringHealthCheckTest() throws JsonProcessingException {
156                 ResponseContext asyncResponse = buildAsyncResponse();
157                 VNFOperation action = VNFOperation.HealthCheck;
158                 String rpcName = convertActionNameToUrl(action.name());
159                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
160                 System.out.println("jsonStr = " + jsonStr);
161                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringHealthCheck,jsonStr);
162         }
163         @Test
164         public void convAsyncResponseToBuilderLiveUpgradeTest() throws JsonProcessingException {
165                 ResponseContext asyncResponse = buildAsyncResponse();
166                 VNFOperation action = VNFOperation.LiveUpgrade;
167                 String rpcName = convertActionNameToUrl(action.name());
168                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
169                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
170         }
171
172         @Test
173         public void convAsyncResponseToDmaapOutgoingMessageJsonStringLiveUpgradeTest() throws JsonProcessingException {
174                 ResponseContext asyncResponse = buildAsyncResponse();
175                 VNFOperation action = VNFOperation.LiveUpgrade;
176                 String rpcName = convertActionNameToUrl(action.name());
177                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
178                 System.out.println("jsonStr = " + jsonStr);
179                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringLiveUpgrade,jsonStr);
180         }
181         @Test
182         public void convAsyncResponseToBuilderLockTest() throws JsonProcessingException {
183                 ResponseContext asyncResponse = buildAsyncResponse();
184                 VNFOperation action = VNFOperation.Lock;
185                 String rpcName = convertActionNameToUrl(action.name());
186
187                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
188                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
189         }
190
191         @Test
192         public void convAsyncResponseToDmaapOutgoingMessageJsonStringLockTest() throws JsonProcessingException {
193                 ResponseContext asyncResponse = buildAsyncResponse();
194                 VNFOperation action = VNFOperation.Lock;
195                 String rpcName = convertActionNameToUrl(action.name());
196                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
197                 System.out.println("jsonStr = " + jsonStr);
198                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringLock,jsonStr);
199         }
200         @Test
201         public void convAsyncResponseToBuilderModifyConfigTest() throws JsonProcessingException {
202                 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
203                 VNFOperation action = VNFOperation.ConfigModify;
204                 String rpcName = convertActionNameToUrl(action.name());
205                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
206                 Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
207         }
208
209         @Test
210         public void convAsyncResponseToDmaapOutgoingMessageJsonStringModifyConfigTest() throws JsonProcessingException {
211                 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
212                 VNFOperation action = VNFOperation.ConfigModify;
213                 String rpcName = convertActionNameToUrl(action.name());
214                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
215                 System.out.println("jsonStr = " + jsonStr);
216                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringModifyConfig,jsonStr);
217         }
218         @Test
219         public void convAsyncResponseToBuilderSoftwareUploadTest() throws JsonProcessingException {
220                 ResponseContext asyncResponse = buildAsyncResponse();
221                 VNFOperation action = VNFOperation.SoftwareUpload;
222                 String rpcName = convertActionNameToUrl(action.name());
223
224                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
225                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
226         }
227
228         @Test
229         public void convAsyncResponseToDmaapOutgoingMessageJsonStringSoftwareUploadTest() throws JsonProcessingException {
230                 ResponseContext asyncResponse = buildAsyncResponse();
231                 VNFOperation action = VNFOperation.SoftwareUpload;
232                 String rpcName = convertActionNameToUrl(action.name());
233                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
234                 System.out.println("jsonStr = " + jsonStr);
235                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringSoftwareUpload,jsonStr);
236         }
237         @Test
238         public void convAsyncResponseToBuilderStopTest() throws JsonProcessingException {
239                 ResponseContext asyncResponse = buildAsyncResponse();
240                 VNFOperation action = VNFOperation.Stop;
241                 String rpcName = convertActionNameToUrl(action.name());
242                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
243                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
244         }
245
246         @Test
247         public void convAsyncResponseToDmaapOutgoingMessageJsonStringStopTest() throws JsonProcessingException {
248                 ResponseContext asyncResponse = buildAsyncResponse();
249                 VNFOperation action = VNFOperation.Stop;
250                 String rpcName = convertActionNameToUrl(action.name());
251                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
252                 System.out.println("jsonStr = " + jsonStr);
253                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringStop,jsonStr);
254         }
255         @Test
256         public void convAsyncResponseToBuilderSync() throws JsonProcessingException {
257                 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
258                 VNFOperation action = VNFOperation.Sync;
259                 String rpcName = convertActionNameToUrl(action.name());
260
261                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
262                 Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
263         }
264
265         @Test
266         public void convAsyncResponseToDmaapOutgoingMessageJsonStringSync() throws JsonProcessingException {
267                 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
268                 VNFOperation action = VNFOperation.Sync;
269                 String rpcName = convertActionNameToUrl(action.name());
270                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
271                 System.out.println("jsonStr = " + jsonStr);
272                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringSync,jsonStr);
273         }
274         @Test
275         public void convAsyncResponseToBuilderTerminateTest() throws JsonProcessingException {
276                 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
277                 VNFOperation action = VNFOperation.Sync;
278                 String rpcName = convertActionNameToUrl(action.name());
279                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
280                 Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
281         }
282
283         @Test
284         public void convAsyncResponseToDmaapOutgoingMessageJsonStringTerminateTest() throws JsonProcessingException {
285                 ResponseContext asyncResponse = buildAsyncResponse();
286                 VNFOperation action = VNFOperation.Terminate;
287                 String rpcName = convertActionNameToUrl(action.name());
288                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
289                 System.out.println("jsonStr = " + jsonStr);
290                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringTerminate,jsonStr);
291         }
292         @Test
293         public void convAsyncResponseToBuilderUnlockTest() throws JsonProcessingException {
294                 ResponseContext asyncResponse = buildAsyncResponse();
295                 VNFOperation action = VNFOperation.Unlock;
296                 String rpcName = convertActionNameToUrl(action.name());
297                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
298                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
299         }
300
301         @Test
302         public void convAsyncResponseToDmaapOutgoingMessageJsonStringUnlockTest() throws JsonProcessingException {
303                 ResponseContext asyncResponse = buildAsyncResponse();
304                 VNFOperation action = VNFOperation.Unlock;
305                 String rpcName = convertActionNameToUrl(action.name());
306                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
307                 System.out.println("jsonStr = " + jsonStr);
308                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUnlock,jsonStr);
309         }
310         /*@Test
311         public void convAsyncResponseToBuilderTest() throws JsonProcessingException {
312                 AsyncResponse asyncResponse = buildAsyncResponse();
313                 String jsonStr = Converter.convAsyncResponseToJsonStringBody(asyncResponse);
314                 Assert.assertEquals(expectedJsonBodyStr,jsonStr);
315         }
316
317         @Test
318         public void convAsyncResponseToDmaapOutgoingMessageJsonStringTest() throws JsonProcessingException {
319                 AsyncResponse asyncResponse = buildAsyncResponse();
320                 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(asyncResponse);
321                 System.out.println("jsonStr = " + jsonStr);
322                 Assert.assertEquals(expectedDmaapOutgoingMessageJsonString,jsonStr);
323         }*/
324
325
326         private ResponseContext buildAsyncResponse() {
327                 ResponseContext asyncResponse = createResponseContextWithSubObjects();
328                 asyncResponse.setStatus(LCMCommandStatus.SUCCESS.toStatus(null));
329                 asyncResponse.getCommonHeader().setOriginatorId("oid");
330                 asyncResponse.getCommonHeader().setApiVer("2.0.0");
331                 asyncResponse.getCommonHeader().setRequestId("reqid");
332                 asyncResponse.getCommonHeader().setTimestamp(Instant.ofEpochMilli(1000L));
333                 asyncResponse.setPayload("any valid JSON string value. Json escape characters need to be added to make it a valid json string value");
334                 return asyncResponse;
335         }
336
337         private ResponseContext buildAsyncResponsewithPayload() {
338                 ResponseContext asyncResponse = createResponseContextWithSubObjects();
339                 asyncResponse.setStatus(LCMCommandStatus.SUCCESS.toStatus(null));
340                 asyncResponse.getCommonHeader().setOriginatorId("oid");
341                 asyncResponse.getCommonHeader().setApiVer("2.0.0");
342                 asyncResponse.getCommonHeader().setRequestId("reqid");
343                 asyncResponse.getCommonHeader().setTimestamp(Instant.ofEpochMilli(1000L));
344                 asyncResponse.setPayload("{}");
345                 return asyncResponse;
346         }
347
348         private ResponseContext createResponseContextWithSubObjects() {
349
350                 ResponseContext responseContext = new ResponseContext();
351                 CommonHeader commonHeader = new CommonHeader();
352                 responseContext.setCommonHeader(commonHeader);
353                 responseContext.setStatus(new Status(0, null));
354                 commonHeader.setFlags(new Flags(null, false, 0));
355                 return responseContext;
356         }
357
358         private String convertActionNameToUrl(String action) {
359                 String regex = "([a-z])([A-Z]+)";
360                 String replacement = "$1-$2";
361                 return action.replaceAll(regex, replacement)
362                                 .toLowerCase();
363         }
364
365
366 }
367
368
369