Java Code Examples for org.apache.flink.streaming.runtime.operators.windowing.functions.InternalWindowFunction#InternalWindowContext

The following examples show how to use org.apache.flink.streaming.runtime.operators.windowing.functions.InternalWindowFunction#InternalWindowContext . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InternalWindowFunctionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalIterableAllWindowFunction() throws Exception {

	AllWindowFunctionMock mock = mock(AllWindowFunctionMock.class);
	InternalIterableAllWindowFunction<Long, String, TimeWindow> windowFunction =
		new InternalIterableAllWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);
	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Iterable<Long> i = (Iterable<Long>) mock(Iterable.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);

	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);

	windowFunction.process(((byte) 0), w, ctx, i, c);
	verify(mock).apply(w, i, c);

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 2
Source File: WindowOperatorContractTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void verifyCorrectTime(
		OneInputStreamOperatorTestHarness testHarness,
		InternalWindowFunction.InternalWindowContext context) {
	assertEquals(testHarness.getProcessingTime(), context.currentProcessingTime());
}
 
Example 3
Source File: WindowOperatorContractTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void verifyCorrectTime(
		OneInputStreamOperatorTestHarness testHarness,
		InternalWindowFunction.InternalWindowContext context) {
	assertEquals(testHarness.getCurrentWatermark(), context.currentWatermark());
}
 
Example 4
Source File: WindowOperatorContractTest.java    From flink with Apache License 2.0 4 votes vote down vote up
void verifyCorrectTime(
OneInputStreamOperatorTestHarness testHarness,
InternalWindowFunction.InternalWindowContext context);
 
Example 5
Source File: WindowOperatorContractTest.java    From flink with Apache License 2.0 4 votes vote down vote up
static InternalWindowFunction.InternalWindowContext anyInternalWindowContext() {
	return Mockito.any();
}
 
Example 6
Source File: InternalWindowFunctionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalSingleValueProcessAllWindowFunction() throws Exception {

	ProcessAllWindowFunctionMock mock = mock(ProcessAllWindowFunctionMock.class);
	InternalSingleValueProcessAllWindowFunction<Long, String, TimeWindow> windowFunction =
		new InternalSingleValueProcessAllWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);

	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);
	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);

	windowFunction.process(((byte) 0), w, ctx, 23L, c);
	verify(mock).process((ProcessAllWindowFunctionMock.Context) anyObject(), (Iterable<Long>) argThat(IsIterableContainingInOrder.contains(23L)), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 7
Source File: InternalWindowFunctionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalSingleValueAllWindowFunction() throws Exception {

	AllWindowFunctionMock mock = mock(AllWindowFunctionMock.class);
	InternalSingleValueAllWindowFunction<Long, String, TimeWindow> windowFunction =
		new InternalSingleValueAllWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);

	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);
	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);

	windowFunction.process(((byte) 0), w, ctx, 23L, c);
	verify(mock).apply(eq(w), (Iterable<Long>) argThat(IsIterableContainingInOrder.contains(23L)), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 8
Source File: InternalWindowFunctionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalSingleValueWindowFunction() throws Exception {

	WindowFunctionMock mock = mock(WindowFunctionMock.class);
	InternalSingleValueWindowFunction<Long, String, Long, TimeWindow> windowFunction =
		new InternalSingleValueWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);

	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);
	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);

	windowFunction.process(42L, w, ctx, 23L, c);
	verify(mock).apply(eq(42L), eq(w), (Iterable<Long>) argThat(IsIterableContainingInOrder.contains(23L)), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 9
Source File: InternalWindowFunctionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalIterableWindowFunction() throws Exception {

	WindowFunctionMock mock = mock(WindowFunctionMock.class);
	InternalIterableWindowFunction<Long, String, Long, TimeWindow> windowFunction =
		new InternalIterableWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);
	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Iterable<Long> i = (Iterable<Long>) mock(Iterable.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);

	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);
	windowFunction.process(42L, w, ctx, i, c);
	verify(mock).apply(eq(42L), eq(w), eq(i), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 10
Source File: InternalWindowFunctionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalIterableProcessAllWindowFunction() throws Exception {

	ProcessAllWindowFunctionMock mock = mock(ProcessAllWindowFunctionMock.class);
	InternalIterableProcessAllWindowFunction<Long, String, TimeWindow> windowFunction =
		new InternalIterableProcessAllWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);
	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Iterable<Long> i = (Iterable<Long>) mock(Iterable.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);

	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);
	windowFunction.process(((byte) 0), w, ctx, i, c);
	verify(mock).process((ProcessAllWindowFunctionMock.Context) anyObject(), eq(i), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 11
Source File: InternalWindowFunctionTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalIterableAllWindowFunction() throws Exception {

	AllWindowFunctionMock mock = mock(AllWindowFunctionMock.class);
	InternalIterableAllWindowFunction<Long, String, TimeWindow> windowFunction =
		new InternalIterableAllWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);
	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Iterable<Long> i = (Iterable<Long>) mock(Iterable.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);

	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);

	windowFunction.process(((byte) 0), w, ctx, i, c);
	verify(mock).apply(w, i, c);

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 12
Source File: WindowOperatorContractTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void verifyCorrectTime(
		OneInputStreamOperatorTestHarness testHarness,
		InternalWindowFunction.InternalWindowContext context) {
	assertEquals(testHarness.getProcessingTime(), context.currentProcessingTime());
}
 
