Java Code Examples for io.vlingo.actors.testkit.TestWorld#startWithDefaults()

The following examples show how to use io.vlingo.actors.testkit.TestWorld#startWithDefaults() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InMemoryStateStoreTest.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  testWorld = TestWorld.startWithDefaults("test-store");
  world = testWorld.world();

  interest = new MockStateStoreResultInterest();
  dispatcher = new MockStateStoreDispatcher(interest);

  dispatcher.afterCompleting(0); // avoid NPE

  final StateAdapterProvider stateAdapterProvider = new StateAdapterProvider(world);
  new EntryAdapterProvider(world);

  stateAdapterProvider.registerAdapter(Entity1.class, new Entity1StateAdapter());
  // NOTE: No adapter registered for Entity2.class because it will use the default

  store = world.actorFor(StateStore.class, InMemoryStateStoreActor.class, Arrays.asList(dispatcher));

  StateTypeStateStoreMap.stateTypeToStoreName(Entity1.class, StoreName1);
  StateTypeStateStoreMap.stateTypeToStoreName(Entity2.class, StoreName2);
}
 
Example 2
Source File: InMemoryStateStoreEntryReaderActorTest.java    From vlingo-symbio with Mozilla Public License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  testWorld = TestWorld.startWithDefaults("test-store");
  world = testWorld.world();

  interest = new MockStateStoreResultInterest();
  dispatcher = new MockStateStoreDispatcher(interest);

  final StateAdapterProvider stateAdapterProvider = new StateAdapterProvider(world);
  entryAdapterProvider = new EntryAdapterProvider(world);

  stateAdapterProvider.registerAdapter(Entity1.class, new Entity1StateAdapter());
  // NOTE: No adapter registered for Entity2.class because it will use the default

  store = world.actorFor(StateStore.class, InMemoryStateStoreActor.class, Arrays.asList(dispatcher));

  final Completes<StateStoreEntryReader<TextEntry>> completes = store.entryReader("test");
  reader = completes.await();

  StateTypeStateStoreMap.stateTypeToStoreName(Entity1.class, Entity1.class.getSimpleName());
  StateTypeStateStoreMap.stateTypeToStoreName(Entity2.class, Entity2.class.getSimpleName());
}
 
Example 3
Source File: EventSourcedTest.java    From vlingo-lattice with Mozilla Public License 2.0 6 votes vote down vote up
@Before
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setUp() {
  testWorld = TestWorld.startWithDefaults("test-es");

  world = testWorld.world();

  dispatcher = new MockJournalDispatcher();

  EntryAdapterProvider entryAdapterProvider = EntryAdapterProvider.instance(world);

  entryAdapterProvider.registerAdapter(Test1Happened.class, new Test1HappenedAdapter());
  entryAdapterProvider.registerAdapter(Test2Happened.class, new Test2HappenedAdapter());
  entryAdapterProvider.registerAdapter(Test3Happened.class, new Test3HappenedAdapter());

  journal = world.actorFor(Journal.class, InMemoryJournalActor.class, dispatcher);

  registry = new SourcedTypeRegistry(world);
  registry.register(new Info(journal, TestEventSourcedEntity.class, TestEventSourcedEntity.class.getSimpleName()));
  registry.register(new Info(journal, ProductEntity.class, ProductEntity.class.getSimpleName()));
  registry.register(new Info(journal, ProductParent.class, ProductParent.class.getSimpleName()));
  registry.register(new Info(journal, ProductGrandparent.class, ProductGrandparent.class.getSimpleName()));

  result = new Result();
  entity = world.actorFor(Entity.class, TestEventSourcedEntity.class, result);
}
 
Example 4
Source File: EntityTest.java    From vlingo-examples with Mozilla Public License 2.0 5 votes vote down vote up
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
  testWorld = TestWorld.startWithDefaults("entity-test");
  world = testWorld.world();
  journalDispatcher = new MockJournalDispatcher();
  journal = world.actorFor(Journal.class, InMemoryJournalActor.class, journalDispatcher);
  registry = new SourcedTypeRegistry(world);
  SourcedRegistration.registerAllWith(registry, journal);
}
 
Example 5
Source File: EntityTest.java    From vlingo-examples with Mozilla Public License 2.0 5 votes vote down vote up
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
  testWorld = TestWorld.startWithDefaults("entity-test");
  world = testWorld.world();
  journalDispatcher = new MockJournalDispatcher();
  journal = world.actorFor(Journal.class, InMemoryJournalActor.class, journalDispatcher);
  registry = new SourcedTypeRegistry(world);
  SourcedRegistration.registerAllWith(registry, journal);
}