Search in sources :

Example 11 with Application

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

the class MemoryApplicationRepositoryTest method testSaveApplication.

@Test
public void testSaveApplication() throws Exception {
    instance.saveApplication(app);
    Application result = instance.getById(appId);
    assertThat(result, is(app));
}
Also used : Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Example 12 with Application

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

the class MemoryApplicationRepositoryTest method testGetApplicationOwnedByWhenNoneOwned.

@DontRepeat
@Test
public void testGetApplicationOwnedByWhenNoneOwned() throws Exception {
    User user = one(pojos(User.class));
    List<Application> result = instance.getApplicationsOwnedBy(user.userId);
    assertThat(result, notNullValue());
    assertThat(result, is(empty()));
}
Also used : User(tech.aroma.thrift.User) Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Example 13 with Application

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

the class MemoryApplicationRepositoryTest method testSaveApplicationWithBadArguments.

@DontRepeat
@Test
public void testSaveApplicationWithBadArguments() throws Exception {
    assertThrows(() -> instance.saveApplication(null)).isInstanceOf(InvalidArgumentException.class);
    Application emptyApplication = new Application();
    assertThrows(() -> instance.saveApplication(emptyApplication)).isInstanceOf(InvalidArgumentException.class);
}
Also used : Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Example 14 with Application

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

the class CassandraFollowerRepository method getApplicationsFollowedBy.

@Override
public List<Application> getApplicationsFollowedBy(String userId) throws TException {
    checkUserId(userId);
    Statement query = createQueryForAppsFollowedBy(userId);
    ResultSet results;
    try {
        results = cassandra.execute(query);
    } catch (Exception ex) {
        LOG.error("Failed to query Cassandra for apps followed by User: [{}]", userId, ex);
        throw new OperationFailedException("Could not find apps followed by user: " + ex.getMessage());
    }
    List<Application> apps = Lists.create();
    for (Row row : results) {
        Application app = createAppFromRow(row);
        apps.add(app);
    }
    LOG.debug("Found {} apps followed by {}", apps.size(), userId);
    return apps;
}
Also used : OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) Application(tech.aroma.thrift.Application) TException(org.apache.thrift.TException) InvalidArgumentException(tech.aroma.thrift.exceptions.InvalidArgumentException) OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException)

Example 15 with Application

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

the class MemoryApplicationRepositoryTest method testSearchByName.

@Test
public void testSearchByName() throws Exception {
    int length = one(integers(100, 200));
    String name = one(alphabeticString(length));
    String term = name.substring(length / 2);
    app.setName(name);
    instance.saveApplication(app);
    List<Application> result = instance.searchByName(term);
    assertThat(result, contains(app));
}
Also used : StringGenerators.alphabeticString(tech.sirwellington.alchemy.generator.StringGenerators.alphabeticString) 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