public void audit(AccessContext acxt, Signal<?> sig) {
    if (sig.isOnComplete()) {
      extractUser(sig)
          .doOnNext(u -> sendAuditRecord(acxt, u))
          .subscribe();
    } else if (sig.isOnError()) {
      extractUser(sig)
          .doOnNext(u -> sendAuditRecord(acxt, u, sig.getThrowable()))
          .subscribe();
    }
  }
@Test
  void auditCallsWriterMethodDependingOnSignal() {
    var auditWriter = mock(AuditWriter.class);
    var auditService = new AuditService(Map.of("test", auditWriter));

    var cxt = AccessContext.builder().cluster("test").build();

    auditService.audit(cxt, Signal.complete());
    verify(auditWriter).write(any(), any(), eq(null));

    var th = new Exception("testError");
    auditService.audit(cxt, Signal.error(th));
    verify(auditWriter).write(any(), any(), eq(th));
  }