ExpressionKeys expressKey = new ExpressionKeys(new String[] {"nestedClass.dumm2", "nestedClass.dumm1", "nestedClass.dumm3"}, pType); try { Assert.assertTrue("Expecting the keys to be compatible", fieldKey.areCompatible(expressKey)); } catch (IncompatibleKeysException e) { e.printStackTrace();
@Test public void testAreCompatible9() throws Keys.IncompatibleKeysException { TypeInformation<Tuple3<String, Long, Integer>> t1 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO ); TypeInformation<PojoWithMultiplePojos> t2 = TypeExtractor.getForClass(PojoWithMultiplePojos.class); ExpressionKeys<Tuple3<String, Long, Integer>> ek1 = new ExpressionKeys<>(new int[]{2,0}, t1); Keys<PojoWithMultiplePojos> ek2 = new Keys.SelectorFunctionKeys<>( new KeySelector3(), t2, new TupleTypeInfo<Tuple2<Integer, String>>(BasicTypeInfo.INT_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO) ); Assert.assertTrue(ek1.areCompatible(ek2)); }
@Test public void testAreCompatible4() throws Keys.IncompatibleKeysException { TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class); TypeInformation<Tuple3<String, Long, Integer>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO, BasicTypeInfo.INT_TYPE_INFO ); ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1", "i0"}, t1); ExpressionKeys<Tuple3<String, Long, Integer>> ek2 = new ExpressionKeys<>(new int[]{0, 0, 2}, t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
@Test public void testAreCompatible8() throws Keys.IncompatibleKeysException { TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO; TypeInformation<Pojo2> t2 = TypeExtractor.getForClass(Pojo2.class); ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1); Keys<Pojo2> ek2 = new Keys.SelectorFunctionKeys<>( new KeySelector1(), t2, BasicTypeInfo.STRING_TYPE_INFO ); Assert.assertTrue(ek1.areCompatible(ek2)); }
@Test(expected = Keys.IncompatibleKeysException.class) public void testAreCompatible6() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(1, t2); ek1.areCompatible(ek2); }
@Test(expected = Keys.IncompatibleKeysException.class) public void testAreCompatible7() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>(new String[]{"a", "b"}, t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2); ek1.areCompatible(ek2); }
@Test public void testAreCompatible2() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
@Test public void testAreCompatible1() throws Keys.IncompatibleKeysException { TypeInformation<Pojo1> t1 = TypeExtractor.getForClass(Pojo1.class); ExpressionKeys<Pojo1> ek1 = new ExpressionKeys<>("a", t1); ExpressionKeys<Pojo1> ek2 = new ExpressionKeys<>("b", t1); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
@Test public void testAreCompatible3() throws Keys.IncompatibleKeysException { TypeInformation<String> t1 = BasicTypeInfo.STRING_TYPE_INFO; TypeInformation<Tuple2<String, Long>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); ExpressionKeys<String> ek1 = new ExpressionKeys<>("*", t1); ExpressionKeys<Tuple2<String, Long>> ek2 = new ExpressionKeys<>(0, t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }
@Test public void testAreCompatible5() throws Keys.IncompatibleKeysException { TypeInformation<PojoWithMultiplePojos> t1 = TypeExtractor.getForClass(PojoWithMultiplePojos.class); TypeInformation<Tuple2<String, String>> t2 = new TupleTypeInfo<>( BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO ); ExpressionKeys<PojoWithMultiplePojos> ek1 = new ExpressionKeys<>(new String[]{"p1.b", "p2.a2"}, t1); ExpressionKeys<Tuple2<String, String>> ek2 = new ExpressionKeys<>("*", t2); Assert.assertTrue(ek1.areCompatible(ek2)); Assert.assertTrue(ek2.areCompatible(ek1)); }