d09437090765ea82ec235eaf11116543d82fa87d
[dcaegen2/collectors/datafile.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * Datafile Collector Service
4  * ================================================================================
5  * Copyright (C) 2018 NOKIA 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.onap.dcaegen2.collectors.datafile.service.config;
22
23 import org.junit.jupiter.api.Assertions;
24 import org.junit.jupiter.api.Test;
25 import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
26 import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapConsumerConfiguration;
27
28 class DmaapConsumerConfigurationTest {
29
30     @Test
31     void builder_shouldBuildConfigurationObject() {
32
33         // Given
34         DmaapConsumerConfiguration configuration;
35         String consumerId = "1";
36         String dmaapHostName = "localhost";
37         Integer dmaapPortNumber = 2222;
38         String dmaapTopicName = "temp";
39         String dmaapProtocol = "http";
40         String dmaapUserName = "admin";
41         String dmaapUserPassword = "admin";
42         String dmaapContentType = "application/json";
43         String consumerGroup = "other";
44         Integer timeoutMs = 1000;
45         Integer messageLimit = 1000;
46
47         // When
48         configuration = new ImmutableDmaapConsumerConfiguration.Builder()
49             .consumerId(consumerId)
50             .dmaapHostName(dmaapHostName)
51             .dmaapPortNumber(dmaapPortNumber)
52             .dmaapTopicName(dmaapTopicName)
53             .dmaapProtocol(dmaapProtocol)
54             .dmaapUserName(dmaapUserName)
55             .dmaapUserPassword(dmaapUserPassword)
56             .dmaapContentType(dmaapContentType)
57             .consumerGroup(consumerGroup)
58             .timeoutMs(timeoutMs)
59             .messageLimit(messageLimit)
60             .build();
61
62         // Then
63         Assertions.assertNotNull(configuration);
64         Assertions.assertEquals(consumerId, configuration.consumerId());
65         Assertions.assertEquals(dmaapHostName, configuration.dmaapHostName());
66         Assertions.assertEquals(dmaapPortNumber, configuration.dmaapPortNumber());
67         Assertions.assertEquals(dmaapTopicName, configuration.dmaapTopicName());
68         Assertions.assertEquals(dmaapProtocol, configuration.dmaapProtocol());
69         Assertions.assertEquals(dmaapUserName, configuration.dmaapUserName());
70         Assertions.assertEquals(dmaapUserPassword, configuration.dmaapUserPassword());
71         Assertions.assertEquals(consumerGroup, configuration.consumerGroup());
72         Assertions.assertEquals(timeoutMs, configuration.timeoutMs());
73         Assertions.assertEquals(messageLimit, configuration.messageLimit());
74     }
75 }