Search in sources :

Example 31 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class SearchFacadeIT method testSearchCollectionsByDocumentsFullText.

@Test
public void testSearchCollectionsByDocumentsFullText() {
    createDocument(collectionIds.get(0), "word");
    createDocument(collectionIds.get(0), "fulltext");
    createDocument(collectionIds.get(1), "something fulltext");
    createDocument(collectionIds.get(1), "some other word");
    createDocument(collectionIds.get(2), "full word");
    List<Collection> collections = searchFacade.searchCollections(new JsonQuery("fulltext"));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(0), collectionIds.get(1));
    collections = searchFacade.searchCollections(new JsonQuery("word"));
    assertThat(collections).extracting(Collection::getId).containsOnlyElementsOf(collectionIds);
}
Also used : JsonQuery(io.lumeer.api.dto.JsonQuery) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 32 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class SearchFacadeIT method testSearchCollectionsCombination.

@Test
public void testSearchCollectionsCombination() {
    createDocument(collectionIds.get(0), "word").getId();
    String id2 = createDocument(collectionIds.get(0), "fulltext").getId();
    String id3 = createDocument(collectionIds.get(1), "something fulltext").getId();
    createDocument(collectionIds.get(1), "some other word").getId();
    String id5 = createDocument(collectionIds.get(2), "full word").getId();
    List<Collection> collections = searchFacade.searchCollections(new JsonQuery(Collections.singleton(collectionIds.get(0)), null, Collections.singleton(id3)));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(0), collectionIds.get(1));
}
Also used : JsonQuery(io.lumeer.api.dto.JsonQuery) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 33 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class SearchFacadeIT method testSearchCollectionsByDocumentsIds.

@Test
public void testSearchCollectionsByDocumentsIds() {
    String id1 = createDocument(collectionIds.get(0), "doc1").getId();
    String id2 = createDocument(collectionIds.get(0), "doc2").getId();
    String id3 = createDocument(collectionIds.get(1), "doc3").getId();
    String id4 = createDocument(collectionIds.get(1), "doc4").getId();
    String id5 = createDocument(collectionIds.get(2), "doc5").getId();
    String id6 = createDocument(collectionIds.get(2), "doc6").getId();
    List<Collection> collections = searchFacade.searchCollections(new JsonQuery(null, null, new HashSet<>(Arrays.asList(id1, id2, id3))));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(0), collectionIds.get(1));
    collections = searchFacade.searchCollections(new JsonQuery(null, null, new HashSet<>(Arrays.asList(id1, id4, id5))));
    assertThat(collections).extracting(Collection::getId).containsOnlyElementsOf(collectionIds);
    collections = searchFacade.searchCollections(new JsonQuery(null, null, new HashSet<>(Arrays.asList(id5, id6))));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(2));
}
Also used : JsonQuery(io.lumeer.api.dto.JsonQuery) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 34 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class CollectionServiceIT method testCreateCollection.

@Test
public void testCreateCollection() {
    Collection collection = prepareCollection(CODE);
    Entity entity = Entity.json(collection);
    Response response = client.target(COLLECTIONS_URL).request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    JsonCollection returnedCollection = response.readEntity(JsonCollection.class);
    assertThat(returnedCollection).isNotNull();
    assertThat(returnedCollection.getId()).isNotNull();
    Collection storedCollection = collectionDao.getCollectionByCode(CODE);
    assertThat(storedCollection).isNotNull();
    assertThat(returnedCollection.getId()).isEqualTo(storedCollection.getId());
    SoftAssertions assertions = new SoftAssertions();
    assertions.assertThat(storedCollection.getCode()).isEqualTo(CODE);
    assertions.assertThat(storedCollection.getName()).isEqualTo(NAME);
    assertions.assertThat(storedCollection.getIcon()).isEqualTo(ICON);
    assertions.assertThat(storedCollection.getColor()).isEqualTo(COLOR);
    assertions.assertThat(storedCollection.getPermissions().getUserPermissions()).containsOnly(USER_PERMISSION);
    assertions.assertThat(storedCollection.getPermissions().getGroupPermissions()).isEmpty();
    assertions.assertAll();
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) SoftAssertions(org.assertj.core.api.SoftAssertions) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) JsonCollection(io.lumeer.api.dto.JsonCollection) Test(org.junit.Test)

Example 35 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class CollectionServiceIT method testDeleteCollectionAttribute.

@Test
public void testDeleteCollectionAttribute() {
    Collection collection = createCollection(CODE);
    assertThat(collection.getAttributes()).hasSize(1);
    Response response = client.target(COLLECTIONS_URL).path(collection.getId()).path("attributes").path(ATTRIBUTE_FULLNAME).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    Collection storedCollection = collectionDao.getCollectionByCode(CODE);
    Set<Attribute> storedAttributes = storedCollection.getAttributes();
    assertThat(storedAttributes).isEmpty();
}
Also used : Response(javax.ws.rs.core.Response) JsonAttribute(io.lumeer.api.dto.JsonAttribute) Attribute(io.lumeer.api.model.Attribute) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Aggregations

Collection (io.lumeer.api.model.Collection)77 Test (org.junit.Test)47 JsonCollection (io.lumeer.api.dto.JsonCollection)34 DataDocument (io.lumeer.engine.api.data.DataDocument)17 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)17 SearchQuery (io.lumeer.storage.api.query.SearchQuery)14 SoftAssertions (org.assertj.core.api.SoftAssertions)12 Document (io.lumeer.api.model.Document)8 ImportedCollection (io.lumeer.api.model.ImportedCollection)8 SuggestionQuery (io.lumeer.storage.api.query.SuggestionQuery)8 Response (javax.ws.rs.core.Response)8 JsonAttribute (io.lumeer.api.dto.JsonAttribute)7 Attribute (io.lumeer.api.model.Attribute)7 HashSet (java.util.HashSet)6 JsonQuery (io.lumeer.api.dto.JsonQuery)5 LocalDateTime (java.time.LocalDateTime)4 List (java.util.List)4 JsonDocument (io.lumeer.api.dto.JsonDocument)3 LinkType (io.lumeer.api.model.LinkType)3 CollectionDao (io.lumeer.storage.api.dao.CollectionDao)3