use of org.kie.dmn.model.v1_1.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesGeneratedTest method assertOrdering.
private void assertOrdering(final ItemDefinition itemDefinition, final List<ItemDefinition> orderedList) {
for (ItemDefinition dependency : itemDefinition.getItemComponent()) {
final String dependencyName = dependency.getTypeRef().getLocalPart();
final int indexOfDependency = indexOfItemDefinitionByName(dependencyName, orderedList);
assertTrue("Cannot find dependency " + dependencyName + " in the ordered list!", indexOfDependency > -1);
assertTrue("Index of " + itemDefinition.getName() + " < " + dependency.getTypeRef().getLocalPart(), orderedList.indexOf(itemDefinition) > indexOfDependency);
if (dependency.getItemComponent() != null && !dependency.getItemComponent().isEmpty()) {
assertOrdering(dependency, orderedList);
}
}
}
use of org.kie.dmn.model.v1_1.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesGeneratedTest method getPermutations.
private static void getPermutations(final List<ItemDefinition> itemDefinitions, final List<ItemDefinition> head, final Collection<List<ItemDefinition>> result) {
if (itemDefinitions.size() == 1) {
final List<ItemDefinition> resultList = new ArrayList<>(head);
resultList.addAll(itemDefinitions);
result.add(resultList);
} else {
for (ItemDefinition itemDefinition : itemDefinitions) {
final List<ItemDefinition> newHead = new ArrayList<>(head);
newHead.add(itemDefinition);
final List<ItemDefinition> possibleDependencies = itemDefinitions.stream().filter(item -> !newHead.contains(item)).collect(Collectors.toList());
getPermutations(possibleDependencies, newHead, result);
}
}
}
use of org.kie.dmn.model.v1_1.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesGeneratedTest method testOrdering.
@Test
public void testOrdering() {
logger.debug("Item definitions:");
itemDefinitions.forEach(itemDefinition -> {
logger.debug(itemDefinition.getName());
itemDefinition.getItemComponent().forEach(dependency -> logger.debug(dependency.getName()));
});
List<ItemDefinition> orderedList = orderingStrategy(itemDefinitions);
for (ItemDefinition itemDefinition : itemDefinitions) {
assertOrdering(itemDefinition, orderedList);
}
}
use of org.kie.dmn.model.v1_1.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 ItemDefinition();
it.setName(ITEM_DEFINITION_NAME_BASE + i);
itemDefinitions.add(it);
}
return itemDefinitions;
}
use of org.kie.dmn.model.v1_1.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesTest method testGeneric2.
@Test
public void testGeneric2() {
ItemDefinition z = build("z");
ItemDefinition b = build("b");
ItemDefinition a = build("a", z);
List<ItemDefinition> originalList = Arrays.asList(new ItemDefinition[] { z, b, a });
List<ItemDefinition> orderedList = orderingStrategy(originalList);
assertTrue("Index of z < a", orderedList.indexOf(z) < orderedList.indexOf(a));
}
Aggregations