private static ArrayList<Tuple2<Tuple2<Integer, String>, Integer>> crossResults = new ArrayList<Tuple2<Tuple2<Integer, String>, Integer>>();
private static ArrayList<Tuple2<Tuple2<Integer, String>, Integer>> crossExpectedResults = new ArrayList<Tuple2<Tuple2<Integer, String>, Integer>>();
@Test
public void test() throws Exception {
LocalStreamEnvironment env = StreamExecutionEnvironment.createLocalEnvironment(1);
env.setBufferTimeout(1);
ArrayList<Tuple2<Integer, String>> in1 = new ArrayList<Tuple2<Integer, String>>();
ArrayList<Integer> in2 = new ArrayList<Integer>();
in1.add(new Tuple2<Integer, String>(10, "a"));
in1.add(new Tuple2<Integer, String>(20, "b"));
in1.add(new Tuple2<Integer, String>(20, "x"));
in1.add(new Tuple2<Integer, String>(0, "y"));
in2.add(0);
in2.add(5);
in2.add(20);
joinExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(20, "b"), 20));
joinExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(20, "x"), 20));
joinExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(0, "y"), 0));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(10, "a"), 0));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(10, "a"), 5));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(10, "a"), 20));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(20, "b"), 0));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(20, "b"), 5));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(20, "b"), 20));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(20, "x"), 0));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(20, "x"), 5));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(20, "x"), 20));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(0, "y"), 0));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(0, "y"), 5));
crossExpectedResults.add(new Tuple2<Tuple2<Integer, String>, Integer>(
new Tuple2<Integer, String>(0, "y"), 20));
DataStream<Tuple2<Integer, String>> inStream1 = env.fromCollection(in1);
DataStream<Integer> inStream2 = env.fromCollection(in2);
inStream1.windowJoin(inStream2, 1000, 1000, new MyTimestamp1(), new MyTimestamp2(), 0, 0)
.addSink(new JoinResultSink());
inStream1.windowCross(inStream2, 1000, 1000, new MyTimestamp1(), new MyTimestamp2())
.addSink(new CrossResultSink());
env.executeTest(MEMORYSIZE);
assertEquals(joinExpectedResults, joinResults);
assertEquals(crossExpectedResults, crossResults);
}