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