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.common;
\r
23 import com.fasterxml.jackson.databind.ObjectMapper;
\r
24 import com.google.common.base.Suppliers;
\r
25 import org.openecomp.dcae.apod.analytics.cdap.common.settings.CDAPAppSettings;
\r
26 import org.openecomp.dcae.apod.analytics.cdap.common.settings.CDAPBaseAppConfig;
\r
27 import org.openecomp.dcae.apod.analytics.cdap.common.utils.ValidationUtils;
\r
28 import org.openecomp.dcae.apod.analytics.cdap.common.validation.CDAPAppSettingsValidator;
\r
29 import org.openecomp.dcae.apod.analytics.common.validation.GenericValidationResponse;
\r
30 import org.openecomp.dcae.apod.analytics.model.util.json.AnalyticsModelObjectMapperSupplier;
\r
31 import org.openecomp.dcae.apod.analytics.test.BaseDCAEAnalyticsUnitTest;
\r
34 * @author Rajiv Singla . Creation Date: 1/12/2017.
\r
36 public abstract class BaseAnalyticsCDAPCommonUnitTest extends BaseDCAEAnalyticsUnitTest {
\r
38 protected static final String CEF_MESSAGE_FILE_LOCATION = "data/json/cef/cef_message.json";
\r
39 protected static final String TCA_POLICY_FILE_LOCATION = "data/json/policy/tca_policy.json";
\r
40 protected static final ObjectMapper ANALYTICS_MODEL_OBJECT_MAPPER =
\r
41 Suppliers.memoize(new AnalyticsModelObjectMapperSupplier()).get();
\r
44 * Test Implementation for {@link CDAPBaseAppConfig}
\r
46 public class CDAPBaseAppConfigImp extends CDAPBaseAppConfig {
\r
51 * Test implementation for {@link CDAPAppSettings}
\r
53 public class CDAPTestAppSettings implements CDAPAppSettings {
\r
55 private String settingsField;
\r
57 public String getSettingsField() {
\r
58 return settingsField;
\r
61 public void setSettingsField(String settingsField) {
\r
62 this.settingsField = settingsField;
\r
68 * Test implementation for {@link CDAPAppSettingsValidator}
\r
70 public class CDAPTestAppSettingsValidator implements CDAPAppSettingsValidator<CDAPTestAppSettings,
\r
71 GenericValidationResponse<CDAPTestAppSettings>> {
\r
73 private static final long serialVersionUID = 1L;
\r
76 public GenericValidationResponse<CDAPTestAppSettings>
\r
77 validateAppSettings(CDAPTestAppSettings cdapTestAppSettings) {
\r
78 GenericValidationResponse<CDAPTestAppSettings> validationResponse = new
\r
79 GenericValidationResponse<>();
\r
80 if (ValidationUtils.isEmpty(cdapTestAppSettings.getSettingsField())) {
\r
82 .addErrorMessage("settingsField", "Settings Field must not be empty");
\r
84 return validationResponse;
\r