d6471381874401caf12b6bc5d69fb4fe67181573
[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.prh.service.config;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24
25 import org.junit.jupiter.api.Test;
26 import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
27 import org.onap.dcaegen2.services.prh.config.ImmutableDmaapPublisherConfiguration;
28
29 class DmaapPublisherConfigurationTest {
30
31
32     @Test
33     void builder_shouldBuildConfigurationObject() {
34
35         // Given
36         DmaapPublisherConfiguration configuration;
37         String dmaapHostName = "localhost";
38         Integer dmaapPortNumber = 2222;
39         String dmaapTopicName = "temp";
40         String dmaapProtocol = "http";
41         String dmaapUserName = "admin";
42         String dmaapUserPassword = "admin";
43         String dmaapContentType = "application/json";
44         String keyFile = "keyFile";
45         String trustStore = "trustStore";
46         String trustStorePass = "trustPass";
47         String keyStore = "keyStore";
48         String keyStorePass = "keyPass";
49         Boolean enableDmaapCertAuth = true;
50
51         // When
52         configuration = new ImmutableDmaapPublisherConfiguration.Builder()
53                 .dmaapHostName(dmaapHostName)
54                 .dmaapPortNumber(dmaapPortNumber)
55                 .dmaapTopicName(dmaapTopicName)
56                 .dmaapProtocol(dmaapProtocol)
57                 .dmaapUserName(dmaapUserName)
58                 .dmaapUserPassword(dmaapUserPassword)
59                 .dmaapContentType(dmaapContentType)
60                 .keyFile(keyFile)
61                 .trustStore(trustStore)
62                 .trustStorePassword(trustStorePass)
63                 .keyStore(keyStore)
64                 .keyStorePassword(keyStorePass)
65                 .enableDmaapCertAuth(enableDmaapCertAuth)
66                 .build();
67
68         // Then
69         assertEquals("DmaapPublisherConfiguration{dmaapHostName=localhost, dmaapPortNumber=2222, "
70                 + "dmaapTopicName=temp, dmaapProtocol=http, dmaapUserName=admin, dmaapUserPassword=admin, "
71                 + "dmaapContentType=application/json, keyFile=keyFile, trustStore=trustStore, "
72                 + "trustStorePassword=trustPass, keyStore=keyStore, keyStorePassword=keyPass, "
73                 + "enableDmaapCertAuth=true}", configuration.toString());
74     }
75 }