d5563a17dce7e548982efee8711a79db8013ea5f
[dcaegen2/analytics/tca.git] / dcae-analytics-dmaap / src / test / java / org / openecomp / dcae / apod / analytics / dmaap / domain / config / DMaaPMRPublisherConfigTest.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 DMaaPMRPublisherConfigTest extends BaseAnalyticsDMaaPUnitTest {
33
34
35     @Test
36     public void testPublisherConfigDefaults() throws Exception {
37
38         final DMaaPMRPublisherConfig actualDefaultPublisherConfig =
39                 new DMaaPMRPublisherConfig.Builder(HOST_NAME, TOPIC_NAME).build();
40
41         final DMaaPMRPublisherConfig expectedDefaultPublisherConfig =
42                 new DMaaPMRPublisherConfig.Builder(HOST_NAME, TOPIC_NAME)
43                         .setPortNumber(AnalyticsConstants.DEFAULT_PORT_NUMBER)
44                         .setContentType(AnalyticsConstants.DEFAULT_CONTENT_TYPE)
45                         .setProtocol(AnalyticsConstants.DEFAULT_PROTOCOL)
46                         .setMaxBatchSize(AnalyticsConstants.DEFAULT_PUBLISHER_MAX_BATCH_SIZE)
47                         .setMaxRecoveryQueueSize(AnalyticsConstants.DEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE)
48                         .build();
49
50         assertTrue("Default Publisher Config parameters must match",
51                 actualDefaultPublisherConfig.equals(expectedDefaultPublisherConfig));
52
53     }
54
55
56     @Test
57     public void testPublisherCustomConfig() throws Exception {
58
59
60         final DMaaPMRPublisherConfig actualCustomPublisherConfig = getPublisherConfig();
61
62         final DMaaPMRPublisherConfig expectedCustomPublisherConfig =
63                 new DMaaPMRPublisherConfig.Builder(HOST_NAME, TOPIC_NAME)
64                         .setPortNumber(PORT_NUMBER)
65                         .setUserName(USERNAME)
66                         .setUserPassword(PASSWORD)
67                         .setContentType(CONTENT_TYPE)
68                         .setProtocol(HTTP_PROTOCOL)
69                         .setMaxBatchSize(PUBLISHER_MAX_BATCH_QUEUE_SIZE)
70                         .setMaxRecoveryQueueSize(PUBLISHER_MAX_RECOVERY_QUEUE_SIZE)
71                         .build();
72
73         assertTrue("Custom Publisher Config parameters must match",
74                 actualCustomPublisherConfig.equals(expectedCustomPublisherConfig));
75     }
76
77
78 }