2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2024 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.common.endpoints.event.comm.bus;
24 import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_AFT_ENV;
25 import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_API_KEY;
26 import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_API_SECRET;
27 import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_CONS_GROUP;
28 import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_CONS_INST;
29 import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_EFFECTIVE_TOPIC;
30 import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_FETCH_LIMIT;
31 import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_FETCH_TIMEOUT;
32 import static org.onap.policy.common.endpoints.event.comm.bus.TopicTestBase.MY_PARTITION;
33 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX;
34 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX;
35 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_MANAGED_SUFFIX;
36 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_API_KEY_SUFFIX;
37 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_API_SECRET_SUFFIX;
38 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX;
39 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX;
40 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX;
41 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX;
42 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX;
43 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX;
44 import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX;
46 import java.util.List;
48 import org.onap.policy.common.endpoints.parameters.TopicParameters;
51 public class UebTopicPropertyBuilder extends TopicPropertyBuilder {
53 public static final String SERVER = "my-server";
54 public static final String TOPIC2 = "my-topic-2";
56 private final TopicParameters params = new TopicParameters();
59 * Constructs the object.
61 * @param prefix the prefix for the properties to be built
63 public UebTopicPropertyBuilder(String prefix) {
68 * Adds a topic and configures its properties with default values.
70 * @param topic the topic to be added
71 * @return this builder
73 public UebTopicPropertyBuilder makeTopic(String topic) {
76 setTopicProperty(PROPERTY_TOPIC_EFFECTIVE_TOPIC_SUFFIX, MY_EFFECTIVE_TOPIC);
77 setTopicProperty(PROPERTY_TOPIC_SOURCE_CONSUMER_GROUP_SUFFIX, MY_CONS_GROUP);
78 setTopicProperty(PROPERTY_TOPIC_SOURCE_CONSUMER_INSTANCE_SUFFIX, MY_CONS_INST);
79 setTopicProperty(PROPERTY_MANAGED_SUFFIX, "true");
80 setTopicProperty(PROPERTY_HTTP_HTTPS_SUFFIX, "true");
81 setTopicProperty(PROPERTY_ALLOW_SELF_SIGNED_CERTIFICATES_SUFFIX, "true");
82 setTopicProperty(PROPERTY_TOPIC_API_KEY_SUFFIX, MY_API_KEY);
83 setTopicProperty(PROPERTY_TOPIC_API_SECRET_SUFFIX, MY_API_SECRET);
84 setTopicProperty(PROPERTY_TOPIC_SOURCE_FETCH_LIMIT_SUFFIX, MY_FETCH_LIMIT);
85 setTopicProperty(PROPERTY_TOPIC_SOURCE_FETCH_TIMEOUT_SUFFIX, MY_FETCH_TIMEOUT);
86 setTopicProperty(PROPERTY_TOPIC_SINK_PARTITION_KEY_SUFFIX, MY_PARTITION);
87 setTopicProperty(PROPERTY_TOPIC_SERVERS_SUFFIX, SERVER);
89 params.setTopicCommInfrastructure("ueb");
90 params.setTopic(topic);
91 params.setEffectiveTopic(MY_EFFECTIVE_TOPIC);
92 params.setConsumerGroup(MY_CONS_GROUP);
93 params.setConsumerInstance(MY_CONS_INST);
94 params.setManaged(true);
95 params.setUseHttps(true);
96 params.setAftEnvironment(MY_AFT_ENV);
97 params.setAllowSelfSignedCerts(true);
98 params.setApiKey(MY_API_KEY);
99 params.setApiSecret(MY_API_SECRET);
100 params.setFetchLimit(MY_FETCH_LIMIT);
101 params.setFetchTimeout(MY_FETCH_TIMEOUT);
102 params.setPartitionId(MY_PARTITION);
103 params.setServers(List.of(SERVER));