diff options
Diffstat (limited to 'models-sim/policy-models-simulators/src/main')
2 files changed, 19 insertions, 9 deletions
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 a0fafbc9b..f82423c11 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 @@ -83,18 +83,22 @@ public class Main extends ServiceManagerContainer { } DmaapSimParameterGroup dmaapProv = params.getDmaapProvider(); - String dmaapName = dmaapProv.getName(); - String provName = dmaapName.replace("simulator", "provider"); + String dmaapName = (dmaapProv != null ? dmaapProv.getName() : null); // dmaap provider - AtomicReference<DmaapSimProvider> provRef = new AtomicReference<>(); - addAction(provName, () -> provRef.set(buildDmaapProvider(dmaapProv)), () -> provRef.get().shutdown()); + if (dmaapProv != null) { + String provName = dmaapName.replace("simulator", "provider"); + AtomicReference<DmaapSimProvider> provRef = new AtomicReference<>(); + addAction(provName, () -> provRef.set(buildDmaapProvider(dmaapProv)), () -> provRef.get().shutdown()); + } CdsServerParameters cdsServer = params.getGrpcServer(); // Cds Simulator - AtomicReference<CdsSimulator> cdsSim = new AtomicReference<>(); - addAction(cdsServer.getName(), () -> cdsSim.set(buildCdsSimulator(cdsServer)), () -> cdsSim.get().stop()); + if (cdsServer != null) { + AtomicReference<CdsSimulator> cdsSim = new AtomicReference<>(); + addAction(cdsServer.getName(), () -> cdsSim.set(buildCdsSimulator(cdsServer)), () -> cdsSim.get().stop()); + } // REST server simulators // @formatter:off @@ -276,7 +280,7 @@ public class Main extends ServiceManagerContainer { props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SWAGGER_SUFFIX, "false"); props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX, "true"); - if (dmaapName.equals(params.getName())) { + if (dmaapName != null && dmaapName.equals(params.getName())) { props.setProperty(svcpfx + PolicyEndPointProperties.PROPERTY_HTTP_SERIALIZATION_PROVIDER, String.join(",", CambriaMessageBodyHandler.class.getName(), GsonMessageBodyHandler.class.getName(), diff --git a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java index 788829f36..c22527165 100644 --- a/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java +++ b/models-sim/policy-models-simulators/src/main/java/org/onap/policy/models/simulators/SimulatorParameters.java @@ -27,14 +27,12 @@ import lombok.Getter; import org.onap.policy.common.endpoints.parameters.TopicParameters; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.BeanValidator; -import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup; /** * Simulator parameters. */ @Getter -@NotNull public class SimulatorParameters { /** @@ -77,6 +75,14 @@ public class SimulatorParameters { public BeanValidationResult validate(String containerName) { BeanValidationResult result = new BeanValidator().validateTop(containerName, this); + if (dmaapProvider != null) { + result.addResult(dmaapProvider.validate()); + } + + if (grpcServer != null) { + result.addResult(grpcServer.validate()); + } + result.validateList("restServers", restServers, params -> params.validate("restServers")); result.validateList("topicServers", topicServers, params -> params.validate("topicServers")); |