コード例 #1
0
 @Test(expected = EventStoreException.class)
 public void testFixtureGeneratesExceptionOnWrongEvents_WrongSequence() {
   String identifier = UUID.randomUUID().toString();
   fixture
       .getEventStore()
       .publish(
           new GenericDomainEventMessage<>("test", identifier, 0, new StubDomainEvent()),
           new GenericDomainEventMessage<>("test", identifier, 2, new StubDomainEvent()));
 }
コード例 #2
0
 @Test(expected = EventStoreException.class)
 public void testFixtureGeneratesExceptionOnWrongEvents_DifferentAggregateIdentifiers() {
   fixture
       .getEventStore()
       .publish(
           new GenericDomainEventMessage<>(
               "test", UUID.randomUUID().toString(), 0, new StubDomainEvent()),
           new GenericDomainEventMessage<>(
               "test", UUID.randomUUID().toString(), 0, new StubDomainEvent()));
 }
コード例 #3
0
  @Test
  public void testAggregateIdentifier_IdentifierAutomaticallyDeducted() {
    fixture.registerAggregateFactory(mockAggregateFactory);
    fixture.registerAnnotatedCommandHandler(
        new MyCommandHandler(fixture.getRepository(), fixture.getEventBus()));
    fixture
        .given(new MyEvent("AggregateId", 1), new MyEvent("AggregateId", 2))
        .when(new TestCommand("AggregateId"))
        .expectEvents(new MyEvent("AggregateId", 3));

    DomainEventStream events = fixture.getEventStore().readEvents("AggregateId");
    for (int t = 0; t < 3; t++) {
      assertTrue(events.hasNext());
      DomainEventMessage next = events.next();
      assertEquals("AggregateId", next.getAggregateIdentifier());
      assertEquals(t, next.getSequenceNumber());
    }
  }