### Question:
CrestAuditor { void auditAccessSuccess(JsonValue responseDetail) { if (auditEventPublisher.isAuditing(realm, ACCESS_TOPIC, EventName.AM_ACCESS_OUTCOME)) { final long endTime = System.currentTimeMillis(); final long elapsedTime = endTime - startTime; AMAccessAuditEventBuilder builder = auditEventFactory.accessEvent(realm) .forHttpRequest(context, request) .timestamp(endTime) .transactionId(AuditRequestContext.getTransactionIdValue()) .eventName(EventName.AM_ACCESS_OUTCOME) .component(component); if (responseDetail == null) { builder.response(SUCCESSFUL, "", elapsedTime, MILLISECONDS); } else { builder.responseWithDetail(SUCCESSFUL, "", elapsedTime, MILLISECONDS, responseDetail); } addSessionDetailsFromSSOTokenContext(builder, context); if (ipAddressHeaderPropertyIsSet()) { setClientFromHttpContextHeaderIfExists(builder, context); } AuditEvent auditEvent = builder.toEvent(); postProcessEvent(auditEvent); auditEventPublisher.tryPublish(ACCESS_TOPIC, auditEvent); } } CrestAuditor(Debug debug, AuditEventPublisher auditEventPublisher,
                 AuditEventFactory auditEventFactory, Context context, Request request);   }### Answer:
@Test(dataProvider = "CRESTRequests") public void auditSuccessShouldPublishEvents(Request request) throws Exception { given(auditEventPublisher.isAuditing(anyString(), anyString(), any(EventName.class))).willReturn(true); auditor = new CrestAuditor(debug, auditEventPublisher, auditEventFactory, context, request); givenAccessAuditingEnabled(auditEventPublisher); final JsonValue detail = json(object(field("foo", "bar"))); auditor.auditAccessSuccess(detail); ArgumentCaptor<AuditEvent> auditEventCaptor = ArgumentCaptor.forClass(AuditEvent.class); verify(auditEventPublisher).tryPublish(eq(ACCESS_TOPIC), auditEventCaptor.capture()); assertThat(getField(auditEventCaptor, EVENT_NAME).asString()).isEqualTo(EventName.AM_ACCESS_OUTCOME.toString()); assertThat(getField(auditEventCaptor, RESPONSE + "/" + DETAIL).asMap()).isEqualTo(detail.asMap()); }