Search in sources :

Example 21 with ItemDefinition

use of org.kie.dmn.model.v1_1.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 22 with ItemDefinition

use of org.kie.dmn.model.v1_1.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 23 with ItemDefinition

use of org.kie.dmn.model.v1_1.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)

Example 24 with ItemDefinition

use of org.kie.dmn.model.v1_1.ItemDefinition in project drools by kiegroup.

the class ItemDefinitionDependenciesTest method testOrdering2.

@Test
public void testOrdering2() {
    ItemDefinition tMortgageType = build("tMortgageType");
    ItemDefinition tObjective = build("tObjective");
    ItemDefinition tRequested = build("tRequested", tMortgageType, tObjective);
    ItemDefinition tProduct = build("tProduct");
    ItemDefinition tProductCollection = build("tProductCollection", tProduct);
    ItemDefinition tConformanceType = build("tConformanceType");
    ItemDefinition tLoanTypes = build("tLoanTypes", tMortgageType, tConformanceType);
    List<ItemDefinition> originalList = Arrays.asList(new ItemDefinition[] { tRequested, tProduct, tProductCollection, tMortgageType, tObjective, tConformanceType, tLoanTypes });
    List<ItemDefinition> orderedList = orderingStrategy(originalList);
    assertTrue("Index of tMortgageType < tRequested", orderedList.indexOf(tMortgageType) < orderedList.indexOf(tRequested));
    assertTrue("Index of tObjective < tRequested", orderedList.indexOf(tObjective) < orderedList.indexOf(tRequested));
    assertTrue("Index of tProduct < tProductCollection", orderedList.indexOf(tProduct) < orderedList.indexOf(tProductCollection));
    assertTrue("Index of tMortgageType < tLoanTypes", orderedList.indexOf(tMortgageType) < orderedList.indexOf(tLoanTypes));
    assertTrue("Index of tConformanceType < tLoanTypes", orderedList.indexOf(tConformanceType) < orderedList.indexOf(tLoanTypes));
}
Also used : ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) Test(org.junit.Test)

Aggregations

ItemDefinition (org.kie.dmn.model.v1_1.ItemDefinition)22 Test (org.junit.Test)10 QName (javax.xml.namespace.QName)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 RunWith (org.junit.runner.RunWith)2 Parameterized (org.junit.runners.Parameterized)2 DMNType (org.kie.dmn.api.core.DMNType)2 Definitions (org.kie.dmn.model.v1_1.Definitions)2 XStream (com.thoughtworks.xstream.XStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1