Search in sources :

Example 1 with OperationFailedException

use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.

the class MeasuredUserRepositoryTest method testContainsUserWhenThrows.

@DontRepeat
@Test
public void testContainsUserWhenThrows() throws Exception {
    when(delegate.containsUser(userId)).thenThrow(new OperationFailedException());
    assertThrows(() -> instance.containsUser(userId)).isInstanceOf(OperationFailedException.class);
    verify(delegate).containsUser(userId);
}
Also used : OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Test(org.junit.Test) DontRepeat(tech.sirwellington.alchemy.test.junit.runners.DontRepeat)

Example 2 with OperationFailedException

use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.

the class MeasuredUserRepositoryTest method testGetUserWhenThrows.

@DontRepeat
@Test
public void testGetUserWhenThrows() throws Exception {
    when(delegate.getUser(userId)).thenThrow(new OperationFailedException());
    assertThrows(() -> instance.getUser(userId)).isInstanceOf(OperationFailedException.class);
}
Also used : OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Test(org.junit.Test) DontRepeat(tech.sirwellington.alchemy.test.junit.runners.DontRepeat)

Example 3 with OperationFailedException

use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.

the class MeasuredApplicationRepositoryTest method testSaveApplicationWhenThrows.

@DontRepeat
@Test
public void testSaveApplicationWhenThrows() throws Exception {
    doThrow(new OperationFailedException()).when(delegate).saveApplication(application);
    assertThrows(() -> instance.saveApplication(application)).isInstanceOf(OperationFailedException.class);
    verify(delegate).saveApplication(application);
}
Also used : OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Test(org.junit.Test) DontRepeat(tech.sirwellington.alchemy.test.junit.runners.DontRepeat)

Example 4 with OperationFailedException

use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.

the class MeasuredApplicationRepositoryTest method testGetRecentlyCreatedWhenThrows.

@DontRepeat
@Test
public void testGetRecentlyCreatedWhenThrows() throws Exception {
    when(delegate.getRecentlyCreated()).thenThrow(new OperationFailedException());
    assertThrows(() -> instance.getRecentlyCreated()).isInstanceOf(OperationFailedException.class);
}
Also used : OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Test(org.junit.Test) DontRepeat(tech.sirwellington.alchemy.test.junit.runners.DontRepeat)

Example 5 with OperationFailedException

use of tech.aroma.thrift.exceptions.OperationFailedException in project aroma-data-operations by RedRoma.

the class CassandraInboxRepository method countInboxForUser.

@Override
public long countInboxForUser(String userId) throws TException {
    checkUserId(userId);
    Statement query = createQueryToCountMessagesFor(userId);
    ResultSet results;
    try {
        results = cassandra.execute(query);
    } catch (Exception ex) {
        LOG.error("Failed to count total messages for User [{}]", userId, ex);
        throw new OperationFailedException("Could not count messags for user: " + ex.getMessage());
    }
    Row row = results.one();
    checkThat(row).throwing(OperationFailedException.class).usingMessage("Query for message failed").is(notNull());
    long count = row.getLong(0);
    return count;
}
Also used : Statement(com.datastax.driver.core.Statement) ResultSet(com.datastax.driver.core.ResultSet) OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Row(com.datastax.driver.core.Row) TException(org.apache.thrift.TException) InvalidArgumentException(tech.aroma.thrift.exceptions.InvalidArgumentException) OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException)

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