public static boolean hasHDFSDelegationToken(UserGroupInformation ugi) {
        Collection<Token<? extends TokenIdentifier>> usrTok = ugi.getTokens();
        for (Token<? extends TokenIdentifier> token : usrTok) {
            if (token.getKind().equals(HDFS_DELEGATION_TOKEN_KIND)) {
                return true;
            }
        }
        return false;
    }
@Test
    public void testShouldReturnFalseIfTheUserHasNoHDFSDelegationToken() {
        UserGroupInformation userWithoutToken = createTestUser(AuthenticationMethod.KERBEROS);
        assumeTrue(userWithoutToken.getTokens().isEmpty());

        boolean result = HadoopUtils.hasHDFSDelegationToken(userWithoutToken);

        assertFalse(result);
    }