@Test
public void updateRecordPolicyTest() {

    // Setup
    when(policyManager.createPolicy(any(PolicyType.class))).thenAnswer(invocation -> {
        PolicyType pt = invocation.getArgumentAt(0, PolicyType.class);
        if (pt.getPolicyId().equals(recordPolicyIRI.stringValue())) {
            return recordPolicy;
        } else {
            return policyPolicy;
        }
    });
    Response response = target().path("record-permissions/" + encode(recordIRI.stringValue())).request().put(Entity.json(recordJson));
    assertEquals(response.getStatus(), 200);
    verify(policyManager).getPolicy(recordPolicyIRI);
    verify(policyManager).getPolicy(policyPolicyIRI);
    verify(policyManager, times(2)).createPolicy(any(PolicyType.class));
    verify(policyManager, times(2)).updatePolicy(any(XACMLPolicy.class));
}