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