0bbd16506cef4c20156495ad77a9f96851e11963
[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         String endpointUrl = "http://dmaap-mr:8080/events/topic";
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                 .trustStorePath(trustStorePath)
61                 .trustStorePasswordPath(trustStorePasswordPath)
62                 .keyStorePath(keyStorePath)
63                 .keyStorePasswordPath(keyStorePasswordPath)
64                 .enableDmaapCertAuth(enableDmaapCertAuth)
65                 .endpointUrl(endpointUrl)
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, trustStorePath=trustStorePath, "
72                 + "trustStorePasswordPath=trustStorePasswordPath, keyStorePath=keyStorePath, "
73                 + "keyStorePasswordPath=keyStorePasswordPath, enableDmaapCertAuth=true, "
74                 + "endpointUrl=http://dmaap-mr:8080/events/topic}", configuration.toString());
75     }
76 }