InviteService extends RestService { public Mono<InviteData> deleteInvite(String inviteCode, @Nullable String reason) { return Routes.INVITE_DELETE.newRequest(inviteCode) .optionalHeader("X-Audit-Log-Reason", reason) .exchange(getRouter()) .bodyToMono(InviteData.class); } InviteService(Router router); Mono<InviteData> getInvite(String inviteCode); Mono<InviteData> deleteInvite(String inviteCode, @Nullable String reason);  }
@Test public void testDeleteInvite() { channelService.getChannelInvites(modifyChannel) .filter(invite -> !invite.maxAge().isAbsent()) .filter(invite -> invite.createdAt().toOptional() .map(this::asInstant) .map(ts -> ts.plusSeconds(invite.maxAge().get())) .map(ts -> ts.isBefore(Instant.now())) .orElse(false)) .map(InviteData::code) .flatMap(code -> inviteService.deleteInvite(code, null)) .blockLast(); }