use of io.airlift.event.client.InMemoryEventClient in project airlift by airlift.
the class TestPersonStore method testIdempotentPut.
@Test
public void testIdempotentPut() {
InMemoryEventClient eventClient = new InMemoryEventClient();
PersonStore store = new PersonStore(new StoreConfig(), eventClient);
store.put("foo", new Person("foo@example.com", "Mr Foo"));
store.put("foo", new Person("foo@example.com", "Mr Bar"));
assertEquals(new Person("foo@example.com", "Mr Bar"), store.get("foo"));
assertEquals(store.getAll().size(), 1);
assertEquals(eventClient.getEvents(), ImmutableList.of(personAdded("foo", new Person("foo@example.com", "Mr Foo")), personUpdated("foo", new Person("foo@example.com", "Mr Bar"))));
}
use of io.airlift.event.client.InMemoryEventClient in project airlift by airlift.
the class TestPersonStore method testStartsEmpty.
@Test
public void testStartsEmpty() {
PersonStore store = new PersonStore(new StoreConfig(), new InMemoryEventClient());
assertTrue(store.getAll().isEmpty());
}
use of io.airlift.event.client.InMemoryEventClient in project airlift by airlift.
the class TestPersonStore method testDelete.
@Test
public void testDelete() {
InMemoryEventClient eventClient = new InMemoryEventClient();
PersonStore store = new PersonStore(new StoreConfig(), eventClient);
store.put("foo", new Person("foo@example.com", "Mr Foo"));
store.delete("foo");
assertNull(store.get("foo"));
assertTrue(store.getAll().isEmpty());
assertEquals(eventClient.getEvents(), ImmutableList.of(personAdded("foo", new Person("foo@example.com", "Mr Foo")), personRemoved("foo", new Person("foo@example.com", "Mr Foo"))));
}
use of io.airlift.event.client.InMemoryEventClient in project airlift by airlift.
the class TestPersonResource method setup.
@BeforeMethod
public void setup() {
eventClient = new InMemoryEventClient();
store = new PersonStore(new StoreConfig(), eventClient);
resource = new PersonResource(store);
}
use of io.airlift.event.client.InMemoryEventClient in project airlift by airlift.
the class TestPersonStore method testIdempotentDelete.
@Test
public void testIdempotentDelete() {
InMemoryEventClient eventClient = new InMemoryEventClient();
PersonStore store = new PersonStore(new StoreConfig(), eventClient);
store.put("foo", new Person("foo@example.com", "Mr Foo"));
store.delete("foo");
assertTrue(store.getAll().isEmpty());
assertNull(store.get("foo"));
store.delete("foo");
assertTrue(store.getAll().isEmpty());
assertNull(store.get("foo"));
assertEquals(eventClient.getEvents(), ImmutableList.of(personAdded("foo", new Person("foo@example.com", "Mr Foo")), personRemoved("foo", new Person("foo@example.com", "Mr Foo"))));
}
Aggregations