FairQueuePlacementUtils { protected static String cleanName(String name) { name = FairSchedulerUtilities.trimQueueName(name); if (name.contains(DOT)) { String converted = name.replaceAll("\\.", DOT_REPLACEMENT); LOG.warn("Name {} is converted to {} when it is used as a queue name.", name, converted); return converted; } else { return name; } } private  FairQueuePlacementUtils();   }
@Test public void testCleanName() { final String clean = "clean"; final String dotted = "not.clean"; final String multiDot = "more.un.clean"; final String seqDot = "not..clean"; final String unTrimmed = " .invalid. "; String cleaned = cleanName(clean); assertEquals("Name was changed and it should not", clean, cleaned); cleaned = cleanName(dotted); assertFalse("Cleaned name contains dots and it should not", cleaned.contains(DOT)); cleaned = cleanName(multiDot); assertFalse("Cleaned name contains dots and it should not", cleaned.contains(DOT)); assertNotEquals("Multi dot failed: wrong replacements found", cleaned.indexOf(DOT_REPLACEMENT), cleaned.lastIndexOf(DOT_REPLACEMENT)); cleaned = cleanName(seqDot); assertFalse("Cleaned name contains dots and it should not", cleaned.contains(DOT)); assertNotEquals("Sequential dot failed: wrong replacements found", cleaned.indexOf(DOT_REPLACEMENT), cleaned.lastIndexOf(DOT_REPLACEMENT)); cleaned = cleanName(unTrimmed); assertTrue("Trimming start failed: space not removed or dot not replaced", cleaned.startsWith(DOT_REPLACEMENT)); assertTrue("Trimming end failed: space not removed or dot not replaced", cleaned.endsWith(DOT_REPLACEMENT)); }