use of tech.aroma.thrift.Message in project aroma-data-operations by RedRoma.
the class CassandraMessageRepository method getByTitle.
@Override
public List<Message> getByTitle(String applicationId, String title) throws TException {
checkAppId(applicationId);
checkTitle(title);
Statement query = createQueryToFindMessagesByTitle(title);
ResultSet results = tryToExecute(query, "Could not get messages by Title: " + title + ", App: " + applicationId);
List<Message> messages = Lists.create();
for (Row row : results) {
Message message = createMessageFromRow(row);
messages.add(message);
}
LOG.debug("Found {} messages by app with ID [{}]", messages.size(), applicationId);
return messages;
}
use of tech.aroma.thrift.Message in project aroma-data-operations by RedRoma.
the class MemoryInboxRepository method saveMessageForUser.
@Override
public void saveMessageForUser(@Required User user, @Required Message message, @Required LengthOfTime lifetime) throws TException {
checkThat(message).throwing(InvalidArgumentException.class).is(validMessage());
checkThat(user).throwing(InvalidArgumentException.class).is(validUser());
String userId = user.userId;
List<Message> messages = messagesForUser.getOrDefault(userId, Lists.create());
messages.add(message);
messagesForUser.put(userId, messages);
}
use of tech.aroma.thrift.Message in project aroma-data-operations by RedRoma.
the class CassandraMessageRepositoryIT method testGetMessage.
@Test
public void testGetMessage() throws Exception {
instance.saveMessage(message, MESSAGE_LIFETIME);
Message result = instance.getMessage(appId, msgId);
assertMessagesMostlyMatch(result, message);
}
use of tech.aroma.thrift.Message in project aroma-data-operations by RedRoma.
the class MemoryMessageRepositoryTest method testGetByTitleWhenApplicationIdDoesNotMatch.
@Test
public void testGetByTitleWhenApplicationIdDoesNotMatch() throws Exception {
messages.forEach(msg -> msg.setTitle(title));
saveMessages(messages);
String otherAppId = one(uuids);
List<Message> result = instance.getByTitle(otherAppId, title);
assertThat(result, is(empty()));
}
use of tech.aroma.thrift.Message in project aroma-data-operations by RedRoma.
the class MemoryMessageRepositoryTest method testSaveMessage.
@Test
public void testSaveMessage() throws Exception {
instance.saveMessage(message);
assertThat(instance.containsMessage(applicationId, messageId), is(true));
assertThrows(() -> instance.saveMessage(null)).isInstanceOf(InvalidArgumentException.class);
assertThrows(() -> instance.saveMessage(new Message())).isInstanceOf(InvalidArgumentException.class);
}
Aggregations