use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsPagination.
@Test
public void testGetCollectionsPagination() {
createCollection(CODE, NAME);
createCollection(CODE2, NAME2);
createCollection(CODE3, NAME3);
SearchQuery searchQuery = SearchQuery.createBuilder(USER).page(1).pageSize(1).build();
List<Collection> collections = collectionDao.getCollections(searchQuery);
assertThat(collections).extracting(Resource::getCode).containsOnly(CODE2);
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testDeleteCollection.
@Test
public void testDeleteCollection() {
String id = createCollection(CODE, NAME).getId();
collectionDao.deleteCollection(id);
Collection storedCollection = datastore.get(collectionDao.databaseCollection(), MorphiaCollection.class, new ObjectId(id));
assertThat(storedCollection).isNull();
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollections.
@Test
public void testGetCollections() {
MorphiaCollection collection = prepareCollection(CODE, NAME);
datastore.save(collectionDao.databaseCollection(), collection);
MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
datastore.save(collectionDao.databaseCollection(), collection2);
SearchQuery query = SearchQuery.createBuilder(USER).build();
List<Collection> views = collectionDao.getCollections(query);
assertThat(views).extracting(Collection::getCode).containsOnly(CODE, CODE2);
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsByIds.
@Test
public void testGetCollectionsByIds() {
MorphiaCollection collection = prepareCollection(CODE, NAME);
String id = collectionDao.createCollection(collection).getId();
MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
String id2 = collectionDao.createCollection(collection2).getId();
MorphiaCollection collection3 = prepareCollection(CODE3, NAME3);
String id3 = collectionDao.createCollection(collection3).getId();
MorphiaCollection collection4 = prepareCollection(CODE4, NAME4);
String id4 = collectionDao.createCollection(collection4).getId();
List<Collection> collections = collectionDao.getCollectionsByIds(Arrays.asList(id, id3));
assertThat(collections).hasSize(2).extracting("id").containsOnlyElementsOf(Arrays.asList(id, id3));
collections = collectionDao.getCollectionsByIds(Arrays.asList(id, id2, id4));
assertThat(collections).hasSize(3).extracting("id").containsOnlyElementsOf(Arrays.asList(id, id2, id4));
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class CollectionFacadeIT method testDeleteCollectionAttribute.
@Test
public void testDeleteCollectionAttribute() {
JsonAttribute attribute = new JsonAttribute(ATTRIBUTE_NAME, ATTRIBUTE_FULLNAME, ATTRIBUTE_CONSTRAINTS, ATTRIBUTE_COUNT);
Collection collection = createCollection(CODE, attribute);
assertThat(collection.getAttributes()).isNotEmpty();
collectionFacade.deleteCollectionAttribute(collection.getId(), ATTRIBUTE_FULLNAME);
collection = collectionDao.getCollectionByCode(CODE);
assertThat(collection).isNotNull();
assertThat(collection.getAttributes()).isEmpty();
}
Aggregations