use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MongoDataDaoTest method initDataDao.
@Before
public void initDataDao() {
Collection collection = Mockito.mock(Collection.class);
Mockito.when(collection.getId()).thenReturn(COLLECTION_ID);
dataDao = new MongoDataDao();
dataDao.setDatabase(database);
dataDao.setDatastore(datastore);
dataDao.createDataRepository(COLLECTION_ID);
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsSuggestionsDifferentUser.
@Test
public void testGetCollectionsSuggestionsDifferentUser() {
createCollection(CODE, NAME, ATTRIBUTES);
createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
createCollection(CODE3, NAME_SUGGESTION, ATTRIBUTES);
SuggestionQuery suggestionQuery = SuggestionQuery.createBuilder(USER2).text("TEST").build();
List<Collection> collections = collectionDao.getCollections(suggestionQuery);
assertThat(collections).isEmpty();
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsSuggestions.
@Test
public void testGetCollectionsSuggestions() {
createCollection(CODE, NAME, ATTRIBUTES);
createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
createCollection(CODE3, NAME_SUGGESTION, ATTRIBUTES);
SuggestionQuery suggestionQuery = SuggestionQuery.createBuilder(USER).text("TEST").build();
List<Collection> collections = collectionDao.getCollections(suggestionQuery);
assertThat(collections).extracting(Resource::getCode).containsOnly(CODE, CODE3);
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testUpdateCollection.
@Test
public void testUpdateCollection() {
String id = createCollection(CODE, NAME).getId();
MorphiaCollection collection = prepareCollection(CODE2, NAME);
Collection updatedCollection = collectionDao.updateCollection(id, collection);
assertThat(updatedCollection).isNotNull();
assertThat(updatedCollection.getCode()).isEqualTo(CODE2);
Collection storedCollection = datastore.get(collectionDao.databaseCollection(), MorphiaCollection.class, new ObjectId(id));
assertThat(storedCollection).isNotNull();
assertThat(updatedCollection).isEqualTo(storedCollection);
}
use of io.lumeer.api.model.Collection in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsByFulltextAndCollectionIds.
@Test
public void testGetCollectionsByFulltextAndCollectionIds() {
String id1 = createCollection(CODE, NAME, ATTRIBUTES).getId();
String id2 = createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES).getId();
String id3 = createCollection(CODE3, NAME3, ATTRIBUTES).getId();
createCollection(CODE4, NAME_FULLTEXT2, ATTRIBUTES);
SearchQuery searchQuery = SearchQuery.createBuilder(USER).collectionIds(new HashSet<>(Arrays.asList(id1, id2, id3))).fulltext("fulltext").build();
List<Collection> collections = collectionDao.getCollections(searchQuery);
assertThat(collections).extracting(Resource::getId).containsOnly(id2, id3);
}
Aggregations