Search in sources :

Example 6 with Attribute

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

the class CollectionFacadeIT method testUpdateCollectionAttributeAdd.

@Test
public void testUpdateCollectionAttributeAdd() {
    Collection collection = createCollection(CODE);
    assertThat(collection.getAttributes()).isEmpty();
    JsonAttribute attribute = new JsonAttribute(ATTRIBUTE_NAME, ATTRIBUTE_FULLNAME, ATTRIBUTE_CONSTRAINTS, ATTRIBUTE_COUNT);
    collectionFacade.updateCollectionAttribute(collection.getId(), ATTRIBUTE_FULLNAME, attribute);
    collection = collectionDao.getCollectionByCode(CODE);
    assertThat(collection).isNotNull();
    assertThat(collection.getAttributes()).hasSize(1);
    Attribute storedAttribute = collection.getAttributes().iterator().next();
    SoftAssertions assertions = new SoftAssertions();
    assertions.assertThat(storedAttribute.getName()).isEqualTo(ATTRIBUTE_NAME);
    assertions.assertThat(storedAttribute.getFullName()).isEqualTo(ATTRIBUTE_FULLNAME);
    assertions.assertThat(storedAttribute.getConstraints()).isEqualTo(ATTRIBUTE_CONSTRAINTS);
    assertions.assertThat(storedAttribute.getUsageCount()).isEqualTo(ATTRIBUTE_COUNT);
    assertions.assertAll();
}
Also used : 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 7 with Attribute

use of io.lumeer.api.model.Attribute 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)

Aggregations

Attribute (io.lumeer.api.model.Attribute)7 JsonAttribute (io.lumeer.api.dto.JsonAttribute)6 Collection (io.lumeer.api.model.Collection)6 JsonCollection (io.lumeer.api.dto.JsonCollection)4 Test (org.junit.Test)4 SoftAssertions (org.assertj.core.api.SoftAssertions)3 CollectionDao (io.lumeer.storage.api.dao.CollectionDao)2 SearchQuery (io.lumeer.storage.api.query.SearchQuery)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 RequestScoped (javax.enterprise.context.RequestScoped)2 Inject (javax.inject.Inject)2 Response (javax.ws.rs.core.Response)2 JsonSuggestions (io.lumeer.api.dto.JsonSuggestions)1 Document (io.lumeer.api.model.Document)1 LinkType (io.lumeer.api.model.LinkType)1 Pagination (io.lumeer.api.model.Pagination)1