use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewsGroupRole.
@Test
public void testGetViewsGroupRole() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
viewDao.databaseCollection().insertOne(view2);
SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP)).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 testGetViewsByCollections.
@Test
public void testGetViewsByCollections() {
createView(CODE, NAME, new HashSet<>(Arrays.asList("c1", "c2", "c3")));
createView(CODE2, NAME2, new HashSet<>(Arrays.asList("c2", "c3", "c4")));
createView(CODE3, NAME3, new HashSet<>(Arrays.asList("c1", "c3")));
SearchQuery query = SearchQuery.createBuilder(USER).collectionIds(new HashSet<>(Arrays.asList("c1", "c5"))).build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE, CODE3);
query = SearchQuery.createBuilder(USER).collectionIds(new HashSet<>(Arrays.asList("c2", "c4"))).build();
views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE, CODE2);
query = SearchQuery.createBuilder(USER).collectionIds(new HashSet<>(Arrays.asList("c4", "c5", "c6"))).build();
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 testGetViewsByFulltextDifferentUser.
@Test
public void testGetViewsByFulltextDifferentUser() {
createView(CODE, NAME);
createView(CODE2, NAME2);
createView(CODE3, NAME3);
SearchQuery query = SearchQuery.createBuilder(USER2).fulltext("text").build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).isEmpty();
}
use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewsByFulltext.
@Test
public void testGetViewsByFulltext() {
createView(CODE, NAME);
createView(CODE2, NAME2);
createView(CODE3, NAME3);
SearchQuery query = SearchQuery.createBuilder(USER).fulltext("text").build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE2, CODE3);
}
use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsByFulltext.
@Test
public void testGetCollectionsByFulltext() {
createCollection(CODE, NAME, ATTRIBUTES);
createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
createCollection(CODE3, NAME3, ATTRIBUTES);
SearchQuery searchQuery = SearchQuery.createBuilder(USER).fulltext("fulltext").build();
List<Collection> collections = collectionDao.getCollections(searchQuery);
assertThat(collections).extracting(Resource::getCode).containsOnly(CODE2, CODE3);
}
Aggregations