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()));
}
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));
}
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);
}
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)));
}
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);
}
Aggregations