@Test
 public void testFixture_WrongEventContents_WithNullValues() {
   List<?> givenEvents =
       Arrays.asList(
           new MyEvent("aggregateId", 1),
           new MyEvent("aggregateId", 2),
           new MyEvent("aggregateId", 3));
   MyCommandHandler commandHandler =
       new MyCommandHandler(fixture.getRepository(), fixture.getEventBus());
   try {
     fixture
         .registerAnnotatedCommandHandler(commandHandler)
         .given(givenEvents)
         .when(new TestCommand("aggregateId"))
         .expectEvents(new MyEvent("aggregateId", null)) // should be 4
         .expectVoidReturnType();
     fail("Expected an AxonAssertionError");
   } catch (AxonAssertionError e) {
     assertTrue(
         e.getMessage()
             .contains(
                 "In an event of type [MyEvent], the property [someValue] was not as expected."));
     assertTrue(e.getMessage().contains("Expected <<null>> but got <4>"));
   }
 }
 @Test
 public void testFixture_UnexpectedReturnValue() {
   List<?> givenEvents =
       Arrays.asList(
           new MyEvent("aggregateId", 1),
           new MyEvent("aggregateId", 2),
           new MyEvent("aggregateId", 3));
   MyCommandHandler commandHandler =
       new MyCommandHandler(fixture.getRepository(), fixture.getEventBus());
   try {
     fixture
         .registerAnnotatedCommandHandler(commandHandler)
         .given(givenEvents)
         .when(new TestCommand("aggregateId"))
         .expectException(RuntimeException.class);
     fail("Expected an AxonAssertionError");
   } catch (AxonAssertionError e) {
     assertTrue(
         e.getMessage()
             .contains("The command handler returned normally, but an exception was expected"));
     assertTrue(
         e.getMessage()
             .contains("<an instance of java.lang.RuntimeException> but returned with <null>"));
   }
 }
 @Test
 public void testFixture_WrongReturnValue() {
   List<?> givenEvents =
       Arrays.asList(
           new MyEvent("aggregateId", 1),
           new MyEvent("aggregateId", 2),
           new MyEvent("aggregateId", 3));
   MyCommandHandler commandHandler =
       new MyCommandHandler(fixture.getRepository(), fixture.getEventBus());
   try {
     fixture
         .registerAnnotatedCommandHandler(commandHandler)
         .given(givenEvents)
         .when(new TestCommand("aggregateId"))
         .expectReturnValue("some");
     fail("Expected an AxonAssertionError");
   } catch (AxonAssertionError e) {
     assertTrue(e.getMessage(), e.getMessage().contains("<\"some\"> but got <null>"));
   }
 }
 @Test
 public void testFixture_ReportWrongNumberOfEvents() {
   List<?> givenEvents =
       Arrays.asList(
           new MyEvent("aggregateId", 1),
           new MyEvent("aggregateId", 2),
           new MyEvent("aggregateId", 3));
   MyCommandHandler commandHandler =
       new MyCommandHandler(fixture.getRepository(), fixture.getEventBus());
   try {
     fixture
         .registerAnnotatedCommandHandler(commandHandler)
         .given(givenEvents)
         .when(new TestCommand("aggregateId"))
         .expectEvents(new MyEvent("aggregateId", 4), new MyEvent("aggregateId", 5));
     fail("Expected an AxonAssertionError");
   } catch (AxonAssertionError e) {
     assertTrue(e.getMessage().contains("org.axonframework.test.MyEvent <|> "));
   }
 }
 @Test
 public void testFixture_UnexpectedException() {
   List<?> givenEvents =
       Arrays.asList(
           new MyEvent("aggregateId", 1),
           new MyEvent("aggregateId", 2),
           new MyEvent("aggregateId", 3));
   MyCommandHandler commandHandler =
       new MyCommandHandler(fixture.getRepository(), fixture.getEventBus());
   try {
     fixture
         .registerAnnotatedCommandHandler(commandHandler)
         .given(givenEvents)
         .when(new StrangeCommand("aggregateId"))
         .expectVoidReturnType();
     fail("Expected an AxonAssertionError");
   } catch (AxonAssertionError e) {
     assertTrue(
         e.getMessage().contains("but got <exception of type [StrangeCommandReceivedException]>"));
   }
 }
 @Test
 public void testFixture_ExpectedPublishedSameAsStored() {
   List<?> givenEvents =
       Arrays.asList(
           new MyEvent("aggregateId", 1),
           new MyEvent("aggregateId", 2),
           new MyEvent("aggregateId", 3));
   MyCommandHandler commandHandler =
       new MyCommandHandler(fixture.getRepository(), fixture.getEventBus());
   try {
     fixture
         .registerAnnotatedCommandHandler(commandHandler)
         .given(givenEvents)
         .when(new StrangeCommand("aggregateId"))
         .expectEvents(new MyEvent("aggregateId", 4)) // should be 4
         .expectException(StrangeCommandReceivedException.class);
     fail("Expected an AxonAssertionError");
   } catch (AxonAssertionError e) {
     assertTrue(e.getMessage().contains("The stored events do not match the published events."));
     assertTrue(e.getMessage().contains(" <|> org.axonframework.test.MyApplicationEvent"));
     assertTrue(e.getMessage().contains("probable cause"));
   }
 }