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