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);
}
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();
}
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();
}
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();
}
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);
}
Aggregations