2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2022 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.clamp.acm.participant.simulator.main.parameters;
23 import java.util.List;
25 import java.util.TreeMap;
26 import org.onap.policy.common.endpoints.parameters.TopicParameters;
27 import org.onap.policy.common.utils.coder.Coder;
28 import org.onap.policy.common.utils.coder.CoderException;
29 import org.onap.policy.common.utils.coder.StandardCoder;
30 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
33 * Class to hold/create all parameters for test cases.
35 public class CommonTestData {
36 public static final String DESCRIPTION = "Participant description";
37 public static final long TIME_INTERVAL = 2000;
38 public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
40 public static final Coder CODER = new StandardCoder();
43 * Get ParticipantSimulatorParameters.
45 * @return ParticipantSimulatorParameters
47 public ParticipantSimulatorParameters getParticipantSimulatorParameters() {
49 return CODER.convert(getParticipantParameterGroupMap(),
50 ParticipantSimulatorParameters.class);
51 } catch (final CoderException e) {
52 throw new RuntimeException("cannot create ParticipantSimulatorParameters from map", e);
57 * Returns a property map for a ApexStarterParameterGroup map for test cases.
59 * @return a property map suitable for constructing an object
61 public Map<String, Object> getParticipantParameterGroupMap() {
62 final Map<String, Object> map = new TreeMap<>();
64 map.put("intermediaryParameters", getIntermediaryParametersMap(false));
69 * Returns a property map for a intermediaryParameters map for test cases.
71 * @param isEmpty boolean value to represent that object created should be empty or not
72 * @return a property map suitable for constructing an object
74 public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
75 final Map<String, Object> map = new TreeMap<>();
77 map.put("name", "Participant parameters");
78 map.put("reportingTimeIntervalMs", TIME_INTERVAL);
79 map.put("description", DESCRIPTION);
80 map.put("participantId", getParticipantId());
81 map.put("participantType", getParticipantId());
82 map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
89 * Returns a property map for a TopicParameters map for test cases.
91 * @param isEmpty boolean value to represent that object created should be empty or not
92 * @return a property map suitable for constructing an object
94 public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
95 final Map<String, Object> map = new TreeMap<>();
97 map.put("topicSources", TOPIC_PARAMS);
98 map.put("topicSinks", TOPIC_PARAMS);
104 * Returns topic parameters for test cases.
106 * @return topic parameters
108 public static TopicParameters getTopicParams() {
109 final TopicParameters topicParams = new TopicParameters();
110 topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
111 topicParams.setTopicCommInfrastructure("dmaap");
112 topicParams.setServers(List.of("localhost"));
117 * Returns participantId for test cases.
119 * @return participant Id
121 public static ToscaConceptIdentifier getParticipantId() {
122 return new ToscaConceptIdentifier("org.onap.PM_CDS_Blueprint", "1.0.0");