use of io.lumeer.api.model.function.FunctionRow in project engine by Lumeer.
the class MongoFunctionDaoTest method testAddRows.
@Test
public void testAddRows() {
FunctionRow row1 = FunctionRow.createForCollection(COLLECTION1, ATTRIBUTE1, COLLECTION2, LINK_TYPE1, ATTRIBUTE2);
FunctionRow row2 = FunctionRow.createForCollection(COLLECTION1, ATTRIBUTE1, COLLECTION3, LINK_TYPE2, ATTRIBUTE3);
FunctionRow row3 = FunctionRow.createForCollection(COLLECTION1, ATTRIBUTE1, COLLECTION3, LINK_TYPE1, ATTRIBUTE2);
FunctionRow row4 = FunctionRow.createForLink(LINK_TYPE1, ATTRIBUTE1, COLLECTION2, LINK_TYPE1, ATTRIBUTE2);
List<FunctionRow> rows = Arrays.asList(row1, row2, row3, row4);
functionDao.createRows(rows);
List<FunctionRow> storedRows = functionDao.databaseCollection().find().into(new ArrayList<>());
assertThat(storedRows).hasSize(4);
assertThat(storedRows).extracting(FunctionRow::getResourceId).contains(COLLECTION1, LINK_TYPE1);
assertThat(storedRows).extracting(FunctionRow::getDependentAttributeId).contains(ATTRIBUTE2, ATTRIBUTE3);
assertThat(storedRows).extracting(FunctionRow::getDependentLinkTypeId).contains(LINK_TYPE1, LINK_TYPE2);
}
use of io.lumeer.api.model.function.FunctionRow in project engine by Lumeer.
the class MongoFunctionDaoTest method testDeleteByResources.
@Test
public void testDeleteByResources() {
FunctionRow row1 = FunctionRow.createForCollection(COLLECTION1, ATTRIBUTE1, COLLECTION2, LINK_TYPE1, ATTRIBUTE2);
FunctionRow row2 = FunctionRow.createForCollection(COLLECTION1, ATTRIBUTE1, COLLECTION3, LINK_TYPE1, ATTRIBUTE3);
FunctionRow row3 = FunctionRow.createForCollection(COLLECTION2, ATTRIBUTE1, COLLECTION1, LINK_TYPE1, ATTRIBUTE2);
FunctionRow row4 = FunctionRow.createForCollection(COLLECTION2, ATTRIBUTE1, COLLECTION2, LINK_TYPE1, ATTRIBUTE3);
FunctionRow row5 = FunctionRow.createForCollection(COLLECTION3, ATTRIBUTE1, COLLECTION1, LINK_TYPE1, ATTRIBUTE1);
FunctionRow row6 = FunctionRow.createForCollection(COLLECTION3, ATTRIBUTE1, COLLECTION3, LINK_TYPE1, ATTRIBUTE3);
FunctionRow row7 = FunctionRow.createForLink(LINK_TYPE1, ATTRIBUTE1, COLLECTION3, null, ATTRIBUTE1);
FunctionRow row8 = FunctionRow.createForLink(LINK_TYPE1, ATTRIBUTE1, COLLECTION2, null, ATTRIBUTE1);
FunctionRow row9 = FunctionRow.createForLink(LINK_TYPE1, ATTRIBUTE1, COLLECTION1, null, ATTRIBUTE1);
List<FunctionRow> rows = Arrays.asList(row1, row2, row3, row4, row5, row6, row7, row8, row9);
functionDao.createRows(rows);
List<FunctionRow> storedRows = functionDao.databaseCollection().find().into(new ArrayList<>());
assertThat(storedRows).hasSize(9).extracting(FunctionRow::getResourceId).contains(COLLECTION1, COLLECTION2, COLLECTION3, LINK_TYPE1);
functionDao.deleteByResources(FunctionResourceType.COLLECTION, COLLECTION1, COLLECTION3);
storedRows = functionDao.databaseCollection().find().into(new ArrayList<>());
assertThat(storedRows).hasSize(5).extracting(FunctionRow::getResourceId).contains(COLLECTION2, LINK_TYPE1);
functionDao.deleteByResources(FunctionResourceType.COLLECTION, COLLECTION2);
storedRows = functionDao.databaseCollection().find().into(new ArrayList<>());
assertThat(storedRows).hasSize(3).extracting(FunctionRow::getResourceId).contains(LINK_TYPE1);
functionDao.deleteByResources(FunctionResourceType.LINK, LINK_TYPE1);
storedRows = functionDao.databaseCollection().find().into(new ArrayList<>());
assertThat(storedRows).isEmpty();
}
use of io.lumeer.api.model.function.FunctionRow in project engine by Lumeer.
the class MongoFunctionDaoTest method testDeleteByCollection.
@Test
public void testDeleteByCollection() {
FunctionRow row1 = FunctionRow.createForCollection(COLLECTION1, ATTRIBUTE1, COLLECTION2, LINK_TYPE1, ATTRIBUTE2);
FunctionRow row2 = FunctionRow.createForCollection(COLLECTION1, ATTRIBUTE2, COLLECTION3, LINK_TYPE1, ATTRIBUTE3);
FunctionRow row3 = FunctionRow.createForCollection(COLLECTION2, ATTRIBUTE1, COLLECTION1, LINK_TYPE1, ATTRIBUTE2);
FunctionRow row4 = FunctionRow.createForCollection(COLLECTION2, ATTRIBUTE3, COLLECTION2, LINK_TYPE1, ATTRIBUTE3);
FunctionRow row5 = FunctionRow.createForCollection(COLLECTION3, ATTRIBUTE1, COLLECTION1, LINK_TYPE1, ATTRIBUTE1);
List<FunctionRow> rows = Arrays.asList(row1, row2, row3, row4, row5);
functionDao.createRows(rows);
List<FunctionRow> storedRows = functionDao.databaseCollection().find().into(new ArrayList<>());
assertThat(storedRows).hasSize(5).extracting(FunctionRow::getResourceId).contains(COLLECTION1, COLLECTION2, COLLECTION3);
functionDao.deleteByCollection(COLLECTION1, ATTRIBUTE2);
storedRows = functionDao.databaseCollection().find().into(new ArrayList<>());
assertThat(storedRows).hasSize(4).extracting(FunctionRow::getResourceId).contains(COLLECTION1, COLLECTION2, COLLECTION3);
functionDao.deleteByCollection(COLLECTION1, ATTRIBUTE1);
storedRows = functionDao.databaseCollection().find().into(new ArrayList<>());
assertThat(storedRows).hasSize(3).extracting(FunctionRow::getResourceId).contains(COLLECTION2, COLLECTION3);
}
use of io.lumeer.api.model.function.FunctionRow in project engine by Lumeer.
the class FunctionFacadeIT method testCreateCollectionQueueSameCollectionMultiple.
@Test
public void testCreateCollectionQueueSameCollectionMultiple() {
createTestData();
// C1(a3) = C1(a1) + C1(a2); C1(a4) = C1(a3) + C1(a2); C1(a5) = C1(a1) + C1(a2);
FunctionRow row1 = FunctionRow.createForCollection(c1.getId(), "a3", c1.getId(), null, "a1");
FunctionRow row2 = FunctionRow.createForCollection(c1.getId(), "a3", c1.getId(), null, "a2");
FunctionRow row3 = FunctionRow.createForCollection(c1.getId(), "a4", c1.getId(), null, "a3");
FunctionRow row4 = FunctionRow.createForCollection(c1.getId(), "a4", c1.getId(), null, "a2");
FunctionRow row5 = FunctionRow.createForCollection(c1.getId(), "a5", c1.getId(), null, "a1");
FunctionRow row6 = FunctionRow.createForCollection(c1.getId(), "a5", c1.getId(), null, "a2");
functionDao.createRows(Arrays.asList(row1, row2, row3, row4, row5, row6));
Document document = getAnyDocument(c1);
final Deque<FunctionFacade.FunctionParameterDocuments> queue = functionFacade.createQueueForDocumentChanged(c1.getId(), Collections.singletonList("a2"), document.getId());
assertThat(queue).hasSize(3);
assertThat(queue).extracting(FunctionFacade.FunctionParameterDocuments::getAttributeId).containsSubsequence("a3", "a4");
final Deque<FunctionFacade.FunctionParameterDocuments> queue2 = functionFacade.createQueueForCreatedDocument(c1, document);
assertThat(queue2).hasSize(5);
assertThat(queue2).extracting(FunctionFacade.FunctionParameterDocuments::getAttributeId).containsSubsequence("a3", "a4");
}
use of io.lumeer.api.model.function.FunctionRow in project engine by Lumeer.
the class FunctionFacadeIT method testCreateCollectionQueueLinkedCollection.
@Test
public void testCreateCollectionQueueLinkedCollection() {
createTestData();
// C1(a1) = C2(a2) + C3(a3); C2(a2) = C4(a4) + C5(a5); C2(a3) = C2(a2) + C2(a4);
LinkType l12 = getLinkType(c1, c2);
LinkType l13 = getLinkType(c1, c3);
LinkType l24 = getLinkType(c2, c4);
LinkType l25 = getLinkType(c2, c5);
FunctionRow row1 = FunctionRow.createForCollection(c1.getId(), "a1", c2.getId(), l12.getId(), "a2");
FunctionRow row2 = FunctionRow.createForCollection(c1.getId(), "a1", c3.getId(), l13.getId(), "a3");
FunctionRow row3 = FunctionRow.createForCollection(c2.getId(), "a2", c4.getId(), l24.getId(), "a4");
FunctionRow row4 = FunctionRow.createForCollection(c2.getId(), "a2", c5.getId(), l25.getId(), "a5");
FunctionRow row5 = FunctionRow.createForCollection(c2.getId(), "a3", c2.getId(), null, "a2");
FunctionRow row6 = FunctionRow.createForCollection(c2.getId(), "a3", c2.getId(), null, "a4");
functionDao.createRows(Arrays.asList(row1, row2, row3, row4, row5, row6));
Document c4Document = getAnyDocument(c4);
List<Document> c2Documents = getDocuments(c2).subList(0, 2);
List<Document> c1Documents = getDocuments(c1).subList(0, 2);
createLinks(l24, Collections.singletonList(c4Document), c2Documents);
createLinks(l12, c2Documents, c1Documents);
Deque<FunctionFacade.FunctionParameterDocuments> queue = functionFacade.createQueueForDocumentChanged(c4.getId(), Collections.singletonList("a4"), c4Document.getId());
assertThat(queue).hasSize(3);
assertThat(queue.getFirst().getResourceId()).isEqualTo(c2.getId());
assertThat(queue.getFirst().getAttributeId()).isEqualTo("a2");
FunctionTask task = functionFacade.convertQueueToTask(queue);
assertThat(task).isNotNull();
assertThat(task.getCollection().getId()).isEqualTo(c2.getId());
assertThat(task.getAttribute().getId()).isEqualTo("a2");
assertThat(task.getDocuments()).hasSize(2);
assertThat(task.getParent()).isNotNull();
assertThat(task.getParent().getParent()).isNotNull();
assertThat(task.getParent().getParent().getParent()).isNull();
}
Aggregations