use of com.google.protobuf.DynamicMessage in project druid by druid-io.
the class SchemaRegistryBasedProtobufBytesDecoderTest method testParse.
@Test
public void testParse() throws Exception {
Mockito.when(registry.getSchemaById(ArgumentMatchers.eq(1234))).thenReturn(parseProtobufSchema());
ProtoTestEventWrapper.ProtoTestEvent event = getTestEvent();
byte[] bytes = event.toByteArray();
ByteBuffer bb = ByteBuffer.allocate(bytes.length + 6).put((byte) 0).putInt(1234).put((byte) 0).put(bytes);
bb.rewind();
// When
DynamicMessage actual = new SchemaRegistryBasedProtobufBytesDecoder(registry).parse(bb);
// Then
Assert.assertEquals(actual.getField(actual.getDescriptorForType().findFieldByName("id")), event.getId());
}
Aggregations