### Question:
CrestAuditor { void auditAccessAttempt() { if (auditEventPublisher.isAuditing(realm, ACCESS_TOPIC, EventName.AM_ACCESS_ATTEMPT)) { AMAccessAuditEventBuilder builder = auditEventFactory.accessEvent(realm) .forHttpRequest(context, request) .timestamp(startTime, auditEventPublisher.isLtzEnabled()) .transactionId(AuditRequestContext.getTransactionIdValue()) .eventName(EventName.AM_ACCESS_ATTEMPT) .component(component); addSessionDetailsFromSSOTokenContextIfNotNull(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 auditAccessShouldPublishEvents(Request request) throws Exception { given(auditEventPublisher.isAuditing(nullable(String.class), nullable(String.class), nullable(EventName.class))).willReturn(true); auditor = new CrestAuditor(debug, auditEventPublisher, auditEventFactory, context, request); givenAccessAuditingEnabled(auditEventPublisher); auditor.auditAccessAttempt(); 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_ATTEMPT.toString()); }