AbstractDeserializationSchema implements DeserializationSchema<T> { @Override public TypeInformation<T> getProducedType() { return TypeExtractor.createTypeInfo(AbstractDeserializationSchema.class, getClass(), 0, null, null); }  @Override abstract T deserialize(byte[] message); @Override boolean isEndOfStream(T nextElement); @Override TypeInformation<T> getProducedType();  }
@Test public void testTypeExtractionTuple() { TypeInformation<Tuple2<byte[], byte[]>> type = new TupleSchema().getProducedType(); TypeInformation<Tuple2<byte[], byte[]>> expected = TypeInformation.of(new TypeHint<Tuple2<byte[], byte[]>>(){}); assertEquals(expected, type); }
@Test public void testTypeExtractionTupleAnonymous() { TypeInformation<Tuple2<byte[], byte[]>> type = new AbstractDeserializationSchema<Tuple2<byte[], byte[]>>() { @Override public Tuple2<byte[], byte[]> deserialize(byte[] message) throws IOException { throw new UnsupportedOperationException(); } }.getProducedType(); TypeInformation<Tuple2<byte[], byte[]>> expected = TypeInformation.of(new TypeHint<Tuple2<byte[], byte[]>>(){}); assertEquals(expected, type); }
@Test public void testTypeExtractionGeneric() { TypeInformation<JSONPObject> type = new JsonSchema().getProducedType(); TypeInformation<JSONPObject> expected = TypeInformation.of(new TypeHint<JSONPObject>(){}); assertEquals(expected, type); }
@Test public void testTypeExtractionGenericAnonymous() { TypeInformation<JSONPObject> type = new AbstractDeserializationSchema<JSONPObject>() { @Override public JSONPObject deserialize(byte[] message) throws IOException { throw new UnsupportedOperationException(); } }.getProducedType(); TypeInformation<JSONPObject> expected = TypeInformation.of(new TypeHint<JSONPObject>(){}); assertEquals(expected, type); }
@Test public void testTypeExtractionRawException() { try { new RawSchema().getProducedType(); fail(); } catch (InvalidTypesException e) { } }