### Question:
BlockHeadersMessage extends Message { public List<BlockHeader> getBlockHeaders() { if (!parsed) { parse(); } return blockHeaders; } BlockHeadersMessage(byte[] encoded);  BlockHeadersMessage(@Nonnull final BlockHeader header);  BlockHeadersMessage(List<BlockHeader> headers); @Override MessageType getMessageType(); @Override byte[] getEncodedMessage(); List<BlockHeader> getBlockHeaders(); @Override String toString();  }### Answer:
@Test public void getBlockHeader() { Block block = new BlockGenerator().getBlock(1); BlockHeadersMessage message = new BlockHeadersMessage(block.getHeader()); Assert.assertSame(block.getHeader(), message.getBlockHeaders().get(0)); }
@Test public void getBlockHeaders() { List<BlockHeader> blocks = new ArrayList<>(); BlockGenerator blockGenerator = new BlockGenerator(); for (int k = 0; k < 5; k++) { Block b = blockGenerator.getBlock(k); blocks.add(b.getHeader()); } BlockHeadersMessage message = new BlockHeadersMessage(blocks); List<BlockHeader> mblocks = message.getBlockHeaders(); Assert.assertEquals(mblocks.size(), blocks.size()); for (int i = 0; i < blocks.size(); i++) { Assert.assertEquals(blocks.get(1).getHash(), mblocks.get(1).getHash()); } }