コード例 #1
0
 @Test
 public void testPojoType2() {
   TypeInformation<?> ti =
       TypeInfoParser.parse(
           "Tuple2<String,Tuple2<Integer,org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo<basic=String>>>");
   Assert.assertTrue(ti instanceof TupleTypeInfo);
   TupleTypeInfo<?> tti = (TupleTypeInfo<?>) ti;
   Assert.assertTrue(tti.getTypeAt(0) instanceof BasicTypeInfo);
   Assert.assertTrue(tti.getTypeAt(1) instanceof TupleTypeInfo);
   TupleTypeInfo<?> tti2 = (TupleTypeInfo<?>) tti.getTypeAt(1);
   Assert.assertTrue(tti2.getTypeAt(0) instanceof BasicTypeInfo);
   Assert.assertTrue(tti2.getTypeAt(1) instanceof PojoTypeInfo);
   PojoTypeInfo<?> pti = (PojoTypeInfo<?>) tti2.getTypeAt(1);
   Assert.assertEquals("basic", pti.getPojoFieldAt(0).field.getName());
   Assert.assertTrue(pti.getPojoFieldAt(0).type instanceof BasicTypeInfo);
 }
コード例 #2
0
 @Test
 public void testPojoType() {
   TypeInformation<?> ti =
       TypeInfoParser.parse(
           "org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyPojo<"
               + "basic=Integer,"
               + "tuple=Tuple2<String, Integer>,"
               + "hadoopCitizen=Writable<org.apache.flink.api.java.typeutils.TypeInfoParserTest$MyWritable>,"
               + "array=String[]"
               + ">");
   Assert.assertTrue(ti instanceof PojoTypeInfo);
   PojoTypeInfo<?> pti = (PojoTypeInfo<?>) ti;
   Assert.assertEquals("array", pti.getPojoFieldAt(0).field.getName());
   Assert.assertTrue(pti.getPojoFieldAt(0).type instanceof BasicArrayTypeInfo);
   Assert.assertEquals("basic", pti.getPojoFieldAt(1).field.getName());
   Assert.assertTrue(pti.getPojoFieldAt(1).type instanceof BasicTypeInfo);
   Assert.assertEquals("hadoopCitizen", pti.getPojoFieldAt(2).field.getName());
   Assert.assertTrue(pti.getPojoFieldAt(2).type instanceof WritableTypeInfo);
   Assert.assertEquals("tuple", pti.getPojoFieldAt(3).field.getName());
   Assert.assertTrue(pti.getPojoFieldAt(3).type instanceof TupleTypeInfo);
 }