### Question:
CSVHelper { public List<String> csvStringToList(final String csv, final boolean lowerCase) { if (csv == null) { return new ArrayList<String>(); } final String[] split = csv.split(","); for(int i = 0; i < split.length; i++) { if (lowerCase) { split[i] = split[i].toLowerCase().trim(); } else { split[i] = split[i].trim(); } } return new ArrayList<String>(Arrays.asList(split)); }  List<String> csvStringToList(final String csv, final boolean lowerCase); String listToCSVString(final List<String> list);  }### Answer:
@Test public void shouldReturnSingleEmptyForNoCommaString() { String one = "one"; List<String> myList = csvHelper.csvStringToList(one, false); assertEquals(myList.size(), 1); assertTrue(myList.contains("one")); }
@Test public void shouldReturnListOfElements() { String myElements = "one, two, three, four"; List<String> myList = csvHelper.csvStringToList(myElements, false); assertNotNull(myList); assertEquals(myList.size(), 4); assertTrue(myList.contains("one")); assertTrue(myList.contains("two")); assertTrue(myList.contains("three")); assertTrue(myList.contains("four")); }
@Test public void shouldNotLowerCaseListOfElements() { String myElements = "one, TWO, thRee, four"; List<String> myList = csvHelper.csvStringToList(myElements, false); assertNotNull(myList); assertEquals(myList.size(), 4); assertTrue(myList.contains("one")); assertTrue(myList.contains("TWO")); assertTrue(myList.contains("thRee")); assertTrue(myList.contains("four")); }
@Test public void shouldLowerCaseListOfElements() { String myElements = "one,TWO, thRee,four"; List<String> myList = csvHelper.csvStringToList(myElements, true); assertNotNull(myList); assertEquals(myList.size(), 4); assertTrue(myList.contains("one")); assertTrue(myList.contains("two")); assertTrue(myList.contains("three")); assertTrue(myList.contains("four")); }
@Test public void shouldReturnListOfElementsRegardlessOfSpaces() { String myElements = "one, two, three, four"; List<String> myList = csvHelper.csvStringToList(myElements, false); assertNotNull(myList); assertEquals(myList.size(), 4); assertTrue(myList.contains("one")); assertTrue(myList.contains("two")); assertTrue(myList.contains("three")); assertTrue(myList.contains("four")); }
@Test public void shouldReturnEmptyListFromNullString() { String myElements = null; List<String> myList = csvHelper.csvStringToList(myElements, false); assertNotNull(myList); assertEquals(myList.size(), 0); }