UriUtils { public static String extractAccountNameFromHostName(final String hostName) { if (hostName == null || hostName.isEmpty()) { return null; } if (!containsAbfsUrl(hostName)) { return null; } String[] splitByDot = hostName.split("\\."); if (splitByDot.length == 0) { return null; } return splitByDot[0]; } private  UriUtils(); static boolean containsAbfsUrl(final String string); static String extractAccountNameFromHostName(final String hostName); static String generateUniqueTestPath();  }
@Test public void testExtractRawAccountName() throws Exception { Assert.assertEquals("abfs", UriUtils.extractAccountNameFromHostName("abfs.dfs.core.windows.net")); Assert.assertEquals("abfs", UriUtils.extractAccountNameFromHostName("abfs.dfs.preprod.core.windows.net")); Assert.assertEquals(null, UriUtils.extractAccountNameFromHostName("abfs.dfs.cores.windows.net")); Assert.assertEquals(null, UriUtils.extractAccountNameFromHostName("")); Assert.assertEquals(null, UriUtils.extractAccountNameFromHostName(null)); Assert.assertEquals(null, UriUtils.extractAccountNameFromHostName("abfs.dfs.cores.windows.net")); }