Initial TCA commit into DCAEGEN2
[dcaegen2/analytics/tca.git] / dcae-analytics-dmaap / src / test / java / org / openecomp / dcae / apod / analytics / dmaap / domain / config / DMaaPMRSubscriberConfigTest.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
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
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
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===========================================
19  */
20
21 package org.openecomp.dcae.apod.analytics.dmaap.domain.config;
22
23 import org.junit.Test;
24 import org.openecomp.dcae.apod.analytics.common.AnalyticsConstants;
25 import org.openecomp.dcae.apod.analytics.dmaap.BaseAnalyticsDMaaPUnitTest;
26
27 import static org.junit.Assert.assertTrue;
28
29 /**
30  * @author Rajiv Singla . Creation Date: 10/14/2016.
31  */
32 public class DMaaPMRSubscriberConfigTest extends BaseAnalyticsDMaaPUnitTest {
33
34     @Test
35     public void testSubscriberConfigDefaults() throws Exception {
36
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();
41
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)
51                         .build();
52
53         assertTrue("Default Subscriber Config parameters must match",
54                 actualDefaultSubscriberConfig.equals(expectedSubscriberConfig));
55
56     }
57
58
59     @Test
60     public void testSubscriberCustomConfig() throws Exception {
61
62         DMaaPMRSubscriberConfig actualSubscriberCustomConfig = getSubscriberConfig(SUBSCRIBER_CONSUMER_ID,
63                 SUBSCRIBER_CONSUMER_GROUP_NAME);
64
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)
76                         .build();
77
78         assertTrue("Custom Subscriber Config parameters must match",
79                 actualSubscriberCustomConfig.equals(expectedSubscriberCustomConfig));
80
81     }
82
83
84 }