2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2024 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.policy.main.parameters;
23 import java.util.ArrayList;
24 import java.util.List;
26 import java.util.TreeMap;
27 import java.util.UUID;
28 import org.onap.policy.clamp.acm.participant.intermediary.parameters.Topics;
29 import org.onap.policy.common.endpoints.parameters.TopicParameters;
30 import org.onap.policy.common.utils.coder.Coder;
31 import org.onap.policy.common.utils.coder.CoderException;
32 import org.onap.policy.common.utils.coder.StandardCoder;
35 * Class to hold/create all parameters for test cases.
37 public class CommonTestData {
38 public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
39 public static final String DESCRIPTION = "Participant description";
40 public static final long TIME_INTERVAL = 2000;
41 public static final List<TopicParameters> SINK_TOPIC_PARAMS = List.of(getSinkTopicParams());
42 public static final List<TopicParameters> SOURCE_TOPIC_PARAMS = List.of(getSinkTopicParams(), getSyncTopicParams());
44 public static final Coder CODER = new StandardCoder();
47 * Get ParticipantPolicyParameters.
49 * @return ParticipantPolicyParameters
51 public ParticipantPolicyParameters getParticipantPolicyParameters() {
53 return CODER.convert(getParticipantPolicyParametersMap(PARTICIPANT_GROUP_NAME),
54 ParticipantPolicyParameters.class);
55 } catch (final CoderException e) {
56 throw new RuntimeException("cannot create ParticipantPolicyParameters from map", e);
61 * Returns a property map for a ParticipantPolicyParameters map for test cases.
63 * @param name name of the parameters
65 * @return a property map suitable for constructing an object
67 public Map<String, Object> getParticipantPolicyParametersMap(final String name) {
68 final Map<String, Object> map = new TreeMap<>();
70 map.put("name", name);
71 map.put("intermediaryParameters", getIntermediaryParametersMap(false));
72 map.put("policyApiParameters", getPolicyApiParametersMap());
73 map.put("policyPapParameters", getPolicyPapParametersMap());
74 map.put("pdpGroup", "defaultGroup");
75 map.put("pdpType", "apex");
80 * Returns a property map for a policyPapParameters map for test cases.
82 * @return a property map suitable for constructing an object
84 public Map<String, Object> getPolicyPapParametersMap() {
85 final Map<String, Object> map = new TreeMap<>();
86 map.put("clientName", "pap");
87 map.put("hostname", "localhost");
88 map.put("port", 6968);
89 map.put("userName", "policyadmin");
90 map.put("password", "zb!XztG34");
91 map.put("https", false);
92 map.put("allowSelfSignedCerts", true);
97 * Returns a property map for a policyApiParameters map for test cases.
99 * @return a property map suitable for constructing an object
101 public Map<String, Object> getPolicyApiParametersMap() {
102 final Map<String, Object> map = new TreeMap<>();
103 map.put("clientName", "api");
104 map.put("hostname", "localhost");
105 map.put("port", 6969);
106 map.put("userName", "policyadmin");
107 map.put("password", "zb!XztG34");
108 map.put("https", false);
109 map.put("allowSelfSignedCerts", true);
115 * Returns a property map for a intermediaryParameters map for test cases.
117 * @param isEmpty boolean value to represent that object created should be empty or not
118 * @return a property map suitable for constructing an object
120 public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
121 final Map<String, Object> map = new TreeMap<>();
123 map.put("name", "Participant parameters");
124 map.put("reportingTimeIntervalMs", TIME_INTERVAL);
125 map.put("description", DESCRIPTION);
126 map.put("participantId", getParticipantId());
127 map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
128 map.put("participantSupportedElementTypes", new ArrayList<>());
129 map.put("topics", new Topics("policy-acruntime-participant", "acm-ppnt-sync"));
136 * Returns a property map for a TopicParameters map for test cases.
138 * @param isEmpty boolean value to represent that object created should be empty or not
139 * @return a property map suitable for constructing an object
141 public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
142 final Map<String, Object> map = new TreeMap<>();
144 map.put("topicSources", SOURCE_TOPIC_PARAMS);
145 map.put("topicSinks", SINK_TOPIC_PARAMS);
151 * Returns topic parameters for test cases.
153 * @return topic parameters
155 public static TopicParameters getSinkTopicParams() {
156 final TopicParameters topicParams = new TopicParameters();
157 topicParams.setTopic("policy-acruntime-participant");
158 topicParams.setTopicCommInfrastructure("NOOP");
159 topicParams.setServers(List.of("localhost"));
164 * Returns sync topic parameters for test cases.
166 * @return topic parameters
168 public static TopicParameters getSyncTopicParams() {
169 final TopicParameters topicParams = new TopicParameters();
170 topicParams.setTopic("acm-ppnt-sync");
171 topicParams.setTopicCommInfrastructure("NOOP");
172 topicParams.setServers(List.of("localhost"));
177 * Returns participantId for test cases.
179 * @return participant Id
181 public static UUID getParticipantId() {
182 return UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c03");