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;
}
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);
}
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());
}
}
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());
}
}
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);
}
Aggregations