Search in sources :

Example 16 with User

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

the class MemoryUserRepositoryTest method testSaveUserWithBadArgs.

@DontRepeat
@Test
public void testSaveUserWithBadArgs() {
    assertThrows(() -> instance.saveUser(null)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.saveUser(new User())).isInstanceOf(InvalidArgumentException.class);
}
Also used : User(tech.aroma.thrift.User) Test(org.junit.Test)

Example 17 with User

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

the class MemoryUserRepositoryTest method testSaveUser.

@Test
public void testSaveUser() throws Exception {
    instance.saveUser(user);
    User result = instance.getUser(userId);
    assertThat(result, is(user));
}
Also used : User(tech.aroma.thrift.User) Test(org.junit.Test)

Example 18 with User

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

the class MemoryInboxRepositoryTest method testSaveMessageForUserWithBadArguments.

@DontRepeat
public void testSaveMessageForUserWithBadArguments() throws Exception {
    assertThrows(() -> instance.saveMessageForUser(null, message)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.saveMessageForUser(user, null)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.saveMessageForUser(new User(), message)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.saveMessageForUser(user, new Message())).isInstanceOf(InvalidArgumentException.class);
}
Also used : User(tech.aroma.thrift.User) Message(tech.aroma.thrift.Message)

Example 19 with User

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

the class MemoryOrganizationRepository method getOrganizationOwners.

@Override
public List<User> getOrganizationOwners(String organizationId) throws TException {
    checkOrgId(organizationId);
    Organization org = getOrganization(organizationId);
    return Sets.copyOf(org.owners).stream().map(id -> new User().setUserId(id)).collect(toList());
}
Also used : Sets(sir.wellington.alchemy.collections.sets.Sets) java.util(java.util) Logger(org.slf4j.Logger) Maps(sir.wellington.alchemy.collections.maps.Maps) StringAssertions(tech.sirwellington.alchemy.arguments.assertions.StringAssertions) LoggerFactory(org.slf4j.LoggerFactory) TException(org.apache.thrift.TException) OrganizationDoesNotExistException(tech.aroma.thrift.exceptions.OrganizationDoesNotExistException) InvalidArgumentException(tech.aroma.thrift.exceptions.InvalidArgumentException) RequestAssertions(tech.aroma.data.assertions.RequestAssertions) Organization(tech.aroma.thrift.Organization) Collectors.toList(java.util.stream.Collectors.toList) Arguments(tech.sirwellington.alchemy.arguments.Arguments) CollectionAssertions.keyInMap(tech.sirwellington.alchemy.arguments.assertions.CollectionAssertions.keyInMap) User(tech.aroma.thrift.User) Internal(tech.sirwellington.alchemy.annotations.access.Internal) OrganizationRepository(tech.aroma.data.OrganizationRepository) Collectors.toSet(java.util.stream.Collectors.toSet) Organization(tech.aroma.thrift.Organization) User(tech.aroma.thrift.User)

Example 20 with User

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

the class CassandraActivityRepositoryTest method testSaveEventWithBadArgs.

@Test
public void testSaveEventWithBadArgs() throws Exception {
    assertThrows(() -> instance.saveEvent(null, user)).isInstanceOf(InvalidArgumentException.class);
    assertThrows(() -> instance.saveEvent(event, null)).isInstanceOf(InvalidArgumentException.class);
    User userMissingId = new User();
    assertThrows(() -> instance.saveEvent(event, userMissingId)).isInstanceOf(InvalidArgumentException.class);
    Event eventMissingId = new Event(event);
    eventMissingId.unsetEventId();
    assertThrows(() -> instance.saveEvent(eventMissingId, user)).isInstanceOf(InvalidArgumentException.class);
    User userWithBadId = new User(user).setUserId(badId);
    assertThrows(() -> instance.saveEvent(event, userWithBadId)).isInstanceOf(InvalidArgumentException.class);
    Event eventWithBadId = new Event(event).setEventId(badId);
    assertThrows(() -> instance.saveEvent(eventWithBadId, user)).isInstanceOf(InvalidArgumentException.class);
}
Also used : User(tech.aroma.thrift.User) Event(tech.aroma.thrift.events.Event) Test(org.junit.Test)

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