2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2023 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 org.onap.policy.common.endpoints.parameters.TopicParameters;
28 import org.onap.policy.common.utils.coder.Coder;
29 import org.onap.policy.common.utils.coder.CoderException;
30 import org.onap.policy.common.utils.coder.StandardCoder;
31 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
34 * Class to hold/create all parameters for test cases.
36 public class CommonTestData {
37 public static final String PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
38 public static final String DESCRIPTION = "Participant description";
39 public static final long TIME_INTERVAL = 2000;
40 public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
42 public static final Coder CODER = new StandardCoder();
45 * Get ParticipantPolicyParameters.
47 * @return ParticipantPolicyParameters
49 public ParticipantPolicyParameters getParticipantPolicyParameters() {
51 return CODER.convert(getParticipantPolicyParametersMap(PARTICIPANT_GROUP_NAME),
52 ParticipantPolicyParameters.class);
53 } catch (final CoderException e) {
54 throw new RuntimeException("cannot create ParticipantPolicyParameters from map", e);
59 * Returns a property map for a ParticipantPolicyParameters map for test cases.
61 * @param name name of the parameters
63 * @return a property map suitable for constructing an object
65 public Map<String, Object> getParticipantPolicyParametersMap(final String name) {
66 final Map<String, Object> map = new TreeMap<>();
68 map.put("name", name);
69 map.put("intermediaryParameters", getIntermediaryParametersMap(false));
70 map.put("policyApiParameters", getPolicyApiParametersMap());
71 map.put("policyPapParameters", getPolicyPapParametersMap());
72 map.put("pdpGroup", "defaultGroup");
73 map.put("pdpType", "apex");
78 * Returns a property map for a policyPapParameters map for test cases.
80 * @return a property map suitable for constructing an object
82 public Map<String, Object> getPolicyPapParametersMap() {
83 final Map<String, Object> map = new TreeMap<>();
84 map.put("clientName", "pap");
85 map.put("hostname", "localhost");
86 map.put("port", 6968);
87 map.put("userName", "policyadmin");
88 map.put("password", "zb!XztG34");
89 map.put("https", false);
90 map.put("allowSelfSignedCerts", true);
95 * Returns a property map for a policyApiParameters map for test cases.
97 * @return a property map suitable for constructing an object
99 public Map<String, Object> getPolicyApiParametersMap() {
100 final Map<String, Object> map = new TreeMap<>();
101 map.put("clientName", "api");
102 map.put("hostname", "localhost");
103 map.put("port", 6969);
104 map.put("userName", "policyadmin");
105 map.put("password", "zb!XztG34");
106 map.put("https", false);
107 map.put("allowSelfSignedCerts", true);
113 * Returns a property map for a intermediaryParameters map for test cases.
115 * @param isEmpty boolean value to represent that object created should be empty or not
116 * @return a property map suitable for constructing an object
118 public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
119 final Map<String, Object> map = new TreeMap<>();
121 map.put("name", "Participant parameters");
122 map.put("reportingTimeIntervalMs", TIME_INTERVAL);
123 map.put("description", DESCRIPTION);
124 map.put("participantId", getParticipantId());
125 map.put("participantType", getParticipantType());
126 map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
127 map.put("participantSupportedElementTypes", new ArrayList<>());
134 * Returns a property map for a TopicParameters map for test cases.
136 * @param isEmpty boolean value to represent that object created should be empty or not
137 * @return a property map suitable for constructing an object
139 public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
140 final Map<String, Object> map = new TreeMap<>();
142 map.put("topicSources", TOPIC_PARAMS);
143 map.put("topicSinks", TOPIC_PARAMS);
149 * Returns topic parameters for test cases.
151 * @return topic parameters
153 public static TopicParameters getTopicParams() {
154 final TopicParameters topicParams = new TopicParameters();
155 topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
156 topicParams.setTopicCommInfrastructure("dmaap");
157 topicParams.setServers(List.of("localhost"));
162 * Returns participantType for test cases.
164 * @return participant Type
166 public static ToscaConceptIdentifier getParticipantType() {
167 return new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
172 * Returns participantId for test cases.
174 * @return participant Id
176 public static ToscaConceptIdentifier getParticipantId() {
177 return new ToscaConceptIdentifier("org.onap.PM_Policy", "1.0.0");