Sonar Critical Fix
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-tca / src / test / java / org / onap / dcae / apod / analytics / cdap / tca / validator / TCAAppConfigValidatorTest.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T 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.dcae.apod.analytics.cdap.tca.validator;
22
23 import org.junit.Test;
24 import org.onap.dcae.apod.analytics.cdap.tca.BaseAnalyticsCDAPTCAUnitTest;
25 import org.onap.dcae.apod.analytics.cdap.tca.settings.TCAAppConfig;
26 import org.onap.dcae.apod.analytics.cdap.tca.settings.TCATestAppConfig;
27 import org.onap.dcae.apod.analytics.common.validation.GenericValidationResponse;
28
29 import static org.junit.Assert.assertFalse;
30 import static org.junit.Assert.assertTrue;
31
32 /**
33  * @author Rajiv Singla . Creation Date: 12/16/2016.
34  */
35 public class TCAAppConfigValidatorTest extends BaseAnalyticsCDAPTCAUnitTest {
36
37
38     @Test
39     public void validateAppSettingsWhenAppConfigIsValid() throws Exception {
40         final TCAAppConfigValidator tcaAppConfigValidator = new TCAAppConfigValidator();
41         final TCATestAppConfig tcaTestAppConfig = getTCATestAppConfig();
42         final GenericValidationResponse<TCAAppConfig> validationResponse =
43                 tcaAppConfigValidator.validateAppSettings(tcaTestAppConfig);
44         assertFalse(validationResponse.hasErrors());
45     }
46
47     @Test
48     public void testWhenSubscriberOutputStreamIsNull() throws Exception {
49         final TCAAppConfigValidator tcaAppConfigValidator = new TCAAppConfigValidator();
50         final TCATestAppConfig tcaTestAppConfig = getTCATestAppConfig();
51         tcaTestAppConfig.setTcaSubscriberOutputStreamName(null);
52         final GenericValidationResponse<TCAAppConfig> validationResponse =
53                 tcaAppConfigValidator.validateAppSettings(tcaTestAppConfig);
54         assertTrue(validationResponse.hasErrors());
55     }
56
57     @Test
58     public void testWhenVESMessageStatusTableNameIsNull() throws Exception {
59         final TCAAppConfigValidator tcaAppConfigValidator = new TCAAppConfigValidator();
60         final TCATestAppConfig tcaTestAppConfig = getTCATestAppConfig();
61         tcaTestAppConfig.setTcaVESMessageStatusTableName(null);
62         final GenericValidationResponse<TCAAppConfig> validationResponse =
63                 tcaAppConfigValidator.validateAppSettings(tcaTestAppConfig);
64         assertTrue(validationResponse.hasErrors());
65     }
66
67     @Test
68     public void testWhenVESAlertsTableNameIsNull() throws Exception {
69         final TCAAppConfigValidator tcaAppConfigValidator = new TCAAppConfigValidator();
70         final TCATestAppConfig tcaTestAppConfig = getTCATestAppConfig();
71         tcaTestAppConfig.setTcaVESAlertsTableName(null);
72         final GenericValidationResponse<TCAAppConfig> validationResponse =
73                 tcaAppConfigValidator.validateAppSettings(tcaTestAppConfig);
74         assertTrue(validationResponse.hasErrors());
75     }
76
77 }