Search in sources :

Example 41 with User

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

the class UserFacadeIT method testUpdateNameAndEmail.

@Test
public void testUpdateNameAndEmail() {
    String userId = createUser(organizationId1, USER1).getId();
    User toUpdate = prepareUser(organizationId1, USER1);
    toUpdate.setEmail(USER3);
    toUpdate.setName("newName");
    userFacade.updateUser(organizationId1, userId, toUpdate);
    User storedNotExisting = getUser(organizationId1, USER1);
    assertThat(storedNotExisting).isNull();
    User storedExisting = getUser(organizationId1, USER3);
    assertThat(storedExisting).isNotNull();
    assertThat(storedExisting.getName()).isEqualTo("newName");
}
Also used : User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) Test(org.junit.Test)

Example 42 with User

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

the class UserFacadeIT method testUpdateGroups.

@Test
public void testUpdateGroups() {
    String userId = createUser(organizationId1, USER1).getId();
    Set<String> newGroups = new HashSet<>(Arrays.asList("g1", "g2"));
    User toUpdate = prepareUser(organizationId1, USER1);
    toUpdate.setGroups(Collections.singletonMap(organizationId1, newGroups));
    userFacade.updateUser(organizationId1, userId, toUpdate);
    User stored = getUser(organizationId1, USER1);
    assertThat(stored).isNotNull();
    assertThat(stored.getName()).isEqualTo(USER1);
    assertThat(stored.getGroups().get(organizationId1)).isEqualTo(newGroups);
}
Also used : User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 43 with User

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

the class UserFacadeIT method testCreateUser.

@Test
public void testCreateUser() {
    userFacade.createUser(organizationId1, prepareUser(organizationId1, USER1));
    User stored = getUser(organizationId1, USER1);
    assertThat(stored).isNotNull();
    assertThat(stored.getName()).isEqualTo(USER1);
    assertThat(stored.getEmail()).isEqualTo(USER1);
    assertThat(stored.getGroups().get(organizationId1)).isEqualTo(GROUPS);
}
Also used : User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) Test(org.junit.Test)

Example 44 with User

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

the class UserFacadeIT method prepareUser.

private User prepareUser(String organizationId, String user) {
    User u = new User(user);
    u.setName(user);
    u.setGroups(Collections.singletonMap(organizationId, GROUPS));
    return u;
}
Also used : User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser)

Example 45 with User

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

the class CollectionServiceIT method configureProject.

@Before
public void configureProject() {
    JsonOrganization organization = new JsonOrganization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new JsonPermissions());
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    User user = new User(USER);
    userDao.createUser(user);
    JsonProject project = new JsonProject();
    project.setCode(PROJECT_CODE);
    JsonPermissions projectPermissions = new JsonPermissions();
    projectPermissions.updateUserPermissions(new JsonPermission(USER, Project.ROLES.stream().map(Role::toString).collect(Collectors.toSet())));
    project.setPermissions(projectPermissions);
    Project storedProject = projectDao.createProject(project);
    collectionDao.setProject(storedProject);
    collectionDao.createCollectionsRepository(project);
}
Also used : JsonProject(io.lumeer.api.dto.JsonProject) Project(io.lumeer.api.model.Project) JsonPermissions(io.lumeer.api.dto.JsonPermissions) Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) JsonOrganization(io.lumeer.api.dto.JsonOrganization) JsonPermission(io.lumeer.api.dto.JsonPermission) JsonProject(io.lumeer.api.dto.JsonProject) Before(org.junit.Before)

Aggregations

User (io.lumeer.api.model.User)50 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)29 Test (org.junit.Test)21 Before (org.junit.Before)18 Organization (io.lumeer.api.model.Organization)17 JsonOrganization (io.lumeer.api.dto.JsonOrganization)13 Project (io.lumeer.api.model.Project)13 JsonPermission (io.lumeer.api.dto.JsonPermission)12 JsonPermissions (io.lumeer.api.dto.JsonPermissions)12 JsonProject (io.lumeer.api.dto.JsonProject)12 JsonCollection (io.lumeer.api.dto.JsonCollection)8 HashSet (java.util.HashSet)7 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)5 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)5 Set (java.util.Set)5 Response (javax.ws.rs.core.Response)4 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)3 HashMap (java.util.HashMap)3 LinkType (io.lumeer.api.model.LinkType)2 MorphiaProject (io.lumeer.storage.mongodb.model.MorphiaProject)2