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));
}
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);
}
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);
}
}
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;
}
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);
}
Aggregations