2 * ===============================LICENSE_START======================================
\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
11 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 package org.openecomp.dcae.apod.analytics.cdap.tca.validator;
\r
23 import org.junit.Before;
\r
24 import org.junit.Test;
\r
25 import org.openecomp.dcae.apod.analytics.cdap.tca.BaseAnalyticsCDAPTCAUnitTest;
\r
26 import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCAAppPreferences;
\r
27 import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCATestAppPreferences;
\r
28 import org.openecomp.dcae.apod.analytics.common.validation.GenericValidationResponse;
\r
30 import static org.junit.Assert.assertFalse;
\r
31 import static org.junit.Assert.assertTrue;
\r
34 * @author Rajiv Singla . Creation Date: 12/19/2016.
\r
36 public class TCAPreferencesValidatorTest extends BaseAnalyticsCDAPTCAUnitTest {
\r
38 private TCAPreferencesValidator tcaPreferencesValidator;
\r
39 private TCATestAppPreferences tcaTestAppPreferences;
\r
42 public void before() {
\r
43 tcaPreferencesValidator = new TCAPreferencesValidator();
\r
44 tcaTestAppPreferences = getTCATestAppPreferences();
\r
48 public void validateAppSettingsWithValidParameters() throws Exception {
\r
49 final GenericValidationResponse<TCAAppPreferences> validationResponse =
\r
50 tcaPreferencesValidator.validateAppSettings(tcaTestAppPreferences);
\r
51 assertFalse(validationResponse.hasErrors());
\r
55 public void validateAppSettingsWhenSubscriberHostOrTopicNameIsNotPresent() throws Exception {
\r
56 tcaTestAppPreferences.setSubscriberHostName(null);
\r
57 tcaTestAppPreferences.setSubscriberTopicName(null);
\r
58 final GenericValidationResponse<TCAAppPreferences> validationResponse =
\r
59 tcaPreferencesValidator.validateAppSettings(tcaTestAppPreferences);
\r
60 assertTrue(validationResponse.hasErrors());
\r
61 assertTrue(validationResponse.getErrorMessages().size() == 2);
\r
65 public void validateAppSettingsWhenPublisherHostOrTopicNameIsNotPresent() throws Exception {
\r
66 tcaTestAppPreferences.setPublisherHostName(null);
\r
67 tcaTestAppPreferences.setPublisherTopicName(null);
\r
68 final GenericValidationResponse<TCAAppPreferences> validationResponse =
\r
69 tcaPreferencesValidator.validateAppSettings(tcaTestAppPreferences);
\r
70 assertTrue(validationResponse.hasErrors());
\r
71 assertTrue(validationResponse.getErrorMessages().size() == 2);
\r
75 public void validateAppSettingsWhenAAIEnrichmentIsEnabledAndAAIRequiredFieldsAreNotPresent() throws Exception {
\r
76 tcaTestAppPreferences.setEnableAAIEnrichment(true);
\r
77 tcaTestAppPreferences.setAaiEnrichmentHost(null);
\r
78 tcaTestAppPreferences.setAaiVMEnrichmentAPIPath(null);
\r
79 tcaTestAppPreferences.setAaiVNFEnrichmentAPIPath(null);
\r
80 final GenericValidationResponse<TCAAppPreferences> validationResponse =
\r
81 tcaPreferencesValidator.validateAppSettings(tcaTestAppPreferences);
\r
82 assertTrue(validationResponse.hasErrors());
\r
83 assertTrue(validationResponse.getErrorMessages().size() == 3);
\r