MavenColorRenderer extends PatternRenderer { @Override protected void renderMessage(Event event, StringBuilder buff) { if (!isActivated) { super.renderMessage(event, buff); return; } if (event.getLevel() == WARN) { buff.append(colorize(event, YELLOW)); } else if (event.getLevel() == INFO) { buff.append(colorizer.colorize(event.getMessage())); } else { super.renderMessage(event, buff); } } MavenColorRenderer();  MavenColorRenderer(boolean isActivated);  MavenColorRenderer(String pattern);  MavenColorRenderer(String pattern, boolean isActivated);   }
@Test public void build_message_in_yellow_for_level_warning() { StringBuilder result = new StringBuilder(); new MavenColorRenderer(true).renderMessage(event(WARN, "warning message"), result); assertThat(result.toString()).isEqualTo(ansi().fgBright(YELLOW).bold().a("warning message").reset().toString()); }
@Test public void do_not_colorize_when_colorization_is_deactivated() { StringBuilder result = new StringBuilder(); new MavenColorRenderer(false).renderMessage(event(WARN, "warning message"), result); assertThat(result.toString()).isEqualTo("warning message"); }
@Test public void strip_existing_colors_when_colorization_is_deactivated() { StringBuilder result = new StringBuilder(); new MavenColorRenderer(false).renderMessage(event(INFO, ansi().fgBright(RED).a("message").toString()), result); assertThat(result.toString()).isEqualTo("message"); }