Search in sources :

Example 66 with Collection

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

the class SearchFacadeIT method testSearchCollectionsByEmptyQuery.

@Test
public void testSearchCollectionsByEmptyQuery() {
    List<Collection> collections = searchFacade.searchCollections(new JsonQuery());
    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 67 with Collection

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

the class CollectionServiceIT method testUpdateCollection.

@Test
public void testUpdateCollection() {
    String collectionId = createCollection(CODE).getId();
    Collection updatedCollection = prepareCollection(CODE2);
    Entity entity = Entity.json(updatedCollection);
    Response response = client.target(COLLECTIONS_URL).path(collectionId).request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    Collection returnedCollection = response.readEntity(JsonCollection.class);
    SoftAssertions assertions = new SoftAssertions();
    assertions.assertThat(returnedCollection.getCode()).isEqualTo(CODE2);
    assertions.assertThat(returnedCollection.getName()).isEqualTo(NAME);
    assertions.assertThat(returnedCollection.getIcon()).isEqualTo(ICON);
    assertions.assertThat(returnedCollection.getColor()).isEqualTo(COLOR);
    assertions.assertThat(returnedCollection.getPermissions().getUserPermissions()).containsOnly(USER_PERMISSION);
    assertions.assertThat(returnedCollection.getPermissions().getGroupPermissions()).isEmpty();
    assertions.assertAll();
    Collection storedCollection = collectionDao.getCollectionByCode(CODE2);
    assertThat(storedCollection).isNotNull();
    assertions = new SoftAssertions();
    assertions.assertThat(storedCollection.getCode()).isEqualTo(CODE2);
    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()).containsOnly(GROUP_PERMISSION);
    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) Test(org.junit.Test)

Example 68 with Collection

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

the class CollectionServiceIT method testGetCollection.

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

Example 69 with Collection

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

the class CollectionServiceIT method testUpdateCollectionAttribute.

@Test
public void testUpdateCollectionAttribute() {
    Collection collection = createCollection(CODE);
    assertThat(collection.getAttributes()).hasSize(1);
    JsonAttribute updatedAttribute = new JsonAttribute(ATTRIBUTE_NAME, ATTRIBUTE_FULLNAME2, ATTRIBUTE_CONSTRAINTS, ATTRIBUTE_COUNT);
    Entity entity = Entity.json(updatedAttribute);
    Response response = client.target(COLLECTIONS_URL).path(collection.getId()).path("attributes").path(ATTRIBUTE_FULLNAME).request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    JsonAttribute attribute = response.readEntity(new GenericType<JsonAttribute>() {
    });
    SoftAssertions assertions = new SoftAssertions();
    assertions.assertThat(attribute.getName()).isEqualTo(ATTRIBUTE_NAME);
    assertions.assertThat(attribute.getFullName()).isEqualTo(ATTRIBUTE_FULLNAME2);
    assertions.assertThat(attribute.getConstraints()).isEqualTo(ATTRIBUTE_CONSTRAINTS);
    assertions.assertThat(attribute.getUsageCount()).isEqualTo(ATTRIBUTE_COUNT);
    assertions.assertAll();
    Collection storedCollection = collectionDao.getCollectionByCode(CODE);
    Set<Attribute> storedAttributes = storedCollection.getAttributes();
    assertThat(storedAttributes).hasSize(1);
    Attribute storedAttribute = storedAttributes.iterator().next();
    assertions = new SoftAssertions();
    assertions.assertThat(storedAttribute.getName()).isEqualTo(ATTRIBUTE_NAME);
    assertions.assertThat(storedAttribute.getFullName()).isEqualTo(ATTRIBUTE_FULLNAME2);
    assertions.assertThat(storedAttribute.getConstraints()).isEqualTo(ATTRIBUTE_CONSTRAINTS);
    assertions.assertThat(storedAttribute.getUsageCount()).isEqualTo(ATTRIBUTE_COUNT);
    assertions.assertAll();
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) JsonAttribute(io.lumeer.api.dto.JsonAttribute) Attribute(io.lumeer.api.model.Attribute) SoftAssertions(org.assertj.core.api.SoftAssertions) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) JsonAttribute(io.lumeer.api.dto.JsonAttribute) Test(org.junit.Test)

Example 70 with Collection

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

the class CollectionServiceIT method createCollection.

private Collection createCollection(String code, String name) {
    Collection collection = prepareCollection(code, name);
    collection.getPermissions().updateUserPermissions(USER_PERMISSION);
    collection.getPermissions().updateGroupPermissions(GROUP_PERMISSION);
    collection.updateAttribute(ATTRIBUTE_FULLNAME, ATTRIBUTE);
    return collectionDao.createCollection(collection);
}
Also used : JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection)

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