StyleFactory { public AttributedString style(final String style, final String value) { requireNonNull(value); AttributedStyle astyle = resolver.resolve(style); return new AttributedString(value, astyle); } StyleFactory(final StyleResolver resolver); AttributedString style(final String style, final String value); AttributedString style(final String style, final String format, final Object... params); AttributedString evaluate(final String expression); AttributedString evaluate(final String format, final Object... params);  }
@Test public void styleDirect() { AttributedString string = underTest.style("bold,fg:red", "foo bar"); System.out.println(string.toAnsi()); assert string.equals(new AttributedString("foo bar", BOLD.foreground(RED))); }
@Test public void styleReferenced() { source.set("test", "very-red", "bold,fg:red"); AttributedString string = underTest.style(".very-red", "foo bar"); System.out.println(string.toAnsi()); assert string.equals(new AttributedString("foo bar", BOLD.foreground(RED))); }
@Test public void missingReferencedStyleWithDefault() { AttributedString string = underTest.style(".very-red:-bold,fg:red", "foo bar"); System.out.println(string.toAnsi()); assert string.equals(new AttributedString("foo bar", BOLD.foreground(RED))); }
@Test public void missingReferencedStyleWithCustomized() { source.set("test", "very-red", "bold,fg:yellow"); AttributedString string = underTest.style(".very-red:-bold,fg:red", "foo bar"); System.out.println(string.toAnsi()); assert string.equals(new AttributedString("foo bar", BOLD.foreground(YELLOW))); }
@Test public void styleFormat() { AttributedString string = underTest.style("bold", "%s", "foo"); System.out.println(string.toAnsi()); assert string.equals(new AttributedString("foo", BOLD)); }