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