@Test
public void testPutRoleThrowException() {

    TestAuditLogger alogger = new TestAuditLogger();
    ZMSImpl zmsImpl = getZmsImpl(alogger);
    String domainName = "DomainName1";
    String roleName = "RoleName1";
    Role role = new Role();
    
    // Tests the getRole() condition : if (!roleResourceName(domainName, roleName).equals(role.getName()))...
    try {
        String roleRoleName = "inconsistentRoleName1";
        role.setName(roleRoleName);
        
        // The role naming is inconsistent.
        zmsImpl.putRole(mockDomRsrcCtx, domainName, roleName, auditRef, role);
        fail("requesterror not thrown.");
    } catch (ResourceException e) {
        assertEquals(e.getCode(), 400);
    }
    
    // Tests the getRole() condition : if (domain == null)...
    try {
        String roleRoleName = "DomainName1:role.RoleName1";
        role.setName(roleRoleName);
        
        // We never created a domain for this role.
        zmsImpl.putRole(mockDomRsrcCtx, domainName, roleName, auditRef, role);
        fail("notfounderror not thrown.");
    } catch (ResourceException e) {
        assertEquals(e.getCode(), 404);
    }
}