use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsByAttributesSuggestionsDifferentUser.
@Test
public void testGetCollectionsByAttributesSuggestionsDifferentUser() {
createCollection(CODE, NAME, Collections.emptySet());
createCollection(CODE2, NAME2, ATTRIBUTES);
createCollection(CODE3, NAME3, ATTRIBUTES_FULLTEXT);
SuggestionQuery suggestionQuery = SuggestionQuery.createBuilder(USER2).text("sugg").build();
List<Collection> collections = collectionDao.getCollectionsByAttributes(suggestionQuery);
assertThat(collections).isEmpty();
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsByCollectionIds.
@Test
public void testGetCollectionsByCollectionIds() {
MorphiaCollection collection = prepareCollection(CODE, NAME);
collection.getPermissions().removeUserPermission(USER);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.READ.toString()));
collection.getPermissions().updateUserPermissions(userPermission);
datastore.save(collectionDao.databaseCollection(), collection);
MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
datastore.save(collectionDao.databaseCollection(), collection2);
MorphiaCollection collection3 = prepareCollection(CODE3, NAME3);
datastore.save(collectionDao.databaseCollection(), collection3);
SearchQuery query = SearchQuery.createBuilder(USER).collectionIds(new HashSet<>(Arrays.asList(collection.getId(), collection3.getId()))).build();
List<Collection> views = collectionDao.getCollections(query);
assertThat(views).extracting(Collection::getId).containsOnly(collection3.getId());
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsGroupsRole.
@Test
public void testGetCollectionsGroupsRole() {
MorphiaCollection collection = prepareCollection(CODE, NAME);
datastore.save(collectionDao.databaseCollection(), collection);
MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
datastore.save(collectionDao.databaseCollection(), collection2);
SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP)).build();
List<Collection> collections = collectionDao.getCollections(query);
assertThat(collections).extracting(Collection::getCode).containsOnly(CODE, CODE2);
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsByFulltextWithAttributes.
@Test
@Ignore("Fulltext index on attribute names does not work at the moment")
public void testGetCollectionsByFulltextWithAttributes() {
createCollection(CODE, NAME, ATTRIBUTES);
createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
createCollection(CODE3, NAME, ATTRIBUTES);
createCollection(CODE4, NAME, ATTRIBUTES_FULLTEXT);
SearchQuery searchQuery = SearchQuery.createBuilder(USER).fulltext("fulltext").build();
List<Collection> collections = collectionDao.getCollections(searchQuery);
assertThat(collections).extracting(Resource::getCode).containsOnly(CODE2, CODE3, CODE4);
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionByCode.
@Test
public void testGetCollectionByCode() {
createCollection(CODE, NAME);
Collection collection = collectionDao.getCollectionByCode(CODE);
assertThat(collection).isNotNull();
assertThat(collection.getCode()).isEqualTo(CODE);
}
Aggregations