Search in sources :

Example 36 with User

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

the class CassandraUserRepositoryIT method testGetRecentlyCreatedUsers.

@Test
public void testGetRecentlyCreatedUsers() throws Exception {
    instance.saveUser(user);
    List<User> result = instance.getRecentlyCreatedUsers();
    Map<String, User> mapping = result.stream().collect(() -> Maps.<String, User>create(), (map, user) -> map.put(user.userId, user), (left, right) -> left.putAll(right));
    assertThat(result, notNullValue());
    assertThat(result, not(empty()));
    if (mapping.containsKey(user.userId)) {
        User savedUser = mapping.get(user.userId);
        assertMostlyMatch(savedUser, user);
    }
}
Also used : User(tech.aroma.thrift.User) IntegrationTest(tech.sirwellington.alchemy.annotations.testing.IntegrationTest)

Example 37 with User

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

the class CassandraOrganizationRepositoryTest method testGetOrganizationOwners.

@Test
public void testGetOrganizationOwners() throws Exception {
    List<User> response = instance.getOrganizationOwners(orgId);
    Set<User> expected = org.owners.stream().map(id -> new User().setUserId(id)).collect(toSet());
    assertThat(Sets.toSet(response), is(expected));
}
Also used : java.util(java.util) ThrowableAssertion(tech.sirwellington.alchemy.test.junit.ThrowableAssertion) RunWith(org.junit.runner.RunWith) Function(java.util.function.Function) UUID(tech.sirwellington.alchemy.test.junit.runners.GenerateString.Type.UUID) Assert.assertThat(org.junit.Assert.assertThat) com.datastax.driver.core(com.datastax.driver.core) Organization(tech.aroma.thrift.Organization) com.datastax.driver.core.querybuilder(com.datastax.driver.core.querybuilder) tech.aroma.thrift.exceptions(tech.aroma.thrift.exceptions) Collectors.toSet(java.util.stream.Collectors.toSet) Before(org.junit.Before) Sets(sir.wellington.alchemy.collections.sets.Sets) org.mockito(org.mockito) Maps(sir.wellington.alchemy.collections.maps.Maps) TException(org.apache.thrift.TException) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) NoHostAvailableException(com.datastax.driver.core.exceptions.NoHostAvailableException) AlchemyGenerator.one(tech.sirwellington.alchemy.generator.AlchemyGenerator.one) CollectionGenerators.listOf(tech.sirwellington.alchemy.generator.CollectionGenerators.listOf) Mockito(org.mockito.Mockito) Collectors.toList(java.util.stream.Collectors.toList) NumberGenerators.positiveLongs(tech.sirwellington.alchemy.generator.NumberGenerators.positiveLongs) StringGenerators.uuids(tech.sirwellington.alchemy.generator.StringGenerators.uuids) User(tech.aroma.thrift.User) ALPHABETIC(tech.sirwellington.alchemy.test.junit.runners.GenerateString.Type.ALPHABETIC) tech.sirwellington.alchemy.test.junit.runners(tech.sirwellington.alchemy.test.junit.runners) Lists(sir.wellington.alchemy.collections.lists.Lists) User(tech.aroma.thrift.User) Test(org.junit.Test)

Example 38 with User

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

the class CassandraOrganizationRepositoryIT method testSaveMemberInOrganization.

@Test
public void testSaveMemberInOrganization() throws Exception {
    instance.saveMemberInOrganization(orgId, user);
    List<User> members = instance.getOrganizationMembers(orgId);
    User match = members.stream().filter(u -> Objects.equal(u.userId, user.userId)).findFirst().get();
    assertUserMostlyMatch(match, user);
}
Also used : User(tech.aroma.thrift.User) IntegrationTest(tech.sirwellington.alchemy.annotations.testing.IntegrationTest)

Example 39 with User

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

the class CassandraFollowerRepository method getApplicationFollowers.

@Override
public List<User> getApplicationFollowers(String applicationId) throws TException {
    checkAppId(applicationId);
    Statement query = createQueryForFollowersOfApp(applicationId);
    ResultSet results;
    try {
        results = cassandra.execute(query);
    } catch (Exception ex) {
        LOG.error("Failed to query for App's followed: App: [{}]", applicationId, ex);
        throw new OperationFailedException("Could not query for App's Followers: " + ex.getMessage());
    }
    List<User> followers = Lists.create();
    for (Row row : results) {
        User follower = createUserFromRow(row);
        followers.add(follower);
    }
    LOG.debug("Found {} Users followed App [{}]", followers.size(), applicationId);
    return followers;
}
Also used : User(tech.aroma.thrift.User) OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException) TException(org.apache.thrift.TException) InvalidArgumentException(tech.aroma.thrift.exceptions.InvalidArgumentException) OperationFailedException(tech.aroma.thrift.exceptions.OperationFailedException)

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