RegistryPathUtils { public static String getUsername(String recPath) { String user = "anonymous"; Matcher matcher = USER_NAME.matcher(recPath); if (matcher.find()) { user = matcher.group(1); } return user; }  static String validateZKPath(String path); static String validateElementsAsDNS(String path); static String createFullPath(String base, String path); static String join(String base, String path); static List<String> split(String path); static String lastPathEntry(String path); static String parentOf(String path); static String encodeForRegistry(String element); static String encodeYarnID(String yarnId); static String getUsername(String recPath);  }
@Test public void testGetUserFromPath() throws Exception { assertEquals("bob", RegistryPathUtils .getUsername("/registry/users/bob/services/yarn-service/test1/")); assertEquals("bob-dev", RegistryPathUtils .getUsername("/registry/users/bob-dev/services/yarn-service/test1")); assertEquals("bob.dev", RegistryPathUtils .getUsername("/registry/users/bob.dev/services/yarn-service/test1")); }