OAuthAuthorityUtils { public static final Set<String> csvToSet(String csv, String delimiter) { if (csv == null || csv.isEmpty()) { return null; } Set<String> set = new HashSet<String>(); if (delimiter == null || delimiter.isEmpty()) { set.add(csv); } else { Collections.addAll(set, csv.split(delimiter)); } return set; } private  OAuthAuthorityUtils(); static final String getProperty(String key, String def); static final Set<String> csvToSet(String csv, String delimiter); static final String extractHeaderToken(HttpServletRequest request);  }
@Test public void testCsvToSet() { Set<String> propValue = null; propValue = OAuthAuthorityUtils.csvToSet(null, ","); assertNull(propValue); propValue = OAuthAuthorityUtils.csvToSet("", ","); assertNull(propValue); propValue = OAuthAuthorityUtils.csvToSet("csv_1,csv_2", null); assertEquals(propValue, new HashSet<>(Arrays.asList("csv_1,csv_2"))); propValue = OAuthAuthorityUtils.csvToSet("csv_1,csv_2", ""); assertEquals(propValue, new HashSet<>(Arrays.asList("csv_1,csv_2"))); propValue = OAuthAuthorityUtils.csvToSet("csv_1,csv_2", ","); assertEquals(propValue, new HashSet<>(Arrays.asList("csv_1", "csv_2"))); propValue = OAuthAuthorityUtils.csvToSet("csv_1,csv_2", "_"); assertEquals(propValue, new HashSet<>(Arrays.asList("csv", "1,csv", "2"))); propValue = OAuthAuthorityUtils.csvToSet("csv_1,csv_2,", ","); assertEquals(propValue, new HashSet<>(Arrays.asList("csv_1", "csv_2"))); propValue = OAuthAuthorityUtils.csvToSet("csv_1,csv_2", "\\d"); assertEquals(propValue, new HashSet<>(Arrays.asList("csv_", ",csv_"))); propValue = OAuthAuthorityUtils.csvToSet("csv_1,csv_2,csv_3", "\\d"); assertEquals(propValue, new HashSet<>(Arrays.asList("csv_", ",csv_"))); }