use of tech.aroma.thrift.Message in project aroma-data-operations by RedRoma.
the class CassandraMessageRepository method getByApplication.
@Override
public List<Message> getByApplication(String applicationId) throws TException {
checkAppId(applicationId);
Statement query = createQueryToFindMessagesByApplication(applicationId);
ResultSet results = tryToExecute(query, "Could not query for messages by 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 CassandraMessageRepository method getByHostname.
@Override
public List<Message> getByHostname(String hostname) throws TException {
checkThat(hostname).usingMessage("missing hostname").throwing(InvalidArgumentException.class).is(nonEmptyString()).is(stringWithLengthGreaterThanOrEqualTo(1));
Statement query = createQueryToFindMessageByHostname(hostname);
ResultSet results = tryToExecute(query, "Could not query for mesages by hostname: " + hostname);
List<Message> messages = Lists.create();
for (Row row : results) {
Message message = createMessageFromRow(row);
messages.add(message);
}
LOG.debug("Found {} messages by hostname {}", messages.size(), hostname);
return messages;
}
use of tech.aroma.thrift.Message in project aroma-data-operations by RedRoma.
the class CassandraMessageRepository method getMessage.
@Override
public Message getMessage(String applicationId, String messageId) throws TException {
checkMessageId(messageId);
checkAppId(applicationId);
Statement query = createQueryForMessageWithId(applicationId, messageId);
LOG.debug("Querying cassandra for message with ID [{}] and App [{}]", messageId, applicationId);
ResultSet results = tryToExecute(query, "Failed to query for message with ID: " + messageId);
Row row = results.one();
checkThat(row).throwing(MessageDoesNotExistException.class).usingMessage(format("No Message with App ID [%s] and Msg ID [%s]", applicationId, messageId)).is(notNull());
Message message = createMessageFromRow(row);
return message;
}
use of tech.aroma.thrift.Message in project aroma-data-operations by RedRoma.
the class CassandraInboxRepositoryIT method testGetMessagesForUser.
@Test
public void testGetMessagesForUser() throws Exception {
saveMessagesInInbox(messages);
List<Message> result = instance.getMessagesForUser(userId);
assertThat(result.size(), is(messages.size()));
for (Message m : result) {
assertThat(messageMapping.containsKey(m.messageId), is(true));
Message expected = messageMapping.get(m.messageId);
assertMostlySame(m, expected);
}
}
use of tech.aroma.thrift.Message in project aroma-data-operations by RedRoma.
the class RequestAssertionsTest method testValidMessageWithBadMessages.
@DontRepeat
@Test
public void testValidMessageWithBadMessages() {
AlchemyAssertion<Message> assertion = RequestAssertions.validMessage();
assertThrows(() -> assertion.check(null)).isInstanceOf(FailedAssertionException.class);
Message emptyMessage = new Message();
assertThrows(() -> assertion.check(emptyMessage)).isInstanceOf(FailedAssertionException.class);
Message messageWithoutTitle = emptyMessage.setMessageId(one(uuids));
assertThrows(() -> assertion.check(messageWithoutTitle)).isInstanceOf(FailedAssertionException.class);
Message messageWithInvalidId = new Message(message).setMessageId(invalidId);
assertThrows(() -> assertion.check(messageWithInvalidId)).isInstanceOf(FailedAssertionException.class);
Message messageWithInvalidAppId = new Message(message).setApplicationId(invalidId);
assertThrows(() -> assertion.check(messageWithInvalidAppId)).isInstanceOf(FailedAssertionException.class);
}
Aggregations