2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * ================================================================================
9 * Modifications Copyright (C) 2018-2019 Orange
10 * =============================================================================
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.requesthandler;
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;
34 import java.text.ParseException;
35 import java.util.Date;
36 import java.util.HashMap;
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\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"rollback\",\"type\":\"response\"}";
43 private String expectedDmaapOutgoingMessageJsonStringSnapshot ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"snapshot\",\"type\":\"response\"}";
44 private String expectedDmaapOutgoingMessageJsonStringAudit ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"audit\",\"type\":\"response\"}";
45 private String expectedDmaapOutgoingMessageJsonStringHealthCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"health-check\",\"type\":\"response\"}";
46 private String expectedDmaapOutgoingMessageJsonStringLiveUpgrade ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"live-upgrade\",\"type\":\"response\"}";
47 private String expectedDmaapOutgoingMessageJsonStringLock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"lock\",\"type\":\"response\"}";
48 private String expectedDmaapOutgoingMessageJsonStringModifyConfig ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"config-modify\",\"type\":\"response\"}";
49 private String expectedDmaapOutgoingMessageJsonStringSoftwareUpload ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"software-upload\",\"type\":\"response\"}";
50 private String expectedDmaapOutgoingMessageJsonStringStop ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"stop\",\"type\":\"response\"}";
51 private String expectedDmaapOutgoingMessageJsonStringSync ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"sync\",\"type\":\"response\"}";
52 private String expectedDmaapOutgoingMessageJsonStringTerminate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"terminate\",\"type\":\"response\"}";
53 private String expectedDmaapOutgoingMessageJsonStringUnlock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"unlock\",\"type\":\"response\"}";
54 private String expectedDmaapOutgoingMessageJsonStringUpgradePreCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgrade-pre-check\",\"type\":\"response\"}";
55 private String expectedDmaapOutgoingMessageJsonStringUpgradePostCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgrade-post-check\",\"type\":\"response\"}";
56 private String expectedDmaapOutgoingMessageJsonStringUpgradeSoftware ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgradesoftware\",\"type\":\"response\"}";
57 private String expectedDmaapOutgoingMessageJsonStringUpgradeBackout ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgradebackout\",\"type\":\"response\"}";
58 private String expectedDmaapOutgoingMessageJsonStringUpgradeBackup ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"upgradebackup\",\"type\":\"response\"}";
59 private String expectedDmaapOutgoingMessageJsonStringReboot ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"reboot\",\"type\":\"response\"}";
60 private String expectedDmaapOutgoingMessageJsonStringPreConfigure ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"pre-configure\",\"type\":\"response\"}";
61 private String expectedDmaapOutgoingMessageJsonStringGetConfig ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"get-config\",\"type\":\"response\"}";
62 private String expectedJsonBodyStrwithPayload ="{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}}";
63 private String expectedDmaapOutgoingMessageJsonStringDistributeTraffic = "{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"distribute-traffic\",\"type\":\"response\"}";
64 private String expectedDmaapOutgoingMessageJsonStringDistributeTrafficCheck = "{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"distribute-traffic-check\",\"type\":\"response\"}";
65 private String expectedDmaapOutgoingMessageJsonStringPreRebuild ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"pre-rebuild\",\"type\":\"response\"}";
66 private String expectedDmaapOutgoingMessageJsonStringPostRebuild ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"post-rebuild\",\"type\":\"response\"}";
67 private String expectedDmaapOutgoingMessageJsonStringPreEvacuate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"pre-evacuate\",\"type\":\"response\"}";
68 private String expectedDmaapOutgoingMessageJsonStringPreMigrate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"pre-migrate\",\"type\":\"response\"}";
69 private String expectedDmaapOutgoingMessageJsonStringPostMigrate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"post-migrate\",\"type\":\"response\"}";
70 private String expectedDmaapOutgoingMessageJsonStringPostEvacuate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"post-evacuate\",\"type\":\"response\"}";
71 private String expectedDmaapOutgoingMessageJsonStringLicenseManagement ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"license-management\",\"type\":\"response\"}";
72 private String expectedDmaapOutgoingMessageJsonStringStartTraffic ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"start-traffic\",\"type\":\"response\"}";
73 private String expectedDmaapOutgoingMessageJsonStringStatusTraffic ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"status-traffic\",\"type\":\"response\"}";
74 private String expectedDmaapOutgoingMessageJsonStringStopTraffic ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"stop-traffic\",\"type\":\"response\"}";
75 private String expectedDmaapOutgoingMessageJsonStringProvisioning ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"provisioning\",\"type\":\"response\"}";
76 private String expectedDmaapOutgoingMessageJsonStringDownloadNESw ="{\"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\":\"download-n-e-sw\",\"type\":\"response\"}";
77 private String expectedDmaapOutgoingMessageJsonStringActivateNESw ="{\"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\":\"activate-n-e-sw\",\"type\":\"response\"}";
80 public void convDateToZuluStringTest(){
81 String dateToZuluString = Converter.convDateToZuluString(new Date(0L));
82 Assert.assertEquals("1970-01-01T00:00:00.000Z", dateToZuluString);
86 public void convAsyncResponseToBuilderTestTest() throws JsonProcessingException {
87 ResponseContext asyncResponse = buildAsyncResponse();
88 VNFOperation action = VNFOperation.Test;
89 String rpcName = action.name().toLowerCase();
90 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
91 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
95 public void convAsyncResponseToDmaapOutgoingMessageJsonStringTestTest() throws JsonProcessingException {
96 ResponseContext asyncResponse = buildAsyncResponse();
97 VNFOperation action = VNFOperation.Test;
98 String rpcName = action.name().toLowerCase();
99 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
100 System.out.println("jsonStr = " + jsonStr);
101 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringTest, jsonStr);
105 public void convPayloadObjectToJsonStringTest() throws JsonProcessingException, ParseException {
106 String jsonString = Converter.convPayloadObjectToJsonString("any valid JSON string value");
107 Assert.assertEquals("any valid JSON string value", jsonString);
109 HashMap<String, String> hashMap = new HashMap<>();
110 hashMap.put("key","value");
111 jsonString = Converter.convPayloadObjectToJsonString(hashMap);
112 Assert.assertEquals("{\"key\":\"value\"}", jsonString);
116 public void convAsyncResponseToBuilderRollbackTest() throws JsonProcessingException {
117 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
118 VNFOperation action = VNFOperation.Rollback;
119 String rpcName = action.name().toLowerCase();
120 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
121 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
125 public void convAsyncResponseToDmaapOutgoingMessageJsonStringRollbackTest() throws JsonProcessingException {
126 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
127 VNFOperation action = VNFOperation.Rollback;
128 String rpcName = action.name().toLowerCase();
129 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
130 System.out.println("jsonStr = " + jsonStr);
131 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringRollback, jsonStr);
135 public void convAsyncResponseToBuilderSnapshotTest() throws JsonProcessingException {
136 ResponseContext asyncResponse = buildAsyncResponse();
137 VNFOperation action = VNFOperation.Snapshot;
138 String rpcName = action.name().toLowerCase();
139 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
140 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
144 public void convAsyncResponseToDmaapOutgoingMessageJsonStringSnapshotTest() throws JsonProcessingException {
145 ResponseContext asyncResponse = buildAsyncResponse();
146 VNFOperation action = VNFOperation.Snapshot;
147 String rpcName = action.name().toLowerCase();
148 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
149 System.out.println("jsonStr = " + jsonStr);
150 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringSnapshot, jsonStr);
153 public void convAsyncResponseToBuilderAuditTest() throws JsonProcessingException {
154 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
155 VNFOperation action = VNFOperation.Audit;
156 String rpcName = action.name().toLowerCase();
157 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
158 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
162 public void convAsyncResponseToDmaapOutgoingMessageJsonStringAuditTest() throws JsonProcessingException {
163 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
164 VNFOperation action = VNFOperation.Audit;
165 String rpcName = action.name().toLowerCase();
166 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
167 System.out.println("jsonStr = " + jsonStr);
168 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringAudit, jsonStr);
171 public void convAsyncResponseToBuilderHealthCheckTest() throws JsonProcessingException {
172 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
173 VNFOperation action = VNFOperation.HealthCheck;
174 String rpcName = convertActionNameToUrl(action.name());
175 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
176 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
180 public void convAsyncResponseToDmaapOutgoingMessageJsonStringHealthCheckTest() throws JsonProcessingException {
181 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
182 VNFOperation action = VNFOperation.HealthCheck;
183 String rpcName = convertActionNameToUrl(action.name());
184 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
185 System.out.println("jsonStr = " + jsonStr);
186 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringHealthCheck, jsonStr);
189 public void convAsyncResponseToBuilderLiveUpgradeTest() throws JsonProcessingException {
190 ResponseContext asyncResponse = buildAsyncResponse();
191 VNFOperation action = VNFOperation.LiveUpgrade;
192 String rpcName = convertActionNameToUrl(action.name());
193 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
194 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
198 public void convAsyncResponseToDmaapOutgoingMessageJsonStringLiveUpgradeTest() throws JsonProcessingException {
199 ResponseContext asyncResponse = buildAsyncResponse();
200 VNFOperation action = VNFOperation.LiveUpgrade;
201 String rpcName = convertActionNameToUrl(action.name());
202 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
203 System.out.println("jsonStr = " + jsonStr);
204 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringLiveUpgrade, jsonStr);
207 public void convAsyncResponseToBuilderLockTest() throws JsonProcessingException {
208 ResponseContext asyncResponse = buildAsyncResponse();
209 VNFOperation action = VNFOperation.Lock;
210 String rpcName = convertActionNameToUrl(action.name());
212 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
213 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
217 public void convAsyncResponseToDmaapOutgoingMessageJsonStringLockTest() throws JsonProcessingException {
218 ResponseContext asyncResponse = buildAsyncResponse();
219 VNFOperation action = VNFOperation.Lock;
220 String rpcName = convertActionNameToUrl(action.name());
221 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
222 System.out.println("jsonStr = " + jsonStr);
223 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringLock, jsonStr);
226 public void convAsyncResponseToBuilderModifyConfigTest() throws JsonProcessingException {
227 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
228 VNFOperation action = VNFOperation.ConfigModify;
229 String rpcName = convertActionNameToUrl(action.name());
230 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
231 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
235 public void convAsyncResponseToDmaapOutgoingMessageJsonStringModifyConfigTest() throws JsonProcessingException {
236 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
237 VNFOperation action = VNFOperation.ConfigModify;
238 String rpcName = convertActionNameToUrl(action.name());
239 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
240 System.out.println("jsonStr = " + jsonStr);
241 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringModifyConfig, jsonStr);
244 public void convAsyncResponseToBuilderSoftwareUploadTest() throws JsonProcessingException {
245 ResponseContext asyncResponse = buildAsyncResponse();
246 VNFOperation action = VNFOperation.SoftwareUpload;
247 String rpcName = convertActionNameToUrl(action.name());
249 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
250 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
254 public void convAsyncResponseToDmaapOutgoingMessageJsonStringSoftwareUploadTest() throws JsonProcessingException {
255 ResponseContext asyncResponse = buildAsyncResponse();
256 VNFOperation action = VNFOperation.SoftwareUpload;
257 String rpcName = convertActionNameToUrl(action.name());
258 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
259 System.out.println("jsonStr = " + jsonStr);
260 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringSoftwareUpload, jsonStr);
264 public void convAsyncResponseToBuilderStopTest() throws JsonProcessingException {
265 ResponseContext asyncResponse = buildAsyncResponse();
266 VNFOperation action = VNFOperation.Stop;
267 String rpcName = convertActionNameToUrl(action.name());
268 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
269 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
273 public void convAsyncResponseToDmaapOutgoingMessageJsonStringStopTest() throws JsonProcessingException {
274 ResponseContext asyncResponse = buildAsyncResponse();
275 VNFOperation action = VNFOperation.Stop;
276 String rpcName = convertActionNameToUrl(action.name());
277 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
278 System.out.println("jsonStr = " + jsonStr);
279 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringStop, jsonStr);
283 public void convAsyncResponseToBuilderSync() throws JsonProcessingException {
284 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
285 VNFOperation action = VNFOperation.Sync;
286 String rpcName = convertActionNameToUrl(action.name());
288 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
289 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
293 public void convAsyncResponseToDmaapOutgoingMessageJsonStringSync() throws JsonProcessingException {
294 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
295 VNFOperation action = VNFOperation.Sync;
296 String rpcName = convertActionNameToUrl(action.name());
297 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
298 System.out.println("jsonStr = " + jsonStr);
299 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringSync, jsonStr);
302 public void convAsyncResponseToBuilderTerminateTest() throws JsonProcessingException {
303 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
304 VNFOperation action = VNFOperation.Sync;
305 String rpcName = convertActionNameToUrl(action.name());
306 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
307 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
311 public void convAsyncResponseToDmaapOutgoingMessageJsonStringTerminateTest() throws JsonProcessingException {
312 ResponseContext asyncResponse = buildAsyncResponse();
313 VNFOperation action = VNFOperation.Terminate;
314 String rpcName = convertActionNameToUrl(action.name());
315 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
316 System.out.println("jsonStr = " + jsonStr);
317 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringTerminate, jsonStr);
321 public void convAsyncResponseToBuilderUnlockTest() throws JsonProcessingException {
322 ResponseContext asyncResponse = buildAsyncResponse();
323 VNFOperation action = VNFOperation.Unlock;
324 String rpcName = convertActionNameToUrl(action.name());
325 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
326 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
330 public void convAsyncResponseToDmaapOutgoingMessageJsonStringUnlockTest() throws JsonProcessingException {
331 ResponseContext asyncResponse = buildAsyncResponse();
332 VNFOperation action = VNFOperation.Unlock;
333 String rpcName = convertActionNameToUrl(action.name());
334 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
335 System.out.println("jsonStr = " + jsonStr);
336 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUnlock, jsonStr);
340 public void convAsyncResponseToBuilderRebootTest() throws JsonProcessingException {
341 ResponseContext asyncResponse = buildAsyncResponse();
342 VNFOperation action = VNFOperation.Reboot;
343 String rpcName = convertActionNameToUrl(action.name());
345 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
346 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
350 public void convAsyncResponseToDmaapOutgoingMessageJsonStringRebootTest() throws JsonProcessingException {
351 ResponseContext asyncResponse = buildAsyncResponse();
352 VNFOperation action = VNFOperation.Reboot;
353 String rpcName = convertActionNameToUrl(action.name());
354 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
355 System.out.println("jsonStr = " + jsonStr);
356 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringReboot, jsonStr);
360 public void convAsyncResponseToBuilderUpgradePreCheckTest() throws JsonProcessingException {
361 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
362 VNFOperation action = VNFOperation.UpgradePreCheck;
363 String rpcName = convertActionNameToUrl(action.name());
364 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
365 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
369 public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradePreCheckTest() throws JsonProcessingException {
370 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
371 VNFOperation action = VNFOperation.UpgradePreCheck;
372 String rpcName = convertActionNameToUrl(action.name());
373 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
374 System.out.println("jsonStr = " + jsonStr);
375 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradePreCheck, jsonStr);
379 public void convAsyncResponseToBuilderUpgradePostCheckTest() throws JsonProcessingException {
380 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
381 VNFOperation action = VNFOperation.UpgradePostCheck;
382 String rpcName = convertActionNameToUrl(action.name());
383 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
384 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
388 public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradePostCheckTest() throws JsonProcessingException {
389 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
390 VNFOperation action = VNFOperation.UpgradePostCheck;
391 String rpcName = convertActionNameToUrl(action.name());
392 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
393 System.out.println("jsonStr = " + jsonStr);
394 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradePostCheck, jsonStr);
398 public void convAsyncResponseToBuilderUpgradeSoftwareTest() throws JsonProcessingException {
399 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
400 VNFOperation action = VNFOperation.UpgradeSoftware;
401 String rpcName = action.name().toLowerCase();
402 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
403 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
407 public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradeSoftwareTest() throws JsonProcessingException {
408 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
409 VNFOperation action = VNFOperation.UpgradeSoftware;
410 String rpcName = action.name().toLowerCase();
411 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
412 System.out.println("jsonStr = " + jsonStr);
413 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradeSoftware, jsonStr);
416 public void convAsyncResponseToBuilderUpgradeBackoutTest() throws JsonProcessingException {
417 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
418 VNFOperation action = VNFOperation.UpgradeBackout;
419 String rpcName = action.name().toLowerCase();
420 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
421 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
425 public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradeBackoutTest() throws JsonProcessingException {
426 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
427 VNFOperation action = VNFOperation.UpgradeBackout;
428 String rpcName = action.name().toLowerCase();
429 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
430 System.out.println("jsonStr = " + jsonStr);
431 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradeBackout, jsonStr);
434 public void convAsyncResponseToBuilderUpgradeBackupTest() throws JsonProcessingException {
435 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
436 VNFOperation action = VNFOperation.UpgradeBackup;
437 String rpcName = action.name().toLowerCase();
438 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
439 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
443 public void convAsyncResponseToDmaapOutgoingMessageJsonStringUpgradeBackupTest() throws JsonProcessingException {
444 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
445 VNFOperation action = VNFOperation.UpgradeBackup;
446 String rpcName = action.name().toLowerCase();
447 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
448 System.out.println("jsonStr = " + jsonStr);
449 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringUpgradeBackup, jsonStr);
452 public void convAsyncResponseToBuilderPreConfigureTest() throws JsonProcessingException {
453 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
454 VNFOperation action = VNFOperation.PreConfigure;
455 String rpcName = convertActionNameToUrl(action.name());
457 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
458 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
462 public void convAsyncResponseToDmaapOutgoingMessageJsonStringPreConfigureTest() throws JsonProcessingException {
463 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
464 VNFOperation action = VNFOperation.PreConfigure;
465 String rpcName = convertActionNameToUrl(action.name());
466 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
467 System.out.println("jsonStr = " + jsonStr);
468 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPreConfigure, jsonStr);
472 public void convAsyncResponseToBuilderGetConfigTest() throws JsonProcessingException {
473 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
474 VNFOperation action = VNFOperation.GetConfig;
475 String rpcName = convertActionNameToUrl(action.name());
477 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
478 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
482 public void convAsyncResponseToDmaapOutgoingMessageJsonStringGetConfigTest() throws JsonProcessingException {
483 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
484 VNFOperation action = VNFOperation.GetConfig;
485 String rpcName = convertActionNameToUrl(action.name());
486 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
487 System.out.println("jsonStr = " + jsonStr);
488 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringGetConfig, jsonStr);
492 public void convAsyncResponseToBuilderDistributeTrafficTest() throws JsonProcessingException {
493 ResponseContext asyncResponse = buildAsyncResponse();
494 VNFOperation action = VNFOperation.DistributeTraffic;
495 String rpcName = convertActionNameToUrl(action.name());
496 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
497 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
501 public void convAsyncResponseToDmaapOutgoingMessageJsonStringDistributeTrafficTest()
502 throws JsonProcessingException {
503 ResponseContext asyncResponse = buildAsyncResponse();
504 VNFOperation action = VNFOperation.DistributeTraffic;
505 String rpcName = convertActionNameToUrl(action.name());
506 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
507 System.out.println("jsonStr = " + jsonStr);
508 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringDistributeTraffic, jsonStr);
512 public void convAsyncResponseToBuilderDistributeTrafficCheckTest() throws JsonProcessingException {
513 ResponseContext asyncResponse = buildAsyncResponse();
514 VNFOperation action = VNFOperation.DistributeTrafficCheck;
515 String rpcName = convertActionNameToUrl(action.name());
516 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
517 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
521 public void convAsyncResponseToDmaapOutgoingMessageJsonStringDistributeTrafficCheckTest()
522 throws JsonProcessingException {
523 ResponseContext asyncResponse = buildAsyncResponse();
524 VNFOperation action = VNFOperation.DistributeTrafficCheck;
525 String rpcName = convertActionNameToUrl(action.name());
526 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
527 System.out.println("jsonStr = " + jsonStr);
528 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringDistributeTrafficCheck, jsonStr);
532 public void convAsyncResponseToBuilderPreRebuildTest() throws JsonProcessingException {
533 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
534 VNFOperation action = VNFOperation.PreRebuild;
535 String rpcName = convertActionNameToUrl(action.name());
537 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
538 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
542 public void convAsyncResponseToDmaapOutgoingMessageJsonStringPreRebuildTest() throws JsonProcessingException {
543 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
544 VNFOperation action = VNFOperation.PreRebuild;
545 String rpcName = convertActionNameToUrl(action.name());
546 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
547 System.out.println("jsonStr = " + jsonStr);
548 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPreRebuild, jsonStr);
552 public void convAsyncResponseToBuilderPostRebuildTest() throws JsonProcessingException {
553 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
554 VNFOperation action = VNFOperation.PostRebuild;
555 String rpcName = convertActionNameToUrl(action.name());
557 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
558 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
562 public void convAsyncResponseToDmaapOutgoingMessageJsonStringPostRebuildTest() throws JsonProcessingException {
563 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
564 VNFOperation action = VNFOperation.PostRebuild;
565 String rpcName = convertActionNameToUrl(action.name());
566 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
567 System.out.println("jsonStr = " + jsonStr);
568 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPostRebuild, jsonStr);
572 public void convAsyncResponseToBuilderPreEvacuateTest() throws JsonProcessingException {
573 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
574 VNFOperation action = VNFOperation.PreEvacuate;
575 String rpcName = convertActionNameToUrl(action.name());
576 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
577 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
581 public void convAsyncResponseToDmaapOutgoingMessageJsonStringPreEvacuateTest() throws JsonProcessingException {
582 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
583 VNFOperation action = VNFOperation.PreEvacuate;
584 String rpcName = convertActionNameToUrl(action.name());
585 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
586 System.out.println("jsonStr = " + jsonStr);
587 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPreEvacuate, jsonStr);
591 public void convAsyncResponseToBuilderPreMigrateTest() throws JsonProcessingException {
592 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
593 VNFOperation action = VNFOperation.PreMigrate;
594 String rpcName = convertActionNameToUrl(action.name());
596 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
597 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
601 public void convAsyncResponseToDmaapOutgoingMessageJsonStringPreMigrateTest() throws JsonProcessingException {
602 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
603 VNFOperation action = VNFOperation.PreMigrate;
604 String rpcName = convertActionNameToUrl(action.name());
605 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
606 System.out.println("jsonStr = " + jsonStr);
607 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPreMigrate, jsonStr);
611 public void convAsyncResponseToBuilderPostMigrateTest() throws JsonProcessingException {
612 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
613 VNFOperation action = VNFOperation.PostMigrate;
614 String rpcName = convertActionNameToUrl(action.name());
616 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
617 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
621 public void convAsyncResponseToDmaapOutgoingMessageJsonStringPostMigrateTest() throws JsonProcessingException {
622 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
623 VNFOperation action = VNFOperation.PostMigrate;
624 String rpcName = convertActionNameToUrl(action.name());
625 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
626 System.out.println("jsonStr = " + jsonStr);
627 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPostMigrate, jsonStr);
631 public void convAsyncResponseToBuilderPostEvacuateTest() throws JsonProcessingException {
632 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
633 VNFOperation action = VNFOperation.PostEvacuate;
634 String rpcName = convertActionNameToUrl(action.name());
636 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
637 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
641 public void convAsyncResponseToDmaapOutgoingMessageJsonStringPostEvacuateTest() throws JsonProcessingException {
642 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
643 VNFOperation action = VNFOperation.PostEvacuate;
644 String rpcName = convertActionNameToUrl(action.name());
645 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
646 System.out.println("jsonStr = " + jsonStr);
647 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringPostEvacuate, jsonStr);
651 public void convAsyncResponseToBuilderStartTrafficTest() throws JsonProcessingException {
652 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
653 VNFOperation action = VNFOperation.StartTraffic;
654 String rpcName = convertActionNameToUrl(action.name());
656 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
657 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
661 public void convAsyncResponseToDmaapOutgoingMessageJsonStringStartTrafficTest() throws JsonProcessingException {
662 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
663 VNFOperation action = VNFOperation.StartTraffic;
664 String rpcName = convertActionNameToUrl(action.name());
665 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
666 System.out.println("jsonStr = " + jsonStr);
667 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringStartTraffic, jsonStr);
671 public void convAsyncResponseToBuilderStatusTrafficTest() throws JsonProcessingException {
672 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
673 VNFOperation action = VNFOperation.StatusTraffic;
674 String rpcName = convertActionNameToUrl(action.name());
675 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
676 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
680 public void convAsyncResponseToDmaapOutgoingMessageJsonStringStatusTrafficTest() throws JsonProcessingException {
681 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
682 VNFOperation action = VNFOperation.StatusTraffic;
683 String rpcName = convertActionNameToUrl(action.name());
684 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
685 System.out.println("jsonStr = " + jsonStr);
686 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringStatusTraffic, jsonStr);
690 public void convAsyncResponseToDmaapOutgoingMessageJsonStringLicenseManagementTest()
691 throws JsonProcessingException {
692 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
693 VNFOperation action = VNFOperation.LicenseManagement;
694 String rpcName = convertActionNameToUrl(action.name());
695 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
696 System.out.println("jsonStr = " + jsonStr);
697 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringLicenseManagement,jsonStr);
701 public void convAsyncResponseToBuilderLicenseManagementTest() throws JsonProcessingException {
702 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
703 VNFOperation action = VNFOperation.LicenseManagement;
704 String rpcName = convertActionNameToUrl(action.name());
705 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
706 Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
709 public void convAsyncResponseToDmaapOutgoingMessageJsonStringProvisioningTest() throws JsonProcessingException {
710 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
711 VNFOperation action = VNFOperation.Provisioning;
712 String rpcName = convertActionNameToUrl(action.name());
713 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
714 System.out.println("jsonStr = " + jsonStr);
715 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringProvisioning,jsonStr);
719 public void convAsyncResponseToBuilderProvisioningTest() throws JsonProcessingException {
720 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
721 VNFOperation action = VNFOperation.Provisioning;
722 String rpcName = convertActionNameToUrl(action.name());
723 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
724 Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
727 public void convAsyncResponseToBuilderStopTrafficTest() throws JsonProcessingException {
728 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
729 VNFOperation action = VNFOperation.StopTraffic;
730 String rpcName = convertActionNameToUrl(action.name());
731 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
732 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
736 public void convAsyncResponseToDmaapOutgoingMessageJsonStringStopTrafficTest() throws JsonProcessingException {
737 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
738 VNFOperation action = VNFOperation.StopTraffic;
739 String rpcName = convertActionNameToUrl(action.name());
740 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
741 System.out.println("jsonStr = " + jsonStr);
742 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringStopTraffic, jsonStr);
746 public void convAsyncResponseToBuilderDownloadNESwTest() throws JsonProcessingException {
747 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
748 VNFOperation action = VNFOperation.DownloadNESw;
749 String rpcName = convertActionNameToUrl(action.name());
750 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
751 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
755 public void convAsyncResponseToDmaapOutgoingMessageJsonStringDownloadNESwTest() throws JsonProcessingException {
756 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
757 VNFOperation action = VNFOperation.DownloadNESw;
758 String rpcName = convertActionNameToUrl(action.name());
759 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
760 System.out.println("jsonStr = " + jsonStr);
761 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringDownloadNESw, jsonStr);
765 public void convAsyncResponseToBuilderActivateNESwTest() throws JsonProcessingException {
766 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
767 VNFOperation action = VNFOperation.ActivateNESw;
768 String rpcName = convertActionNameToUrl(action.name());
769 String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
770 Assert.assertEquals(expectedJsonBodyStrwithPayload, jsonStr);
774 public void convAsyncResponseToDmaapOutgoingMessageJsonStringActivateNESwTest() throws JsonProcessingException {
775 ResponseContext asyncResponse = buildAsyncResponsewithPayload();
776 VNFOperation action = VNFOperation.ActivateNESw;
777 String rpcName = convertActionNameToUrl(action.name());
778 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
779 System.out.println("jsonStr = " + jsonStr);
780 Assert.assertEquals(expectedDmaapOutgoingMessageJsonStringActivateNESw, jsonStr);
784 public void convAsyncResponseToBuilderTest() throws JsonProcessingException {
785 AsyncResponse asyncResponse = buildAsyncResponse();
786 String jsonStr = Converter.convAsyncResponseToJsonStringBody(asyncResponse);
787 Assert.assertEquals(expectedJsonBodyStr, jsonStr);
791 public void convAsyncResponseToDmaapOutgoingMessageJsonStringTest() throws JsonProcessingException {
792 AsyncResponse asyncResponse = buildAsyncResponse();
793 String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(asyncResponse);
794 System.out.println("jsonStr = " + jsonStr);
795 Assert.assertEquals(expectedDmaapOutgoingMessageJsonString, jsonStr);
799 private ResponseContext buildAsyncResponse() {
800 ResponseContext asyncResponse = createResponseContextWithSubObjects();
801 asyncResponse.getStatus().setCode(LCMCommandStatus.SUCCESS.getResponseCode());
802 asyncResponse.getStatus().setMessage(LCMCommandStatus.SUCCESS.getResponseMessage());
803 asyncResponse.getCommonHeader().setOriginatorId("oid");
804 asyncResponse.getCommonHeader().setApiVer("2.0.0");
805 asyncResponse.getCommonHeader().setRequestId("reqid");
806 asyncResponse.getCommonHeader().setTimestamp(new Date(1000L));
807 asyncResponse.setPayload(
808 "any valid JSON string value. Json escape characters need to be added to make it a valid json string value");
809 return asyncResponse;
812 private ResponseContext buildAsyncResponsewithPayload() {
813 ResponseContext asyncResponse = createResponseContextWithSubObjects();
814 asyncResponse.getStatus().setCode(LCMCommandStatus.SUCCESS.getResponseCode());
815 asyncResponse.getStatus().setMessage(LCMCommandStatus.SUCCESS.getResponseMessage());
816 asyncResponse.getCommonHeader().setOriginatorId("oid");
817 asyncResponse.getCommonHeader().setApiVer("2.0.0");
818 asyncResponse.getCommonHeader().setRequestId("reqid");
819 asyncResponse.getCommonHeader().setTimestamp(new Date(1000L));
820 asyncResponse.setPayload("{}");
821 return asyncResponse;
824 private ResponseContext createResponseContextWithSubObjects() {
826 ResponseContext responseContext = new ResponseContext();
827 CommonHeader commonHeader = new CommonHeader();
828 Flags flags = new Flags();
829 Status status = new Status();
830 responseContext.setCommonHeader(commonHeader);
831 responseContext.setStatus(status);
832 commonHeader.setFlags(flags);
833 return responseContext;
836 private String convertActionNameToUrl(String action) {
837 return Converter.getRpcName(action);