コード例 #1
0
 @Test
 public void testFixtureDetectsStateChangeOutsideOfHandler_AggregateDeleted() {
   TestExecutor exec =
       fixture
           .registerAnnotatedCommandHandler(
               new MyCommandHandler(fixture.getRepository(), fixture.getEventBus()))
           .given(new MyEvent("aggregateId", 5));
   try {
     exec.when(new DeleteCommand("aggregateId", true));
     fail("Fixture should have failed");
   } catch (AssertionError error) {
     assertTrue(
         "Wrong message: " + error.getMessage(),
         error.getMessage().contains("considered deleted"));
   }
 }
コード例 #2
0
 @Test
 public void testFixtureDetectsStateChangeOutsideOfHandler_NullValue() {
   List<?> givenEvents =
       Arrays.asList(
           new MyEvent("aggregateId", 1),
           new MyEvent("aggregateId", 2),
           new MyEvent("aggregateId", 3));
   try {
     fixture
         .registerAnnotatedCommandHandler(
             new MyCommandHandler(fixture.getRepository(), fixture.getEventBus()))
         .given(givenEvents)
         .when(new IllegalStateChangeCommand("aggregateId", null));
     fail("Expected AssertionError");
   } catch (AssertionError e) {
     assertTrue("Wrong message: " + e.getMessage(), e.getMessage().contains(".lastNumber\""));
     assertTrue("Wrong message: " + e.getMessage(), e.getMessage().contains("<null>"));
     assertTrue("Wrong message: " + e.getMessage(), e.getMessage().contains("<4>"));
   }
 }