2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2023 Nordix Foundation.
4 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.clamp.acm.participant.kubernetes.parameters;
24 import java.util.ArrayList;
25 import java.util.List;
27 import java.util.TreeMap;
28 import java.util.UUID;
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;
34 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());
40 public static final Coder CODER = new StandardCoder();
41 private static final UUID AC_ID = UUID.randomUUID();
44 * Get ParticipantK8sParameters.
46 * @return ParticipantK8sParameters
48 public ParticipantK8sParameters getParticipantK8sParameters() {
50 return CODER.convert(getParticipantK8sParametersMap(PARTICIPANT_GROUP_NAME),
51 ParticipantK8sParameters.class);
52 } catch (final CoderException e) {
53 throw new RuntimeException("cannot create ParticipantK8sParameters from map", e);
58 * Returns a property map for a ParticipantK8sParameters 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> getParticipantK8sParametersMap(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("localChartDirectory", getLocalChartDir());
70 map.put("infoFileName", getInfoFileName());
76 * Returns string value of local chart Directory.
77 * @return a string value
79 public String getLocalChartDir() {
80 return "/var/helm-manager/local-charts";
84 * Returns string value of Info file name.
85 * @return string value
87 public String getInfoFileName() {
88 return "CHART-INFO.json";
94 * Returns a property map for a intermediaryParameters map for test cases.
96 * @param isEmpty boolean value to represent that object created should be empty or not
97 * @return a property map suitable for constructing an object
99 public Map<String, Object> getIntermediaryParametersMap(final boolean isEmpty) {
100 final Map<String, Object> map = new TreeMap<>();
102 map.put("name", "Participant parameters");
103 map.put("reportingTimeIntervalMs", TIME_INTERVAL);
104 map.put("description", DESCRIPTION);
105 map.put("participantId", getParticipantId());
106 map.put("clampAutomationCompositionTopics", getTopicParametersMap(false));
107 map.put("participantSupportedElementTypes", new ArrayList<>());
114 * Returns participantId for test cases.
116 * @return participant Id
118 public static UUID getParticipantId() {
119 return UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c02");
123 * Returns a property map for a TopicParameters map for test cases.
125 * @param isEmpty boolean value to represent that object created should be empty or not
126 * @return a property map suitable for constructing an object
128 public Map<String, Object> getTopicParametersMap(final boolean isEmpty) {
129 final Map<String, Object> map = new TreeMap<>();
131 map.put("topicSources", TOPIC_PARAMS);
132 map.put("topicSinks", TOPIC_PARAMS);
138 * Returns topic parameters for test cases.
140 * @return topic parameters
142 public static TopicParameters getTopicParams() {
143 final TopicParameters topicParams = new TopicParameters();
144 topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
145 topicParams.setTopicCommInfrastructure("dmaap");
146 topicParams.setServers(List.of("localhost"));
151 * Get automation composition id.
152 * @return UUID automationCompositionId
154 public UUID getAutomationCompositionId() {