aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2020-10-07 14:10:40 +0000
committerGerrit Code Review <gerrit@onap.org>2020-10-07 14:10:40 +0000
commitf8d759ecc3803f178447604a58a1f8672fdacaf4 (patch)
treef4bf525fcf87bb6a1054b5b44022a708584cd7c4
parent83119e48610df9ed0cc8424ce86e877f7455e29e (diff)
parentc3599bd58bc5e6738570f5737d6a3129573f0e8a (diff)
Merge "Adding basic logging to CDS Simulator"
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java9
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java6
2 files changed, 14 insertions, 1 deletions
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java
index 3418780bc..6c505b3d9 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/CdsSimulator.java
@@ -39,8 +39,13 @@ import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceIn
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput.Builder;
import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CdsSimulator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CdsSimulator.class);
+
@Getter
private final int port;
@@ -83,6 +88,7 @@ public class CdsSimulator {
@Override
public void onNext(final ExecutionServiceInput executionServiceInput) {
+ LOGGER.info("Received request input to CDS: {}", executionServiceInput);
try {
String responseString = getResponseString(executionServiceInput, countOfSuccesfulEvents);
Builder builder = ExecutionServiceOutput.newBuilder();
@@ -141,11 +147,14 @@ public class CdsSimulator {
} else {
resourceName = resourceName + ".json";
}
+ LOGGER.info("Fetching response from {}", resourceName);
String responseString = ResourceUtils.getResourceAsString(resourceLocation + resourceName);
if (responseString == null) {
+ LOGGER.info("Expected response file {} not found in {}", resourceName, resourceLocation);
responseString = ResourceUtils.getResourceAsString(resourceLocation
+ "DefaultResponseEvent.json");
}
+ LOGGER.debug("Returning response from CDS Simulator: {}", responseString);
return responseString;
}
}
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
index 6e9c2239c..cd4f3b593 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
@@ -24,6 +24,7 @@ package org.onap.policy.simulators;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import com.google.protobuf.util.JsonFormat;
import io.grpc.ManagedChannel;
import io.grpc.internal.DnsNameResolverProvider;
import io.grpc.internal.PickFirstLoadBalancerProvider;
@@ -42,6 +43,7 @@ import org.junit.Test;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc.BluePrintProcessingServiceStub;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
+import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput.Builder;
import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -72,7 +74,9 @@ public class CdsSimulatorTest {
@Test
public void test() throws Exception {
String reqstr = IOUtils.toString(getClass().getResource("cds/cds.request.json"), StandardCharsets.UTF_8);
- ExecutionServiceInput request = coder.decode(reqstr, ExecutionServiceInput.class);
+ Builder builder = ExecutionServiceInput.newBuilder();
+ JsonFormat.parser().ignoringUnknownFields().merge(reqstr, builder);
+ ExecutionServiceInput request = builder.build();
ManagedChannel channel = NettyChannelBuilder.forAddress(Util.LOCALHOST, sim.getPort())
.nameResolverFactory(new DnsNameResolverProvider())
.loadBalancerFactory(new PickFirstLoadBalancerProvider()).usePlaintext().build();