Search in sources :

Example 6 with Application

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

the class CassandraApplicationRepositoryTest method testGetById.

@Test
public void testGetById() throws Exception {
    ResultSet results = mock(ResultSet.class);
    when(results.one()).thenReturn(mockRow);
    when(session.execute(Mockito.any(Statement.class))).thenReturn(results);
    Application result = instance.getById(appId);
    verify(session).execute(captor.capture());
    Statement statementMade = captor.getValue();
    assertThat(statementMade, notNullValue());
    assertThat(result.applicationId, is(appId));
}
Also used : Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Example 7 with Application

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

the class CassandraFollowerRepositoryTest method testSaveFollowingWithBadArgs.

@Test
public void testSaveFollowingWithBadArgs() throws Exception {
    User emptyUser = new User();
    Application emptyApp = new Application();
    assertThrows(() -> instance.saveFollowing(emptyUser, app)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.saveFollowing(user, emptyApp)).isInstanceOf(InvalidArgumentException.class);
    User userWithBadId = user.setUserId(one(alphabeticString()));
    Application appWithBadId = app.setApplicationId(one(alphabeticString()));
    assertThrows(() -> instance.saveFollowing(userWithBadId, app)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.saveFollowing(user, appWithBadId)).isInstanceOf(InvalidArgumentException.class);
}
Also used : User(tech.aroma.thrift.User) Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Example 8 with Application

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

the class CassandraApplicationRepository method deleteApplication.

@Override
public void deleteApplication(String applicationId) throws TException {
    checkApplicationId(applicationId);
    //Must fetch the full Application first
    Application app = this.getById(applicationId);
    Statement statement = createDeleteStatementFor(app);
    try {
        cassandra.execute(statement);
        LOG.debug("Successfully deleted Application with ID {}", applicationId);
    } catch (Exception ex) {
        LOG.error("Failed to delete application with ID [{}] from Cassandra", applicationId, ex);
        throw new OperationFailedException("Could not delete Application with ID: " + applicationId);
    }
}
Also used : Application(tech.aroma.thrift.Application) TException(org.apache.thrift.TException)

Example 9 with Application

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

the class CassandraApplicationRepository method getById.

@Override
public Application getById(String applicationId) throws TException {
    checkApplicationId(applicationId);
    Statement query = createQueryForAppWithId(applicationId);
    ResultSet results;
    try {
        results = cassandra.execute(query);
    } catch (Exception ex) {
        LOG.error("Failed to query for application with ID {}", applicationId, ex);
        throw new OperationFailedException("Could not Query Application with ID: " + applicationId);
    }
    Row row = results.one();
    checkRowNotMissing(applicationId, row);
    Application app = createApplicationFromRow(row);
    return app;
}
Also used : Application(tech.aroma.thrift.Application) TException(org.apache.thrift.TException)

Example 10 with Application

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

the class MeasuredApplicationRepositoryTest method testGetById.

@Test
public void testGetById() throws Exception {
    when(delegate.getById(appId)).thenReturn(application);
    Application result = instance.getById(appId);
    assertThat(result, is(application));
    verify(delegate).getById(appId);
}
Also used : Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Aggregations

Application (tech.aroma.thrift.Application)22 Test (org.junit.Test)11 TException (org.apache.thrift.TException)6 IntegrationTest (tech.sirwellington.alchemy.annotations.testing.IntegrationTest)5 User (tech.aroma.thrift.User)3 StringGenerators.alphabeticString (tech.sirwellington.alchemy.generator.StringGenerators.alphabeticString)3 InvalidArgumentException (tech.aroma.thrift.exceptions.InvalidArgumentException)1 OperationFailedException (tech.aroma.thrift.exceptions.OperationFailedException)1