Search in sources :

Example 6 with InMemoryEventClient

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"))));
}
Also used : InMemoryEventClient(io.airlift.event.client.InMemoryEventClient) Test(org.testng.annotations.Test)

Example 7 with InMemoryEventClient

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());
}
Also used : InMemoryEventClient(io.airlift.event.client.InMemoryEventClient) Test(org.testng.annotations.Test)

Example 8 with InMemoryEventClient

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"))));
}
Also used : InMemoryEventClient(io.airlift.event.client.InMemoryEventClient) Test(org.testng.annotations.Test)

Example 9 with InMemoryEventClient

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);
}
Also used : InMemoryEventClient(io.airlift.event.client.InMemoryEventClient) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 10 with InMemoryEventClient

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"))));
}
Also used : InMemoryEventClient(io.airlift.event.client.InMemoryEventClient) Test(org.testng.annotations.Test)

Aggregations

InMemoryEventClient (io.airlift.event.client.InMemoryEventClient)14 Test (org.testng.annotations.Test)13 DoubleSummaryStatistics (java.util.DoubleSummaryStatistics)6 Request (org.eclipse.jetty.server.Request)6 Response (org.eclipse.jetty.server.Response)6 TraceTokenManager (io.airlift.tracetoken.TraceTokenManager)2 Duration (io.airlift.units.Duration)1 Principal (java.security.Principal)1 HttpURI (org.eclipse.jetty.http.HttpURI)1 BeforeMethod (org.testng.annotations.BeforeMethod)1