Search in sources :

Example 1 with IntervalData

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());
}
Also used : AggregationWindowData(io.opencensus.stats.ViewData.AggregationWindowData) Timestamp(io.opencensus.common.Timestamp) IntervalData(io.opencensus.stats.ViewData.AggregationWindowData.IntervalData) CumulativeData(io.opencensus.stats.ViewData.AggregationWindowData.CumulativeData) Test(org.junit.Test)

Aggregations

Timestamp (io.opencensus.common.Timestamp)1 AggregationWindowData (io.opencensus.stats.ViewData.AggregationWindowData)1 CumulativeData (io.opencensus.stats.ViewData.AggregationWindowData.CumulativeData)1 IntervalData (io.opencensus.stats.ViewData.AggregationWindowData.IntervalData)1 Test (org.junit.Test)1