use of io.opencensus.stats.ViewData.AggregationWindowData.IntervalData in project instrumentation-java by census-instrumentation.
the class ViewDataTest method testAggregationWindowDataMatch.
@Test
public void testAggregationWindowDataMatch() {
final Timestamp start = Timestamp.fromMillis(1000);
final Timestamp end = Timestamp.fromMillis(2000);
final AggregationWindowData windowData1 = CumulativeData.create(start, end);
final AggregationWindowData windowData2 = IntervalData.create(end);
windowData1.match(new Function<CumulativeData, Void>() {
@Override
public Void apply(CumulativeData windowData) {
assertThat(windowData.getStart()).isEqualTo(start);
assertThat(windowData.getEnd()).isEqualTo(end);
return null;
}
}, new Function<IntervalData, Void>() {
@Override
public Void apply(IntervalData windowData) {
fail("CumulativeData expected.");
return null;
}
}, Functions.<Void>throwIllegalArgumentException());
windowData2.match(new Function<CumulativeData, Void>() {
@Override
public Void apply(CumulativeData windowData) {
fail("IntervalData expected.");
return null;
}
}, new Function<IntervalData, Void>() {
@Override
public Void apply(IntervalData windowData) {
assertThat(windowData.getEnd()).isEqualTo(end);
return null;
}
}, Functions.<Void>throwIllegalArgumentException());
}
Aggregations