@Test public void testOrFromFactory() { Mockito.when(repository.get("1")) .thenReturn(Optional.of(order)); AggregateRoot<?> aggregateRoot = underTest.fromRepository() .orFromFactory(); Assertions.assertThat(aggregateRoot) .isNotNull(); Assertions.assertThat(aggregateRoot) .isEqualTo(order); Assertions.assertThat(((Order) aggregateRoot).getProduct()) .isEqualTo("lightsaber"); }
@Override public A orFromFactory() { return multipleMerger.orFromFactory() .asStream() .findFirst() .orElseThrow(() -> new IllegalStateException("Nothing to merge")); }
MergeSingleAggregateFromRepositoryImpl implements MergeFromRepository<A>,
        MergeFromRepositoryOrFactory<A> { @Override public A orFromFactory() { return multipleMerger.orFromFactory() .asStream() .findFirst() .orElseThrow(() -> new IllegalStateException("Nothing to merge")); } }
MergeSingleAggregateFromRepositoryImpl implements MergeFromRepository<A>,
        MergeFromRepositoryOrFactory<A> { @Override public A orFromFactory() { return multipleMerger.orFromFactory() .asStream() .findFirst() .orElseThrow(() -> new IllegalStateException("Nothing to merge")); } MergeSingleAggregateFromRepositoryImpl(Context context, D dto, Class<A> aggregateRootClass); }
MergeSingleAggregateFromRepositoryImpl implements MergeFromRepository<A>,
        MergeFromRepositoryOrFactory<A> { @Override public A orFromFactory() { return multipleMerger.orFromFactory() .asStream() .findFirst() .orElseThrow(() -> new IllegalStateException("Nothing to merge")); } MergeSingleAggregateFromRepositoryImpl(Context context, D dto, Class<A> aggregateRootClass); @Override MergeFromRepositoryOrFactory<A> fromRepository(); @Override MergeFromRepositoryOrFactory<A> fromRepository(Annotation qualifier); @Override MergeFromRepositoryOrFactory<A> fromRepository(String qualifier); @Override MergeFromRepositoryOrFactory<A> fromRepository(Class<? extends Annotation> qualifier); @Override A fromFactory(); @Override A fromFactory(Annotation qualifier); @Override A fromFactory(String qualifier); @Override A fromFactory(Class<? extends Annotation> qualifier); @Override A orFail(); @Override A orFromFactory(); @Override A orFromFactory(Annotation qualifier); @Override A orFromFactory(String qualifier); @Override A orFromFactory(Class<? extends Annotation> qualifier); }
MergeSingleAggregateFromRepositoryImpl implements MergeFromRepository<A>,
        MergeFromRepositoryOrFactory<A> { @Override public A orFromFactory() { return multipleMerger.orFromFactory() .asStream() .findFirst() .orElseThrow(() -> new IllegalStateException("Nothing to merge")); } MergeSingleAggregateFromRepositoryImpl(Context context, D dto, Class<A> aggregateRootClass); @Override MergeFromRepositoryOrFactory<A> fromRepository(); @Override MergeFromRepositoryOrFactory<A> fromRepository(Annotation qualifier); @Override MergeFromRepositoryOrFactory<A> fromRepository(String qualifier); @Override MergeFromRepositoryOrFactory<A> fromRepository(Class<? extends Annotation> qualifier); @Override A fromFactory(); @Override A fromFactory(Annotation qualifier); @Override A fromFactory(String qualifier); @Override A fromFactory(Class<? extends Annotation> qualifier); @Override A orFail(); @Override A orFromFactory(); @Override A orFromFactory(Annotation qualifier); @Override A orFromFactory(String qualifier); @Override A orFromFactory(Class<? extends Annotation> qualifier);  }