@Test
public void canConvertAppendEntriesToAndFromProtobuf() throws Exception {

  List<Entry> entries = Lists.newArrayList(new Entry("bar".getBytes(), 12), new Entry("baz".getBytes(), 12));
  AppendEntries pojo = new AppendEntries(12, "foo", 13, 14, 15, entries);
  RaftProto.AppendEntries proto = RaftProto.AppendEntries.newBuilder()
    .setTerm(12)
    .setLeaderId("foo")
    .setPrevLogIndex(13)
    .setPrevLogTerm(14)
    .setCommitIndex(15)
    .addEntries(RaftEntry.Entry.newBuilder()
      .setTerm(12)
      .setCommand(ByteString.copyFromUtf8("bar"))
      .build())
    .addEntries(RaftEntry.Entry.newBuilder()
      .setTerm(12)
      .setCommand(ByteString.copyFromUtf8("baz"))
      .build())
    .build();
  assertThat(ProtoUtils.convert(pojo)).isEqualTo(proto);
  assertThat(ProtoUtils.convert(proto)).isEqualTo(pojo);
}