Search in sources :

Example 1 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 2 with Application

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

the class CassandraFollowerRepositoryTest method testGetApplicationsFollowedBy.

@Test
public void testGetApplicationsFollowedBy() throws Exception {
    Map<String, Row> rows = Maps.create();
    for (Application app : apps) {
        Row mockRow = mock(Row.class);
        when(applicationMapper.apply(mockRow)).thenReturn(app);
        rows.put(app.applicationId, mockRow);
    }
    when(results.iterator()).thenReturn(rows.values().iterator());
    Set<Application> result = toSet(instance.getApplicationsFollowedBy(userId));
    assertThat(result, is(toSet(apps)));
}
Also used : StringGenerators.alphabeticString(tech.sirwellington.alchemy.generator.StringGenerators.alphabeticString) GenerateString(tech.sirwellington.alchemy.test.junit.runners.GenerateString) Row(com.datastax.driver.core.Row) Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Example 3 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) DontRepeat(tech.sirwellington.alchemy.test.junit.runners.DontRepeat)

Example 4 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) DontRepeat(tech.sirwellington.alchemy.test.junit.runners.DontRepeat)

Example 5 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(application);
    Application result = instance.getById(applicationId);
    assertThat(result, is(application));
}
Also used : Application(tech.aroma.thrift.Application) Test(org.junit.Test)

Aggregations

Application (tech.aroma.thrift.Application)25 Test (org.junit.Test)17 RequestAssertions.validApplication (tech.aroma.data.assertions.RequestAssertions.validApplication)8 InvalidArgumentException (tech.aroma.thrift.exceptions.InvalidArgumentException)8 BatchStatement (com.datastax.driver.core.BatchStatement)7 Statement (com.datastax.driver.core.Statement)7 ResultSet (com.datastax.driver.core.ResultSet)6 Row (com.datastax.driver.core.Row)6 TException (org.apache.thrift.TException)6 OperationFailedException (tech.aroma.thrift.exceptions.OperationFailedException)6 ApplicationDoesNotExistException (tech.aroma.thrift.exceptions.ApplicationDoesNotExistException)5 IntegrationTest (tech.sirwellington.alchemy.annotations.testing.IntegrationTest)5 GenerateString (tech.sirwellington.alchemy.test.junit.runners.GenerateString)5 User (tech.aroma.thrift.User)4 StringGenerators.alphabeticString (tech.sirwellington.alchemy.generator.StringGenerators.alphabeticString)3 StringAssertions.nonEmptyString (tech.sirwellington.alchemy.arguments.assertions.StringAssertions.nonEmptyString)2 DontRepeat (tech.sirwellington.alchemy.test.junit.runners.DontRepeat)2 RequestAssertions.validUser (tech.aroma.data.assertions.RequestAssertions.validUser)1