2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.models.simulators;
24 import java.util.LinkedList;
25 import java.util.List;
27 import org.onap.policy.common.endpoints.parameters.TopicParameters;
28 import org.onap.policy.common.parameters.BeanValidationResult;
29 import org.onap.policy.common.parameters.BeanValidator;
30 import org.onap.policy.common.parameters.ValidationStatus;
31 import org.onap.policy.common.parameters.annotations.Valid;
32 import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
35 * Simulator parameters.
38 public class SimulatorParameters {
41 * Note: this is only used to capture the provider's parameters; the rest server
42 * parameters that it contains are ignored. Instead, the parameters for the rest
43 * server are contained within the {@link #restServers} entry having the same name as
44 * the provider parameters.
46 private DmaapSimParameterGroup dmaapProvider;
48 private @Valid CdsServerParameters grpcServer;
51 * Parameters for the REST server simulators that are to be started.
53 private List<@Valid ClassRestServerParameters> restServers = new LinkedList<>();
56 * Topic sinks that are used by {@link #topicServers}.
58 private List<@Valid TopicParameters> topicSinks = new LinkedList<>();
61 * Topic sources that are used by {@link #topicServers}.
63 private List<@Valid TopicParameters> topicSources = new LinkedList<>();
66 * Parameters for the TOPIC server simulators that are to be started.
68 private List<@Valid TopicServerParameters> topicServers = new LinkedList<>();
72 * Validates the parameters.
74 * @param containerName name of the parameter container
75 * @return the validation result
77 public BeanValidationResult validate(String containerName) {
78 BeanValidationResult result = new BeanValidator().validateTop(containerName, this);
80 if (dmaapProvider != null) {
81 // do not want full validation of the provider, so validate the relevant
83 var subResult = new BeanValidationResult("dmaapProvider", dmaapProvider);
84 subResult.validateNotNull("name", dmaapProvider.getName());
85 if (dmaapProvider.getTopicSweepSec() < 1) {
86 subResult.addResult("topicSweepSec", dmaapProvider.getTopicSweepSec(),
87 ValidationStatus.INVALID, "is below the minimum value: 1");
89 result.addResult(subResult);