// Path: axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/shared/TestAuditEventRepository.java
// public class TestAuditEventRepository
//         implements AuditEventRepository {
//     private final List<AuditEvent> trail = new ArrayList<>();
// 
//     @Override
//     public List<AuditEvent> find(final String principal, final Date after) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public void add(final AuditEvent event) {
//         trail.add(event);
//     }
// 
//     public void reset() {
//         trail.clear();
//     }
// 
//     public int received() {
//         return trail.size();
//     }
// 
//     public AuditEvent eventAt(final int sequence) {
//         return trail.get(sequence);
//     }
// }
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/AxonCommandAuditEvent.java
// public static final String AXON_COMMAND_AUDIT_TYPE = CommandMessage.class
//         .getName();
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/AxonEventAuditEvent.java
// public static final String AXON_EVENT_AUDIT_TYPE = EventMessage.class
//         .getName();
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/SpringBootAuditLogger.java
// public static final String FAILURE_CAUSE = inNamespace("failure-cause");
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/SpringBootAuditLogger.java
// public static final String MESSAGE_TYPE = inNamespace("message-type");
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/SpringBootAuditLogger.java
// public static final String RETURN_VALUE = inNamespace("return-value");


import hm.binkley.spring.axon.shared.TestAuditEventRepository;
import org.axonframework.commandhandling.GenericCommandMessage;
import org.axonframework.commandhandling.gateway.CommandGateway;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.audit.AuditEvent;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Map;
import static hm.binkley.spring.axon.AxonCommandAuditEvent.AXON_COMMAND_AUDIT_TYPE;
import static hm.binkley.spring.axon.AxonEventAuditEvent.AXON_EVENT_AUDIT_TYPE;
import static hm.binkley.spring.axon.SpringBootAuditLogger.FAILURE_CAUSE;
import static hm.binkley.spring.axon.SpringBootAuditLogger.MESSAGE_TYPE;
import static hm.binkley.spring.axon.SpringBootAuditLogger.RETURN_VALUE;
import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
                isEqualTo(AXON_EVENT_AUDIT_TYPE);
        final Map<String, Object> eventData = eventAuditEvent.getData();
        assertThat(eventData.get(MESSAGE_TYPE)).
                isEqualTo(SuccessfulEvent.class.getName());
        assertThat(eventData.get(FAILURE_CAUSE)).
                isNull();
    }

    @Test
    public void shouldAuditWhenFailed() {
        final FailedException cause = new FailedException();
        final FailedCommand payload = new FailedCommand("def", cause);
        commands.send(payload);

        assertThat(trail.received()).
                isEqualTo(2);

        final AuditEvent commandAuditEvent = trail.eventAt(1);
        assertThat(commandAuditEvent.getType()).
                isEqualTo(AXON_COMMAND_AUDIT_TYPE);
        final Map<String, Object> commandData = commandAuditEvent.getData();
        assertThat(commandData.get(MESSAGE_TYPE)).
                isEqualTo(FailedCommand.class.getName());
        assertThat(commandData.get(RETURN_VALUE)).
                isNull();
        assertThat(commandData.get(FAILURE_CAUSE)).
                isSameAs(cause);

        final AuditEvent eventAuditEvent = trail.eventAt(0);
        assertThat(eventAuditEvent.getType()).
// Path: axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/shared/TestAuditEventRepository.java
// public class TestAuditEventRepository
//         implements AuditEventRepository {
//     private final List<AuditEvent> trail = new ArrayList<>();
// 
//     @Override
//     public List<AuditEvent> find(final String principal, final Date after) {
//         throw new UnsupportedOperationException();
//     }
// 
//     @Override
//     public void add(final AuditEvent event) {
//         trail.add(event);
//     }
// 
//     public void reset() {
//         trail.clear();
//     }
// 
//     public int received() {
//         return trail.size();
//     }
// 
//     public AuditEvent eventAt(final int sequence) {
//         return trail.get(sequence);
//     }
// }
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/AxonCommandAuditEvent.java
// public static final String AXON_COMMAND_AUDIT_TYPE = CommandMessage.class
//         .getName();
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/AxonEventAuditEvent.java
// public static final String AXON_EVENT_AUDIT_TYPE = EventMessage.class
//         .getName();
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/SpringBootAuditLogger.java
// public static final String FAILURE_CAUSE = inNamespace("failure-cause");
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/SpringBootAuditLogger.java
// public static final String MESSAGE_TYPE = inNamespace("message-type");
// 
// Path: axon-spring-boot-starter-monitoring/src/main/java/hm/binkley/spring/axon/SpringBootAuditLogger.java
// public static final String RETURN_VALUE = inNamespace("return-value");


// Path: axon-spring-boot-starter-monitoring/src/test/java/hm/binkley/spring/axon/metadata/MetaDataIT.java
import hm.binkley.spring.axon.shared.TestAuditEventRepository;
import org.axonframework.commandhandling.GenericCommandMessage;
import org.axonframework.commandhandling.gateway.CommandGateway;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.audit.AuditEvent;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Map;
import static hm.binkley.spring.axon.AxonCommandAuditEvent.AXON_COMMAND_AUDIT_TYPE;
import static hm.binkley.spring.axon.AxonEventAuditEvent.AXON_EVENT_AUDIT_TYPE;
import static hm.binkley.spring.axon.SpringBootAuditLogger.FAILURE_CAUSE;
import static hm.binkley.spring.axon.SpringBootAuditLogger.MESSAGE_TYPE;
import static hm.binkley.spring.axon.SpringBootAuditLogger.RETURN_VALUE;
import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;

                isEqualTo(AXON_EVENT_AUDIT_TYPE);
        final Map<String, Object> eventData = eventAuditEvent.getData();
        assertThat(eventData.get(MESSAGE_TYPE)).
                isEqualTo(SuccessfulEvent.class.getName());
        assertThat(eventData.get(FAILURE_CAUSE)).
                isNull();
    }

    @Test
    public void shouldAuditWhenFailed() {
        final FailedException cause = new FailedException();
        final FailedCommand payload = new FailedCommand("def", cause);
        commands.send(payload);

        assertThat(trail.received()).
                isEqualTo(2);

        final AuditEvent commandAuditEvent = trail.eventAt(1);
        assertThat(commandAuditEvent.getType()).
                isEqualTo(AXON_COMMAND_AUDIT_TYPE);
        final Map<String, Object> commandData = commandAuditEvent.getData();
        assertThat(commandData.get(MESSAGE_TYPE)).
                isEqualTo(FailedCommand.class.getName());
        assertThat(commandData.get(RETURN_VALUE)).
                isNull();
        assertThat(commandData.get(FAILURE_CAUSE)).
                isSameAs(cause);

        final AuditEvent eventAuditEvent = trail.eventAt(0);
        assertThat(eventAuditEvent.getType()).
                isEqualTo(AXON_EVENT_AUDIT_TYPE);