Search in sources :

Example 11 with ItemDefinition

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

the class ItemDefinitionDependenciesGeneratedTest method testOrdering.

@Test
public void testOrdering() {
    logger.trace("Item definitions:");
    itemDefinitions.forEach(itemDefinition -> {
        logger.trace(itemDefinition.getName());
        itemDefinition.getItemComponent().forEach(dependency -> logger.trace(dependency.getName()));
    });
    final List<ItemDefinition> orderedList = orderingStrategy(itemDefinitions);
    for (final ItemDefinition itemDefinition : itemDefinitions) {
        assertOrdering(itemDefinition, orderedList);
    }
}
Also used : TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) ItemDefinition(org.kie.dmn.model.api.ItemDefinition) Test(org.junit.Test)

Example 12 with ItemDefinition

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

the class ItemDefinitionDependenciesGeneratedTest method createAndAddDependency.

private static void createAndAddDependency(final ItemDefinition itemDefinition, final ItemDefinition dependency) {
    final ItemDefinition newDependency = new TItemDefinition();
    newDependency.setName("_" + itemDefinition.getName() + "-" + dependency.getName());
    newDependency.setTypeRef(new QName(TEST_NS, dependency.getName()));
    itemDefinition.getItemComponent().add(newDependency);
}
Also used : QName(javax.xml.namespace.QName) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) ItemDefinition(org.kie.dmn.model.api.ItemDefinition)

Example 13 with ItemDefinition

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

the class ItemDefinitionDependenciesGeneratedTest method getBaseListOfItemDefinitions.

private static List<ItemDefinition> getBaseListOfItemDefinitions(final int nameIndexFrom) {
    final List<ItemDefinition> itemDefinitions = new ArrayList<>();
    for (int i = nameIndexFrom; i < NUMBER_OF_BASE_ITEM_DEFINITIONS + nameIndexFrom; i++) {
        final ItemDefinition it = new TItemDefinition();
        it.setName(ITEM_DEFINITION_NAME_BASE + i);
        itemDefinitions.add(it);
    }
    return itemDefinitions;
}
Also used : TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) ItemDefinition(org.kie.dmn.model.api.ItemDefinition) ArrayList(java.util.ArrayList)

Example 14 with ItemDefinition

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

the class ItemDefinitionDependenciesTest method testGeneric2.

@Test
public void testGeneric2() {
    final ItemDefinition z = build("z");
    final ItemDefinition b = build("b");
    final ItemDefinition a = build("a", z);
    final List<ItemDefinition> originalList = Arrays.asList(z, b, a);
    final List<ItemDefinition> orderedList = orderingStrategy(originalList);
    assertTrue("Index of z < a", orderedList.indexOf(z) < orderedList.indexOf(a));
}
Also used : ItemDefinition(org.kie.dmn.model.api.ItemDefinition) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) Test(org.junit.Test)

Example 15 with ItemDefinition

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

the class ItemDefinitionDependenciesTest method testCircular3.

@Test
public void testCircular3() {
    final ItemDefinition fhirAge = build("fhirAge");
    addComponent(fhirAge, "fhirExtension");
    final ItemDefinition fhirExtension = build("fhirExtension", fhirAge);
    final ItemDefinition fhirT1 = build("fhirT1", fhirAge);
    final List<ItemDefinition> originalList = Arrays.asList(fhirT1, fhirAge, fhirExtension);
    final List<ItemDefinition> orderedList = orderingStrategy(originalList);
    assertThat(orderedList.subList(0, 2), containsInAnyOrder(fhirAge, fhirExtension));
    assertThat(orderedList.subList(2, 3), contains(fhirT1));
}
Also used : ItemDefinition(org.kie.dmn.model.api.ItemDefinition) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) Test(org.junit.Test)

Aggregations

ItemDefinition (org.kie.dmn.model.api.ItemDefinition)50 TItemDefinition (org.kie.dmn.model.v1_1.TItemDefinition)19 Test (org.junit.Test)15 QName (javax.xml.namespace.QName)13 Definitions (org.kie.dmn.model.api.Definitions)13 ArrayList (java.util.ArrayList)10 DRGElement (org.kie.dmn.model.api.DRGElement)9 List (java.util.List)7 Collectors (java.util.stream.Collectors)7 Artifact (org.kie.dmn.model.api.Artifact)7 BusinessContextElement (org.kie.dmn.model.api.BusinessContextElement)7 Decision (org.kie.dmn.model.api.Decision)7 Import (org.kie.dmn.model.api.Import)7 Collection (java.util.Collection)6 TItemDefinition (org.kie.dmn.model.v1_2.TItemDefinition)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 DecisionService (org.kie.dmn.model.api.DecisionService)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4