diff options
Diffstat (limited to 'dcae-analytics-cdap-tca/src/test/java/org')
3 files changed, 31 insertions, 1 deletions
diff --git a/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/BaseAnalyticsCDAPTCAUnitTest.java b/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/BaseAnalyticsCDAPTCAUnitTest.java index eff7374..37458fa 100644 --- a/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/BaseAnalyticsCDAPTCAUnitTest.java +++ b/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/BaseAnalyticsCDAPTCAUnitTest.java @@ -221,6 +221,9 @@ public abstract class BaseAnalyticsCDAPTCAUnitTest extends BaseDCAEAnalyticsUnit tcaTestAppPreferences.setAaiEnrichmentIgnoreSSLCertificateErrors(true); tcaTestAppPreferences.setAaiVMEnrichmentAPIPath("VM_ENRICHMENT_PATH"); tcaTestAppPreferences.setAaiVNFEnrichmentAPIPath("VNF_ENRICHMENT_PATH"); + + tcaTestAppPreferences.setEnableRedisCaching(false); + tcaTestAppPreferences.setRedisHosts("127.0.0.1:6379"); return tcaTestAppPreferences; } @@ -248,6 +251,10 @@ public abstract class BaseAnalyticsCDAPTCAUnitTest extends BaseDCAEAnalyticsUnit preference.put("publisherMaxBatchSize", "1000"); preference.put("publisherMaxRecoveryQueueSize", "100"); preference.put("publisherPollingInterval", "6000"); + + preference.put("enableRedisCaching", "false"); + preference.put("redisHosts", "127.0.0.1:6379"); + return preference; } diff --git a/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/flowlet/TCAVESAlertsAbatementFlowletTest.java b/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/flowlet/TCAVESAlertsAbatementFlowletTest.java index 7755a13..5df12f2 100644 --- a/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/flowlet/TCAVESAlertsAbatementFlowletTest.java +++ b/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/flowlet/TCAVESAlertsAbatementFlowletTest.java @@ -20,11 +20,13 @@ package org.onap.dcae.apod.analytics.cdap.tca.flowlet; +import co.cask.cdap.api.app.ApplicationSpecification; import co.cask.cdap.api.dataset.lib.ObjectMappedTable; import co.cask.cdap.api.flow.flowlet.FlowletContext; import co.cask.cdap.api.flow.flowlet.OutputEmitter; import com.google.common.collect.ImmutableList; import org.junit.Test; +import org.mockito.Mockito; import org.onap.dcae.apod.analytics.cdap.common.CDAPComponentsConstants; import org.onap.dcae.apod.analytics.cdap.common.domain.tca.ThresholdCalculatorOutput; import org.onap.dcae.apod.analytics.cdap.common.exception.CDAPSettingsException; @@ -36,6 +38,7 @@ import org.onap.dcae.apod.analytics.model.domain.policy.tca.MetricsPerEventName; import org.onap.dcae.apod.analytics.model.domain.policy.tca.Threshold; import org.onap.dcae.apod.analytics.tca.utils.TCAUtils; +import java.io.IOException; import java.util.Date; import java.util.List; @@ -99,6 +102,7 @@ public class TCAVESAlertsAbatementFlowletTest extends BaseAnalyticsCDAPTCAUnitTe final FlowletContext mockFlowletContext = mock(FlowletContext.class); final ObjectMappedTable<TCAAlertsAbatementEntity> mockObjectMappedTable = mock(ObjectMappedTable.class); when(mockFlowletContext.getDataset(eq(testTCAAlertsAbatementTableName))).thenReturn(mockObjectMappedTable); + configureFlowletContext(mockFlowletContext); tcaAlertsAbatementFlowlet.initialize(mockFlowletContext); doNothing().when(mockObjectMappedTable).write(any(String.class), any(TCAAlertsAbatementEntity.class)); @@ -125,6 +129,7 @@ public class TCAVESAlertsAbatementFlowletTest extends BaseAnalyticsCDAPTCAUnitTe final FlowletContext mockFlowletContext = mock(FlowletContext.class); final ObjectMappedTable<TCAAlertsAbatementEntity> mockObjectMappedTable = mock(ObjectMappedTable.class); when(mockFlowletContext.getDataset(eq(testTCAAlertsAbatementTableName))).thenReturn(mockObjectMappedTable); + configureFlowletContext(mockFlowletContext); tcaAlertsAbatementFlowlet.initialize(mockFlowletContext); doNothing().when(mockObjectMappedTable).write(any(String.class), any(TCAAlertsAbatementEntity.class)); @@ -154,6 +159,7 @@ public class TCAVESAlertsAbatementFlowletTest extends BaseAnalyticsCDAPTCAUnitTe final FlowletContext mockFlowletContext = mock(FlowletContext.class); final ObjectMappedTable<TCAAlertsAbatementEntity> mockObjectMappedTable = mock(ObjectMappedTable.class); when(mockFlowletContext.getDataset(eq(testTCAAlertsAbatementTableName))).thenReturn(mockObjectMappedTable); + configureFlowletContext(mockFlowletContext); tcaAlertsAbatementFlowlet.initialize(mockFlowletContext); doNothing().when(mockObjectMappedTable).write(any(String.class), any(TCAAlertsAbatementEntity.class)); @@ -185,8 +191,8 @@ public class TCAVESAlertsAbatementFlowletTest extends BaseAnalyticsCDAPTCAUnitTe final FlowletContext mockFlowletContext = mock(FlowletContext.class); final ObjectMappedTable<TCAAlertsAbatementEntity> mockObjectMappedTable = mock(ObjectMappedTable.class); when(mockFlowletContext.getDataset(eq(testTCAAlertsAbatementTableName))).thenReturn(mockObjectMappedTable); + configureFlowletContext(mockFlowletContext); tcaAlertsAbatementFlowlet.initialize(mockFlowletContext); - doNothing().when(mockObjectMappedTable).write(any(String.class), any(TCAAlertsAbatementEntity.class)); when(mockObjectMappedTable.read(any(String.class))).thenReturn(null); @@ -248,4 +254,11 @@ public class TCAVESAlertsAbatementFlowletTest extends BaseAnalyticsCDAPTCAUnitTe return thresholdCalculatorOutput; } + private void configureFlowletContext(final FlowletContext mockFlowletContext) throws IOException { + when(mockFlowletContext.getRuntimeArguments()).thenReturn(getPreferenceMap()); + ApplicationSpecification mockApplicationSpecification = Mockito.mock(ApplicationSpecification.class); + when(mockApplicationSpecification.getConfiguration()).thenReturn(fromStream(TCA_APP_CONFIG_FILE_LOCATION)); + when(mockFlowletContext.getApplicationSpecification()).thenReturn(mockApplicationSpecification); + } + } diff --git a/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/settings/TCATestAppPreferences.java b/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/settings/TCATestAppPreferences.java index 729630c..ad299b9 100644 --- a/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/settings/TCATestAppPreferences.java +++ b/dcae-analytics-cdap-tca/src/test/java/org/onap/dcae/apod/analytics/cdap/tca/settings/TCATestAppPreferences.java @@ -173,4 +173,14 @@ public class TCATestAppPreferences extends TCAAppPreferences { public void setAaiVMEnrichmentAPIPath(String aaiVMEnrichmentAPIPath) { this.aaiVMEnrichmentAPIPath = aaiVMEnrichmentAPIPath; } + + public void setEnableRedisCaching(final Boolean enableRedisCaching) { + this.enableRedisCaching = enableRedisCaching; + } + + public void setRedisHosts(final String redisHosts) { + this.redisHosts = redisHosts; + } + + } |