d7f06d1bc48c51454beac01ed7601194d61e05cc
[dcaegen2/services/sdk.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * DCAEGEN2-SERVICES-SDK
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.sdk.rest.services.dmaap.client.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.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
27 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.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 trustStorePath = "trustStorePath";
45         String trustStorePasswordPath = "trustStorePasswordPath";
46         String keyStorePath = "keyStorePath";
47         String keyStorePasswordPath = "keyStorePasswordPath";
48         Boolean enableDmaapCertAuth = true;
49
50         // When
51         configuration = new ImmutableDmaapPublisherConfiguration.Builder()
52                 .dmaapHostName(dmaapHostName)
53                 .dmaapPortNumber(dmaapPortNumber)
54                 .dmaapTopicName(dmaapTopicName)
55                 .dmaapProtocol(dmaapProtocol)
56                 .dmaapUserName(dmaapUserName)
57                 .dmaapUserPassword(dmaapUserPassword)
58                 .dmaapContentType(dmaapContentType)
59                 .trustStorePath(trustStorePath)
60                 .trustStorePasswordPath(trustStorePasswordPath)
61                 .keyStorePath(keyStorePath)
62                 .keyStorePasswordPath(keyStorePasswordPath)
63                 .enableDmaapCertAuth(enableDmaapCertAuth)
64                 .build();
65
66         // Then
67         assertEquals("DmaapPublisherConfiguration{dmaapHostName=localhost, dmaapPortNumber=2222, "
68                 + "dmaapTopicName=temp, dmaapProtocol=http, dmaapUserName=admin, dmaapUserPassword=admin, "
69                 + "dmaapContentType=application/json, trustStorePath=trustStorePath, "
70                 + "trustStorePasswordPath=trustStorePasswordPath, keyStorePath=keyStorePath, "
71                 + "keyStorePasswordPath=keyStorePasswordPath, enableDmaapCertAuth=true}", configuration.toString());
72     }
73 }