### Question:
KafkaProtobufSerializer implements Serializer<T> { @Override public byte[] serialize( String topic, T data ) { return data.toByteArray(); }  @Override void configure( Map<String, ?> configs, boolean isKey ); @Override byte[] serialize( String topic, T data ); @Override void close();  }### Answer:
@Test public void testSerialize() { MessageLite messageLite = mock( MessageLite.class ); byte[] mockByteArray = "test".getBytes(); when( messageLite.toByteArray() ).thenReturn( mockByteArray ); KafkaProtobufSerializer<MessageLite> serializer = new KafkaProtobufSerializer(); byte[] result = serializer.serialize( "topic", messageLite ); assertEquals( mockByteArray, result ); }