2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.common.endpoints.event.comm.bus;
23 import java.util.Arrays;
24 import java.util.List;
26 import java.util.TreeMap;
27 import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
28 import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams.TopicParamsBuilder;
31 * Base class for BusTopicXxxTest classes.
33 public class BusTopicTestBase {
35 public static final String MY_AFT_ENV = "my-aft-env";
36 public static final String MY_API_KEY = "my-api-key";
37 public static final String MY_API_SECRET = "my-api-secret";
38 public static final String MY_BASE_PATH = "my-base";
39 public static final String MY_CLIENT_NAME = "my-client";
40 public static final String MY_CONS_GROUP = "my-cons-group";
41 public static final String MY_CONS_INST = "my-cons-inst";
42 public static final String MY_ENV = "my-env";
43 public static final int MY_FETCH_LIMIT = 100;
44 public static final int MY_FETCH_TIMEOUT = 101;
45 public static final String MY_HOST = "my-host";
46 public static final String MY_LAT = "my-lat";
47 public static final String MY_LONG = "my-long";
48 public static final String MY_PARTNER = "my-partner";
49 public static final String MY_PASSWD = "my-pass";
50 public static final int MY_PORT = 102;
51 public static final String MY_TOPIC = "my-topic";
52 public static final String MY_USERNAME = "my-user";
54 public static final String MY_MESSAGE = "my-message";
55 public static final String MY_PARTITION = "my-partition";
56 public static final String MY_MESSAGE2 = "my-message-2";
57 public static final String MY_PARTITION2 = "my-partition-2";
59 public static final String ROUTE_PROP = "routeOffer";
60 public static final String MY_ROUTE = "my-route";
63 * Message used within exceptions that are expected.
65 public static final String EXPECTED = "expected exception";
68 * Additional properties to be added to the parameter builder.
70 protected Map<String, String> addProps;
73 * Servers to be added to the parameter builder.
75 protected List<String> servers;
78 * Parameter builder used to build topic parameters.
80 protected TopicParamsBuilder builder;
83 * Initializes {@link #addProps}, {@link #servers}, and {@link #builder}.
86 addProps = new TreeMap<>();
87 addProps.put("my-key-A", "my-value-A");
88 addProps.put("my-key-B", "my-value-B");
90 servers = Arrays.asList("svra", "svrb");
92 builder = makeBuilder();
96 * Makes a fully populated parameter builder.
98 * @return a new parameter builder
100 public TopicParamsBuilder makeBuilder() {
101 return makeBuilder(addProps, servers);
105 * Makes a fully populated parameter builder.
107 * @param addProps additional properties to be added to the builder
108 * @param servers servers to be added to the builder
109 * @return a new parameter builder
111 public TopicParamsBuilder makeBuilder(Map<String, String> addProps, List<String> servers) {
113 return BusTopicParams.builder().additionalProps(addProps).aftEnvironment(MY_AFT_ENV).allowSelfSignedCerts(true)
114 .apiKey(MY_API_KEY).apiSecret(MY_API_SECRET).basePath(MY_BASE_PATH).clientName(MY_CLIENT_NAME)
115 .consumerGroup(MY_CONS_GROUP).consumerInstance(MY_CONS_INST).environment(MY_ENV)
116 .fetchLimit(MY_FETCH_LIMIT).fetchTimeout(MY_FETCH_TIMEOUT).hostname(MY_HOST).latitude(MY_LAT)
117 .longitude(MY_LONG).managed(true).partitionId(MY_PARTITION).partner(MY_PARTNER)
118 .password(MY_PASSWD).port(MY_PORT).servers(servers).topic(MY_TOPIC).useHttps(true)
119 .userName(MY_USERNAME);