AggregateRepository extends CommonAggregateRepository<T, CT> { public CompletableFuture<EntityWithIdAndVersion<T>> save(CT cmd) { return save(cmd, Optional.empty()); } AggregateRepository(Class<T> clasz, EventuateAggregateStore aggregateStore); CompletableFuture<EntityWithIdAndVersion<T>> save(CT cmd); CompletableFuture<EntityWithIdAndVersion<T>> save(CT cmd, Optional<SaveOptions> saveOptions); CompletableFuture<EntityWithIdAndVersion<T>> update(String entityId, final CT cmd); CompletableFuture<EntityWithIdAndVersion<T>> update(final String entityId, final CT cmd, Optional<UpdateOptions> updateOptions); CompletableFuture<EntityWithIdAndVersion<T>> updateWithProvidedCommand(final String entityId, final Function<T, Optional<CT>> commandProvider, Optional<UpdateOptions> updateOptions); CompletableFuture<EntityWithMetadata<T>> find(String entityId); CompletableFuture<EntityWithMetadata<T>> find(String entityId, FindOptions findOptions); CompletableFuture<EntityWithMetadata<T>> find(String entityId, Optional<FindOptions> findOptions);  }
@Test public void shouldSave() throws ExecutionException, InterruptedException { when(aggregateStore.save(Account.class, creationEvents, Optional.empty())) .thenReturn(CompletableFuture.completedFuture(entityIdAndVersion)); EntityWithIdAndVersion<Account> ewidv = repository.save(new CreateAccountCommand(INITIAL_BALANCE), Optional.empty()).get(); assertEquals(entityId, ewidv.getEntityIdAndVersion().getEntityId()); assertEquals(createdEntityVersion, ewidv.getEntityIdAndVersion().getEntityVersion()); assertEquals(INITIAL_BALANCE, ewidv.getAggregate().getBalance()); verify(aggregateStore).save(Account.class, creationEvents, Optional.empty()); verifyNoMoreInteractions(aggregateStore); }