SimpleAuditClient implements AuditClient { @Override public void auditEntry(final JsonEnvelope envelope, final String component) { logger.info(createAuditMessageFrom(envelope, component)); }  @Override void auditEntry(final JsonEnvelope envelope, final String component);  }
@Test public void shouldPrependTheAppNameToTheEnvelopeJsonAndLog() throws Exception { final String serviceContextName = "the-service-context-name"; final String propertyValue = "value"; final String envelopeJson = new JSONObject() .put("propertyName", propertyValue) .toString(); final JsonEnvelope envelope = mock(JsonEnvelope.class); when(envelope.toString()).thenReturn(envelopeJson); when(serviceContextNameProvider.getServiceContextName()).thenReturn(serviceContextName); simpleAuditClient.auditEntry(envelope, COMPONENT); final ArgumentCaptor<String> argumentCaptor = forClass(String.class); verify(logger).info(argumentCaptor.capture()); final String json = argumentCaptor.getValue(); with(json) .assertEquals("serviceContext", serviceContextName) .assertEquals("component", COMPONENT) .assertEquals("envelope.propertyName", propertyValue); }