Search in sources :

Example 36 with OperationFailedException

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");
    }
}
Also used : InvalidArgumentException(tech.aroma.thrift.exceptions.InvalidArgumentException) Statement(com.datastax.driver.core.Statement) OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) MessageDoesNotExistException(tech.aroma.thrift.exceptions.MessageDoesNotExistException) TException(org.apache.thrift.TException) InvalidArgumentException(tech.aroma.thrift.exceptions.InvalidArgumentException) OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException)

Example 37 with OperationFailedException

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);
}
Also used : OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Test(org.junit.Test) DontRepeat(tech.sirwellington.alchemy.test.junit.runners.DontRepeat)

Example 38 with OperationFailedException

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);
}
Also used : OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Test(org.junit.Test)

Example 39 with OperationFailedException

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);
}
Also used : OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Test(org.junit.Test)

Example 40 with OperationFailedException

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);
}
Also used : OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Test(org.junit.Test) DontRepeat(tech.sirwellington.alchemy.test.junit.runners.DontRepeat)

Aggregations

OperationFailedException (tech.aroma.thrift.exceptions.OperationFailedException)40 TException (org.apache.thrift.TException)32 InvalidArgumentException (tech.aroma.thrift.exceptions.InvalidArgumentException)32 Statement (com.datastax.driver.core.Statement)29 ResultSet (com.datastax.driver.core.ResultSet)19 Row (com.datastax.driver.core.Row)17 BatchStatement (com.datastax.driver.core.BatchStatement)13 OrganizationDoesNotExistException (tech.aroma.thrift.exceptions.OrganizationDoesNotExistException)9 Test (org.junit.Test)8 ApplicationDoesNotExistException (tech.aroma.thrift.exceptions.ApplicationDoesNotExistException)7 RequestAssertions.validApplication (tech.aroma.data.assertions.RequestAssertions.validApplication)6 Application (tech.aroma.thrift.Application)6 DontRepeat (tech.sirwellington.alchemy.test.junit.runners.DontRepeat)6 RequestAssertions.validUser (tech.aroma.data.assertions.RequestAssertions.validUser)4 User (tech.aroma.thrift.User)4 RequestAssertions.validMessage (tech.aroma.data.assertions.RequestAssertions.validMessage)2 Message (tech.aroma.thrift.Message)2 InvalidTokenException (tech.aroma.thrift.exceptions.InvalidTokenException)2 MessageDoesNotExistException (tech.aroma.thrift.exceptions.MessageDoesNotExistException)2 Session (com.datastax.driver.core.Session)1