use of io.spine.server.Given.CustomerAggregateRepository in project core-java by SpineEventEngine.
the class StandShould method register_aggregate_repositories.
@Test
public void register_aggregate_repositories() {
final BoundedContext boundedContext = BoundedContext.newBuilder().build();
final Stand stand = boundedContext.getStand();
checkTypesEmpty(stand);
final CustomerAggregateRepository customerAggregateRepo = new CustomerAggregateRepository();
stand.registerTypeSupplier(customerAggregateRepo);
final Descriptors.Descriptor customerEntityDescriptor = Customer.getDescriptor();
checkHasExactlyOne(stand.getExposedTypes(), customerEntityDescriptor);
checkHasExactlyOne(stand.getExposedAggregateTypes(), customerEntityDescriptor);
@SuppressWarnings("LocalVariableNamingConvention") final CustomerAggregateRepository anotherCustomerAggregateRepo = new CustomerAggregateRepository();
stand.registerTypeSupplier(anotherCustomerAggregateRepo);
checkHasExactlyOne(stand.getExposedTypes(), customerEntityDescriptor);
checkHasExactlyOne(stand.getExposedAggregateTypes(), customerEntityDescriptor);
}
use of io.spine.server.Given.CustomerAggregateRepository in project core-java by SpineEventEngine.
the class StandShould method operate_with_storage_provided_through_builder.
@SuppressWarnings("OverlyCoupledMethod")
@Test
public void operate_with_storage_provided_through_builder() {
final StandStorage standStorageMock = mock(StandStorage.class);
final BoundedContext boundedContext = BoundedContext.newBuilder().setStand(Stand.newBuilder().setStorage(standStorageMock)).build();
final Stand stand = boundedContext.getStand();
assertNotNull(stand);
final CustomerAggregateRepository customerAggregateRepo = new CustomerAggregateRepository();
stand.registerTypeSupplier(customerAggregateRepo);
final int numericIdValue = 17;
final CustomerId customerId = customerIdFor(numericIdValue);
final CustomerAggregate customerAggregate = customerAggregateRepo.create(customerId);
final Customer customerState = customerAggregate.getState();
final TypeUrl customerType = TypeUrl.of(Customer.class);
final Version stateVersion = GivenVersion.withNumber(1);
verify(standStorageMock, never()).write(any(AggregateStateId.class), any(EntityRecordWithColumns.class));
stand.update(asEnvelope(customerId, customerState, stateVersion));
final AggregateStateId expectedAggregateStateId = AggregateStateId.of(customerId, customerType);
final Any packedState = AnyPacker.pack(customerState);
final EntityRecord expectedRecord = EntityRecord.newBuilder().setState(packedState).build();
verify(standStorageMock, times(1)).write(eq(expectedAggregateStateId), recordStateMatcher(expectedRecord));
}
use of io.spine.server.Given.CustomerAggregateRepository in project core-java by SpineEventEngine.
the class StandShould method prepareStandWithAggregateRepo.
protected Stand prepareStandWithAggregateRepo(StandStorage standStorage) {
final BoundedContext boundedContext = BoundedContext.newBuilder().setMultitenant(multitenant).setStand(Stand.newBuilder().setStorage(standStorage)).build();
final Stand stand = boundedContext.getStand();
assertNotNull(stand);
final CustomerAggregateRepository customerAggregateRepo = new CustomerAggregateRepository();
stand.registerTypeSupplier(customerAggregateRepo);
final StandTestProjectionRepository projectProjectionRepo = new StandTestProjectionRepository();
stand.registerTypeSupplier(projectProjectionRepo);
return stand;
}
Aggregations