Search in sources :

Example 6 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)

Example 7 with Event

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

the class MappersTest method testEventMapper.

@Test
public void testEventMapper() throws TException {
    Function<Row, Event> instance = Mappers.eventMapper();
    assertThat(instance, notNullValue());
    Row eventRow = rowFor(event);
    Event result = instance.apply(eventRow);
    assertThat(result, is(event));
}
Also used : Event(tech.aroma.thrift.events.Event) Row(com.datastax.driver.core.Row) Test(org.junit.Test)

Example 8 with Event

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

the class CassandraActivityRepositoryTest method testSaveEventWithBadArgs.

@Test
public void testSaveEventWithBadArgs() throws Exception {
    assertThrows(() -> instance.saveEvent(null, user)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.saveEvent(event, null)).isInstanceOf(InvalidArgumentException.class);
    User userMissingId = new User();
    assertThrows(() -> instance.saveEvent(event, userMissingId)).isInstanceOf(InvalidArgumentException.class);
    Event eventMissingId = new Event(event);
    eventMissingId.unsetEventId();
    assertThrows(() -> instance.saveEvent(eventMissingId, user)).isInstanceOf(InvalidArgumentException.class);
    User userWithBadId = new User(user).setUserId(badId);
    assertThrows(() -> instance.saveEvent(event, userWithBadId)).isInstanceOf(InvalidArgumentException.class);
    Event eventWithBadId = new Event(event).setEventId(badId);
    assertThrows(() -> instance.saveEvent(eventWithBadId, user)).isInstanceOf(InvalidArgumentException.class);
}
Also used : User(tech.aroma.thrift.User) Event(tech.aroma.thrift.events.Event) Test(org.junit.Test)

Example 9 with Event

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

the class CassandraActivityRepositoryIT method testGetAllEventsFor.

@Test
public void testGetAllEventsFor() throws Exception {
    for (Event event : events) {
        instance.saveEvent(event, user);
    }
    List<Event> result = instance.getAllEventsFor(user);
    result.forEach(e -> assertThat(e, isIn(events)));
    events.forEach(e -> assertThat(e, isIn(result)));
}
Also used : Event(tech.aroma.thrift.events.Event) IntegrationTest(tech.sirwellington.alchemy.annotations.testing.IntegrationTest)

Example 10 with Event

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

the class MemoryActivityRepository method saveEvent.

@Override
public void saveEvent(Event event, User forUser, LengthOfTime lifetime) throws TException {
    checkEvent(event);
    checkUser(forUser);
    checkLifetime(lifetime);
    User user = forUser;
    List<Event> eventsForUser = events.getOrDefault(user, Lists.create());
    eventsForUser.add(event);
    events.put(user, eventsForUser);
}
Also used : RequestAssertions.validUser(tech.aroma.data.assertions.RequestAssertions.validUser) User(tech.aroma.thrift.User) Event(tech.aroma.thrift.events.Event)

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