Java Code Examples for org.apache.flink.api.common.serialization.DeserializationSchema#deserialize()

The following examples show how to use org.apache.flink.api.common.serialization.DeserializationSchema#deserialize() . 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: AvroDeserializationSchemaTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testGenericRecord() throws Exception {
	DeserializationSchema<GenericRecord> deserializationSchema =
		AvroDeserializationSchema.forGeneric(
			address.getSchema()
		);

	byte[] encodedAddress = writeRecord(address, Address.getClassSchema());
	GenericRecord genericRecord = deserializationSchema.deserialize(encodedAddress);
	assertEquals(address.getCity(), genericRecord.get("city").toString());
	assertEquals(address.getNum(), genericRecord.get("num"));
	assertEquals(address.getState(), genericRecord.get("state").toString());
}
 
Example 2
Source File: AvroDeserializationSchemaTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpecificRecordWithConfluentSchemaRegistry() throws Exception {
	DeserializationSchema<Address> deserializer = AvroDeserializationSchema.forSpecific(Address.class);

	byte[] encodedAddress = writeRecord(address, Address.getClassSchema());
	Address deserializedAddress = deserializer.deserialize(encodedAddress);
	assertEquals(address, deserializedAddress);
}
 
Example 3
Source File: AvroDeserializationSchemaTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGenericRecord() throws Exception {
	DeserializationSchema<GenericRecord> deserializationSchema =
		AvroDeserializationSchema.forGeneric(
			address.getSchema()
		);

	byte[] encodedAddress = writeRecord(address, Address.getClassSchema());
	GenericRecord genericRecord = deserializationSchema.deserialize(encodedAddress);
	assertEquals(address.getCity(), genericRecord.get("city").toString());
	assertEquals(address.getNum(), genericRecord.get("num"));
	assertEquals(address.getState(), genericRecord.get("state").toString());
}
 
Example 4
Source File: AvroDeserializationSchemaTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpecificRecordWithConfluentSchemaRegistry() throws Exception {
	DeserializationSchema<Address> deserializer = AvroDeserializationSchema.forSpecific(Address.class);

	byte[] encodedAddress = writeRecord(address, Address.getClassSchema());
	Address deserializedAddress = deserializer.deserialize(encodedAddress);
	assertEquals(address, deserializedAddress);
}
 
Example 5
Source File: AvroDeserializationSchemaTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testGenericRecord() throws Exception {
	DeserializationSchema<GenericRecord> deserializationSchema =
		AvroDeserializationSchema.forGeneric(
			address.getSchema()
		);

	byte[] encodedAddress = writeRecord(address, Address.getClassSchema());
	GenericRecord genericRecord = deserializationSchema.deserialize(encodedAddress);
	assertEquals(address.getCity(), genericRecord.get("city").toString());
	assertEquals(address.getNum(), genericRecord.get("num"));
	assertEquals(address.getState(), genericRecord.get("state").toString());
}
 
Example 6
Source File: AvroDeserializationSchemaTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testSpecificRecordWithConfluentSchemaRegistry() throws Exception {
	DeserializationSchema<Address> deserializer = AvroDeserializationSchema.forSpecific(Address.class);

	byte[] encodedAddress = writeRecord(address, Address.getClassSchema());
	Address deserializedAddress = deserializer.deserialize(encodedAddress);
	assertEquals(address, deserializedAddress);
}
 
Example 7
Source File: BackupCreatorIntegrationTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenProperJson_whenDeserializeIsInvoked_thenProperObjectIsReturned() throws IOException {
    InputMessage message = new InputMessage("Me", "User", LocalDateTime.now(), "Test Message");
    byte[] messageSerialized = mapper.writeValueAsBytes(message);
    DeserializationSchema<InputMessage> deserializationSchema = new InputMessageDeserializationSchema();
    InputMessage messageDeserialized = deserializationSchema.deserialize(messageSerialized);

    assertEquals(message, messageDeserialized);
}