Search in sources :

Example 11 with LinkType

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

the class LinkTypeFacadeIT method testUpdateLinkType.

@Test
public void testUpdateLinkType() {
    LinkType linkType = prepareLinkType();
    String id = linkTypeFacade.createLinkType(linkType).getId();
    LinkType updateLinkedType = prepareLinkType();
    updateLinkedType.setName(NAME2);
    updateLinkedType.setCollectionIds(Arrays.asList(collectionIds.get(1), collectionIds.get(2)));
    linkTypeFacade.updateLinkType(id, updateLinkedType);
    LinkType storedLinkType = linkTypeDao.getLinkType(id);
    assertThat(storedLinkType).isNotNull();
    assertThat(storedLinkType.getName()).isEqualTo(NAME2);
    assertThat(storedLinkType.getAttributes()).isEqualTo(ATTRIBUTES);
    assertThat(storedLinkType.getCollectionIds()).containsOnlyElementsOf(Arrays.asList(collectionIds.get(1), collectionIds.get(2)));
}
Also used : LinkType(io.lumeer.api.model.LinkType) Test(org.junit.Test)

Example 12 with LinkType

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

the class LinkTypeFacadeIT method testGetLinkTypes.

@Test
public void testGetLinkTypes() {
    String id1 = linkTypeFacade.createLinkType(prepareLinkType()).getId();
    LinkType linkType2 = prepareLinkType();
    linkType2.setCollectionIds(Arrays.asList(collectionIds.get(0), collectionIds.get(2)));
    String id2 = linkTypeFacade.createLinkType(linkType2).getId();
    LinkType linkType3 = prepareLinkType();
    linkType3.setCollectionIds(Arrays.asList(collectionIds.get(1), collectionIds.get(2)));
    String id3 = linkTypeFacade.createLinkType(linkType3).getId();
    LinkType linkType4 = prepareLinkType();
    linkType4.setCollectionIds(Arrays.asList(collectionIds.get(1), collectionIds.get(0)));
    String id4 = linkTypeFacade.createLinkType(linkType4).getId();
    JsonQuery jsonQuery = new JsonQuery(Collections.singleton(collectionIds.get(0)), null, null);
    List<LinkType> linkTypes = linkTypeFacade.getLinkTypes(jsonQuery);
    assertThat(linkTypes).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id4));
    JsonQuery jsonQuery2 = new JsonQuery(null, new HashSet<>(Arrays.asList(id1, id3)), null);
    linkTypes = linkTypeFacade.getLinkTypes(jsonQuery2);
    assertThat(linkTypes).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id3));
}
Also used : JsonQuery(io.lumeer.api.dto.JsonQuery) LinkType(io.lumeer.api.model.LinkType) Test(org.junit.Test)

Example 13 with LinkType

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

the class LinkTypeFacadeIT method testCreateLinkType.

@Test
public void testCreateLinkType() {
    LinkType linkType = prepareLinkType();
    String id = linkTypeFacade.createLinkType(linkType).getId();
    assertThat(id).isNotNull().isNotEmpty();
    assertThat(ObjectId.isValid(id)).isTrue();
    LinkType storedLinkType = linkTypeDao.getLinkType(id);
    assertThat(storedLinkType).isNotNull();
    assertThat(storedLinkType.getName()).isEqualTo(NAME);
    assertThat(storedLinkType.getAttributes()).isEqualTo(ATTRIBUTES);
    assertThat(storedLinkType.getCollectionIds()).containsOnlyElementsOf(Arrays.asList(collectionIds.get(0), collectionIds.get(1)));
}
Also used : LinkType(io.lumeer.api.model.LinkType) Test(org.junit.Test)

Example 14 with LinkType

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

the class LinkTypeServiceIT method testCreateLinkType.

@Test
public void testCreateLinkType() {
    LinkType linkType = prepareLinkType();
    Entity entity = Entity.json(linkType);
    Response response = client.target(LINK_TYPES_URL).request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    LinkType returnedLinkType = response.readEntity(LinkType.class);
    assertThat(returnedLinkType).isNotNull();
    assertThat(returnedLinkType.getName()).isEqualTo(NAME);
    assertThat(returnedLinkType.getAttributes()).isEqualTo(ATTRIBUTES);
    assertThat(returnedLinkType.getCollectionIds()).containsOnlyElementsOf(Arrays.asList(collectionIds.get(0), collectionIds.get(1)));
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) LinkType(io.lumeer.api.model.LinkType) Test(org.junit.Test)

Example 15 with LinkType

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

the class LinkTypeServiceIT method testDeleteLinkType.

@Test
public void testDeleteLinkType() {
    LinkType created = linkTypeDao.createLinkType(prepareLinkType());
    assertThat(created.getId()).isNotNull();
    Response response = client.target(LINK_TYPES_URL).path(created.getId()).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    assertThat(response.getLinks()).extracting(Link::getUri).containsOnly(UriBuilder.fromUri(LINK_TYPES_URL).build());
    assertThatThrownBy(() -> linkTypeDao.getLinkType(created.getId())).isInstanceOf(StorageException.class);
}
Also used : Response(javax.ws.rs.core.Response) LinkType(io.lumeer.api.model.LinkType) Test(org.junit.Test)

Aggregations

LinkType (io.lumeer.api.model.LinkType)26 Test (org.junit.Test)18 SearchQuery (io.lumeer.storage.api.query.SearchQuery)6 Response (javax.ws.rs.core.Response)5 ArrayList (java.util.ArrayList)4 Entity (javax.ws.rs.client.Entity)4 JsonQuery (io.lumeer.api.dto.JsonQuery)3 HashSet (java.util.HashSet)3 List (java.util.List)3 JsonCollection (io.lumeer.api.dto.JsonCollection)2 JsonOrganization (io.lumeer.api.dto.JsonOrganization)2 JsonPermission (io.lumeer.api.dto.JsonPermission)2 JsonPermissions (io.lumeer.api.dto.JsonPermissions)2 JsonProject (io.lumeer.api.dto.JsonProject)2 Collection (io.lumeer.api.model.Collection)2 Organization (io.lumeer.api.model.Organization)2 Project (io.lumeer.api.model.Project)2 User (io.lumeer.api.model.User)2 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)2 Before (org.junit.Before)2