Search in sources :

Example 1 with MonthsWindows

use of org.apache.beam.sdk.transforms.windowing.CalendarWindows.MonthsWindows in project beam by apache.

the class CalendarWindowsTest method testDefaultWindowMappingFn.

@Test
public void testDefaultWindowMappingFn() {
    MonthsWindows windowFn = CalendarWindows.months(2);
    WindowMappingFn<?> mapping = windowFn.getDefaultWindowMappingFn();
    assertThat(mapping.getSideInputWindow(new BoundedWindow() {

        @Override
        public Instant maxTimestamp() {
            return new Instant(100L);
        }
    }), equalTo(windowFn.assignWindow(new Instant(100L))));
    assertThat(mapping.maximumLookback(), equalTo(Duration.ZERO));
}
Also used : Instant(org.joda.time.Instant) MonthsWindows(org.apache.beam.sdk.transforms.windowing.CalendarWindows.MonthsWindows) Test(org.junit.Test)

Example 2 with MonthsWindows

use of org.apache.beam.sdk.transforms.windowing.CalendarWindows.MonthsWindows in project beam by apache.

the class CalendarWindowsTest method testMonthsCompatibility.

@Test
public void testMonthsCompatibility() throws IncompatibleWindowException {
    CalendarWindows.MonthsWindows monthsWindows = CalendarWindows.months(10).beginningOnDay(15);
    monthsWindows.verifyCompatibility(CalendarWindows.months(10).beginningOnDay(15));
    thrown.expect(IncompatibleWindowException.class);
    monthsWindows.verifyCompatibility(CalendarWindows.months(10).beginningOnDay(30));
}
Also used : MonthsWindows(org.apache.beam.sdk.transforms.windowing.CalendarWindows.MonthsWindows) Test(org.junit.Test)

Example 3 with MonthsWindows

use of org.apache.beam.sdk.transforms.windowing.CalendarWindows.MonthsWindows in project beam by apache.

the class CalendarWindowsTest method testDefaultWindowMappingFnGlobal.

@Test
public void testDefaultWindowMappingFnGlobal() {
    MonthsWindows windowFn = CalendarWindows.months(2);
    WindowMappingFn<?> mapping = windowFn.getDefaultWindowMappingFn();
    thrown.expect(IllegalArgumentException.class);
    mapping.getSideInputWindow(GlobalWindow.INSTANCE);
}
Also used : MonthsWindows(org.apache.beam.sdk.transforms.windowing.CalendarWindows.MonthsWindows) Test(org.junit.Test)

Aggregations

MonthsWindows (org.apache.beam.sdk.transforms.windowing.CalendarWindows.MonthsWindows)3 Test (org.junit.Test)3 Instant (org.joda.time.Instant)1