Util { public static List<String> getPossibleUuids(String... ids) { List<String> results = new LinkedList<>(); for (String id : ids) { if (id != null) { id = id.toLowerCase(); } results.add(id); if (isUuid(id)) { results.add(transformUuid(id)); } } return results; } private  Util(); static String generateUUID(); static String generateDbUUID(); static Set<T> asSet(T... values); static Date tomorrow(); static Date yesterday(); static Date midnight(); static Date addDaysToDt(int dayField); static Date addMinutesToDt(int minuteField); static Date toDate(String dt); static T assertNotNull(T value, String message); static boolean equals(String str, String str1); static void closeSafely(Object closable, String msg); static String capitalize(String str); static long generateUniqueLong(); static String toBase64(byte[] data); static SimpleDateFormat getUTCDateFormat(); static String readFile(InputStream is); static String hash(String password); static String toJson(Object anObject); static T fromJson(String json, Class<T> clazz); @SuppressWarnings("rawtypes") static String getClassName(Class c); static String getClassName(String fullClassName); static String reverseEndian(String in); static String transformUuid(String uuid); static List<String> getPossibleUuids(String... ids); static boolean isUuid(String uuid); static String collectionToString(Collection c); static boolean collectionsAreEqual(Collection<T> c1, Collection<T> c2); static boolean collectionsAreEqual(Collection<T> c1, Collection<T> c2, Comparator<T> comp); static String getHostname(); static final String UTC_STR; }
@Test public void testPossibleUuids() { String uuid = "78d7e200-b7d6-4cfe-b7a9-5700e8094df3"; String expectedReversed = "00e2d778-d6b7-fe4c-b7a9-5700e8094df3"; List<String> result = Util.getPossibleUuids(uuid); assertEquals(2, result.size()); assertTrue(result.contains(uuid)); assertTrue(result.contains(expectedReversed)); }
@Test public void testPossibleUuidsForcesLowerCase() { String uuid = "78d7e200-b7d6-4cfE-b7a9-5700e8094DF3"; String expectedUuid = "78d7e200-b7d6-4cfe-b7a9-5700e8094df3"; String expectedReversed = "00e2d778-d6b7-fe4c-b7a9-5700e8094df3"; List<String> result = Util.getPossibleUuids(uuid); assertEquals(2, result.size()); assertTrue(result.contains(expectedUuid)); assertTrue(result.contains(expectedReversed)); }
@Test public void testPossibleUuidsWithNonUuid() { String id = "some_non_uuid"; List<String> result = Util.getPossibleUuids(id); assertEquals(1, result.size()); assertTrue(result.contains(id)); }
@Test public void testPossibleUuidsWithEmptyString() { String id = ""; List<String> result = Util.getPossibleUuids(id); assertEquals(1, result.size()); assertTrue(result.contains(id)); }
@Test public void testPossibleUuidsWithNull() { String id = null; List<String> result = Util.getPossibleUuids(id); assertEquals(1, result.size()); assertTrue(result.contains(id)); }