aboutsummaryrefslogtreecommitdiffstats
path: root/models-sim
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2021-10-15 18:02:21 +0100
committera.sreekumar <ajith.sreekumar@bell.ca>2021-10-19 15:07:29 +0100
commit125e445b650897d75967ed8d3710098a7702cf04 (patch)
tree817af70accb104dc5aedf107a97288b5b2d54ef9 /models-sim
parent6ed822fabd7c39e71b821134fcf8ac299e261108 (diff)
Improve AAI simulator by configuring responses
Change-Id: Ide7f572dac91110a5d560fc388dd87246c9d195b Issue-ID: POLICY-3709 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'models-sim')
-rw-r--r--models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java2
-rw-r--r--models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java10
2 files changed, 11 insertions, 1 deletions
diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java
index 65f94abe9..404c7a7f9 100644
--- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java
+++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/ClassRestServerParameters.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,4 +29,5 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@Getter
public class ClassRestServerParameters extends RestServerParameters {
private @NotNull @ClassName String providerClass;
+ private String resourceLocation;
}
diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java
index 4c299914b..5e585b414 100644
--- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java
+++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/Main.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
import lombok.AccessLevel;
import lombok.Getter;
+import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
@@ -45,6 +46,7 @@ import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.common.utils.services.ServiceManagerContainer;
import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
import org.onap.policy.models.sim.dmaap.provider.DmaapSimProvider;
@@ -104,6 +106,12 @@ public class Main extends ServiceManagerContainer {
// @formatter:off
for (ClassRestServerParameters restsim : params.getRestServers()) {
AtomicReference<HttpServletServer> ref = new AtomicReference<>();
+ if (StringUtils.isNotBlank(restsim.getResourceLocation())) {
+ String resourceLocationId = restsim.getProviderClass() + "_RESOURCE_LOCATION";
+ addAction(resourceLocationId,
+ () -> Registry.register(resourceLocationId, restsim.getResourceLocation()),
+ () -> Registry.unregister(resourceLocationId));
+ }
addAction(restsim.getName(),
() -> ref.set(buildRestServer(dmaapName, restsim)),
() -> ref.get().shutdown());