use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class LinkInstanceFacade method deleteLinkInstance.
public void deleteLinkInstance(String id) {
LinkInstance linkInstance = linkInstanceDao.getLinkInstance(id);
LinkType linkType = linkTypeDao.getLinkType(linkInstance.getLinkTypeId());
checkLinkInstancePermission(linkType.getCollectionIds());
linkInstanceDao.deleteLinkInstance(id);
}
use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class MongoLinkInstanceDaoTest method testGetLinkType.
@Test
public void testGetLinkType() {
String id = linkInstanceDao.createLinkInstance(prepareLinkInstance()).getId();
LinkInstance linkInstance = linkInstanceDao.getLinkInstance(id);
assertThat(linkInstance).isNotNull();
assertThat(linkInstance.getId()).isEqualTo(id);
}
use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class MongoLinkInstanceDaoTest method testGetLinkInstancesByLinkTypeIds.
@Test
public void testGetLinkInstancesByLinkTypeIds() {
String id1 = linkInstanceDao.createLinkInstance(prepareLinkInstance()).getId();
LinkInstance linkInstance2 = prepareLinkInstance();
linkInstance2.setLinkTypeId(LINK_TYPE_ID2);
String id2 = linkInstanceDao.createLinkInstance(linkInstance2).getId();
LinkInstance linkInstance3 = prepareLinkInstance();
linkInstance3.setLinkTypeId(LINK_TYPE_ID2);
String id3 = linkInstanceDao.createLinkInstance(linkInstance3).getId();
LinkInstance linkInstance4 = prepareLinkInstance();
linkInstance4.setLinkTypeId(LINK_TYPE_ID3);
String id4 = linkInstanceDao.createLinkInstance(linkInstance4).getId();
SearchQuery query1 = SearchQuery.createBuilder(USER).linkTypeIds(new HashSet<>(Arrays.asList(LINK_TYPE_ID1, LINK_TYPE_ID2))).build();
List<LinkInstance> linkInstances = linkInstanceDao.getLinkInstances(query1);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id3));
SearchQuery query2 = SearchQuery.createBuilder(USER).linkTypeIds(Collections.singleton(LINK_TYPE_ID3)).build();
linkInstances = linkInstanceDao.getLinkInstances(query2);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Collections.singletonList(id4));
}
use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class MongoLinkInstanceDaoTest method testUpdateLinkInstance.
@Test
public void testUpdateLinkInstance() {
LinkInstance linkInstance = prepareLinkInstance();
String id = linkInstanceDao.createLinkInstance(linkInstance).getId();
LinkInstance updateLinkedInstance = prepareLinkInstance();
updateLinkedInstance.setLinkTypeId(LINK_TYPE_ID2);
updateLinkedInstance.setDocumentIds(Arrays.asList(DOCUMENT_ID3, DOCUMENT_ID4));
linkInstanceDao.updateLinkInstance(id, updateLinkedInstance);
LinkInstance storedLinkInstance = linkInstanceDao.getLinkInstance(id);
assertThat(storedLinkInstance).isNotNull();
assertThat(storedLinkInstance.getLinkTypeId()).isEqualTo(LINK_TYPE_ID2);
assertThat(storedLinkInstance.getDocumentIds()).containsOnlyElementsOf(Arrays.asList(DOCUMENT_ID3, DOCUMENT_ID4));
assertThat(storedLinkInstance.getData().keySet()).containsOnlyElementsOf(DATA.keySet());
}
use of io.lumeer.api.model.LinkInstance in project engine by Lumeer.
the class LinkInstanceFacadeIT method testUpdateLinkInstance.
@Test
public void testUpdateLinkInstance() {
LinkInstance linkInstance = prepareLinkInstance();
String id = linkInstanceFacade.createLinkInstance(linkInstance).getId();
LinkInstance updateLinkedInstance = prepareLinkInstance();
updateLinkedInstance.setLinkTypeId(linkTypeId2);
updateLinkedInstance.setDocumentIds(Arrays.asList(documentIdsColl1.get(1), documentIdsColl2.get(1)));
linkInstanceFacade.updateLinkInstance(id, updateLinkedInstance);
LinkInstance storedLinkInstance = linkInstanceDao.getLinkInstance(id);
assertThat(storedLinkInstance).isNotNull();
assertThat(storedLinkInstance.getLinkTypeId()).isEqualTo(linkTypeId2);
assertThat(storedLinkInstance.getDocumentIds()).containsOnlyElementsOf(Arrays.asList(documentIdsColl1.get(1), documentIdsColl2.get(1)));
assertThat(storedLinkInstance.getData().keySet()).containsOnlyElementsOf(DATA.keySet());
}
Aggregations