b67946b273e017d5f885253a06827d05b1bd6b55
[dcaegen2/collectors/datafile.git] /
1 /*
2  * ============LICENSE_START======================================================================
3  * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. All rights reserved.
4  * ===============================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * ============LICENSE_END========================================================================
17  */
18
19 package org.onap.dcaegen2.collectors.datafile.service.config;
20
21 import org.junit.jupiter.api.Assertions;
22 import org.junit.jupiter.api.Test;
23 import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
24 import org.onap.dcaegen2.collectors.datafile.config.ImmutableDmaapConsumerConfiguration;
25
26 public class DmaapConsumerConfigurationTest {
27
28     @Test
29     public void builder_shouldBuildConfigurationObject() {
30
31         // Given
32         DmaapConsumerConfiguration configuration;
33         String consumerId = "1";
34         String dmaapHostName = "localhost";
35         Integer dmaapPortNumber = 2222;
36         String dmaapTopicName = "temp";
37         String dmaapProtocol = "http";
38         String dmaapUserName = "admin";
39         String dmaapUserPassword = "admin";
40         String dmaapContentType = "application/json";
41         String consumerGroup = "other";
42         Integer timeoutMs = 1000;
43         Integer messageLimit = 1000;
44
45         // When
46         configuration = new ImmutableDmaapConsumerConfiguration.Builder().consumerId(consumerId)
47                 .dmaapHostName(dmaapHostName).dmaapPortNumber(dmaapPortNumber).dmaapTopicName(dmaapTopicName)
48                 .dmaapProtocol(dmaapProtocol).dmaapUserName(dmaapUserName).dmaapUserPassword(dmaapUserPassword)
49                 .dmaapContentType(dmaapContentType).consumerGroup(consumerGroup).timeoutMS(timeoutMs)
50                 .messageLimit(messageLimit).build();
51
52         // Then
53         Assertions.assertNotNull(configuration);
54         Assertions.assertEquals(consumerId, configuration.consumerId());
55         Assertions.assertEquals(dmaapHostName, configuration.dmaapHostName());
56         Assertions.assertEquals(dmaapPortNumber, configuration.dmaapPortNumber());
57         Assertions.assertEquals(dmaapTopicName, configuration.dmaapTopicName());
58         Assertions.assertEquals(dmaapProtocol, configuration.dmaapProtocol());
59         Assertions.assertEquals(dmaapUserName, configuration.dmaapUserName());
60         Assertions.assertEquals(dmaapUserPassword, configuration.dmaapUserPassword());
61         Assertions.assertEquals(consumerGroup, configuration.consumerGroup());
62         Assertions.assertEquals(timeoutMs, configuration.timeoutMS());
63         Assertions.assertEquals(messageLimit, configuration.messageLimit());
64     }
65 }