use of io.lumeer.api.dto.JsonAttribute 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();
}
use of io.lumeer.api.dto.JsonAttribute in project engine by Lumeer.
the class LinkTypeCodec method decode.
@Override
public LinkType decode(final BsonReader reader, final DecoderContext decoderContext) {
Document bson = documentCodec.decode(reader, decoderContext);
String id = bson.getObjectId(ID).toHexString();
String name = bson.getString(NAME);
List<String> collectionCodes = bson.get(COLLECTION_IDS, List.class);
List<JsonAttribute> attributes = new ArrayList<Document>(bson.get(ATTRIBUTES, List.class)).stream().map(AttributeCodec::convertFromDocument).collect(Collectors.toList());
return new LinkType(id, name, collectionCodes, attributes);
}
use of io.lumeer.api.dto.JsonAttribute 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();
}
Aggregations