Search in sources :

Example 36 with Organization

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();
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) Organization(io.lumeer.api.model.Organization) ObjectId(org.bson.types.ObjectId) SoftAssertions(org.assertj.core.api.SoftAssertions) Test(org.junit.Test)

Example 37 with Organization

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);
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) Organization(io.lumeer.api.model.Organization) Test(org.junit.Test)

Example 38 with Organization

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);
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) Organization(io.lumeer.api.model.Organization) Test(org.junit.Test)

Example 39 with Organization

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);
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) Organization(io.lumeer.api.model.Organization) DatabaseQuery(io.lumeer.storage.api.query.DatabaseQuery) Test(org.junit.Test)

Example 40 with Organization

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);
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) Organization(io.lumeer.api.model.Organization) Test(org.junit.Test)

Aggregations

Organization (io.lumeer.api.model.Organization)69 JsonOrganization (io.lumeer.api.dto.JsonOrganization)42 Test (org.junit.Test)31 JsonPermission (io.lumeer.api.dto.JsonPermission)22 Response (javax.ws.rs.core.Response)20 Before (org.junit.Before)18 User (io.lumeer.api.model.User)17 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)17 Project (io.lumeer.api.model.Project)15 JsonProject (io.lumeer.api.dto.JsonProject)14 JsonPermissions (io.lumeer.api.dto.JsonPermissions)13 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)13 JsonCollection (io.lumeer.api.dto.JsonCollection)8 Permission (io.lumeer.api.model.Permission)7 SoftAssertions (org.assertj.core.api.SoftAssertions)6 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)5 ResourceNotFoundException (io.lumeer.storage.api.exception.ResourceNotFoundException)4 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)4 Role (io.lumeer.api.model.Role)3 DatabaseQuery (io.lumeer.storage.api.query.DatabaseQuery)3