@Test void testAggregateDoesNotCreateSequenceNumbersWhenEventBusIsNotDomainEventSequenceAware() { SimpleEventBus testEventBus = spy(SimpleEventBus.builder().build()); testSubject = GenericJpaRepository.builder(StubJpaAggregate.class) .entityManagerProvider(new SimpleEntityManagerProvider(mockEntityManager)) .eventBus(testEventBus) .identifierConverter(identifierConverter) .build(); DefaultUnitOfWork.startAndGet(null).executeWithResult(() -> { Aggregate<StubJpaAggregate> agg = testSubject.load(aggregateId); agg.execute(e -> e.doSomething("test2")); return null; }); CurrentUnitOfWork.commit(); @SuppressWarnings("unchecked") ArgumentCaptor<List<? extends EventMessage<?>>> eventCaptor = ArgumentCaptor.forClass((Class<List<? extends EventMessage<?>>>) (Class) List.class); verify(testEventBus).publish(eventCaptor.capture()); List<? extends EventMessage<?>> capturedEvents = eventCaptor.getValue(); assertEquals(1, capturedEvents.size()); EventMessage<?> eventOne = capturedEvents.get(0); assertFalse(eventOne instanceof DomainEventMessage); assertEquals("test2", eventOne.getPayload()); }
public static <T> Builder<T> builder(Class<T> aggregateType) { return new Builder<>(aggregateType); }
GenericJpaRepository extends LockingRepository<T, AnnotatedAggregate<T>> { public static <T> Builder<T> builder(Class<T> aggregateType) { return new Builder<>(aggregateType); } }
GenericJpaRepository extends LockingRepository<T, AnnotatedAggregate<T>> { public static <T> Builder<T> builder(Class<T> aggregateType) { return new Builder<>(aggregateType); } protected  GenericJpaRepository(Builder<T> builder); }
GenericJpaRepository extends LockingRepository<T, AnnotatedAggregate<T>> { public static <T> Builder<T> builder(Class<T> aggregateType) { return new Builder<>(aggregateType); } protected  GenericJpaRepository(Builder<T> builder); static Builder<T> builder(Class<T> aggregateType); void setForceFlushOnSave(boolean forceFlushOnSave); }
GenericJpaRepository extends LockingRepository<T, AnnotatedAggregate<T>> { public static <T> Builder<T> builder(Class<T> aggregateType) { return new Builder<>(aggregateType); } protected  GenericJpaRepository(Builder<T> builder); static Builder<T> builder(Class<T> aggregateType); void setForceFlushOnSave(boolean forceFlushOnSave);  }