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