TCA: Replace any openecomp reference by onap
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-common / src / test / java / org / onap / dcae / apod / analytics / cdap / common / BaseAnalyticsCDAPCommonUnitTest.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.common;
22
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;
32
33 /**
34  * @author Rajiv Singla . Creation Date: 1/12/2017.
35  */
36 public abstract class BaseAnalyticsCDAPCommonUnitTest extends BaseDCAEAnalyticsUnitTest {
37
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();
42
43     /**
44      * Test Implementation for {@link CDAPBaseAppConfig}
45      */
46     public class CDAPBaseAppConfigImp extends CDAPBaseAppConfig {
47     }
48
49
50     /**
51      * Test implementation for {@link CDAPAppSettings}
52      */
53     public class CDAPTestAppSettings implements CDAPAppSettings {
54
55         private String settingsField;
56
57         public String getSettingsField() {
58             return settingsField;
59         }
60
61         public void setSettingsField(String settingsField) {
62             this.settingsField = settingsField;
63         }
64     }
65
66
67     /**
68      * Test implementation for {@link CDAPAppSettingsValidator}
69      */
70     public class CDAPTestAppSettingsValidator implements CDAPAppSettingsValidator<CDAPTestAppSettings,
71             GenericValidationResponse<CDAPTestAppSettings>> {
72
73         private static final long serialVersionUID = 1L;
74
75         @Override
76         public GenericValidationResponse<CDAPTestAppSettings>
77         validateAppSettings(CDAPTestAppSettings cdapTestAppSettings) {
78             GenericValidationResponse<CDAPTestAppSettings> validationResponse = new
79                     GenericValidationResponse<>();
80             if (ValidationUtils.isEmpty(cdapTestAppSettings.getSettingsField())) {
81                 validationResponse
82                         .addErrorMessage("settingsField", "Settings Field must not be empty");
83             }
84             return validationResponse;
85         }
86     }
87
88
89 }