Search in sources :

Example 51 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionDependenciesGeneratedTest method addDepsToItemDefinition.

private static void addDepsToItemDefinition(final ItemDefinition itemDefinition, final List<ItemDefinition> dependencies, final int numberOfDeps, final Set<String> usedNames) {
    int addedDepsCount = 0;
    for (ItemDefinition dependency : dependencies) {
        if (!usedNames.contains(dependency.getName())) {
            createAndAddDependency(itemDefinition, dependency);
            usedNames.add(dependency.getName());
            addedDepsCount++;
            if (addedDepsCount == numberOfDeps) {
                return;
            }
        }
    }
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition)

Example 52 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionDependenciesGeneratedTest method createItemDefinitionWithDeps.

private static ItemDefinition createItemDefinitionWithDeps(final ItemDefinition itemDefinitionTemplate, final List<ItemDefinition> dependencies, final int maxNumberOfDepsPerItemDefinition, final Set<String> usedNames) {
    // New ItemDefinition is created, so the original one stays untouched.
    final ItemDefinition it = new ItemDefinition();
    it.setName(itemDefinitionTemplate.getName());
    final List<ItemDefinition> possibleDependencies = dependencies.stream().filter(item -> !item.getName().equals(it.getName())).collect(Collectors.toList());
    addDepsToItemDefinition(it, possibleDependencies, maxNumberOfDepsPerItemDefinition, usedNames);
    return it;
}
Also used : Logger(org.slf4j.Logger) Collection(java.util.Collection) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) QName(javax.xml.namespace.QName) Parameterized(org.junit.runners.Parameterized) ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition)

Example 53 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionDependenciesTest method build.

private ItemDefinition build(String name, ItemDefinition... components) {
    ItemDefinition res = new ItemDefinition();
    res.setName(name);
    for (ItemDefinition ic : components) {
        ItemDefinition c = new ItemDefinition();
        c.setName("_" + name + "-" + ic.getName());
        c.setTypeRef(new QName(TEST_NS, ic.getName()));
        res.getItemComponent().add(c);
    }
    return res;
}
Also used : QName(javax.xml.namespace.QName) ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition)

Example 54 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionDependenciesTest method testOrdering1.

@Test
public void testOrdering1() {
    ItemDefinition tCollateralRiskCategory = build("tCollateralRiskCategory");
    ItemDefinition tCreditRiskCategory = build("tCreditRiskCategory");
    ItemDefinition tAffordabilityCategory = build("tAffordabilityCategory");
    ItemDefinition tLoanRecommendation = build("tLoanRecommendation");
    ItemDefinition tLoan = build("tLoan");
    ItemDefinition tAge = build("tAge");
    ItemDefinition temploementStatus = build("temploementStatus");
    ItemDefinition tCreditScore = build("tCreditScore");
    ItemDefinition tRiskCategory = build("tRiskCategory");
    ItemDefinition tIncomeRisk = build("tIncomeRisk");
    ItemDefinition tBorrowe = build("tBorrowe", tAge, temploementStatus);
    ItemDefinition tPrequalification = build("tPrequalification");
    List<ItemDefinition> originalList = Arrays.asList(new ItemDefinition[] { tCollateralRiskCategory, tCreditRiskCategory, tAffordabilityCategory, tLoanRecommendation, tLoan, tAge, temploementStatus, tCreditScore, tRiskCategory, tIncomeRisk, tBorrowe, tPrequalification });
    List<ItemDefinition> orderedList = orderingStrategy(originalList);
    assertTrue("Index of tAge < tBorrowe", orderedList.indexOf(tAge) < orderedList.indexOf(tBorrowe));
    assertTrue("Index of temploementStatus < tBorrowe", orderedList.indexOf(temploementStatus) < orderedList.indexOf(tBorrowe));
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) Test(org.junit.Test)

Example 55 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionDependenciesTest method testOrdering3.

@Test
public void testOrdering3() {
    ItemDefinition tNumberList = build("tNumberList");
    ItemDefinition tTax = build("tTax");
    ItemDefinition tStateModel = build("tStateModel");
    ItemDefinition tTaxList = build("tTaxList", tTax);
    ItemDefinition tCategory = build("tCategory");
    ItemDefinition tItem = build("tItem", tCategory);
    ItemDefinition tItemList = build("tItemList", tItem);
    ItemDefinition tOrder = build("tOrder", tItemList);
    List<ItemDefinition> originalList = Arrays.asList(new ItemDefinition[] { tOrder, tItem, tCategory, tNumberList, tItemList, tTax, tStateModel, tTaxList });
    List<ItemDefinition> orderedList = orderingStrategy(originalList);
    assertTrue("Index of tCategory < tItem", orderedList.indexOf(tCategory) < orderedList.indexOf(tItem));
    assertTrue("Index of tItem < tItemList", orderedList.indexOf(tItem) < orderedList.indexOf(tItemList));
    assertTrue("Index of tItemList < tOrder", orderedList.indexOf(tItemList) < orderedList.indexOf(tOrder));
    assertTrue("Index of tTax < tTaxList", orderedList.indexOf(tTax) < orderedList.indexOf(tTaxList));
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) Test(org.junit.Test)

Aggregations

ItemDefinition (org.kie.dmn.model.v1_1.ItemDefinition)22 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)21 ArrayList (java.util.ArrayList)17 RootElement (org.eclipse.bpmn2.RootElement)17 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)13 Process (org.eclipse.bpmn2.Process)13 SubProcess (org.eclipse.bpmn2.SubProcess)13 Entry (java.util.Map.Entry)11 FlowElement (org.eclipse.bpmn2.FlowElement)11 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)11 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)11 Message (org.eclipse.bpmn2.Message)10 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)9 Test (org.junit.Test)9 List (java.util.List)8 CallActivity (org.eclipse.bpmn2.CallActivity)7 DataInput (org.eclipse.bpmn2.DataInput)7 QName (javax.xml.namespace.QName)6 Activity (org.eclipse.bpmn2.Activity)6 DataOutput (org.eclipse.bpmn2.DataOutput)6