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 java.util.UUID;
28 import org.onap.policy.common.endpoints.parameters.TopicParameters;
29 import org.onap.policy.common.utils.coder.Coder;
30 import org.onap.policy.common.utils.coder.CoderException;
31 import org.onap.policy.common.utils.coder.StandardCoder;
32 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
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> TOPIC_PARAMS = List.of(getTopicParams());
43 public static final Coder CODER = new StandardCoder();
46 * Get ParticipantPolicyParameters.
48 * @return ParticipantPolicyParameters
50 public ParticipantPolicyParameters getParticipantPolicyParameters() {
52 return CODER.convert(getParticipantPolicyParametersMap(PARTICIPANT_GROUP_NAME),
53 ParticipantPolicyParameters.class);
54 } catch (final CoderException e) {
55 throw new RuntimeException("cannot create ParticipantPolicyParameters from map", e);
60 * Returns a property map for a ParticipantPolicyParameters map for test cases.
62 * @param name name of the parameters
64 * @return a property map suitable for constructing an object
66 public Map<String, Object> getParticipantPolicyParametersMap(final String name) {
67 final Map<String, Object> map = new TreeMap<>();
69 map.put("name", name);
70 map.put("intermediaryParameters", getIntermediaryParametersMap(false));
71 map.put("policyApiParameters", getPolicyApiParametersMap());
72 map.put("policyPapParameters", getPolicyPapParametersMap());
73 map.put("pdpGroup", "defaultGroup");
74 map.put("pdpType", "apex");
79 * Returns a property map for a policyPapParameters map for test cases.
81 * @return a property map suitable for constructing an object
83 public Map<String, Object> getPolicyPapParametersMap() {
84 final Map<String, Object> map = new TreeMap<>();
85 map.put("clientName", "pap");
86 map.put("hostname", "localhost");
87 map.put("port", 6968);
88 map.put("userName", "policyadmin");
89 map.put("password", "zb!XztG34");
90 map.put("https", false);
91 map.put("allowSelfSignedCerts", true);
96 * Returns a property map for a policyApiParameters map for test cases.
98 * @return a property map suitable for constructing an object
100 public Map<String, Object> getPolicyApiParametersMap() {
101 final Map<String, Object> map = new TreeMap<>();
102 map.put("clientName", "api");
103 map.put("hostname", "localhost");
104 map.put("port", 6969);
105 map.put("userName", "policyadmin");
106 map.put("password", "zb!XztG34");
107 map.put("https", false);
108 map.put("allowSelfSignedCerts", true);
114 * Returns a property map for a intermediaryParameters map for test cases.
116 * @param isEmpty boolean value to represent that object created should be empty or not
117 * @return a property map suitable for constructing an object
119 public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
120 final Map<String, Object> map = new TreeMap<>();
122 map.put("name", "Participant parameters");
123 map.put("reportingTimeIntervalMs", TIME_INTERVAL);
124 map.put("description", DESCRIPTION);
125 map.put("participantId", getParticipantId());
126 map.put("participantType", getParticipantType());
127 map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
128 map.put("participantSupportedElementTypes", new ArrayList<>());
135 * Returns a property map for a TopicParameters map for test cases.
137 * @param isEmpty boolean value to represent that object created should be empty or not
138 * @return a property map suitable for constructing an object
140 public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
141 final Map<String, Object> map = new TreeMap<>();
143 map.put("topicSources", TOPIC_PARAMS);
144 map.put("topicSinks", TOPIC_PARAMS);
150 * Returns topic parameters for test cases.
152 * @return topic parameters
154 public static TopicParameters getTopicParams() {
155 final TopicParameters topicParams = new TopicParameters();
156 topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
157 topicParams.setTopicCommInfrastructure("dmaap");
158 topicParams.setServers(List.of("localhost"));
163 * Returns participantType for test cases.
165 * @return participant Type
167 public static ToscaConceptIdentifier getParticipantType() {
168 return new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");
173 * Returns participantId for test cases.
175 * @return participant Id
177 public static UUID getParticipantId() {
178 return UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c03");