Topics { public static String antidote(String topic) { return topic.substring(0, topic.length() - 2).replaceAll(EMPTY, ""); } private  Topics(); static String antidote(String topic); static String antidote(List<String> topicLevels); static List<String> sanitize(String topic); static List<String> sanitizeTopicName(String topicName); static List<String> sanitizeTopicFilter(String topicFilter); static boolean isTopicFilter(List<String> topicLevels); static final String EMPTY; static final String END; }
@Test public void antidoteTest() { assert Topics.antidote(Arrays.asList(new String[]{"abc", "+", "g", "h", END})).equals("abc/+/g/h"); assert Topics.antidote(Arrays.asList(new String[]{"abc", "def", "g", "#", END})).equals("abc/def/g/#"); assert Topics.antidote(Arrays.asList(new String[]{"abc", "def", "#", END})).equals("abc/def/#"); assert Topics.antidote(Arrays.asList(new String[]{"+", "+", "g", "#", END})).equals("+/+/g/#"); assert Topics.antidote(Arrays.asList(new String[]{EMPTY, "abc", "def", "g", "#", END})).equals("/abc/def/g/#"); assert Topics.antidote(Arrays.asList(new String[]{EMPTY, "abc", EMPTY, "def", "g", "#", END})).equals("/abc assert Topics.antidote(Arrays.asList(new String[]{EMPTY, "abc", "+", "g", "h", EMPTY, END})).equals("/abc/+/g/h/"); assert Topics.antidote(Arrays.asList(new String[]{"abc", "def", "g", "h", END})).equals("abc/def/g/h"); assert Topics.antidote(Arrays.asList(new String[]{EMPTY, "abc", "def", "g", "h", END})).equals("/abc/def/g/h"); assert Topics.antidote(Arrays.asList(new String[]{EMPTY, "abc", "def", "g", "h", EMPTY, END})).equals("/abc/def/g/h/"); assert Topics.antidote(Arrays.asList(new String[]{EMPTY, "abc", "def", EMPTY, "g", "h", END})).equals("/abc/def }
@Test public void antidoteTest() { assert Topics.antidote(Arrays.asList(new String[]{"abc", "+", "g", "h", Topics.END})).equals("abc/+/g/h"); assert Topics.antidote(Arrays.asList(new String[]{"abc", "def", "g", "#", Topics.END})).equals("abc/def/g/#"); assert Topics.antidote(Arrays.asList(new String[]{"abc", "def", "#", Topics.END})).equals("abc/def/#"); assert Topics.antidote(Arrays.asList(new String[]{"+", "+", "g", "#", Topics.END})).equals("+/+/g/#"); assert Topics.antidote(Arrays.asList(new String[]{Topics.EMPTY, "abc", "def", "g", "#", Topics.END})).equals("/abc/def/g/#"); assert Topics.antidote(Arrays.asList(new String[]{Topics.EMPTY, "abc", Topics.EMPTY, "def", "g", "#", Topics.END})).equals("/abc assert Topics.antidote(Arrays.asList(new String[]{Topics.EMPTY, "abc", "+", "g", "h", Topics.EMPTY, Topics.END})).equals("/abc/+/g/h/"); assert Topics.antidote(Arrays.asList(new String[]{"abc", "def", "g", "h", Topics.END})).equals("abc/def/g/h"); assert Topics.antidote(Arrays.asList(new String[]{Topics.EMPTY, "abc", "def", "g", "h", Topics.END})).equals("/abc/def/g/h"); assert Topics.antidote(Arrays.asList(new String[]{Topics.EMPTY, "abc", "def", "g", "h", Topics.EMPTY, Topics.END})).equals("/abc/def/g/h/"); assert Topics.antidote(Arrays.asList(new String[]{Topics.EMPTY, "abc", "def", Topics.EMPTY, "g", "h", Topics.END})).equals("/abc/def }