use of io.lumeer.api.model.Organization in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testCreateOrganization.
@Test
public void testCreateOrganization() {
Organization organization = prepareOrganization(CODE1);
String id = organizationDao.createOrganization(organization).getId();
assertThat(id).isNotNull().isNotEmpty();
assertThat(ObjectId.isValid(id)).isTrue();
Organization storedOrganization = datastore.get(MorphiaOrganization.class, new ObjectId(id));
assertThat(storedOrganization).isNotNull();
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(storedOrganization.getCode()).isEqualTo(CODE1);
assertions.assertThat(storedOrganization.getName()).isEqualTo(NAME);
assertions.assertThat(storedOrganization.getColor()).isEqualTo(COLOR);
assertions.assertThat(storedOrganization.getIcon()).isEqualTo(ICON);
assertions.assertThat(storedOrganization.getPermissions()).isEqualTo(PERMISSIONS);
assertions.assertAll();
}
use of io.lumeer.api.model.Organization in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testGetOrganizationByCode.
@Test
public void testGetOrganizationByCode() {
Organization organization = prepareOrganization(CODE1);
datastore.save(organization);
Organization storedOrganization = organizationDao.getOrganizationByCode(CODE1);
assertThat(storedOrganization).isNotNull();
assertThat(storedOrganization.getId()).isNotNull().isNotEmpty();
assertThat(storedOrganization.getCode()).isEqualTo(CODE1);
assertThat(storedOrganization.getName()).isEqualTo(NAME);
}
use of io.lumeer.api.model.Organization in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testGetOrganizationById.
@Test
public void testGetOrganizationById() {
Organization organization = prepareOrganization(CODE1);
Organization createdOrganization = organizationDao.createOrganization(organization);
Organization storedOrganization = organizationDao.getOrganizationById(createdOrganization.getId());
assertThat(storedOrganization).isNotNull();
assertThat(storedOrganization.getId()).isNotNull().isNotEmpty();
assertThat(storedOrganization.getCode()).isEqualTo(CODE1);
assertThat(storedOrganization.getName()).isEqualTo(NAME);
}
use of io.lumeer.api.model.Organization in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testGetOrganizationsGroupRole.
@Test
public void testGetOrganizationsGroupRole() {
Organization organization = prepareOrganization(CODE1);
datastore.save(organization);
Organization organization2 = prepareOrganization(CODE2);
datastore.save(organization2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP)).build();
List<Organization> organizations = organizationDao.getOrganizations(query);
assertThat(organizations).extracting(Organization::getCode).containsOnly(CODE1, CODE2);
}
use of io.lumeer.api.model.Organization in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testCreateOrganizationExistingCode.
@Test
public void testCreateOrganizationExistingCode() {
Organization organization = prepareOrganization(CODE1);
datastore.save(organization);
Organization organization2 = prepareOrganization(CODE1);
assertThatThrownBy(() -> organizationDao.createOrganization(organization2)).isInstanceOf(DuplicateKeyException.class);
}
Aggregations