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