2 * ===============================LICENSE_START======================================
4 * ================================================================================
5 * Copyright © 2017 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.openecomp.dcae.apod.analytics.dmaap.domain.config;
23 import org.junit.Test;
24 import org.openecomp.dcae.apod.analytics.common.AnalyticsConstants;
25 import org.openecomp.dcae.apod.analytics.dmaap.BaseAnalyticsDMaaPUnitTest;
27 import static org.junit.Assert.assertTrue;
30 * @author Rajiv Singla . Creation Date: 10/14/2016.
32 public class DMaaPMRSubscriberConfigTest extends BaseAnalyticsDMaaPUnitTest {
35 public void testSubscriberConfigDefaults() throws Exception {
37 DMaaPMRSubscriberConfig actualDefaultSubscriberConfig =
38 new DMaaPMRSubscriberConfig.Builder(HOST_NAME, TOPIC_NAME)
39 .setConsumerGroup(AnalyticsConstants.DEFAULT_SUBSCRIBER_GROUP_PREFIX + SUBSCRIBER_CONSUMER_ID)
40 .setConsumerId(SUBSCRIBER_CONSUMER_ID).build();
42 DMaaPMRSubscriberConfig expectedSubscriberConfig =
43 new DMaaPMRSubscriberConfig.Builder(HOST_NAME, TOPIC_NAME)
44 .setPortNumber(AnalyticsConstants.DEFAULT_PORT_NUMBER)
45 .setContentType(AnalyticsConstants.DEFAULT_CONTENT_TYPE)
46 .setProtocol(AnalyticsConstants.DEFAULT_PROTOCOL)
47 .setConsumerGroup(AnalyticsConstants.DEFAULT_SUBSCRIBER_GROUP_PREFIX + SUBSCRIBER_CONSUMER_ID)
48 .setConsumerId(SUBSCRIBER_CONSUMER_ID)
49 .setMessageLimit(AnalyticsConstants.DEFAULT_SUBSCRIBER_MESSAGE_LIMIT)
50 .setTimeoutMS(AnalyticsConstants.DEFAULT_SUBSCRIBER_TIMEOUT_MS)
53 assertTrue("Default Subscriber Config parameters must match",
54 actualDefaultSubscriberConfig.equals(expectedSubscriberConfig));
60 public void testSubscriberCustomConfig() throws Exception {
62 DMaaPMRSubscriberConfig actualSubscriberCustomConfig = getSubscriberConfig(SUBSCRIBER_CONSUMER_ID,
63 SUBSCRIBER_CONSUMER_GROUP_NAME);
65 DMaaPMRSubscriberConfig expectedSubscriberCustomConfig =
66 new DMaaPMRSubscriberConfig.Builder(HOST_NAME, TOPIC_NAME)
67 .setPortNumber(PORT_NUMBER)
68 .setUserName(USERNAME)
69 .setUserPassword(PASSWORD)
70 .setContentType(CONTENT_TYPE)
71 .setProtocol(HTTP_PROTOCOL)
72 .setConsumerGroup(SUBSCRIBER_CONSUMER_GROUP_NAME)
73 .setConsumerId(SUBSCRIBER_CONSUMER_ID)
74 .setMessageLimit(SUBSCRIBER_MESSAGE_LIMIT)
75 .setTimeoutMS(SUBSCRIBER_TIMEOUT_MS)
78 assertTrue("Custom Subscriber Config parameters must match",
79 actualSubscriberCustomConfig.equals(expectedSubscriberCustomConfig));