Search in sources :

Example 1 with TestClock

use of io.opencensus.testing.common.TestClock in project instrumentation-java by census-instrumentation.

the class MeasureToViewMapTest method testRegisterAndGetView.

@Test
public void testRegisterAndGetView() {
    MeasureToViewMap measureToViewMap = new MeasureToViewMap();
    TestClock clock = TestClock.create(Timestamp.create(10, 20));
    measureToViewMap.registerView(VIEW, clock);
    clock.setTime(Timestamp.create(30, 40));
    ViewData viewData = measureToViewMap.getView(VIEW_NAME, clock, State.ENABLED);
    assertThat(viewData.getView()).isEqualTo(VIEW);
    assertThat(viewData.getWindowData()).isEqualTo(CumulativeData.create(Timestamp.create(10, 20), Timestamp.create(30, 40)));
    assertThat(viewData.getAggregationMap()).isEmpty();
}
Also used : TestClock(io.opencensus.testing.common.TestClock) ViewData(io.opencensus.stats.ViewData) Test(org.junit.Test)

Aggregations

ViewData (io.opencensus.stats.ViewData)1 TestClock (io.opencensus.testing.common.TestClock)1 Test (org.junit.Test)1