### Question:
FileAuthorizer extends AbstractPolicyBasedAuthorizer { @Override public synchronized User deleteUser(final User user) throws AuthorizationAccessException { if (user == null) { throw new IllegalArgumentException("User cannot be null"); } final AuthorizationsHolder holder = this.authorizationsHolder.get(); final Tenants tenants = holder.getTenants(); final Authorizations authorizations = holder.getAuthorizations(); final List<org.apache.nifi.authorization.file.tenants.generated.User> users = tenants.getUsers().getUser(); for (org.apache.nifi.authorization.file.tenants.generated.Group group : tenants.getGroups().getGroup()) { Iterator<org.apache.nifi.authorization.file.tenants.generated.Group.User> groupUserIter = group.getUser().iterator(); while (groupUserIter.hasNext()) { org.apache.nifi.authorization.file.tenants.generated.Group.User groupUser = groupUserIter.next(); if (groupUser.getIdentifier().equals(user.getIdentifier())) { groupUserIter.remove(); break; } } } for (Policy policy : authorizations.getPolicies().getPolicy()) { Iterator<Policy.User> policyUserIter = policy.getUser().iterator(); while (policyUserIter.hasNext()) { Policy.User policyUser = policyUserIter.next(); if (policyUser.getIdentifier().equals(user.getIdentifier())) { policyUserIter.remove(); break; } } } boolean removedUser = false; Iterator<org.apache.nifi.authorization.file.tenants.generated.User> iter = users.iterator(); while (iter.hasNext()) { org.apache.nifi.authorization.file.tenants.generated.User jaxbUser = iter.next(); if (user.getIdentifier().equals(jaxbUser.getIdentifier())) { iter.remove(); removedUser = true; break; } } if (removedUser) { saveAndRefreshHolder(authorizations, tenants); return user; } else { return null; } }  @Override void initialize(final AuthorizerInitializationContext initializationContext); @Override void doOnConfigured(final AuthorizerConfigurationContext configurationContext); @AuthorizerContext void setNiFiProperties(NiFiProperties properties); @Override void preDestruction(); @Override synchronized Group doAddGroup(Group group); @Override Group getGroup(String identifier); @Override synchronized Group doUpdateGroup(Group group); @Override synchronized Group deleteGroup(Group group); @Override Set<Group> getGroups(); @Override synchronized User doAddUser(final User user); @Override User getUser(final String identifier); @Override User getUserByIdentity(final String identity); @Override synchronized User doUpdateUser(final User user); @Override synchronized User deleteUser(final User user); @Override Set<User> getUsers(); @Override synchronized AccessPolicy doAddAccessPolicy(final AccessPolicy accessPolicy); @Override AccessPolicy getAccessPolicy(final String identifier); @Override synchronized AccessPolicy updateAccessPolicy(final AccessPolicy accessPolicy); @Override synchronized AccessPolicy deleteAccessPolicy(final AccessPolicy accessPolicy); @Override Set<AccessPolicy> getAccessPolicies(); @Override UsersAndAccessPolicies getUsersAndAccessPolicies();  }### Answer:
@Test public void testDeleteUser() throws Exception { writeFile(primaryAuthorizations, AUTHORIZATIONS); writeFile(primaryTenants, TENANTS); authorizer.onConfigured(configurationContext); assertEquals(2, authorizer.getUsers().size()); final User user = authorizer.getUser("user-1"); assertEquals("user-1", user.getIdentifier()); final AccessPolicy policy1 = authorizer.getAccessPolicy("policy-1"); assertTrue(policy1.getUsers().contains("user-1")); final User deletedUser = authorizer.deleteUser(user); assertNotNull(deletedUser); assertEquals("user-1", deletedUser.getIdentifier()); assertEquals(1, authorizer.getUsers().size()); assertNull(authorizer.getUser(user.getIdentifier())); final AccessPolicy updatedPolicy1 = authorizer.getAccessPolicy("policy-1"); assertFalse(updatedPolicy1.getUsers().contains("user-1")); }