TagParser { public List<String> fromTagString(String tags) { if (tags == null) { return new ArrayList<String>(); } String[] splittedTags = tags.split(TAG_SEPARATOR); List<String> result = new ArrayList<String>(); if (splittedTags != null) { for (String tag : splittedTags) { result.add(tag); } } return result; }  List<String> fromTagString(String tags); String toTagString(List<String> tags);  }
@Test public void whenTagStringInputIsNullShouldReturnEmptyList() { TagParser parser = createParser(); List<String> tags = parser.fromTagString(null); assertThat(tags.size(), is(0)); }
@Test public void whenTagStringInputIsSeparatedStringShouldReturnTags() { TagParser parser = createParser(); List<String> tags = parser.fromTagString("a;b;c"); assertThat(tags, hasItems("a", "b", "c")); }
@Test public void whenTagStringInputIsSimpleStringShouldReturnSingleTag() { TagParser parser = createParser(); List<String> tags = parser.fromTagString("abc"); assertThat(tags, hasItems("abc")); }