DelegateSentryStore implements SentryStoreLayer { @Override public CommitContext dropRole(String component, String role, String requestor) throws SentryNoSuchObjectException { boolean rollbackTransaction = true; PersistenceManager pm = null; role = toTrimmedLower(role); try { pm = openTransaction(); Query query = pm.newQuery(MSentryRole.class); query.setFilter("this.roleName == t"); query.declareParameters("java.lang.String t"); query.setUnique(true); MSentryRole sentryRole = (MSentryRole) query.execute(role); if (sentryRole == null) { throw new SentryNoSuchObjectException("Role: " + role + " doesn't exist"); } else { pm.retrieve(sentryRole); sentryRole.removeGMPrivileges(); sentryRole.removePrivileges(); pm.deletePersistent(sentryRole); } CommitContext commit = commitUpdateTransaction(pm); rollbackTransaction = false; return commit; } finally { if (rollbackTransaction) { rollbackTransaction(pm); } } } DelegateSentryStore(Configuration conf); @Override CommitContext createRole(String component, String role,
      String requestor); @Override CommitContext dropRole(String component, String role, String requestor); @Override Set<String> getAllRoleNames(); @Override CommitContext alterRoleAddGroups(String component, String role,
      Set<String> groups, String requestor); @Override CommitContext alterRoleDeleteGroups(String component, String role,
      Set<String> groups, String requestor); @Override CommitContext alterRoleGrantPrivilege(String component, String role,
      PrivilegeObject privilege, String grantorPrincipal); @Override CommitContext alterRoleRevokePrivilege(String component,
      String role, PrivilegeObject privilege, String grantorPrincipal); @Override CommitContext renamePrivilege(String component, String service,
      List<? extends Authorizable> oldAuthorizables,
      List<? extends Authorizable> newAuthorizables, String requestor); @Override CommitContext dropPrivilege(String component,
      PrivilegeObject privilege, String requestor); @Override Set<String> getRolesByGroups(String component, Set<String> groups); @Override Set<String> getGroupsByRoles(String component, Set<String> roles); @Override Set<PrivilegeObject> getPrivilegesByRole(String component,
      Set<String> roles); @Override Set<PrivilegeObject> getPrivilegesByProvider(String component,
      String service, Set<String> roles, Set<String> groups,
      List<? extends Authorizable> authorizables); @Override Set<MSentryGMPrivilege> getPrivilegesByAuthorizable(String component, String service,
      Set<String> validActiveRoles, List<? extends Authorizable> authorizables); @Override void close();  }
@Test(expected=SentryNoSuchObjectException.class) public void testDropNotExistRole() throws Exception { String roleName = "not-exist"; String grantor = "grantor"; sentryStore.dropRole(SEARCH, roleName, grantor); }