@Test
  public void testMandatoryWarning() throws IOException {
    expectDiagnostic(Kind.MANDATORY_WARNING, "mandatory warning", "abcdefg", 1L, 5L, 1L);

    control.replay();
    listener.reportOn(diagnostic);

    assertErr("mandatory warning", "abcdefg", "^");
    assertNoOut();
  }
  @Test
  public void testWarning() throws IOException {
    expectDiagnostic(Kind.WARNING, "warning", "abcdefg", 1L, 3L, 2L);

    control.replay();
    listener.reportOn(diagnostic);

    assertErr("warning", "abcdefg", " ^");
    assertNoOut();
  }
  @Test
  public void testErrorEol() throws IOException {
    expectDiagnostic(Kind.ERROR, "error", "a\nbcd\n", 5L, 6L, 4L);

    control.replay();
    listener.reportOn(diagnostic);

    assertErr("error", "bcd", "   ^");
    assertNoOut();
  }
  @Test
  public void testOther() throws IOException {
    expectDiagnostic(
        Kind.OTHER, "unknown", null, Diagnostic.NOPOS, Diagnostic.NOPOS, Diagnostic.NOPOS);

    control.replay();
    listener.reportOn(diagnostic);

    assertOut("unknown");
    assertNoErr();
  }
  @Test
  public void testNote() throws IOException {
    expectDiagnostic(
        Kind.NOTE, "aside", null, Diagnostic.NOPOS, Diagnostic.NOPOS, Diagnostic.NOPOS);

    control.replay();
    listener.reportOn(diagnostic);

    assertOut("aside");
    assertNoErr();
  }
  @Before
  public void setUp() {
    out = new StringWriter();
    err = new StringWriter();

    listener =
        new AnsiColorDiagnosticListener<FileObject>(new PrintWriter(out), new PrintWriter(err));
    listener.prepareConsole(false);
    addTearDown(
        new TearDown() {
          @Override
          public void tearDown() {
            listener.releaseConsole();
          }
        });

    diagnostic = createMock(new TypeToken<Diagnostic<FileObject>>() {});
    file = createMock(FileObject.class);
  }