@Test
public void testParseTransportStreamWithKLVCallback() throws Exception {

  final Stanag4609TransportStreamParser parser = getParser();
  // Mockito can't spy anonymous classes.
  final BiConsumer<Integer, DecodedKLVMetadataPacket> callback =
      new BiConsumer<Integer, DecodedKLVMetadataPacket>() {
        @Override
        public void accept(Integer integer, DecodedKLVMetadataPacket decodedKLVMetadataPacket) {}
      };
  final BiConsumer<Integer, DecodedKLVMetadataPacket> callbackSpy = spy(callback);
  parser.parse(callbackSpy);
  final ArgumentCaptor<DecodedKLVMetadataPacket> decodedPacketCaptor =
      ArgumentCaptor.forClass(DecodedKLVMetadataPacket.class);
  // The packet ID of the metadata stream in this file is 497.
  verify(callbackSpy, times(1)).accept(eq(497), decodedPacketCaptor.capture());
  verifyDecodedMetadataPacket(decodedPacketCaptor.getValue());
}