2 * ============LICENSE_START=======================================================
3 * Copyright (C) 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.sim.comm;
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.sim.parameters.ParticipantSimParameters;
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 {
35 public static final Coder CODER = new StandardCoder();
36 public static final String DESCRIPTION = "Participant description";
37 public static final long TIME_INTERVAL = 2000;
38 public static final List<TopicParameters> TOPIC_PARAMS = List.of(getTopicParams());
41 * Get ParticipantSimParameters.
43 * @return ParticipantSimParameters
45 public static ParticipantSimParameters getParticipantSimParameters() {
47 return CODER.convert(getParticipantSimParametersMap(), ParticipantSimParameters.class);
48 } catch (final CoderException e) {
49 throw new RuntimeException("cannot create ParticipantSimParameters from map", e);
54 * Returns a property map for a ParticipantSimParameters map for test cases.
56 * @return a property map suitable for constructing an object
58 private static Map<String, Object> getParticipantSimParametersMap() {
59 final Map<String, Object> map = new TreeMap<>();
61 map.put("intermediaryParameters", getIntermediaryParametersMap());
66 * Returns a property map for a intermediaryParameters map for test cases.
68 * @return a property map suitable for constructing an object
70 private static Map<String, Object> getIntermediaryParametersMap() {
71 final Map<String, Object> map = new TreeMap<>();
72 map.put("name", "Participant parameters");
73 map.put("reportingTimeIntervalMs", TIME_INTERVAL);
74 map.put("description", DESCRIPTION);
75 map.put("participantId", getParticipantId());
76 map.put("clampAutomationCompositionTopics", getTopicParametersMap());
77 map.put("participantSupportedElementTypes", new ArrayList<>());
83 * Returns a property map for a TopicParameters map for test cases.
85 * @return a property map suitable for constructing an object
87 private static Map<String, Object> getTopicParametersMap() {
88 final Map<String, Object> map = new TreeMap<>();
89 map.put("topicSources", TOPIC_PARAMS);
90 map.put("topicSinks", TOPIC_PARAMS);
95 * Returns topic parameters for test cases.
97 * @return topic parameters
99 private static TopicParameters getTopicParams() {
100 final TopicParameters topicParams = new TopicParameters();
101 topicParams.setTopic("POLICY-ACRUNTIME-PARTICIPANT");
102 topicParams.setTopicCommInfrastructure("dmaap");
103 topicParams.setServers(List.of("localhost"));
108 * Returns participantId for test cases.
110 * @return participant Id
112 public static UUID getParticipantId() {
113 return UUID.fromString("101c62b3-8918-41b9-a747-d21eb79c6c01");