Sonar Critical Fix
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-tca / src / test / java / org / openecomp / dcae / apod / analytics / cdap / tca / utils / AppPreferencesToPublisherConfigMapperTest.java
1 /*\r
2  * ===============================LICENSE_START======================================\r
3  *  dcae-analytics\r
4  * ================================================================================\r
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  *  Licensed under the Apache License, Version 2.0 (the "License");\r
8  *  you may not use this file except in compliance with the License.\r
9  *   You may obtain a copy of the License at\r
10  *\r
11  *          http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  *  Unless required by applicable law or agreed to in writing, software\r
14  *  distributed under the License is distributed on an "AS IS" BASIS,\r
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  *  See the License for the specific language governing permissions and\r
17  *  limitations under the License.\r
18  *  ============================LICENSE_END===========================================\r
19  */\r
20 \r
21 package org.openecomp.dcae.apod.analytics.cdap.tca.utils;\r
22 \r
23 import org.junit.Test;\r
24 import org.openecomp.dcae.apod.analytics.cdap.tca.BaseAnalyticsCDAPTCAUnitTest;\r
25 import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCATestAppPreferences;\r
26 import org.openecomp.dcae.apod.analytics.dmaap.domain.config.DMaaPMRPublisherConfig;\r
27 \r
28 import static org.junit.Assert.assertEquals;\r
29 import static org.junit.Assert.assertTrue;\r
30 \r
31 /**\r
32  * @author Manjesh Gowda. Creation Date: 11/21/2016.\r
33  */\r
34 public class AppPreferencesToPublisherConfigMapperTest extends BaseAnalyticsCDAPTCAUnitTest {\r
35     @Test\r
36     public void testMapTCAConfigToPublisherConfigFunctionGood() {\r
37         DMaaPMRPublisherConfig dMaaPMRPublisherConfig =\r
38                 (new AppPreferencesToPublisherConfigMapper()).apply(getTCATestAppPreferences());\r
39         assertEquals(dMaaPMRPublisherConfig.getHostName(), "PUBLISHER_HOST_NAME");\r
40     }\r
41 \r
42     @Test\r
43     public void testMapTCAConfigToPublisherConfigFunctionMap() {\r
44         DMaaPMRPublisherConfig dMaaPMRPublisherConfig = AppPreferencesToPublisherConfigMapper.map(\r
45                 getTCATestAppPreferences());\r
46         assertEquals(dMaaPMRPublisherConfig.getHostName(), "PUBLISHER_HOST_NAME");\r
47     }\r
48 \r
49     @Test\r
50     public void testMapTCAConfigToPublisherConfigFunction() {\r
51         final TCATestAppPreferences tcaAppPreferences = new TCATestAppPreferences();\r
52         final String publisherHostName = "publisherHostName";\r
53         final String publisherTopicName = "publisherTopicName";\r
54         tcaAppPreferences.setPublisherHostName(publisherHostName);\r
55         tcaAppPreferences.setPublisherTopicName(publisherTopicName);\r
56         DMaaPMRPublisherConfig dMaaPMRPublisherConfig =\r
57                 (new AppPreferencesToPublisherConfigMapper()).apply(tcaAppPreferences);\r
58         assertTrue(publisherHostName.equals(dMaaPMRPublisherConfig.getHostName()));\r
59         assertTrue(publisherTopicName.equals(dMaaPMRPublisherConfig.getTopicName()));\r
60 \r
61     }\r
62 }\r