use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewsNoReadRole.
@Test
public void testGetViewsNoReadRole() {
JsonView view = prepareView();
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
view.getPermissions().updateUserPermissions(userPermission);
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
view2.getPermissions().updateGroupPermissions(groupPermission);
viewDao.databaseCollection().insertOne(view2);
SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<View> views = viewDao.getViews(query);
assertThat(views).isEmpty();
}
use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewsByFulltextAndPagination.
@Test
public void testGetViewsByFulltextAndPagination() {
createView(CODE, NAME);
createView(CODE2, NAME2);
createView(CODE3, NAME3);
SearchQuery query = SearchQuery.createBuilder(USER).fulltext("text").page(1).pageSize(1).build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE2);
}
use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MongoViewDaoTest method testGetViews.
@Test
public void testGetViews() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
viewDao.databaseCollection().insertOne(view2);
SearchQuery query = SearchQuery.createBuilder(USER).build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE, CODE2);
}
use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewsPagination.
@Test
public void testGetViewsPagination() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
viewDao.databaseCollection().insertOne(view2);
SearchQuery query = SearchQuery.createBuilder(USER).page(1).pageSize(1).build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE2);
}
use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsByFulltextAndCollectionIds.
@Test
public void testGetCollectionsByFulltextAndCollectionIds() {
String id1 = createCollection(CODE, NAME, ATTRIBUTES).getId();
String id2 = createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES).getId();
String id3 = createCollection(CODE3, NAME3, ATTRIBUTES).getId();
createCollection(CODE4, NAME_FULLTEXT2, ATTRIBUTES);
SearchQuery searchQuery = SearchQuery.createBuilder(USER).collectionIds(new HashSet<>(Arrays.asList(id1, id2, id3))).fulltext("fulltext").build();
List<Collection> collections = collectionDao.getCollections(searchQuery);
assertThat(collections).extracting(Resource::getId).containsOnly(id2, id3);
}
Aggregations