@Test
public void testRevokeParentPrivilegeWithChildsExist() throws Exception {

  String roleName = "r1";
  /**
   * grantor is admin, there is no need to check grant option
   */
  String grantor = ADMIN_USER;
  PrivilegeObject updatePrivilege1 = new Builder()
      .setComponent(SEARCH)
      .setAction(SearchConstants.UPDATE)
      .setService(SERVICE)
      .setAuthorizables(Arrays.asList(new Collection(COLLECTION_NAME), new Field(FIELD_NAME)))
      .build();
  PrivilegeObject queryPrivilege1 = new Builder()
      .setComponent(SEARCH)
      .setAction(SearchConstants.QUERY)
      .setService(SERVICE)
      .setAuthorizables(Arrays.asList(new Collection(COLLECTION_NAME),new Field(FIELD_NAME)))
      .build();
  PrivilegeObject queryPrivilege2 = new Builder()
      .setComponent(SEARCH)
      .setAction(SearchConstants.QUERY)
      .setService(SERVICE)
      .setAuthorizables(Arrays.asList(new Collection(NOT_COLLECTION_NAME)))
      .build();
  sentryStore.createRole(SEARCH, roleName, grantor);
  sentryStore.alterRoleGrantPrivilege(SEARCH, roleName, updatePrivilege1, grantor);
  sentryStore.alterRoleGrantPrivilege(SEARCH, roleName, queryPrivilege1, grantor);
  sentryStore.alterRoleGrantPrivilege(SEARCH, roleName, queryPrivilege2, grantor);
  /**
   * revoke all privilege with collection[COLLECTION_NAME=collection1] and its child privileges
   */
  PrivilegeObject allPrivilege = new Builder()
      .setComponent(SEARCH)
      .setAction(SearchConstants.ALL)
      .setService(SERVICE)
      .setAuthorizables(Arrays.asList(new Collection(COLLECTION_NAME)))
      .build();
  sentryStore.alterRoleRevokePrivilege(SEARCH, roleName, allPrivilege, grantor);
  assertEquals(Sets.newHashSet(queryPrivilege2),
      sentryStore.getPrivilegesByRole(SEARCH, Sets.newHashSet(roleName)));
}