Search in sources :

Example 1 with SearchQuery

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

the class MongoDataDaoTest method testGetDataByFulltextAttributeName.

@Test
@Ignore("Does not work at the moment")
public void testGetDataByFulltextAttributeName() {
    String id1 = createDocument(KEY1, VALUE1);
    String id2 = createDocument("fulltext", VALUE1);
    String id3 = createDocument(KEY1, VALUE1);
    SearchQuery searchQuery = SearchQuery.createBuilder(USER).fulltext("fulltext").build();
    List<DataDocument> data = dataDao.getData(COLLECTION_ID, searchQuery);
    assertThat(data).extracting(DataDocument::getId).containsOnly(id2);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) DataDocument(io.lumeer.engine.api.data.DataDocument) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with SearchQuery

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

the class MongoDataDaoTest method testGetDataByFulltextAttributeValue.

@Test
public void testGetDataByFulltextAttributeValue() {
    String id1 = createDocument(KEY1, VALUE1);
    String id2 = createDocument(KEY1, "fulltext");
    String id3 = createDocument(KEY1, "something fulltext");
    String id4 = createDocument(KEY1, VALUE1);
    SearchQuery searchQuery = SearchQuery.createBuilder(USER).fulltext("fulltext").build();
    List<DataDocument> data = dataDao.getData(COLLECTION_ID, searchQuery);
    assertThat(data).extracting(DataDocument::getId).containsOnly(id2, id3);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) DataDocument(io.lumeer.engine.api.data.DataDocument) Test(org.junit.Test)

Example 3 with SearchQuery

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

the class MongoLinkInstanceDaoTest method testGetLinkInstancesByLinkTypeIds.

@Test
public void testGetLinkInstancesByLinkTypeIds() {
    String id1 = linkInstanceDao.createLinkInstance(prepareLinkInstance()).getId();
    LinkInstance linkInstance2 = prepareLinkInstance();
    linkInstance2.setLinkTypeId(LINK_TYPE_ID2);
    String id2 = linkInstanceDao.createLinkInstance(linkInstance2).getId();
    LinkInstance linkInstance3 = prepareLinkInstance();
    linkInstance3.setLinkTypeId(LINK_TYPE_ID2);
    String id3 = linkInstanceDao.createLinkInstance(linkInstance3).getId();
    LinkInstance linkInstance4 = prepareLinkInstance();
    linkInstance4.setLinkTypeId(LINK_TYPE_ID3);
    String id4 = linkInstanceDao.createLinkInstance(linkInstance4).getId();
    SearchQuery query1 = SearchQuery.createBuilder(USER).linkTypeIds(new HashSet<>(Arrays.asList(LINK_TYPE_ID1, LINK_TYPE_ID2))).build();
    List<LinkInstance> linkInstances = linkInstanceDao.getLinkInstances(query1);
    assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id3));
    SearchQuery query2 = SearchQuery.createBuilder(USER).linkTypeIds(Collections.singleton(LINK_TYPE_ID3)).build();
    linkInstances = linkInstanceDao.getLinkInstances(query2);
    assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Collections.singletonList(id4));
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) LinkInstance(io.lumeer.api.model.LinkInstance) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with SearchQuery

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

the class MongoLinkTypeDaoTest method testGetLinkTypesByCollections.

@Test
public void testGetLinkTypesByCollections() {
    String id1 = linkTypeDao.createLinkType(prepareLinkType()).getId();
    LinkType linkType2 = prepareLinkType();
    linkType2.setCollectionIds(Arrays.asList(COLLECTION_ID3, COLLECTION_ID4));
    String id2 = linkTypeDao.createLinkType(linkType2).getId();
    LinkType linkType3 = prepareLinkType();
    linkType3.setCollectionIds(Arrays.asList(COLLECTION_ID1, COLLECTION_ID4));
    String id3 = linkTypeDao.createLinkType(linkType3).getId();
    LinkType linkType4 = prepareLinkType();
    linkType4.setCollectionIds(Arrays.asList(COLLECTION_ID2, COLLECTION_ID3));
    String id4 = linkTypeDao.createLinkType(linkType4).getId();
    SearchQuery query1 = SearchQuery.createBuilder(USER).collectionIds(new HashSet<>(Arrays.asList(COLLECTION_ID1, COLLECTION_ID2))).build();
    List<LinkType> linkTypes = linkTypeDao.getLinkTypes(query1);
    assertThat(linkTypes).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id3, id4));
    SearchQuery query2 = SearchQuery.createBuilder(USER).collectionIds(Collections.singleton(COLLECTION_ID3)).build();
    linkTypes = linkTypeDao.getLinkTypes(query2);
    assertThat(linkTypes).extracting("id").containsOnlyElementsOf(Arrays.asList(id2, id4));
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) LinkType(io.lumeer.api.model.LinkType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with SearchQuery

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

the class MongoLinkTypeDaoTest method testDeleteLinkTypesByCollections.

@Test
public void testDeleteLinkTypesByCollections() {
    linkTypeDao.createLinkType(prepareLinkType());
    LinkType linkType2 = prepareLinkType();
    linkType2.setCollectionIds(Arrays.asList(COLLECTION_ID2, COLLECTION_ID3));
    linkTypeDao.createLinkType(linkType2);
    LinkType linkType3 = prepareLinkType();
    linkType3.setCollectionIds(Arrays.asList(COLLECTION_ID2, COLLECTION_ID4));
    linkTypeDao.createLinkType(linkType3);
    LinkType linkType4 = prepareLinkType();
    linkType4.setCollectionIds(Arrays.asList(COLLECTION_ID3, COLLECTION_ID4));
    linkTypeDao.createLinkType(linkType4);
    assertThat(linkTypeDao.databaseCollection().find().into(new ArrayList<>()).size()).isEqualTo(4);
    SearchQuery query1 = SearchQuery.createBuilder(USER).collectionIds((Collections.singleton(COLLECTION_ID2))).build();
    linkTypeDao.deleteLinkTypes(query1);
    assertThat(linkTypeDao.databaseCollection().find().into(new ArrayList<>()).size()).isEqualTo(1);
    SearchQuery query2 = SearchQuery.createBuilder(USER).collectionIds((Collections.singleton(COLLECTION_ID3))).build();
    linkTypeDao.deleteLinkTypes(query2);
    assertThat(linkTypeDao.databaseCollection().find().into(new ArrayList<>())).isEmpty();
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) ArrayList(java.util.ArrayList) LinkType(io.lumeer.api.model.LinkType) 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