Search in sources :

Example 16 with Organization

use of io.lumeer.api.model.Organization in project engine by Lumeer.

the class OrganizationFacadeIT method testUpdateOrganization.

@Test
public void testUpdateOrganization() {
    String id = createOrganization(CODE1);
    Organization updatedOrganization = new JsonOrganization(CODE2, NAME, ICON, COLOR, null, null);
    organizationFacade.updateOrganization(CODE1, updatedOrganization);
    Organization storedOrganization = organizationDao.getOrganizationByCode(CODE2);
    assertThat(storedOrganization).isNotNull();
    assertThat(storedOrganization.getId()).isEqualTo(id);
    assertThat(storedOrganization.getName()).isEqualTo(NAME);
    assertThat(storedOrganization.getIcon()).isEqualTo(ICON);
    assertThat(storedOrganization.getColor()).isEqualTo(COLOR);
    assertThat(storedOrganization.getPermissions().getUserPermissions()).containsOnly(USER_PERMISSION);
}
Also used : JsonOrganization(io.lumeer.api.dto.JsonOrganization) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) Test(org.junit.Test)

Example 17 with Organization

use of io.lumeer.api.model.Organization in project engine by Lumeer.

the class OrganizationFacadeIT method testCreateOrganization.

@Test
public void testCreateOrganization() {
    Organization organization = new JsonOrganization(CODE1, NAME, ICON, COLOR, null, null);
    Organization createdOrganization = organizationFacade.createOrganization(organization);
    assertThat(createdOrganization).isNotNull();
    assertThat(createdOrganization.getId()).isNotNull();
    Organization storedOrganization = organizationDao.getOrganizationByCode(CODE1);
    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().getUserPermissions()).containsOnly(USER_PERMISSION);
    assertions.assertThat(storedOrganization.getPermissions().getGroupPermissions()).isEmpty();
    assertions.assertAll();
}
Also used : JsonOrganization(io.lumeer.api.dto.JsonOrganization) Organization(io.lumeer.api.model.Organization) SoftAssertions(org.assertj.core.api.SoftAssertions) JsonOrganization(io.lumeer.api.dto.JsonOrganization) Test(org.junit.Test)

Example 18 with Organization

use of io.lumeer.api.model.Organization in project engine by Lumeer.

the class ProjectFacadeIT method configureProject.

@Before
public void configureProject() {
    MorphiaOrganization organization = new MorphiaOrganization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new MorphiaPermissions());
    organization.getPermissions().updateUserPermissions(new MorphiaPermission(USER, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    User user = new User(USER);
    userDao.createUser(user);
    workspaceKeeper.setOrganization(ORGANIZATION_CODE);
}
Also used : Organization(io.lumeer.api.model.Organization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Example 19 with Organization

use of io.lumeer.api.model.Organization in project engine by Lumeer.

the class OrganizationServiceIT method testUpdateOrganization.

@Test
public void testUpdateOrganization() {
    createOrganization(CODE1);
    Organization updatedOrganization = new JsonOrganization(CODE2, NAME, ICON, COLOR, null, null);
    Entity entity = Entity.json(updatedOrganization);
    Response response = client.target(ORGANIZATION_URL).path(CODE1).request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    Organization returnedOrganization = response.readEntity(JsonOrganization.class);
    SoftAssertions assertions = new SoftAssertions();
    assertions.assertThat(returnedOrganization.getCode()).isEqualTo(CODE2);
    assertions.assertThat(returnedOrganization.getName()).isEqualTo(NAME);
    assertions.assertThat(returnedOrganization.getIcon()).isEqualTo(ICON);
    assertions.assertThat(returnedOrganization.getColor()).isEqualTo(COLOR);
    assertions.assertThat(returnedOrganization.getPermissions().getUserPermissions()).containsOnly(USER_PERMISSION);
    assertions.assertThat(returnedOrganization.getPermissions().getGroupPermissions()).isEmpty();
    assertions.assertAll();
    Organization storedOrganization = organizationFacade.getOrganization(CODE2);
    assertThat(storedOrganization).isNotNull();
    assertions = new SoftAssertions();
    assertions.assertThat(storedOrganization.getCode()).isEqualTo(CODE2);
    assertions.assertThat(storedOrganization.getName()).isEqualTo(NAME);
    assertions.assertThat(storedOrganization.getIcon()).isEqualTo(ICON);
    assertions.assertThat(storedOrganization.getColor()).isEqualTo(COLOR);
    assertions.assertThat(storedOrganization.getPermissions().getUserPermissions()).containsOnly(USER_PERMISSION);
    assertions.assertThat(returnedOrganization.getPermissions().getGroupPermissions()).isEmpty();
    assertions.assertAll();
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) SoftAssertions(org.assertj.core.api.SoftAssertions) JsonOrganization(io.lumeer.api.dto.JsonOrganization) Test(org.junit.Test)

Example 20 with Organization

use of io.lumeer.api.model.Organization in project engine by Lumeer.

the class ProjectServiceIT method configureProject.

@Before
public void configureProject() {
    MorphiaOrganization organization = new MorphiaOrganization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new MorphiaPermissions());
    organization.getPermissions().updateUserPermissions(new MorphiaPermission(USER, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    User user = new User(USER);
    userDao.createUser(user);
}
Also used : Organization(io.lumeer.api.model.Organization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

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