Search in sources :

Example 16 with Application

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

the class MemoryFollowerRepositoryTest method testGetApplicationsFollowedBy.

@Test
public void testGetApplicationsFollowedBy() throws Exception {
    for (Application app : this.appsFollowed) {
        instance.saveFollowing(user, app);
    }
    List<Application> result = instance.getApplicationsFollowedBy(userId);
    assertThat(result, notNullValue());
    assertThat(Sets.containTheSameElements(result, appsFollowed), is(true));
}
Also used : Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Example 17 with Application

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

the class MemoryApplicationRepositoryTest method testGetById.

@Test
public void testGetById() throws Exception {
    instance.saveApplication(app);
    Application result = instance.getById(appId);
    assertThat(result, is(app));
    String randomId = one(uuids);
    assertThrows(() -> instance.getById(randomId)).isInstanceOf(TException.class);
}
Also used : StringGenerators.alphabeticString(tech.sirwellington.alchemy.generator.StringGenerators.alphabeticString) Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Example 18 with Application

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

the class MemoryApplicationRepositoryTest method testGetApplicationsOwnedBy.

@Test
public void testGetApplicationsOwnedBy() throws Exception {
    User user = one(UserGenerators.users());
    applications.forEach(app -> app.owners.add(user.userId));
    saveApplications(applications);
    List<Application> result = instance.getApplicationsOwnedBy(user.userId);
    assertThat(containTheSameElements(applications, result), is(true));
}
Also used : User(tech.aroma.thrift.User) Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Example 19 with Application

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

the class CassandraFollowerRepositoryIT method testGetApplicationsFollowedBy.

@Test
public void testGetApplicationsFollowedBy() throws Exception {
    instance.saveFollowing(user, app);
    List<Application> apps = instance.getApplicationsFollowedBy(userId);
    assertThat(apps, notNullValue());
    assertThat(apps, not(empty()));
    assertThat(apps.size(), is(1));
    Application savedApp = Lists.oneOf(apps);
    assertThat(savedApp.applicationId, is(appId));
    assertThat(savedApp.name, is(app.name));
}
Also used : Application(tech.aroma.thrift.Application) IntegrationTest(tech.sirwellington.alchemy.annotations.testing.IntegrationTest)

Example 20 with Application

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

the class CassandraApplicationRepository method getApplicationsByOrg.

@Override
public List<Application> getApplicationsByOrg(String orgId) throws TException {
    checkThat(orgId).throwing(InvalidArgumentException.class).is(validOrgId());
    Statement query = createQueryForAppsWithOrg(orgId);
    ResultSet results;
    try {
        results = cassandra.execute(query);
    } catch (Exception ex) {
        LOG.error("Failed to find Apps by Org with ID [{}]", orgId, ex);
        throw new OperationFailedException("Could not find Org's Apps: " + orgId);
    }
    List<Application> apps = Lists.create();
    for (Row row : results) {
        Application app = createApplicationFromRow(row);
        apps.add(app);
    }
    LOG.debug("Found {} apps in Org {}", apps.size(), orgId);
    return apps;
}
Also used : Application(tech.aroma.thrift.Application) TException(org.apache.thrift.TException)

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