Search in sources :

Example 26 with User

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

the class MongoUserDaoTest method prepareUser.

private User prepareUser() {
    User user = new User(EMAIL);
    user.setName(USERNAME);
    user.setGroups(Collections.singletonMap(organization.getId(), GROUPS));
    return user;
}
Also used : User(io.lumeer.api.model.User)

Example 27 with User

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

the class MongoUserDaoTest method testUpdateNameAndEmail.

@Test
public void testUpdateNameAndEmail() {
    User user = prepareUser();
    String id = mongoUserDao.createUser(user).getId();
    assertThat(id).isNotNull().isNotEmpty();
    String anotherMail = "someother@email.com";
    user.setName(USERNAME2);
    user.setEmail(anotherMail);
    String id2 = mongoUserDao.updateUser(id, user).getId();
    assertThat(id).isEqualTo(id2);
    User storedUser = mongoUserDao.databaseCollection().find(MongoFilters.idFilter(id)).first();
    assertThat(storedUser).isNotNull();
    assertThat(storedUser.getEmail()).isEqualTo(anotherMail);
    assertThat(storedUser.getName()).isEqualTo(USERNAME2);
    assertThat(storedUser.getGroups()).containsKey(organization.getId());
    assertThat(storedUser.getGroups().get(organization.getId())).containsOnlyElementsOf(GROUPS);
}
Also used : User(io.lumeer.api.model.User) Test(org.junit.Test)

Example 28 with User

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

the class LinkInstanceServiceIT method configureLinkInstances.

@Before
public void configureLinkInstances() {
    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.setPermissions(new JsonPermissions());
    project.setCode(PROJECT_CODE);
    Project storedProject = projectDao.createProject(project);
    collectionDao.setProject(storedProject);
    linkTypeDao.setProject(storedProject);
    linkInstanceDao.setProject(storedProject);
    documentDao.setProject(storedProject);
    JsonPermissions collectionPermissions = new JsonPermissions();
    collectionPermissions.updateUserPermissions(new JsonPermission(USER, Project.ROLES.stream().map(Role::toString).collect(Collectors.toSet())));
    JsonCollection jsonCollection = new JsonCollection("col1", "col1", "icon", "color", collectionPermissions);
    jsonCollection.setDocumentsCount(0);
    String collection1 = collectionDao.createCollection(jsonCollection).getId();
    JsonCollection jsonCollection2 = new JsonCollection("col2", "col2", "icon", "color", collectionPermissions);
    jsonCollection.setDocumentsCount(0);
    String collection2 = collectionDao.createCollection(jsonCollection2).getId();
    LinkType linkType = new LinkType(null, NAME, Arrays.asList(collection1, collection2), ATTRIBUTES);
    linkTypeId1 = linkTypeDao.createLinkType(linkType).getId();
    LinkType linkType2 = new LinkType(null, NAME2, Arrays.asList(collection1, collection2), ATTRIBUTES);
    linkTypeId2 = linkTypeDao.createLinkType(linkType2).getId();
    documentIdsColl1.clear();
    for (int i = 0; i < 3; i++) {
        documentIdsColl1.add(createDocument(collection1).getId());
    }
    documentIdsColl2.clear();
    for (int i = 0; i < 3; i++) {
        documentIdsColl2.add(createDocument(collection2).getId());
    }
}
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) LinkType(io.lumeer.api.model.LinkType) JsonCollection(io.lumeer.api.dto.JsonCollection) JsonProject(io.lumeer.api.dto.JsonProject) Before(org.junit.Before)

Example 29 with User

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

the class LinkTypeServiceIT method configureLinkTypes.

@Before
public void configureLinkTypes() {
    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.setPermissions(new JsonPermissions());
    project.setCode(PROJECT_CODE);
    Project storedProject = projectDao.createProject(project);
    collectionDao.setProject(storedProject);
    linkTypeDao.setProject(storedProject);
    collectionIds.clear();
    for (String name : COLLECTION_NAMES) {
        JsonPermissions collectionPermissions = new JsonPermissions();
        collectionPermissions.updateUserPermissions(new JsonPermission(USER, Project.ROLES.stream().map(Role::toString).collect(Collectors.toSet())));
        JsonCollection jsonCollection = new JsonCollection(name, name, COLLECTION_ICON, COLLECTION_COLOR, collectionPermissions);
        jsonCollection.setDocumentsCount(0);
        collectionIds.add(collectionDao.createCollection(jsonCollection).getId());
    }
}
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) JsonCollection(io.lumeer.api.dto.JsonCollection) JsonProject(io.lumeer.api.dto.JsonProject) Before(org.junit.Before)

Example 30 with User

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

the class UserServiceIT method testGetUsers.

@Test
public void testGetUsers() {
    createUser(organizationId1, USER1);
    createUser(organizationId1, USER2);
    createUser(organizationId2, USER1);
    createUser(organizationId2, USER3);
    Response response = client.target(getPath(organizationId2)).request(MediaType.APPLICATION_JSON).buildGet().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    List<User> users = response.readEntity(new GenericType<List<User>>() {
    });
    assertThat(users).extracting(User::getEmail).containsOnly(USER1, USER3);
}
Also used : Response(javax.ws.rs.core.Response) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) List(java.util.List) Test(org.junit.Test)

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