use of io.lumeer.storage.mongodb.model.MorphiaCollection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method createCollection.
private MorphiaCollection createCollection(String code, String name, Set<Attribute> attributes) {
MorphiaCollection collection = prepareCollection(code, name);
collection.setAttributes(attributes);
datastore.insert(collectionDao.databaseCollection(), collection);
return collection;
}
use of io.lumeer.storage.mongodb.model.MorphiaCollection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollections.
@Test
public void testGetCollections() {
MorphiaCollection collection = prepareCollection(CODE, NAME);
datastore.save(collectionDao.databaseCollection(), collection);
MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
datastore.save(collectionDao.databaseCollection(), collection2);
SearchQuery query = SearchQuery.createBuilder(USER).build();
List<Collection> views = collectionDao.getCollections(query);
assertThat(views).extracting(Collection::getCode).containsOnly(CODE, CODE2);
}
use of io.lumeer.storage.mongodb.model.MorphiaCollection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsByIds.
@Test
public void testGetCollectionsByIds() {
MorphiaCollection collection = prepareCollection(CODE, NAME);
String id = collectionDao.createCollection(collection).getId();
MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
String id2 = collectionDao.createCollection(collection2).getId();
MorphiaCollection collection3 = prepareCollection(CODE3, NAME3);
String id3 = collectionDao.createCollection(collection3).getId();
MorphiaCollection collection4 = prepareCollection(CODE4, NAME4);
String id4 = collectionDao.createCollection(collection4).getId();
List<Collection> collections = collectionDao.getCollectionsByIds(Arrays.asList(id, id3));
assertThat(collections).hasSize(2).extracting("id").containsOnlyElementsOf(Arrays.asList(id, id3));
collections = collectionDao.getCollectionsByIds(Arrays.asList(id, id2, id4));
assertThat(collections).hasSize(3).extracting("id").containsOnlyElementsOf(Arrays.asList(id, id2, id4));
}
use of io.lumeer.storage.mongodb.model.MorphiaCollection in project engine by Lumeer.
the class MorphiaCollectionDao method createCollection.
@Override
public Collection createCollection(final Collection collection) {
MorphiaCollection morphiaCollection = new MorphiaCollection(collection);
datastore.insert(databaseCollection(), morphiaCollection);
return morphiaCollection;
}
use of io.lumeer.storage.mongodb.model.MorphiaCollection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsNoReadRole.
@Test
public void testGetCollectionsNoReadRole() {
MorphiaCollection collection = prepareCollection(CODE, NAME);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
collection.getPermissions().updateUserPermissions(userPermission);
datastore.save(collectionDao.databaseCollection(), collection);
MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
collection2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(collectionDao.databaseCollection(), collection2);
SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<Collection> collections = collectionDao.getCollections(query);
assertThat(collections).isEmpty();
}
Aggregations