TCA: Support for VES/A&AI enrichment
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-tca / src / test / java / org / openecomp / dcae / apod / analytics / cdap / tca / BaseAnalyticsCDAPTCAUnitTest.java
index 9c72183..e30a1ca 100644 (file)
-/*
- * ===============================LICENSE_START======================================
- *  dcae-analytics
- * ================================================================================
- *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *          http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  ============================LICENSE_END===========================================
- */
-
-package org.openecomp.dcae.apod.analytics.cdap.tca;
-
-import co.cask.cdap.api.flow.flowlet.AbstractFlowlet;
-import co.cask.cdap.api.flow.flowlet.FlowletContext;
-import co.cask.cdap.internal.flow.DefaultFlowletConfigurer;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.Suppliers;
-import org.junit.Assert;
-import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCAPolicyPreferences;
-import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCATestAppConfig;
-import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCATestAppPreferences;
-import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
-import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
-import org.openecomp.dcae.apod.analytics.model.util.AnalyticsModelIOUtils;
-import org.openecomp.dcae.apod.analytics.model.util.json.AnalyticsModelObjectMapperSupplier;
-import org.openecomp.dcae.apod.analytics.test.BaseDCAEAnalyticsUnitTest;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-/**
- * @author Rajiv Singla . Creation Date: 10/25/2016.
- */
-public abstract class BaseAnalyticsCDAPTCAUnitTest extends BaseDCAEAnalyticsUnitTest {
-
-    /**
-     * Object mapper to be used for all TCA Json Parsing
-     */
-    protected static final ObjectMapper ANALYTICS_MODEL_OBJECT_MAPPER =
-            Suppliers.memoize(new AnalyticsModelObjectMapperSupplier()).get();
-
-    protected static final String TCA_POLICY_JSON_FILE_LOCATION = "data/json/policy/tca_policy.json";
-    protected static final String CEF_MESSAGES_JSON_FILE_LOCATION = "data/json/cef/cef_messages.json";
-    protected static final String CEF_MESSAGE_JSON_FILE_LOCATION = "data/json/cef/cef_message.json";
-    protected static final String CEF_MESSAGE_WITH_THRESHOLD_VIOLATION_JSON_FILE_LOCATION =
-            "data/json/cef/cef_message_with_threshold_violation.json";
-    protected static final String TCA_APP_CONFIG_FILE_LOCATION = "data/json/config/controller_app_config.json";
-    protected static final String TCA_ALERT_JSON_FILE_LOCATION = "data/json/facade/tca_ves_cef_response.json";
-
-
-    protected static final String TCA_CONTROLLER_POLICY_FILE_LOCATION =
-            "data/properties/tca_controller_policy.properties";
-
-    protected static final String TCA_CONTROLLER_POLICY_FROM_JSON_FILE_LOCATION =
-            "data/properties/tca_controller_policy_from_json.properties";
-
-
-    protected static final String TCA_TEST_APP_CONFIG_NAME = "testTCAAppName";
-    protected static final String TCA_TEST_APP_CONFIG_DESCRIPTION = "testTCAAppDescription";
-    protected static final String TCA_TEST_APP_CONFIG_SUBSCRIBER_OUTPUT_STREAM_NAME =
-            "testTcaSubscriberOutputStreamName";
-    protected static final String TCA_TEST_APP_CONFIG_VES_ALERT_TABLE_NAME = "testTcaVESAlertsTableName";
-    protected static final String TCA_TEST_APP_CONFIG_VES_MESSAGE_STATUS_TABLE_NAME =
-            "testTcaVESMessageStatusTableName";
-
-
-    /**
-     * Provides TCA Policy that can be used for testing
-     *
-     * @return test TCA Policy Object
-     */
-    protected static TCAPolicy getSampleTCAPolicy() {
-        return deserializeJsonFileToModel(TCA_POLICY_JSON_FILE_LOCATION, TCAPolicy.class);
-    }
-
-    /**
-     * Provides TCA Policy that can be used for testing
-     *
-     * @return test {@link TCAPolicyPreferences}
-     */
-    protected static TCAPolicyPreferences getSampleTCAPolicyPreferences() {
-        return deserializeJsonFileToModel(TCA_POLICY_JSON_FILE_LOCATION, TCAPolicyPreferences.class);
-    }
-
-    /**
-     * Provides list containing 350 CEF messages
-     *
-     * @return CEF Test Message
-     *
-     * @throws Exception Exception
-     */
-    protected static List<EventListener> getCEFMessages() throws Exception {
-        final String cefMessageAsString = fromStream(CEF_MESSAGES_JSON_FILE_LOCATION);
-        final TypeReference<List<EventListener>> eventListenerListTypeReference =
-                new TypeReference<List<EventListener>>() {
-                };
-        return ANALYTICS_MODEL_OBJECT_MAPPER.readValue(cefMessageAsString, eventListenerListTypeReference);
-    }
-
-    /**
-     * Provides 1 valid CEF messages which does not violate Threshold as String
-     *
-     * @return CEF Test Message String
-     *
-     * @throws Exception Exception
-     */
-    protected static String getValidCEFMessage() throws Exception {
-        return fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);
-    }
-
-
-    /**
-     * Provides single CEF Test Message
-     *
-     * @return CEF Test Message
-     *
-     * @throws Exception Exception
-     */
-    protected static EventListener getCEFEventListener() throws Exception {
-        final String cefMessageAsString = fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);
-        return ANALYTICS_MODEL_OBJECT_MAPPER.readValue(cefMessageAsString, EventListener.class);
-    }
-
-    /**
-     * Deserialize given Json file location to given model class and returns it back without any validation check
-     *
-     * @param jsonFileLocation Classpath location of the json file
-     * @param modelClass Model Class type
-     * @param <T> Json Model Type
-     *
-     * @return Json model object
-     */
-    public static <T> T deserializeJsonFileToModel(String jsonFileLocation, Class<T> modelClass) {
-        final InputStream jsonFileInputStream =
-                BaseDCAEAnalyticsUnitTest.class.getClassLoader().getResourceAsStream(jsonFileLocation);
-        Assert.assertNotNull("Json File Location must be valid", jsonFileInputStream);
-        try {
-            return ANALYTICS_MODEL_OBJECT_MAPPER.readValue(jsonFileInputStream, modelClass);
-        } catch (IOException ex) {
-            LOG.error("Error while doing assert Json for fileLocation: {}, modelClass: {}, Exception {}",
-                    jsonFileLocation, modelClass, ex);
-            throw new RuntimeException(ex);
-        } finally {
-            try {
-                jsonFileInputStream.close();
-            } catch (IOException e) {
-                LOG.error("Error while closing input stream at file location: {}", jsonFileLocation);
-                throw new RuntimeException(e);
-            }
-        }
-    }
-
-    protected static TCATestAppConfig getTCATestAppConfig() {
-        final TCATestAppConfig tcaAppConfig = new TCATestAppConfig();
-        tcaAppConfig.setAppName(TCA_TEST_APP_CONFIG_NAME);
-        tcaAppConfig.setAppDescription(TCA_TEST_APP_CONFIG_DESCRIPTION);
-        tcaAppConfig.setTcaSubscriberOutputStreamName(TCA_TEST_APP_CONFIG_SUBSCRIBER_OUTPUT_STREAM_NAME);
-        tcaAppConfig.setTcaVESAlertsTableName(TCA_TEST_APP_CONFIG_VES_ALERT_TABLE_NAME);
-        tcaAppConfig.setTcaVESMessageStatusTableName(TCA_TEST_APP_CONFIG_VES_MESSAGE_STATUS_TABLE_NAME);
-        return tcaAppConfig;
-    }
-
-    /**
-     * Provides a test application preference for unit testing
-     *
-     * @return tca app preferences
-     */
-    protected static TCATestAppPreferences getTCATestAppPreferences() {
-        final TCATestAppPreferences tcaTestAppPreferences = new TCATestAppPreferences();
-        tcaTestAppPreferences.setSubscriberHostName("SUBSCRIBER_HOST_NAME");
-        tcaTestAppPreferences.setSubscriberHostPortNumber(10000);
-        tcaTestAppPreferences.setSubscriberTopicName("SUBSCRIBER_TOPIC_NAME");
-        tcaTestAppPreferences.setSubscriberUserName("SUBSCRIBER_USERNAME");
-        tcaTestAppPreferences.setSubscriberUserPassword("SUBSCRIBER_PASSWORD");
-        tcaTestAppPreferences.setSubscriberProtocol("https");
-        tcaTestAppPreferences.setSubscriberContentType("application/json");
-        tcaTestAppPreferences.setSubscriberConsumerId("SUBSCRIBER_CONSUMER_ID");
-        tcaTestAppPreferences.setSubscriberConsumerGroup("SUBSCRIBER_CONSUMER_GROUP_NAME");
-        tcaTestAppPreferences.setSubscriberTimeoutMS(10);
-        tcaTestAppPreferences.setSubscriberMessageLimit(100);
-        tcaTestAppPreferences.setSubscriberPollingInterval(1000);
-
-        tcaTestAppPreferences.setPublisherHostName("PUBLISHER_HOST_NAME");
-        tcaTestAppPreferences.setPublisherHostPort(1234);
-        tcaTestAppPreferences.setPublisherTopicName("PUBLISHER_TOPIC_NAME");
-        tcaTestAppPreferences.setPublisherUserName("PUBLISHER_USERNAME");
-        tcaTestAppPreferences.setPublisherUserPassword("PUBLISHER_PASSWORD");
-        tcaTestAppPreferences.setPublisherProtocol("https");
-        tcaTestAppPreferences.setPublisherContentType("application/json");
-        tcaTestAppPreferences.setPublisherMaxBatchSize(100);
-        tcaTestAppPreferences.setPublisherMaxRecoveryQueueSize(100);
-        tcaTestAppPreferences.setPublisherPollingInterval(6000);
-        return tcaTestAppPreferences;
-    }
-
-    protected static Map<String, String> getPreferenceMap() {
-        Map<String, String> preference = new HashMap<>();
-        preference.put("subscriberHostName", "mrlocal-mtnjftle01.homer.com");
-        preference.put("subscriberHostPort", "3905");
-        preference.put("subscriberTopicName", "com.dcae.dmaap.mtnje2.DcaeTestVESPub");
-        preference.put("subscriberProtocol", "https");
-        preference.put("subscriberUserName", "USER");
-        preference.put("subscriberUserPassword", "PASSWORD");
-        preference.put("subscriberContentType", "application/json");
-        preference.put("subscriberConsumerId", "123");
-        preference.put("subscriberConsumerGroup", "testTCAConsumerName-123");
-        preference.put("subscriberTimeoutMS", "-1");
-        preference.put("subscriberMessageLimit", "-1");
-        preference.put("subscriberPollingInterval", "30000");
-
-        preference.put("publisherHostName", "publisherHostName");
-        preference.put("publisherHostPort", "3905");
-        preference.put("publisherTopicName", "publisherTopicName");
-        preference.put("publisherProtocol", "https");
-        preference.put("publisherUserName", "publisherUserName");
-        preference.put("publisherContentType", "application/json");
-        preference.put("publisherMaxBatchSize", "1000");
-        preference.put("publisherMaxRecoveryQueueSize", "100");
-        preference.put("publisherPollingInterval", "6000");
-        return preference;
-    }
-
-    protected static <T extends AbstractFlowlet> void assertFlowletNameAndDescription(
-            final String expectedName, final String expectedDescription, final T flowlet) {
-        final DefaultFlowletConfigurer defaultFlowletConfigurer =
-                new DefaultFlowletConfigurer(flowlet);
-        flowlet.configure(defaultFlowletConfigurer);
-
-        final String flowletName = getPrivateFiledValue(defaultFlowletConfigurer, "name", String.class);
-        final String flowletDescription =
-                getPrivateFiledValue(defaultFlowletConfigurer, "description", String.class);
-
-        assertThat("Flowlet name must match with CDAPComponentsConstants",
-                flowletName, is(expectedName));
-
-        assertThat("Flowlet description must match with CDAPComponentsConstants",
-                flowletDescription, is(expectedDescription));
-
-    }
-
-    protected static FlowletContext getTestFlowletContextWithValidPolicy() {
-        return createNewFlowletContextFromPropertiesFile(TCA_CONTROLLER_POLICY_FILE_LOCATION);
-    }
-
-    protected static FlowletContext getTestFlowletContextWithValidPolicyFromJSON() {
-        return createNewFlowletContextFromPropertiesFile(TCA_CONTROLLER_POLICY_FROM_JSON_FILE_LOCATION);
-    }
-
-    private static FlowletContext createNewFlowletContextFromPropertiesFile(final String propertyFileLocation) {
-        final Properties controllerProperties =
-                AnalyticsModelIOUtils.loadPropertiesFile(propertyFileLocation, new Properties());
-
-        Map<String, String> runtimeArgs = new LinkedHashMap<>();
-        for (Map.Entry<Object, Object> property : controllerProperties.entrySet()) {
-            runtimeArgs.put(property.getKey().toString(), property.getValue().toString());
-        }
-
-        final FlowletContext flowletContext = mock(FlowletContext.class);
-        when(flowletContext.getRuntimeArguments()).thenReturn(runtimeArgs);
-        return flowletContext;
-    }
-
-}
+/*\r
+ * ===============================LICENSE_START======================================\r
+ *  dcae-analytics\r
+ * ================================================================================\r
+ *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *   You may obtain a copy of the License at\r
+ *\r
+ *          http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ *  ============================LICENSE_END===========================================\r
+ */\r
+\r
+package org.openecomp.dcae.apod.analytics.cdap.tca;\r
+\r
+import co.cask.cdap.api.flow.flowlet.AbstractFlowlet;\r
+import co.cask.cdap.api.flow.flowlet.FlowletContext;\r
+import co.cask.cdap.internal.flow.DefaultFlowletConfigurer;\r
+import com.fasterxml.jackson.core.type.TypeReference;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+import com.google.common.base.Suppliers;\r
+import org.junit.Assert;\r
+import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCAPolicyPreferences;\r
+import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCATestAppConfig;\r
+import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCATestAppPreferences;\r
+import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;\r
+import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;\r
+import org.openecomp.dcae.apod.analytics.model.util.AnalyticsModelIOUtils;\r
+import org.openecomp.dcae.apod.analytics.model.util.json.AnalyticsModelObjectMapperSupplier;\r
+import org.openecomp.dcae.apod.analytics.test.BaseDCAEAnalyticsUnitTest;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.util.HashMap;\r
+import java.util.LinkedHashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Properties;\r
+\r
+import static org.hamcrest.CoreMatchers.is;\r
+import static org.junit.Assert.assertThat;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.when;\r
+\r
+/**\r
+ * @author Rajiv Singla . Creation Date: 10/25/2016.\r
+ */\r
+public abstract class BaseAnalyticsCDAPTCAUnitTest extends BaseDCAEAnalyticsUnitTest {\r
+\r
+    /**\r
+     * Object mapper to be used for all TCA Json Parsing\r
+     */\r
+    protected static final ObjectMapper ANALYTICS_MODEL_OBJECT_MAPPER =\r
+            Suppliers.memoize(new AnalyticsModelObjectMapperSupplier()).get();\r
+\r
+    protected static final String TCA_POLICY_JSON_FILE_LOCATION = "data/json/policy/tca_policy.json";\r
+    protected static final String CEF_MESSAGES_JSON_FILE_LOCATION = "data/json/cef/cef_messages.json";\r
+    protected static final String CEF_MESSAGE_JSON_FILE_LOCATION = "data/json/cef/cef_message.json";\r
+    protected static final String CEF_MESSAGE_WITH_THRESHOLD_VIOLATION_JSON_FILE_LOCATION =\r
+            "data/json/cef/cef_message_with_threshold_violation.json";\r
+    protected static final String TCA_APP_CONFIG_FILE_LOCATION = "data/json/config/controller_app_config.json";\r
+    protected static final String TCA_ALERT_JSON_FILE_LOCATION = "data/json/facade/tca_ves_cef_response.json";\r
+\r
+\r
+    protected static final String TCA_CONTROLLER_POLICY_FILE_LOCATION =\r
+            "data/properties/tca_controller_policy.properties";\r
+\r
+    protected static final String TCA_CONTROLLER_POLICY_FROM_JSON_FILE_LOCATION =\r
+            "data/properties/tca_controller_policy_from_json.properties";\r
+\r
+\r
+    protected static final String TCA_TEST_APP_CONFIG_NAME = "testTCAAppName";\r
+    protected static final String TCA_TEST_APP_CONFIG_DESCRIPTION = "testTCAAppDescription";\r
+    protected static final String TCA_TEST_APP_CONFIG_SUBSCRIBER_OUTPUT_STREAM_NAME =\r
+            "testTcaSubscriberOutputStreamName";\r
+    protected static final String TCA_TEST_APP_CONFIG_VES_ALERT_TABLE_NAME = "testTcaVESAlertsTableName";\r
+    protected static final String TCA_TEST_APP_CONFIG_VES_MESSAGE_STATUS_TABLE_NAME =\r
+            "testTcaVESMessageStatusTableName";\r
+\r
+\r
+    /**\r
+     * Provides TCA Policy that can be used for testing\r
+     *\r
+     * @return test TCA Policy Object\r
+     */\r
+    protected static TCAPolicy getSampleTCAPolicy() {\r
+        return deserializeJsonFileToModel(TCA_POLICY_JSON_FILE_LOCATION, TCAPolicy.class);\r
+    }\r
+\r
+    /**\r
+     * Provides TCA Policy that can be used for testing\r
+     *\r
+     * @return test {@link TCAPolicyPreferences}\r
+     */\r
+    protected static TCAPolicyPreferences getSampleTCAPolicyPreferences() {\r
+        return deserializeJsonFileToModel(TCA_POLICY_JSON_FILE_LOCATION, TCAPolicyPreferences.class);\r
+    }\r
+\r
+    /**\r
+     * Provides list containing 350 CEF messages\r
+     *\r
+     * @return CEF Test Message\r
+     *\r
+     * @throws Exception Exception\r
+     */\r
+    protected static List<EventListener> getCEFMessages() throws Exception {\r
+        final String cefMessageAsString = fromStream(CEF_MESSAGES_JSON_FILE_LOCATION);\r
+        final TypeReference<List<EventListener>> eventListenerListTypeReference =\r
+                new TypeReference<List<EventListener>>() {\r
+                };\r
+        return ANALYTICS_MODEL_OBJECT_MAPPER.readValue(cefMessageAsString, eventListenerListTypeReference);\r
+    }\r
+\r
+    /**\r
+     * Provides 1 valid CEF messages which does not violate Threshold as String\r
+     *\r
+     * @return CEF Test Message String\r
+     *\r
+     * @throws Exception Exception\r
+     */\r
+    protected static String getValidCEFMessage() throws Exception {\r
+        return fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);\r
+    }\r
+\r
+\r
+    /**\r
+     * Provides single CEF Test Message\r
+     *\r
+     * @return CEF Test Message\r
+     *\r
+     * @throws Exception Exception\r
+     */\r
+    protected static EventListener getCEFEventListener() throws Exception {\r
+        final String cefMessageAsString = fromStream(CEF_MESSAGE_JSON_FILE_LOCATION);\r
+        return ANALYTICS_MODEL_OBJECT_MAPPER.readValue(cefMessageAsString, EventListener.class);\r
+    }\r
+\r
+    /**\r
+     * Deserialize given Json file location to given model class and returns it back without any validation check\r
+     *\r
+     * @param jsonFileLocation Classpath location of the json file\r
+     * @param modelClass Model Class type\r
+     * @param <T> Json Model Type\r
+     *\r
+     * @return Json model object\r
+     */\r
+    public static <T> T deserializeJsonFileToModel(String jsonFileLocation, Class<T> modelClass) {\r
+        final InputStream jsonFileInputStream =\r
+                BaseDCAEAnalyticsUnitTest.class.getClassLoader().getResourceAsStream(jsonFileLocation);\r
+        Assert.assertNotNull("Json File Location must be valid", jsonFileInputStream);\r
+        try {\r
+            return ANALYTICS_MODEL_OBJECT_MAPPER.readValue(jsonFileInputStream, modelClass);\r
+        } catch (IOException ex) {\r
+            LOG.error("Error while doing assert Json for fileLocation: {}, modelClass: {}, Exception {}",\r
+                    jsonFileLocation, modelClass, ex);\r
+            throw new RuntimeException(ex);\r
+        } finally {\r
+            try {\r
+                jsonFileInputStream.close();\r
+            } catch (IOException e) {\r
+                LOG.error("Error while closing input stream at file location: {}", jsonFileLocation);\r
+                throw new RuntimeException(e);\r
+            }\r
+        }\r
+    }\r
+\r
+    protected static TCATestAppConfig getTCATestAppConfig() {\r
+        final TCATestAppConfig tcaAppConfig = new TCATestAppConfig();\r
+        tcaAppConfig.setAppName(TCA_TEST_APP_CONFIG_NAME);\r
+        tcaAppConfig.setAppDescription(TCA_TEST_APP_CONFIG_DESCRIPTION);\r
+        tcaAppConfig.setTcaSubscriberOutputStreamName(TCA_TEST_APP_CONFIG_SUBSCRIBER_OUTPUT_STREAM_NAME);\r
+        tcaAppConfig.setTcaVESAlertsTableName(TCA_TEST_APP_CONFIG_VES_ALERT_TABLE_NAME);\r
+        tcaAppConfig.setTcaVESMessageStatusTableName(TCA_TEST_APP_CONFIG_VES_MESSAGE_STATUS_TABLE_NAME);\r
+        return tcaAppConfig;\r
+    }\r
+\r
+    /**\r
+     * Provides a test application preference for unit testing\r
+     *\r
+     * @return tca app preferences\r
+     */\r
+    protected static TCATestAppPreferences getTCATestAppPreferences() {\r
+        final TCATestAppPreferences tcaTestAppPreferences = new TCATestAppPreferences();\r
+        tcaTestAppPreferences.setSubscriberHostName("SUBSCRIBER_HOST_NAME");\r
+        tcaTestAppPreferences.setSubscriberHostPortNumber(10000);\r
+        tcaTestAppPreferences.setSubscriberTopicName("SUBSCRIBER_TOPIC_NAME");\r
+        tcaTestAppPreferences.setSubscriberUserName("SUBSCRIBER_USERNAME");\r
+        tcaTestAppPreferences.setSubscriberUserPassword("SUBSCRIBER_PASSWORD");\r
+        tcaTestAppPreferences.setSubscriberProtocol("https");\r
+        tcaTestAppPreferences.setSubscriberContentType("application/json");\r
+        tcaTestAppPreferences.setSubscriberConsumerId("SUBSCRIBER_CONSUMER_ID");\r
+        tcaTestAppPreferences.setSubscriberConsumerGroup("SUBSCRIBER_CONSUMER_GROUP_NAME");\r
+        tcaTestAppPreferences.setSubscriberTimeoutMS(10);\r
+        tcaTestAppPreferences.setSubscriberMessageLimit(100);\r
+        tcaTestAppPreferences.setSubscriberPollingInterval(1000);\r
+\r
+        tcaTestAppPreferences.setPublisherHostName("PUBLISHER_HOST_NAME");\r
+        tcaTestAppPreferences.setPublisherHostPort(1234);\r
+        tcaTestAppPreferences.setPublisherTopicName("PUBLISHER_TOPIC_NAME");\r
+        tcaTestAppPreferences.setPublisherUserName("PUBLISHER_USERNAME");\r
+        tcaTestAppPreferences.setPublisherUserPassword("PUBLISHER_PASSWORD");\r
+        tcaTestAppPreferences.setPublisherProtocol("https");\r
+        tcaTestAppPreferences.setPublisherContentType("application/json");\r
+        tcaTestAppPreferences.setPublisherMaxBatchSize(100);\r
+        tcaTestAppPreferences.setPublisherMaxRecoveryQueueSize(100);\r
+        tcaTestAppPreferences.setPublisherPollingInterval(6000);\r
+\r
+        tcaTestAppPreferences.setEnableAAIEnrichment(true);\r
+        tcaTestAppPreferences.setAaiEnrichmentHost("AAI_ENRICHMENT_HOST");\r
+        tcaTestAppPreferences.setAaiEnrichmentPortNumber(8443);\r
+        tcaTestAppPreferences.setAaiEnrichmentProtocol("https");\r
+        tcaTestAppPreferences.setAaiEnrichmentUserName("AAI_USERNAME");\r
+        tcaTestAppPreferences.setAaiEnrichmentUserPassword("AAI_USERPASSWORD");\r
+        tcaTestAppPreferences.setAaiEnrichmentIgnoreSSLCertificateErrors(true);\r
+        tcaTestAppPreferences.setAaiVMEnrichmentAPIPath("VM_ENRICHMENT_PATH");\r
+        tcaTestAppPreferences.setAaiVNFEnrichmentAPIPath("VNF_ENRICHMENT_PATH");\r
+        return tcaTestAppPreferences;\r
+    }\r
+\r
+    protected static Map<String, String> getPreferenceMap() {\r
+        Map<String, String> preference = new HashMap<>();\r
+        preference.put("subscriberHostName", "mrlocal-mtnjftle01.homer.com");\r
+        preference.put("subscriberHostPort", "3905");\r
+        preference.put("subscriberTopicName", "com.dcae.dmaap.mtnje2.DcaeTestVESPub");\r
+        preference.put("subscriberProtocol", "https");\r
+        preference.put("subscriberUserName", "USER");\r
+        preference.put("subscriberUserPassword", "PASSWORD");\r
+        preference.put("subscriberContentType", "application/json");\r
+        preference.put("subscriberConsumerId", "123");\r
+        preference.put("subscriberConsumerGroup", "testTCAConsumerName-123");\r
+        preference.put("subscriberTimeoutMS", "-1");\r
+        preference.put("subscriberMessageLimit", "-1");\r
+        preference.put("subscriberPollingInterval", "30000");\r
+\r
+        preference.put("publisherHostName", "publisherHostName");\r
+        preference.put("publisherHostPort", "3905");\r
+        preference.put("publisherTopicName", "publisherTopicName");\r
+        preference.put("publisherProtocol", "https");\r
+        preference.put("publisherUserName", "publisherUserName");\r
+        preference.put("publisherContentType", "application/json");\r
+        preference.put("publisherMaxBatchSize", "1000");\r
+        preference.put("publisherMaxRecoveryQueueSize", "100");\r
+        preference.put("publisherPollingInterval", "6000");\r
+        return preference;\r
+    }\r
+\r
+    protected static <T extends AbstractFlowlet> void assertFlowletNameAndDescription(\r
+            final String expectedName, final String expectedDescription, final T flowlet) {\r
+        final DefaultFlowletConfigurer defaultFlowletConfigurer =\r
+                new DefaultFlowletConfigurer(flowlet);\r
+        flowlet.configure(defaultFlowletConfigurer);\r
+\r
+        final String flowletName = getPrivateFiledValue(defaultFlowletConfigurer, "name", String.class);\r
+        final String flowletDescription =\r
+                getPrivateFiledValue(defaultFlowletConfigurer, "description", String.class);\r
+\r
+        assertThat("Flowlet name must match with CDAPComponentsConstants",\r
+                flowletName, is(expectedName));\r
+\r
+        assertThat("Flowlet description must match with CDAPComponentsConstants",\r
+                flowletDescription, is(expectedDescription));\r
+\r
+    }\r
+\r
+    protected static FlowletContext getTestFlowletContextWithValidPolicy() {\r
+        return createNewFlowletContextFromPropertiesFile(TCA_CONTROLLER_POLICY_FILE_LOCATION);\r
+    }\r
+\r
+    protected static FlowletContext getTestFlowletContextWithValidPolicyFromJSON() {\r
+        return createNewFlowletContextFromPropertiesFile(TCA_CONTROLLER_POLICY_FROM_JSON_FILE_LOCATION);\r
+    }\r
+\r
+    private static FlowletContext createNewFlowletContextFromPropertiesFile(final String propertyFileLocation) {\r
+        final Properties controllerProperties =\r
+                AnalyticsModelIOUtils.loadPropertiesFile(propertyFileLocation, new Properties());\r
+\r
+        Map<String, String> runtimeArgs = new LinkedHashMap<>();\r
+        for (Map.Entry<Object, Object> property : controllerProperties.entrySet()) {\r
+            runtimeArgs.put(property.getKey().toString(), property.getValue().toString());\r
+        }\r
+\r
+        final FlowletContext flowletContext = mock(FlowletContext.class);\r
+        when(flowletContext.getRuntimeArguments()).thenReturn(runtimeArgs);\r
+        return flowletContext;\r
+    }\r
+\r
+}\r