@Test
public void parseWithError() {

  String line =
    "AGPBI: {\"kind\":\"error\",\"text\":\"Error message.\",\"sources\":[{\"file\":\"/app/src/main/res/layout/activity_main.xml\",\"position\":{\"startLine\":10,\"startColumn\":31,\"startOffset\":456,\"endColumn\":44,\"endOffset\":469}}],\"tool\":\"AAPT\"}";
  when(myReader.getParentEventId()).thenReturn("BUILD_ID_MOCK");
  ArgumentCaptor<MessageEvent> messageCaptor = ArgumentCaptor.forClass(MessageEvent.class);
  String detailLine = "This is a detail line";
  assertTrue(myParser.parse(line, myReader, myConsumer));
  assertFalse(myParser.parse(detailLine, myReader, myConsumer));
  verify(myConsumer).accept(messageCaptor.capture());
  List<MessageEvent> generatedMessages = messageCaptor.getAllValues();
  assertThat(generatedMessages).hasSize(1);
  assertThat(generatedMessages.get(0)).isInstanceOf(FileMessageEvent.class);
  FileMessageEvent fileMessageEvent = (FileMessageEvent)generatedMessages.get(0);
  assertThat(fileMessageEvent.getGroup()).isEqualTo("AAPT errors");
  assertThat(fileMessageEvent.getKind()).isEqualTo(MessageEvent.Kind.ERROR);
  assertThat(fileMessageEvent.getResult().getDetails()).isEqualTo("Error message.");
}