Example 13
Source File: WindowOperatorContractTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public void verifyCorrectTime(
		OneInputStreamOperatorTestHarness testHarness,
		InternalWindowFunction.InternalWindowContext context) {
	assertEquals(testHarness.getCurrentWatermark(), context.currentWatermark());
}
 
Example 14
Source File: WindowOperatorContractTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
void verifyCorrectTime(
OneInputStreamOperatorTestHarness testHarness,
InternalWindowFunction.InternalWindowContext context);
 
Example 15
Source File: WindowOperatorContractTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
static InternalWindowFunction.InternalWindowContext anyInternalWindowContext() {
	return Mockito.any();
}
 
Example 16
Source File: InternalWindowFunctionTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalSingleValueProcessAllWindowFunction() throws Exception {

	ProcessAllWindowFunctionMock mock = mock(ProcessAllWindowFunctionMock.class);
	InternalSingleValueProcessAllWindowFunction<Long, String, TimeWindow> windowFunction =
		new InternalSingleValueProcessAllWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);

	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);
	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);

	windowFunction.process(((byte) 0), w, ctx, 23L, c);
	verify(mock).process((ProcessAllWindowFunctionMock.Context) anyObject(), (Iterable<Long>) argThat(IsIterableContainingInOrder.contains(23L)), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 17
Source File: InternalWindowFunctionTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalSingleValueAllWindowFunction() throws Exception {

	AllWindowFunctionMock mock = mock(AllWindowFunctionMock.class);
	InternalSingleValueAllWindowFunction<Long, String, TimeWindow> windowFunction =
		new InternalSingleValueAllWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);

	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);
	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);

	windowFunction.process(((byte) 0), w, ctx, 23L, c);
	verify(mock).apply(eq(w), (Iterable<Long>) argThat(IsIterableContainingInOrder.contains(23L)), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 18
Source File: InternalWindowFunctionTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalSingleValueWindowFunction() throws Exception {

	WindowFunctionMock mock = mock(WindowFunctionMock.class);
	InternalSingleValueWindowFunction<Long, String, Long, TimeWindow> windowFunction =
		new InternalSingleValueWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);

	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);
	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);

	windowFunction.process(42L, w, ctx, 23L, c);
	verify(mock).apply(eq(42L), eq(w), (Iterable<Long>) argThat(IsIterableContainingInOrder.contains(23L)), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 19
Source File: InternalWindowFunctionTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalIterableWindowFunction() throws Exception {

	WindowFunctionMock mock = mock(WindowFunctionMock.class);
	InternalIterableWindowFunction<Long, String, Long, TimeWindow> windowFunction =
		new InternalIterableWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);
	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Iterable<Long> i = (Iterable<Long>) mock(Iterable.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);

	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);
	windowFunction.process(42L, w, ctx, i, c);
	verify(mock).apply(eq(42L), eq(w), eq(i), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}
 
Example 20
Source File: InternalWindowFunctionTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testInternalIterableProcessAllWindowFunction() throws Exception {

	ProcessAllWindowFunctionMock mock = mock(ProcessAllWindowFunctionMock.class);
	InternalIterableProcessAllWindowFunction<Long, String, TimeWindow> windowFunction =
		new InternalIterableProcessAllWindowFunction<>(mock);

	// check setOutputType
	TypeInformation<String> stringType = BasicTypeInfo.STRING_TYPE_INFO;
	ExecutionConfig execConf = new ExecutionConfig();
	execConf.setParallelism(42);

	StreamingFunctionUtils.setOutputType(windowFunction, stringType, execConf);
	verify(mock).setOutputType(stringType, execConf);

	// check open
	Configuration config = new Configuration();

	windowFunction.open(config);
	verify(mock).open(config);

	// check setRuntimeContext
	RuntimeContext rCtx = mock(RuntimeContext.class);

	windowFunction.setRuntimeContext(rCtx);
	verify(mock).setRuntimeContext(rCtx);

	// check apply
	TimeWindow w = mock(TimeWindow.class);
	Iterable<Long> i = (Iterable<Long>) mock(Iterable.class);
	Collector<String> c = (Collector<String>) mock(Collector.class);

	InternalWindowFunction.InternalWindowContext ctx = mock(InternalWindowFunction.InternalWindowContext.class);
	windowFunction.process(((byte) 0), w, ctx, i, c);
	verify(mock).process((ProcessAllWindowFunctionMock.Context) anyObject(), eq(i), eq(c));

	// check close
	windowFunction.close();
	verify(mock).close();
}