use of ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric in project ddf by codice.
the class SourceMetricsImplTest method assertMetricCount.
private void assertMetricCount(String sourceId, String metricName, int expectedCount) {
String key = sourceId + "." + metricName;
SourceMetric sourceMetric = sourceMetrics.metrics.get(key);
if (sourceMetric.isHistogram()) {
Histogram histogram = (Histogram) sourceMetric.getMetric();
assertThat(histogram.getCount(), is((long) expectedCount));
} else {
Meter meter = (Meter) sourceMetric.getMetric();
assertThat(meter.getCount(), is((long) expectedCount));
}
}
use of ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric in project ddf by codice.
the class SourceMetricsImplTest method testUpdateNonExistingSourceMetric.
@Test
public void testUpdateNonExistingSourceMetric() throws Exception {
String sourceId = "existing-source";
String metricName = SourceMetrics.QUERIES_SCOPE;
sourceMetrics = configureSourceMetrics(sourceId);
String nonExistingSourceId = "non-existing-source-id";
sourceMetrics.updateMetric(nonExistingSourceId, metricName, 1);
String key = nonExistingSourceId + "." + metricName;
SourceMetric sourceMetric = sourceMetrics.metrics.get(key);
assertThat(sourceMetric, is(nullValue()));
}
use of ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric in project ddf by codice.
the class SourceMetricsImplTest method testDeleteSourceBlankSourceId.
@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()));
}
use of ddf.catalog.metrics.source.SourceMetricsImpl.SourceMetric in project ddf by codice.
the class SourceMetricsImplTest method testAddDeleteSource.
@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()));
}
Aggregations