Search in sources :

Example 1 with Organization

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

the class CassandraOrganizationRepositoryTest method testSaveOrganizationWithBadArgs.

@Test
public void testSaveOrganizationWithBadArgs() throws Exception {
    assertThrows(() -> instance.saveOrganization(null)).isInstanceOf(InvalidArgumentException.class);
    Organization emptyOrg = new Organization();
    assertThrows(() -> instance.saveOrganization(emptyOrg)).isInstanceOf(InvalidArgumentException.class);
    Organization orgWithoutName = new Organization(org);
    orgWithoutName.unsetOrganizationName();
    assertThrows(() -> instance.saveOrganization(orgWithoutName)).isInstanceOf(InvalidArgumentException.class);
}
Also used : Organization(tech.aroma.thrift.Organization) Test(org.junit.Test)

Example 2 with Organization

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

the class CassandraOrganizationRepositoryTest method testGetOrganization.

@Test
public void testGetOrganization() throws Exception {
    Organization result = instance.getOrganization(orgId);
    assertThat(result, is(org));
    verify(cassandra).execute(statementCaptor.capture());
    Statement statement = statementCaptor.getValue();
    assertThat(statement, notNullValue());
    assertThat(statement, instanceOf(Select.Where.class));
}
Also used : Organization(tech.aroma.thrift.Organization) Test(org.junit.Test)

Example 3 with Organization

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

the class MemoryOrganizationRepositoryTest method testSearchByName.

@Test
public void testSearchByName() throws Exception {
    List<Organization> orgs = listOf(pojos(Organization.class)).stream().map(org -> org.setOrganizationId(one(uuids))).map(org -> org.setOwners(Lists.emptyList())).collect(toList());
    Set<String> orgNames = orgs.stream().map(Organization::getOrganizationName).collect(toSet());
    String oneName = Sets.oneOf(orgNames);
    for (Organization organization : orgs) {
        instance.saveOrganization(organization);
    }
    List<Organization> result = instance.searchByName(oneName);
    assertThat(result, not(empty()));
    for (Organization organization : result) {
        assertThat(organization, isIn(orgs));
    }
}
Also used : Sets(sir.wellington.alchemy.collections.sets.Sets) ThrowableAssertion(tech.sirwellington.alchemy.test.junit.ThrowableAssertion) RunWith(org.junit.runner.RunWith) Set(java.util.Set) Matchers(org.hamcrest.Matchers) ObjectGenerators.pojos(tech.sirwellington.alchemy.generator.ObjectGenerators.pojos) Test(org.junit.Test) OrganizationDoesNotExistException(tech.aroma.thrift.exceptions.OrganizationDoesNotExistException) AlchemyGenerator.one(tech.sirwellington.alchemy.generator.AlchemyGenerator.one) UUID(tech.sirwellington.alchemy.test.junit.runners.GenerateString.Type.UUID) InvalidArgumentException(tech.aroma.thrift.exceptions.InvalidArgumentException) CollectionGenerators.listOf(tech.sirwellington.alchemy.generator.CollectionGenerators.listOf) Assert.assertThat(org.junit.Assert.assertThat) List(java.util.List) Organization(tech.aroma.thrift.Organization) Collectors.toList(java.util.stream.Collectors.toList) 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) Collectors.toSet(java.util.stream.Collectors.toSet) Before(org.junit.Before) Lists(sir.wellington.alchemy.collections.lists.Lists) Organization(tech.aroma.thrift.Organization) Test(org.junit.Test)

Example 4 with Organization

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

the class MemoryOrganizationRepositoryTest method testGetOrganization.

@Test
public void testGetOrganization() throws Exception {
    instance.saveOrganization(org);
    Organization result = instance.getOrganization(orgId);
    assertThat(result, is(org));
}
Also used : Organization(tech.aroma.thrift.Organization) Test(org.junit.Test)

Example 5 with Organization

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

Aggregations

Organization (tech.aroma.thrift.Organization)8 Test (org.junit.Test)5 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 Sets (sir.wellington.alchemy.collections.sets.Sets)2 User (tech.aroma.thrift.User)2 InvalidArgumentException (tech.aroma.thrift.exceptions.InvalidArgumentException)2 OrganizationDoesNotExistException (tech.aroma.thrift.exceptions.OrganizationDoesNotExistException)2 IntegrationTest (tech.sirwellington.alchemy.annotations.testing.IntegrationTest)2 java.util (java.util)1 List (java.util.List)1 Set (java.util.Set)1 TException (org.apache.thrift.TException)1 Matchers (org.hamcrest.Matchers)1 Assert.assertThat (org.junit.Assert.assertThat)1 Before (org.junit.Before)1 RunWith (org.junit.runner.RunWith)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Lists (sir.wellington.alchemy.collections.lists.Lists)1