Search in sources :

Example 26 with SearchQuery

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);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) JsonView(io.lumeer.api.dto.JsonView) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Example 27 with SearchQuery

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);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 28 with SearchQuery

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();
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Example 29 with SearchQuery

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);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Example 30 with SearchQuery

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);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Aggregations

SearchQuery (io.lumeer.storage.api.query.SearchQuery)39 Test (org.junit.Test)37 View (io.lumeer.api.model.View)15 Collection (io.lumeer.api.model.Collection)11 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)9 JsonView (io.lumeer.api.dto.JsonView)8 HashSet (java.util.HashSet)8 MorphiaView (io.lumeer.storage.mongodb.model.MorphiaView)7 LinkType (io.lumeer.api.model.LinkType)5 DataDocument (io.lumeer.engine.api.data.DataDocument)5 LinkInstance (io.lumeer.api.model.LinkInstance)4 Permission (io.lumeer.api.model.Permission)4 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)4 ArrayList (java.util.ArrayList)4 Ignore (org.junit.Ignore)2 HashMap (java.util.HashMap)1