use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class CassandraMessageRepository method saveMessage.
@Override
public void saveMessage(Message message, LengthOfTime lifetime) throws TException {
checkThat(message, lifetime).throwing(InvalidArgumentException.class).is(notNull());
Statement insertStatement = createInsertForMessage(message, lifetime);
Statement updateTotalMessagesByApp = createUpdateForMessageByApp(message);
Statement updateTotalMessageByTitle = createUpdateForMessageCounterByTitle(message);
try {
cassandra.execute(insertStatement);
LOG.debug("Successfully saved message in Cassandra with a lifetime of {}: {}", lifetime, message);
cassandra.executeAsync(updateTotalMessageByTitle);
cassandra.executeAsync(updateTotalMessagesByApp);
LOG.debug("Successfully Updated Total Message Counters for App {} and title {}", message.applicationId, message.title);
} catch (Exception ex) {
LOG.error("Failed to store message in Cassandra: {}", message, ex);
throw new OperationFailedException("Could save Message");
}
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class MeasuredUserRepositoryTest method testFindByGithubProfileWhenThrows.
@DontRepeat
@Test
public void testFindByGithubProfileWhenThrows() throws Exception {
when(delegate.findByGithubProfile(githubProfile)).thenThrow(new OperationFailedException());
assertThrows(() -> instance.findByGithubProfile(githubProfile)).isInstanceOf(OperationFailedException.class);
verify(delegate).findByGithubProfile(githubProfile);
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class MeasuredUserRepositoryTest method testSaveUserWhenThrows.
@Test
public void testSaveUserWhenThrows() throws Exception {
doThrow(new OperationFailedException()).when(delegate).saveUser(user);
assertThrows(() -> instance.saveUser(user)).isInstanceOf(OperationFailedException.class);
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class MeasuredApplicationRepositoryTest method testSearchByNameWhenThrows.
@Test
public void testSearchByNameWhenThrows() throws Exception {
when(delegate.searchByName(appName)).thenThrow(new OperationFailedException());
assertThrows(() -> instance.searchByName(appName)).isInstanceOf(OperationFailedException.class);
}
use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.
the class MeasuredApplicationRepositoryTest method testContainsApplicationWhenThrows.
@DontRepeat
@Test
public void testContainsApplicationWhenThrows() throws Exception {
when(delegate.containsApplication(appId)).thenThrow(new OperationFailedException());
assertThrows(() -> instance.containsApplication(appId)).isInstanceOf(OperationFailedException.class);
}
Aggregations