FileUtils { public static String[] convertCommaSeparatedStringToArray( String stringToConvert ) { if ( stringToConvert == null || stringToConvert.isEmpty() ) { throw new IllegalArgumentException( "String cannot be null or empty" ); } return stringToConvert.split( "[,]" ); }  static String idToPath( String pathId ); static boolean closeQuietly( FileInputStream fileInputStream ); static boolean containsReservedCharacter( String path, char[] reserved ); static boolean containsControlCharacters( String path ); static String[] convertCommaSeparatedStringToArray( String stringToConvert ); static String getParentPath( final String path ); static boolean isRootLevelPath( final String path ); static final String PATH_SEPARATOR; static final String ENCODED_PATH_SEPARATOR; }
@Test public void convertCommaSeparatedString() { String comma = ","; String string2 = "string2"; String string1 = "string1"; String commaSeparatedStr = string1 + comma + string2; String[] result = FileUtils.convertCommaSeparatedStringToArray( commaSeparatedStr ); assertEquals( result.length, 2 ); assertEquals( result[ 0 ], string1 ); assertEquals( result[ 1 ], string2 ); }
@Test public void convertSingleString() { String string = "string"; String[] result = FileUtils.convertCommaSeparatedStringToArray( string ); assertEquals( result.length, 1 ); assertEquals( result[ 0 ], string ); }
@Test( expected = IllegalArgumentException.class ) public void convertEmptyString() { FileUtils.convertCommaSeparatedStringToArray( StringUtils.EMPTY ); }