PropertyPatternMessageColorizer implements MessageColorizer { protected int countGroups(Pattern pattern) { return StringUtils.countMatches(pattern.pattern().replace("\\(", ""), "("); } PropertyPatternMessageColorizer(Theme theme); void init(InputStream in); void store(OutputStream out); @Override boolean colorizingNeeded(String message); @Override Collection<MessageFragmentStyle> colorize(String message); @Override String getName(); @Override String getDescription(); @Override String getPluginableId(); @Override int getApiVersion(); String getFile(); void setFile(String file); String getTestMessage(); void setTestMessage(String testMessage); void setName(String name); static final String PROP_TYPE; static final String PROP_VERSION; static final String PROP_NAME; static final String PROP_DESCRIPTION; static final String PROP_PATTERN; static final String PROP_PATTERN_CANON_EQ; static final String PROP_PATTERN_CASE_INSENSITIVE; static final String PROP_PATTERN_COMMENTS; static final String PROP_PATTERN_DOTALL; static final String PROP_PATTERN_LITERAL; static final String PROP_PATTERN_MULTILINE; static final String PROP_PATTERN_UNICODE_CASE; static final String PROP_PATTERN_UNIX_LINES; static final String PROP_TEST_MESSAGE; }
@Test public void testCountGroups() { assertEquals(0, colorizer.countGroups(Pattern.compile(""))); assertEquals(1, colorizer.countGroups(Pattern.compile("a(a)"))); assertEquals(3, colorizer.countGroups(Pattern.compile("(a(a)(b))"))); assertEquals(0, colorizer.countGroups(Pattern.compile("\\(asdf"))); assertEquals(1, colorizer.countGroups(Pattern.compile("aaa\\(ffds(a)fsfd\\)\\(\\)"))); }