Search in sources :

Example 1 with Event

use of tech.aroma.thrift.events.Event in project aroma-data-operations by RedRoma.

the class CassandraActivityRepositoryTest method testGetAllEventsFor.

@Test
public void testGetAllEventsFor() throws Exception {
    List<Event> events = listOf(events());
    List<Row> rows = Lists.create();
    Map<Row, Event> rowMap = Maps.create();
    for (Event event : events) {
        Row row = mock(Row.class);
        when(eventMapper.apply(row)).thenReturn(event);
        rows.add(row);
        rowMap.put(row, event);
    }
    when(results.iterator()).thenReturn(rows.iterator());
    when(results.all()).thenReturn(rows);
    List<Event> response = instance.getAllEventsFor(user);
    assertThat(response, is(events));
}
Also used : Event(tech.aroma.thrift.events.Event) Test(org.junit.Test)

Example 2 with Event

use of tech.aroma.thrift.events.Event in project aroma-data-operations by RedRoma.

the class CassandraActivityRepositoryTest method testGetEvent.

@Test
public void testGetEvent() throws Exception {
    Event result = instance.getEvent(eventId, user);
    assertThat(result, is(event));
    verify(session).execute(captor.capture());
    Statement statement = captor.getValue();
    assertThat(statement, notNullValue());
    assertThat(statement, is(instanceOf(Select.Where.class)));
}
Also used : Event(tech.aroma.thrift.events.Event) Test(org.junit.Test)

Example 3 with Event

use of tech.aroma.thrift.events.Event in project aroma-data-operations by RedRoma.

the class CassandraActivityRepository method mapRowToEvent.

private Event mapRowToEvent(Row row) throws DoesNotExistException {
    if (row == null) {
        return new Event();
    }
    Event event = eventMapper.apply(row);
    checkThat(event).usingMessage("event does not exist").throwing(DoesNotExistException.class).is(notNull());
    return event;
}
Also used : Event(tech.aroma.thrift.events.Event)

Example 4 with Event

use of tech.aroma.thrift.events.Event in project aroma-data-operations by RedRoma.

the class MemoryActivityRepositoryTest method testGetEvent.

@Test
public void testGetEvent() throws Exception {
    instance.saveEvent(event, user);
    Event result = instance.getEvent(eventId, user);
    assertThat(result, is(event));
}
Also used : Event(tech.aroma.thrift.events.Event) Test(org.junit.Test)

Example 5 with Event

use of tech.aroma.thrift.events.Event in project aroma-data-operations by RedRoma.

the class MemoryActivityRepositoryTest method testDeleteAllEventsFor.

@Test
public void testDeleteAllEventsFor() throws Exception {
    for (Event e : events) {
        instance.saveEvent(e, user);
    }
    instance.deleteAllEventsFor(user);
    assertThat(instance.getAllEventsFor(user), is(empty()));
}
Also used : Event(tech.aroma.thrift.events.Event) Test(org.junit.Test)

Aggregations

Event (tech.aroma.thrift.events.Event)11 Test (org.junit.Test)7 User (tech.aroma.thrift.User)2 IntegrationTest (tech.sirwellington.alchemy.annotations.testing.IntegrationTest)2 Row (com.datastax.driver.core.Row)1 RequestAssertions.validUser (tech.aroma.data.assertions.RequestAssertions.validUser)1