@Test
public void testExecutePutGroupMembershipDecisionFailure() {

    final String domainName = "put-group-mbr-dec-err";
    final String groupName = "group1";
    Mockito.when(mockObjStore.getConnection(false, true)).thenReturn(mockJdbcConn);
    Mockito.when(mockJdbcConn.confirmGroupMember(anyString(), anyString(), any(GroupMember.class),
            anyString(), anyString())).thenReturn(false).thenThrow(new ResourceException(409));
    ObjectStore saveStore = zms.dbService.store;
    zms.dbService.store = mockObjStore;
    Group group = createGroupObject(domainName, groupName, "user.joe", "user.jane");
    GroupMember groupMember = new GroupMember().setMemberName("user.john");
    // first time we should get false and stand bad request
    try {
        zms.dbService.executePutGroupMembershipDecision(mockDomRsrcCtx, domainName, group, groupMember, auditRef);
        fail();
    } catch (ResourceException ex) {
        assertEquals(ResourceException.BAD_REQUEST, ex.getCode());
    }
    // next we should get back our exception
    try {
        zms.dbService.executePutGroupMembershipDecision(mockDomRsrcCtx, domainName, group, groupMember, auditRef);
        fail();
    } catch (ResourceException ex) {
        assertEquals(ResourceException.CONFLICT, ex.getCode());
    }
    zms.dbService.store = saveStore;
}