Search in sources :

Example 36 with SearchQuery

use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.

the class MorphiaViewDaoTest method testGetViewsByFulltextDifferentUser.

@Test
public void testGetViewsByFulltextDifferentUser() {
    createView(CODE, NAME);
    createView(CODE2, NAME2);
    createView(CODE3, NAME3);
    SearchQuery query = SearchQuery.createBuilder(USER2).fulltext("fulltext").build();
    List<View> views = viewDao.getViews(query);
    assertThat(views).extracting(View::getCode).isEmpty();
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) View(io.lumeer.api.model.View) MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) Test(org.junit.Test)

Example 37 with SearchQuery

use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.

the class MorphiaViewDaoTest method testGetViewsNoReadRole.

@Test
public void testGetViewsNoReadRole() {
    MorphiaView view = prepareView();
    Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
    view.getPermissions().updateUserPermissions(userPermission);
    datastore.save(viewDao.databaseCollection(), view);
    MorphiaView view2 = prepareView();
    view2.setCode(CODE2);
    view2.setName(NAME2);
    Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
    view2.getPermissions().updateGroupPermissions(groupPermission);
    datastore.save(viewDao.databaseCollection(), view2);
    SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
    List<View> views = viewDao.getViews(query);
    assertThat(views).isEmpty();
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) Permission(io.lumeer.api.model.Permission) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) View(io.lumeer.api.model.View) MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) Test(org.junit.Test)

Example 38 with SearchQuery

use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.

the class MorphiaViewDaoTest method testGetViewsByFulltextAndPagination.

@Test
public void testGetViewsByFulltextAndPagination() {
    createView(CODE, NAME);
    createView(CODE2, NAME2);
    createView(CODE3, NAME3);
    SearchQuery query = SearchQuery.createBuilder(USER).fulltext("fulltext").page(1).pageSize(1).build();
    List<View> views = viewDao.getViews(query);
    assertThat(views).extracting(View::getCode).containsOnly(CODE2);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) View(io.lumeer.api.model.View) MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) Test(org.junit.Test)

Example 39 with SearchQuery

use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.

the class MorphiaViewDaoTest method testGetViewsByFulltext.

@Test
public void testGetViewsByFulltext() {
    createView(CODE, NAME);
    createView(CODE2, NAME2);
    createView(CODE3, NAME3);
    SearchQuery query = SearchQuery.createBuilder(USER).fulltext("fulltext").build();
    List<View> views = viewDao.getViews(query);
    assertThat(views).extracting(View::getCode).containsOnly(CODE2, CODE3);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) View(io.lumeer.api.model.View) MorphiaView(io.lumeer.storage.mongodb.model.MorphiaView) 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