ConfigurationParser { public static List<String> getTags() { List<String> tags = new ArrayList<String>(); for (String writerProperty : Configuration.getSiblings("writer").keySet()) { String tag = Configuration.get(writerProperty + ".tag"); if (tag != null && !tag.isEmpty() && !tag.equals("-")) { String[] tagArray = tag.split(","); for (String tagArrayItem : tagArray) { tagArrayItem = tagArrayItem.replaceAll("@.*", "").trim(); if (!tags.contains(tagArrayItem) && !tagArrayItem.isEmpty()) { tags.add(tagArrayItem); } } } } return tags; } private  ConfigurationParser(); static Level getGlobalLevel(); static Map<String, Level> getCustomLevels(); static List<String> getTags(); static boolean isWritingThreadEnabled(); static boolean isAutoShutdownEnabled(); static Level parse(final String property, final Level defaultValue);  }
@Test public void writerWithoutTag() { Configuration.set("writer", "console"); List<String> tags = ConfigurationParser.getTags(); assertThat(tags).isEmpty(); }
@Test public void writerWithTag() { Configuration.set("writer", "console"); Configuration.set("writer.tag", "system"); List<String> tags = ConfigurationParser.getTags(); assertThat(tags).containsExactly("system"); }
@Test public void writerWithEmptyTag() { Configuration.set("writer", "console"); Configuration.set("writer.tag", ""); List<String> tags = ConfigurationParser.getTags(); assertThat(tags).isEmpty(); }
@Test public void writerWithMinusTag() { Configuration.set("writer", "console"); Configuration.set("writer.tag", "-"); List<String> tags = ConfigurationParser.getTags(); assertThat(tags).isEmpty(); }
@Test public void writerWithMultipleTags() { Configuration.set("writer", "console"); Configuration.set("writer.tag", " system , , backup , test, , "); List<String> tags = ConfigurationParser.getTags(); assertThat(tags).containsExactlyInAnyOrder("system", "backup", "test"); }
@Test public void writerWithMultipleTagsWithLevels() { Configuration.set("writer", "console"); Configuration.set("writer.tag", " system@INFO , backup , test@TRACE "); List<String> tags = ConfigurationParser.getTags(); assertThat(tags).containsExactlyInAnyOrder("system", "backup", "test"); }
@Test public void multipleWritersWithTags() { Configuration.set("writer1", "console"); Configuration.set("writer1.tag", "system"); Configuration.set("writer2", "console"); Configuration.set("writer2.tag", "technical"); Configuration.set("writer3", "console"); Configuration.set("writer3.tag", "system"); List<String> tags = ConfigurationParser.getTags(); assertThat(tags).containsExactlyInAnyOrder("system", "technical"); }