Search in sources :

Example 61 with Collection

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

the class MorphiaCollectionDaoTest method testGetCollectionsByFulltextDifferentUser.

@Test
public void testGetCollectionsByFulltextDifferentUser() {
    createCollection(CODE, NAME, ATTRIBUTES);
    createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
    createCollection(CODE3, NAME3, ATTRIBUTES);
    SearchQuery searchQuery = SearchQuery.createBuilder(USER2).fulltext("fulltext").build();
    List<Collection> collections = collectionDao.getCollections(searchQuery);
    assertThat(collections).isEmpty();
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 62 with Collection

use of io.lumeer.api.model.Collection 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 63 with Collection

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

the class ProjectServicePermissionsIT method testCreateCollectionInProjectNoRole.

@Test
public void testCreateCollectionInProjectNoRole() {
    String projectCode = "testCreateCollectionInProjectNoRole_code1";
    String projectName = "estCreateCollectionInProjectNoRole";
    createProject(projectCode, projectName);
    projectFacade.removeUserPermission(projectCode, userEmail);
    String collectionName = "CollectionName";
    String collectionCode = "ColCode";
    Collection collection = new JsonCollection(collectionCode, collectionName, "a", "b", null);
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode + "/collections").request(MediaType.APPLICATION_JSON).buildPost(Entity.json(collection)).invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.UNAUTHORIZED);
}
Also used : Response(javax.ws.rs.core.Response) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) JsonCollection(io.lumeer.api.dto.JsonCollection) Test(org.junit.Test)

Example 64 with Collection

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

the class ProjectServicePermissionsIT method testCreateCollectionInProjectWriteRole.

@Test
public void testCreateCollectionInProjectWriteRole() {
    String projectCode = "testCreateCollectionInProjectWriteRole_code1";
    String projectName = "testCreateCollectionInProjectWriteRole";
    createProject(projectCode, projectName);
    String collectionName = "CollectionName";
    String collectionCode = "ColCode2";
    Collection collection = new JsonCollection(collectionCode, collectionName, "a", "b", null);
    Response response = client.target(TARGET_URI).path(PATH_PREFIX + projectCode + "/collections").request(MediaType.APPLICATION_JSON).buildPost(Entity.json(collection)).invoke();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
}
Also used : Response(javax.ws.rs.core.Response) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) JsonCollection(io.lumeer.api.dto.JsonCollection) Test(org.junit.Test)

Example 65 with Collection

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

the class SearchFacadeIT method testSearchCollectionsByCollectionIds.

@Test
public void testSearchCollectionsByCollectionIds() {
    List<Collection> collections = searchFacade.searchCollections(new JsonQuery(new HashSet<>(Arrays.asList(collectionIds.get(0), collectionIds.get(2))), null, null));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(0), collectionIds.get(2));
    collections = searchFacade.searchCollections(new JsonQuery(Collections.singleton(collectionIds.get(1)), null, null));
    assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(1));
}
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)

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