Search in sources :

Example 6 with User

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

the class CassandraOrganizationRepositoryIT method testGetOrganizationMembers.

@Test
public void testGetOrganizationMembers() throws Exception {
    saveMembers(members);
    deleteMembersAtEnd = true;
    List<User> response = instance.getOrganizationMembers(orgId);
    for (User member : response) {
        User expected = mapOfMembers.get(member.userId);
        assertThat(expected, notNullValue());
        assertUserMostlyMatch(member, expected);
    }
}
Also used : User(tech.aroma.thrift.User) IntegrationTest(tech.sirwellington.alchemy.annotations.testing.IntegrationTest)

Example 7 with User

use of tech.aroma.thrift.User 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 User

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

the class CassandraActivityRepositoryTest method testDeleteAllEventsForWithBadArgs.

@Test
public void testDeleteAllEventsForWithBadArgs() throws Exception {
    assertThrows(() -> instance.deleteAllEventsFor(null)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.deleteAllEventsFor(new User())).isInstanceOf(InvalidArgumentException.class);
    User userWithBadId = new User(user).setUserId(badId);
    assertThrows(() -> instance.deleteAllEventsFor(userWithBadId)).isInstanceOf(InvalidArgumentException.class);
}
Also used : User(tech.aroma.thrift.User) Test(org.junit.Test)

Example 9 with User

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

the class CassandraActivityRepositoryTest method testDeleteEventWithBadArgs.

@Test
public void testDeleteEventWithBadArgs() throws Exception {
    assertThrows(() -> instance.deleteEvent("", user)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.deleteEvent(eventId, null)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.deleteEvent(eventId, new User())).isInstanceOf(InvalidArgumentException.class);
    User userWithBadId = new User(user).setUserId(badId);
    assertThrows(() -> instance.deleteEvent(eventId, userWithBadId)).isInstanceOf(InvalidArgumentException.class);
}
Also used : User(tech.aroma.thrift.User) Test(org.junit.Test)

Example 10 with User

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

the class MemoryUserRepository method deleteUser.

@Override
public void deleteUser(String userId) throws TException {
    checkThat(userId).throwing(InvalidArgumentException.class).is(nonEmptyString()).throwing(UserDoesNotExistException.class).is(keyInMap(users));
    User removedUser = users.remove(userId);
    String email = removedUser.email;
    if (!isNullOrEmpty(email)) {
        this.usersByEmail.remove(email);
    }
    String githubProfile = removedUser.githubProfile;
    if (!isNullOrEmpty(githubProfile)) {
        this.usersByGithubProfile.remove(githubProfile);
    }
}
Also used : InvalidArgumentException(tech.aroma.thrift.exceptions.InvalidArgumentException) RequestAssertions.validUser(tech.aroma.data.assertions.RequestAssertions.validUser) User(tech.aroma.thrift.User) UserDoesNotExistException(tech.aroma.thrift.exceptions.UserDoesNotExistException)

Aggregations

User (tech.aroma.thrift.User)39 Test (org.junit.Test)25 IntegrationTest (tech.sirwellington.alchemy.annotations.testing.IntegrationTest)8 TException (org.apache.thrift.TException)4 InvalidArgumentException (tech.aroma.thrift.exceptions.InvalidArgumentException)4 Collectors.toList (java.util.stream.Collectors.toList)3 Application (tech.aroma.thrift.Application)3 java.util (java.util)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 Matchers (org.hamcrest.Matchers)2 Assert.assertThat (org.junit.Assert.assertThat)2 Before (org.junit.Before)2 RunWith (org.junit.runner.RunWith)2 Maps (sir.wellington.alchemy.collections.maps.Maps)2 Sets (sir.wellington.alchemy.collections.sets.Sets)2 RequestAssertions.validUser (tech.aroma.data.assertions.RequestAssertions.validUser)2 Message (tech.aroma.thrift.Message)2 Organization (tech.aroma.thrift.Organization)2 Event (tech.aroma.thrift.events.Event)2 AlchemyGenerator.one (tech.sirwellington.alchemy.generator.AlchemyGenerator.one)2