use of io.spine.server.storage.StorageFactory in project core-java by SpineEventEngine.
the class ProcessManagerShould method setUp.
@Before
public void setUp() {
final StorageFactory storageFactory = StorageFactorySwitch.get(true);
final TenantIndex tenantIndex = TenantAwareTest.createTenantIndex(false, storageFactory);
final CommandStore commandStore = spy(new CommandStore(storageFactory, tenantIndex));
commandBus = spy(CommandBus.newBuilder().setCommandStore(commandStore).build());
processManager = Given.processManagerOfClass(TestProcessManager.class).withId(ID).withVersion(2).withState(Any.getDefaultInstance()).build();
}
use of io.spine.server.storage.StorageFactory in project core-java by SpineEventEngine.
the class StorageFactorySwitchShould method return_InMemoryStorageFactory_in_tests_if_tests_supplier_was_not_set.
@Test
public void return_InMemoryStorageFactory_in_tests_if_tests_supplier_was_not_set() {
final StorageFactory storageFactory = storageFactorySwitch.get();
assertNotNull(storageFactory);
assertTrue(storageFactory instanceof InMemoryStorageFactory);
}
use of io.spine.server.storage.StorageFactory in project core-java by SpineEventEngine.
the class StorageFactorySwitchShould method return_custom_test_StorageFactory_if_supplier_for_tests_was_set.
@Test
public void return_custom_test_StorageFactory_if_supplier_for_tests_was_set() {
// This call avoids the racing conditions anomaly when running
// the Gradle build from the console.
// Despite the fact that we reset the switch state in `cleanUp()`, we still
// get the cached value of the StorageFactory remembered by the switch in a previous test.
// Having this call avoids the problem.
storageFactorySwitch.reset();
final StorageFactory custom = mock(StorageFactory.class);
storageFactorySwitch.init(testsSupplier, new Supplier<StorageFactory>() {
@Override
public StorageFactory get() {
return custom;
}
});
// These calls ensure that we're under the testing mode and we get the supplier for tests.
assertTrue(Environment.getInstance().isTests());
assertTrue(storageFactorySwitch.testsSupplier().isPresent());
// Get the StorageFactory from the switch.
final StorageFactory obtained = storageFactorySwitch.get();
assertEquals(custom, obtained);
}
use of io.spine.server.storage.StorageFactory in project core-java by SpineEventEngine.
the class BoundedContextShould method not_change_storage_during_registration_if_a_repository_has_one.
@Test
public void not_change_storage_during_registration_if_a_repository_has_one() {
final ProjectAggregateRepository repository = new ProjectAggregateRepository(boundedContext);
repository.initStorage(storageFactory);
final Repository spy = spy(repository);
boundedContext.register(repository);
verify(spy, never()).initStorage(any(StorageFactory.class));
}
Aggregations