@Test
public void testProcessGroupFailure() {

    final String domainName = "failure-group-domain";
    // group object without the domain part
    Group group1 = new Group().setName("group1");
    StringBuilder auditDetails = new StringBuilder("testAudit");
    try {
        zms.dbService.processGroup(zms.dbService.store.getConnection(true, true), null, domainName,
                "group1", group1, adminUser, auditRef, auditDetails);
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), ResourceException.BAD_REQUEST);
    }
    // mock returning failure
    group1 = new Group().setName(domainName + ":group.group1");
    Mockito.when(mockObjStore.getConnection(true, true)).thenReturn(mockJdbcConn);
    Mockito.when(mockJdbcConn.insertGroup(anyString(), any(Group.class)))
            .thenReturn(false);
    assertFalse(zms.dbService.processGroup(mockJdbcConn, null, domainName,
            "group1", group1, adminUser, auditRef, auditDetails));
    Mockito.when(mockJdbcConn.insertGroup(anyString(), any(Group.class)))
            .thenReturn(true);
    Mockito.when(mockJdbcConn.insertGroupMember(anyString(), anyString(), any(GroupMember.class),
            anyString(), anyString())).thenReturn(false);
    List<GroupMember> groupMembers = new ArrayList<>();
    groupMembers.add(new GroupMember().setMemberName("user.user1"));
    group1.setGroupMembers(groupMembers);
    assertFalse(zms.dbService.processGroup(mockJdbcConn, null, domainName,
            "group1", group1, adminUser, auditRef, auditDetails));
}