summaryrefslogtreecommitdiffstats
path: root/examples/examples-onap-vcpe/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-onap-vcpe/src')
-rw-r--r--examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java53
1 files changed, 33 insertions, 20 deletions
diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java
index 4a12b3baa..10f425302 100644
--- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java
+++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java
@@ -5,38 +5,39 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.domains.onap.vcpe;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.BlockingQueue;
-import org.onap.policy.appclcm.LcmRequest;
-import org.onap.policy.appclcm.LcmRequestWrapper;
-import org.onap.policy.appclcm.LcmResponse;
-import org.onap.policy.appclcm.LcmResponseWrapper;
-import org.onap.policy.appclcm.util.Serialization;
+import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
+import org.onap.policy.appclcm.AppcLcmInput;
+import org.onap.policy.appclcm.AppcLcmOutput;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
/**
* Respond to an APPC request with a given delay.
*/
public class AppcResponseCreator {
+ private static final XLogger LOGGER = XLoggerFactory.getXLogger(AppcResponseCreator.class);
+
// The request from APPC
private final String jsonRequestString;
@@ -48,7 +49,7 @@ public class AppcResponseCreator {
/**
* Respond to the given APPC request after the given amount of milliseconds.
- *
+ *
* @param appcResponseQueue the queue into which to put the APPC response
* @param jsonRequestString the request JSON string
* @param milliSecondsToWait the number of milliseconds to wait
@@ -68,25 +69,37 @@ public class AppcResponseCreator {
*/
@Override
public void run() {
- Gson gson = new GsonBuilder().registerTypeAdapter(LcmRequest.class, new Serialization.RequestAdapter())
- .registerTypeAdapter(LcmResponse.class, new Serialization.ResponseAdapter())
- .setPrettyPrinting().create();
- LcmRequestWrapper requestWrapper = gson.fromJson(jsonRequestString, LcmRequestWrapper.class);
+ StandardCoder standardCoder = new StandardCoder();
+
+ AppcLcmDmaapWrapper requestWrapper = null;
+ try {
+ requestWrapper = standardCoder.decode(jsonRequestString, AppcLcmDmaapWrapper.class);
+ } catch (CoderException e) {
+ LOGGER.warn("decoding of the APPC request message failed", e);
+ return;
+ }
+
+ AppcLcmInput request = requestWrapper.getBody().getInput();
- LcmResponse response = new LcmResponse(requestWrapper.getBody());
+ AppcLcmOutput response = new AppcLcmOutput(request);
response.getStatus().setCode(400);
response.getStatus().setMessage("Restart Successful");
- LcmResponseWrapper responseWrapper = new LcmResponseWrapper();
- responseWrapper.setBody(response);
+ AppcLcmDmaapWrapper responseWrapper = new AppcLcmDmaapWrapper();
+ responseWrapper.getBody().setOutput(response);
responseWrapper.setVersion(requestWrapper.getVersion());
responseWrapper.setRpcName(requestWrapper.getRpcName());
responseWrapper.setCorrelationId(requestWrapper.getCorrelationId());
responseWrapper.setType(requestWrapper.getType());
- appcResponseQueue.add(gson.toJson(responseWrapper, LcmResponseWrapper.class));
+ try {
+ appcResponseQueue.add(standardCoder.encode(responseWrapper));
+ } catch (CoderException e) {
+ LOGGER.warn("encoding of the APPC request message failed", e);
+ return;
+ }
}
}
}