use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class LinkInstanceFacadeIT method testDeleteLinkInstance.
@Test
public void testDeleteLinkInstance() {
LinkInstance created = linkInstanceFacade.createLinkInstance(prepareLinkInstance());
assertThat(created.getId()).isNotNull();
linkInstanceFacade.deleteLinkInstance(created.getId());
assertThatThrownBy(() -> linkInstanceDao.getLinkInstance(created.getId())).isInstanceOf(StorageException.class);
}
use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class LinkInstanceFacadeIT method testGetLinkInstances.
@Test
public void testGetLinkInstances() {
String id1 = linkInstanceFacade.createLinkInstance(prepareLinkInstance()).getId();
LinkInstance linkInstance2 = prepareLinkInstance();
linkInstance2.setLinkTypeId(linkTypeId1);
linkInstance2.setDocumentIds(Arrays.asList(documentIdsColl1.get(0), documentIdsColl2.get(2)));
String id2 = linkInstanceFacade.createLinkInstance(linkInstance2).getId();
LinkInstance linkInstance3 = prepareLinkInstance();
linkInstance3.setLinkTypeId(linkTypeId1);
linkInstance3.setDocumentIds(Arrays.asList(documentIdsColl1.get(1), documentIdsColl2.get(1)));
String id3 = linkInstanceFacade.createLinkInstance(linkInstance3).getId();
LinkInstance linkInstance4 = prepareLinkInstance();
linkInstance4.setLinkTypeId(linkTypeId2);
linkInstance4.setDocumentIds(Arrays.asList(documentIdsColl1.get(0), documentIdsColl2.get(0)));
String id4 = linkInstanceFacade.createLinkInstance(linkInstance4).getId();
JsonQuery jsonQuery1 = new JsonQuery(null, null, Collections.singleton(documentIdsColl1.get(0)));
List<LinkInstance> linkInstances = linkInstanceFacade.getLinkInstances(jsonQuery1);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id4));
JsonQuery jsonQuery2 = new JsonQuery(null, null, Collections.singleton(documentIdsColl2.get(1)));
linkInstances = linkInstanceFacade.getLinkInstances(jsonQuery2);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Collections.singletonList(id3));
JsonQuery jsonQuery3 = new JsonQuery(null, new HashSet<>(Arrays.asList(linkTypeId1, linkTypeId2)), null);
linkInstances = linkInstanceFacade.getLinkInstances(jsonQuery3);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id3, id4));
JsonQuery jsonQuery4 = new JsonQuery(null, Collections.singleton(linkTypeId1), null);
linkInstances = linkInstanceFacade.getLinkInstances(jsonQuery4);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id3));
}
use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class LinkInstanceFacadeIT method testCreateLinkInstance.
@Test
public void testCreateLinkInstance() {
LinkInstance linkInstance = prepareLinkInstance();
String id = linkInstanceFacade.createLinkInstance(linkInstance).getId();
assertThat(id).isNotNull().isNotEmpty();
assertThat(ObjectId.isValid(id)).isTrue();
LinkInstance storedLinkInstance = linkInstanceDao.getLinkInstance(id);
assertThat(storedLinkInstance).isNotNull();
assertThat(storedLinkInstance.getLinkTypeId()).isEqualTo(linkTypeId1);
assertThat(storedLinkInstance.getDocumentIds()).containsOnlyElementsOf(Arrays.asList(documentIdsColl1.get(0), documentIdsColl2.get(0)));
assertThat(storedLinkInstance.getData().keySet()).containsOnlyElementsOf(DATA.keySet());
}
use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class LinkInstanceServiceIT method testDeleteLinkInstance.
@Test
public void testDeleteLinkInstance() {
LinkInstance created = linkInstanceDao.createLinkInstance(prepareLinkInstance());
assertThat(created.getId()).isNotNull();
Response response = client.target(LINK_INSTANCES_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_INSTANCES_URL).build());
assertThatThrownBy(() -> linkInstanceDao.getLinkInstance(created.getId())).isInstanceOf(StorageException.class);
}
use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class LinkInstanceFacade method updateLinkInstance.
public LinkInstance updateLinkInstance(String id, LinkInstance linkInstance) {
LinkInstance stored = linkInstanceDao.getLinkInstance(id);
Set<String> collectionIds = new HashSet<>(linkTypeDao.getLinkType(stored.getLinkTypeId()).getCollectionIds());
collectionIds.addAll(linkTypeDao.getLinkType(linkInstance.getLinkTypeId()).getCollectionIds());
checkLinkInstancePermission(collectionIds);
return linkInstanceDao.updateLinkInstance(id, linkInstance);
}
Aggregations