@Test
public void testPutPolicyThrowException() {

    String domainName = "DomainName";
    String policyName = "PolicyName";
    String wrongPolicyName = "WrongPolicyName";
    
    // Tests the putPolicy() condition : if (!policyResourceName(domainName, policyName).equals(policy.getName()))...
    try {
        Policy policy = createPolicyObject(domainName, wrongPolicyName);
        
        // policyName should not be the same as policy.getName()
        zms.putPolicy(mockDomRsrcCtx, domainName, policyName, auditRef, policy);
        fail("requesterror not thrown.");
    } catch (ResourceException e) {
        assertEquals(e.getCode(), 400);
    }
    
    // Tests the putPolicy() condition: if (domain == null)...
    try {
        Policy policy = createPolicyObject(domainName, policyName);
        
        // should fail b/c we never created a top level domain.
        zms.putPolicy(mockDomRsrcCtx, domainName, policyName, auditRef, policy);
        fail("requesterror not thrown.");
    } catch (ResourceException e) {
        assertEquals(e.getCode(), 404);
    }
}