@Test
  public void testAddCredentialsWithCredentialSupplierTokenExistsNothingAdded() {
    IncrementalIntDagCredentialSupplier supplier = new IncrementalIntDagCredentialSupplier();
    DagUtils dagUtils = new DagUtils(Collections.singletonList(supplier));
    DAG dag = DAG.create("test_credentials_dag");
    Token<TokenIdentifier> oldToken = new Token<>();
    // Add explicitly the token in the DAG before calling addCredentials simulating the use-case where the DAG has already the token
    dag.getCredentials().addToken(supplier.getTokenAlias(), oldToken);
    
    dagUtils.addCredentials(mock(MapWork.class), dag, null);
    Token<?> newToken = dag.getCredentials().getToken(supplier.getTokenAlias());
    assertEquals(oldToken, newToken);
    assertEquals(0, supplier.tokenCalls);
  }
Tests for {@link DagUtils} where {@link UserGroupInformation#isSecurityEnabled()} is true.
ql/src/test/org/apache/hadoop/hive/ql/exec/tez/TestDagUtilsSecurityEnabled.java