@Test
public void testGetGroupMembersWithUpdatedDueDates() {

    Authority savedAuthority = zms.dbService.zmsConfig.getUserAuthority();
    Authority authority = Mockito.mock(Authority.class);
    Date currentDate = new Date();
    Timestamp authorityDate = Timestamp.fromDate(currentDate);
    Mockito.when(authority.getDateAttribute("user.john", "elevated-clearance"))
            .thenReturn(currentDate);
    zms.dbService.zmsConfig.setUserAuthority(authority);
    // service users are not processed
    List<GroupMember> groupMembers = new ArrayList<>();
    groupMembers.add(new GroupMember().setMemberName("sports.api"));
    List<GroupMember> members = zms.dbService.getGroupMembersWithUpdatedDueDates(groupMembers, "elevated-clearance");
    assertTrue(members.isEmpty());
    // no expiry and no user filter - no changes
    groupMembers.clear();
    groupMembers.add(new GroupMember().setMemberName("user.john"));
    members = zms.dbService.getGroupMembersWithUpdatedDueDates(groupMembers, null);
    assertTrue(members.isEmpty());
    // if group member expiry was set and now we have no userAuthorityExpiry - we'll reset
    groupMembers.clear();
    groupMembers.add(new GroupMember().setMemberName("user.john").setExpiration(Timestamp.fromCurrentTime()));
    members = zms.dbService.getGroupMembersWithUpdatedDueDates(groupMembers, null);
    assertFalse(members.isEmpty());
    assertNull(members.get(0).getExpiration());
    // if no expiry and user authority expiry is set - we'll update
    groupMembers.clear();
    groupMembers.add(new GroupMember().setMemberName("user.john"));
    members = zms.dbService.getGroupMembersWithUpdatedDueDates(groupMembers, "elevated-clearance");
    assertFalse(members.isEmpty());
    assertEquals(members.get(0).getExpiration(), authorityDate);
    zms.dbService.zmsConfig.setUserAuthority(savedAuthority);
}