use of io.lumeer.core.task.FunctionTask 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();
}
use of io.lumeer.core.task.FunctionTask in project engine by Lumeer.
the class FunctionFacadeIT method testCreateCollectionQueueWithCycle.
@Test
public void testCreateCollectionQueueWithCycle() {
createTestData();
// C1(a1) = C2(a2) + C3(a3); C2(a2) = C4(a4) + C5(a5); C4(a4) = C1(a1) + C1(a2)
LinkType l12 = getLinkType(c1, c2);
LinkType l13 = getLinkType(c1, c3);
LinkType l24 = getLinkType(c2, c4);
LinkType l25 = getLinkType(c2, c5);
LinkType l41 = getLinkType(c4, c1);
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(c4.getId(), "a4", c1.getId(), l41.getId(), "a1");
FunctionRow row6 = FunctionRow.createForCollection(c4.getId(), "a4", c1.getId(), l41.getId(), "a2");
functionDao.createRows(Arrays.asList(row1, row2, row3, row4, row5, row6));
List<Document> c4Documents = getDocuments(c4).subList(0, 2);
List<Document> c2Documents = getDocuments(c2).subList(0, 2);
List<Document> c1Documents = getDocuments(c1).subList(0, 2);
createLinks(l12, c2Documents, c1Documents);
createLinks(l24, c4Documents, c2Documents);
createLinks(l41, c4Documents, c1Documents);
Deque<FunctionFacade.FunctionParameterDocuments> queue = functionFacade.createQueueForDocumentChanged(c1.getId(), Collections.singletonList("a2"), c1Documents.get(0).getId());
assertThat(queue).hasSize(3);
assertThat(queue).extracting(FunctionFacade.FunctionParameterDocuments::getResourceId).contains(c4.getId(), c2.getId(), c1.getId());
FunctionTask task = functionFacade.convertQueueToTask(queue);
assertThat(task).isNotNull();
assertThat(task.getParent()).isNotNull();
assertThat(task.getParent().getParent()).isNotNull();
assertThat(task.getParent().getParent().getParent()).isNull();
}
Aggregations