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.policy.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 PARTICIPANT_GROUP_NAME = "AutomationCompositionParticipantGroup";
37 public static final String DESCRIPTION = "Participant description";
38 public static final long TIME_INTERVAL = 2000;
39 public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
41 public static final Coder CODER = new StandardCoder();
44 * Get ParticipantPolicyParameters.
46 * @return ParticipantPolicyParameters
48 public ParticipantPolicyParameters getParticipantPolicyParameters() {
50 return CODER.convert(getParticipantPolicyParametersMap(PARTICIPANT_GROUP_NAME),
51 ParticipantPolicyParameters.class);
52 } catch (final CoderException e) {
53 throw new RuntimeException("cannot create ParticipantPolicyParameters from map", e);
58 * Returns a property map for a ParticipantPolicyParameters map for test cases.
60 * @param name name of the parameters
62 * @return a property map suitable for constructing an object
64 public Map<String, Object> getParticipantPolicyParametersMap(final String name) {
65 final Map<String, Object> map = new TreeMap<>();
67 map.put("name", name);
68 map.put("intermediaryParameters", getIntermediaryParametersMap(false));
69 map.put("policyApiParameters", getPolicyApiParametersMap());
70 map.put("policyPapParameters", getPolicyPapParametersMap());
71 map.put("pdpGroup", "defaultGroup");
72 map.put("pdpType", "apex");
77 * Returns a property map for a policyPapParameters map for test cases.
79 * @return a property map suitable for constructing an object
81 public Map<String, Object> getPolicyPapParametersMap() {
82 final Map<String, Object> map = new TreeMap<>();
83 map.put("clientName", "pap");
84 map.put("hostname", "localhost");
85 map.put("port", 6968);
86 map.put("userName", "policyadmin");
87 map.put("password", "zb!XztG34");
88 map.put("https", false);
89 map.put("allowSelfSignedCerts", true);
94 * Returns a property map for a policyApiParameters map for test cases.
96 * @return a property map suitable for constructing an object
98 public Map<String, Object> getPolicyApiParametersMap() {
99 final Map<String, Object> map = new TreeMap<>();
100 map.put("clientName", "api");
101 map.put("hostname", "localhost");
102 map.put("port", 6969);
103 map.put("userName", "policyadmin");
104 map.put("password", "zb!XztG34");
105 map.put("https", false);
106 map.put("allowSelfSignedCerts", true);
112 * Returns a property map for a intermediaryParameters map for test cases.
114 * @param isEmpty boolean value to represent that object created should be empty or not
115 * @return a property map suitable for constructing an object
117 public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
118 final Map<String, Object> map = new TreeMap<>();
120 map.put("name", "Participant parameters");
121 map.put("reportingTimeIntervalMs", TIME_INTERVAL);
122 map.put("description", DESCRIPTION);
123 map.put("participantId", getParticipantId());
124 map.put("participantType", getParticipantId());
125 map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
132 * Returns a property map for a TopicParameters map for test cases.
134 * @param isEmpty boolean value to represent that object created should be empty or not
135 * @return a property map suitable for constructing an object
137 public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
138 final Map<String, Object> map = new TreeMap<>();
140 map.put("topicSources", TOPIC_PARAMS);
141 map.put("topicSinks", TOPIC_PARAMS);
147 * Returns topic parameters for test cases.
149 * @return topic parameters
151 public static TopicParameters getTopicParams() {
152 final TopicParameters topicParams = new TopicParameters();
153 topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
154 topicParams.setTopicCommInfrastructure("dmaap");
155 topicParams.setServers(List.of("localhost"));
160 * Returns participantId for test cases.
162 * @return participant Id
164 public static ToscaConceptIdentifier getParticipantId() {
165 return new ToscaConceptIdentifier("org.onap.PM_Policy", "0.0.0");