### Question:
FileAuthorizer extends AbstractPolicyBasedAuthorizer { @Override public synchronized AccessPolicy updateAccessPolicy(final AccessPolicy accessPolicy) throws AuthorizationAccessException { if (accessPolicy == null) { throw new IllegalArgumentException("AccessPolicy cannot be null"); } final AuthorizationsHolder holder = this.authorizationsHolder.get(); final Tenants tenants = holder.getTenants(); final Authorizations authorizations = holder.getAuthorizations(); Policy updatePolicy = null; for (Policy policy : authorizations.getPolicies().getPolicy()) { if (policy.getIdentifier().equals(accessPolicy.getIdentifier())) { updatePolicy = policy; break; } } if (updatePolicy == null) { return null; } transferUsersAndGroups(accessPolicy, updatePolicy); saveAndRefreshHolder(authorizations, tenants); return this.authorizationsHolder.get().getPoliciesById().get(accessPolicy.getIdentifier()); }  @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 testUpdateAccessPolicy() throws Exception { writeFile(primaryAuthorizations, AUTHORIZATIONS); writeFile(primaryTenants, TENANTS); authorizer.onConfigured(configurationContext); assertEquals(2, authorizer.getAccessPolicies().size()); final AccessPolicy policy = new AccessPolicy.Builder() .identifier("policy-1") .resource("resource-A") .addUser("user-A") .addGroup("group-A") .action(RequestAction.READ) .build(); final AccessPolicy updateAccessPolicy = authorizer.updateAccessPolicy(policy); assertNotNull(updateAccessPolicy); assertEquals("policy-1", updateAccessPolicy.getIdentifier()); assertEquals("/flow", updateAccessPolicy.getResource()); assertEquals(1, updateAccessPolicy.getUsers().size()); assertTrue(updateAccessPolicy.getUsers().contains("user-A")); assertEquals(1, updateAccessPolicy.getGroups().size()); assertTrue(updateAccessPolicy.getGroups().contains("group-A")); assertEquals(RequestAction.READ, updateAccessPolicy.getAction()); }