use of org.kie.dmn.model.api.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesGeneratedTest method assertOrdering.
private void assertOrdering(final ItemDefinition itemDefinition, final List<ItemDefinition> orderedList) {
for (final 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.api.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 (final 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.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);
}
}
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);
}
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;
}
Aggregations