use of io.spine.server.BoundedContext in project core-java by SpineEventEngine.
the class BoundedContextShould method propagate_registered_repositories_to_stand.
@Test
public void propagate_registered_repositories_to_stand() {
final BoundedContext boundedContext = BoundedContext.newBuilder().build();
final Stand stand = Spy.ofClass(Stand.class).on(boundedContext);
verify(stand, never()).registerTypeSupplier(any(Repository.class));
final ProjectAggregateRepository repository = new ProjectAggregateRepository(boundedContext);
boundedContext.register(repository);
verify(stand).registerTypeSupplier(eq(repository));
}
use of io.spine.server.BoundedContext in project core-java by SpineEventEngine.
the class BoundedContextShould method set_multi_tenancy_in_CommandBus.
@Test
public void set_multi_tenancy_in_CommandBus() {
BoundedContext bc = BoundedContext.newBuilder().setMultitenant(true).build();
assertEquals(bc.isMultitenant(), bc.getCommandBus().isMultitenant());
bc = BoundedContext.newBuilder().setMultitenant(false).build();
assertEquals(bc.isMultitenant(), bc.getCommandBus().isMultitenant());
}
use of io.spine.server.BoundedContext in project core-java by SpineEventEngine.
the class StandPostShould method projectionRepositoryDispatch.
private static BoundedContextAction projectionRepositoryDispatch() {
return new BoundedContextAction() {
@Override
public void perform(BoundedContext context) {
// Init repository
final ProjectionRepository repository = Given.projectionRepo(context);
repository.initStorage(storageFactory(context.isMultitenant()));
// Dispatch an update from projection repo
repository.dispatch(EventEnvelope.of(Given.validEvent()));
}
};
}
use of io.spine.server.BoundedContext in project core-java by SpineEventEngine.
the class StandPostShould method checkUpdatesDelivery.
private static void checkUpdatesDelivery(boolean isConcurrent, BoundedContextAction... dispatchActions) {
checkNotNull(dispatchActions);
final Executor executor = isConcurrent ? Executors.newFixedThreadPool(Given.THREADS_COUNT_IN_POOL_EXECUTOR) : MoreExecutors.directExecutor();
final StandUpdateDelivery delivery = spy(new SpyableStandUpdateDelivery(executor));
final BoundedContext boundedContext = BoundedContext.newBuilder().setStand(Stand.newBuilder().setDelivery(delivery)).build();
final Stand stand = boundedContext.getStand();
for (BoundedContextAction dispatchAction : dispatchActions) {
dispatchAction.perform(boundedContext);
}
// Was called as many times as there are dispatch actions.
verify(delivery, times(dispatchActions.length)).deliver(any(EntityStateEnvelope.class));
if (isConcurrent) {
try {
((ExecutorService) executor).awaitTermination(Given.SEVERAL, TimeUnit.SECONDS);
} catch (InterruptedException ignored) {
}
}
verify(stand, times(dispatchActions.length)).update(any(EntityStateEnvelope.class));
}
use of io.spine.server.BoundedContext in project core-java by SpineEventEngine.
the class StandShould method register_projection_repositories.
@Test
public void register_projection_repositories() {
final boolean multitenant = isMultitenant();
final BoundedContext boundedContext = BoundedContext.newBuilder().setMultitenant(multitenant).build();
final Stand stand = boundedContext.getStand();
checkTypesEmpty(stand);
final StandTestProjectionRepository standTestProjectionRepo = new StandTestProjectionRepository(boundedContext);
stand.registerTypeSupplier(standTestProjectionRepo);
checkHasExactlyOne(stand.getExposedTypes(), Project.getDescriptor());
final ImmutableSet<TypeUrl> knownAggregateTypes = stand.getExposedAggregateTypes();
// As we registered a projection repo, known aggregate types should be still empty.
assertTrue("For some reason an aggregate type was registered", knownAggregateTypes.isEmpty());
final StandTestProjectionRepository anotherTestProjectionRepo = new StandTestProjectionRepository(boundedContext);
stand.registerTypeSupplier(anotherTestProjectionRepo);
checkHasExactlyOne(stand.getExposedTypes(), Project.getDescriptor());
}
Aggregations