@Test public void testDeleteSourceBlankSourceId() throws Exception { String sourceId = "cp-1"; String metricName = SourceMetrics.QUERIES_SCOPE; sourceMetrics = configureSourceMetrics(sourceId); addSource(); // Simulate Source returning empty sourceId when(catalogProvider.getId()).thenReturn(""); sourceMetrics.deletingSource(catalogProvider, null); String key = sourceId + "." + metricName; SourceMetric sourceMetric = sourceMetrics.metrics.get(key); assertThat(sourceMetric, not(nullValue())); sourceMetrics.deletingSource(null, null); key = sourceId + "." + metricName; sourceMetric = sourceMetrics.metrics.get(key); assertThat(sourceMetric, not(nullValue())); }
@Test public void testAddDeleteSource() throws Exception { String sourceId = "cp-1"; String metricName = SourceMetrics.QUERIES_SCOPE; sourceMetrics = configureSourceMetrics(sourceId); addSource(); String key = sourceId + "." + metricName; SourceMetric sourceMetric = sourceMetrics.metrics.get(key); assertThat(sourceMetric, not(nullValue())); sourceMetrics.deletingSource(catalogProvider, null); sourceMetric = sourceMetrics.metrics.get(key); assertThat(sourceMetric, is(nullValue())); }