use of org.kie.dmn.model.v1_2.TItemDefinition in project kie-wb-common by kiegroup.
the class DMNMarshallerImportsHelperStandaloneImplTest method testGetItemDefinitionsWithNamespace.
@Test
public void testGetItemDefinitionsWithNamespace() {
final Definitions definitions = mock(Definitions.class);
final Import anImport = mock(Import.class);
final ItemDefinition itemDefinition1 = new TItemDefinition();
final ItemDefinition itemDefinition2 = new TItemDefinition();
final ItemDefinition itemDefinition3 = new TItemDefinition();
final ItemDefinition itemDefinition4 = new TItemDefinition();
final ItemDefinition itemDefinition5 = new TItemDefinition();
final List<ItemDefinition> itemDefinitions = asList(itemDefinition1, itemDefinition2, itemDefinition3, itemDefinition4, itemDefinition5);
itemDefinition1.setName("tUUID");
itemDefinition2.setName("tPerson");
itemDefinition3.setName("id");
itemDefinition4.setName("name");
itemDefinition5.setName("age");
itemDefinition1.setTypeRef(new QName("string"));
itemDefinition2.setTypeRef(null);
itemDefinition3.setTypeRef(new QName("tUUID"));
itemDefinition4.setTypeRef(new QName("string"));
itemDefinition5.setTypeRef(new QName("number"));
when(anImport.getName()).thenReturn("model");
when(definitions.getItemDefinition()).thenReturn(itemDefinitions);
final List<ItemDefinition> actualItemDefinitions = helper.getItemDefinitionsWithNamespace(definitions, anImport);
assertEquals(5, actualItemDefinitions.size());
final ItemDefinition actualItemDefinition1 = actualItemDefinitions.get(0);
assertEquals("model.tUUID", actualItemDefinition1.getName());
assertEquals("string", actualItemDefinition1.getTypeRef().getLocalPart());
final ItemDefinition actualItemDefinition2 = actualItemDefinitions.get(1);
assertEquals("model.tPerson", actualItemDefinition2.getName());
assertNull(actualItemDefinition2.getTypeRef());
final ItemDefinition actualItemDefinition3 = actualItemDefinitions.get(2);
assertEquals("model.id", actualItemDefinition3.getName());
assertEquals("model.tUUID", actualItemDefinition3.getTypeRef().getLocalPart());
final ItemDefinition actualItemDefinition4 = actualItemDefinitions.get(3);
assertEquals("model.name", actualItemDefinition4.getName());
assertEquals("string", actualItemDefinition4.getTypeRef().getLocalPart());
final ItemDefinition actualItemDefinition5 = actualItemDefinitions.get(4);
assertEquals("model.age", actualItemDefinition5.getName());
assertEquals("number", actualItemDefinition5.getTypeRef().getLocalPart());
}
use of org.kie.dmn.model.v1_2.TItemDefinition 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.v1_2.TItemDefinition 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;
}
use of org.kie.dmn.model.v1_2.TItemDefinition in project drools by kiegroup.
the class ItemDefinitionDependenciesTest method addComponent.
private void addComponent(ItemDefinition i, String componentName) {
final ItemDefinition c = new TItemDefinition();
c.setName("_" + i.getName() + "-" + componentName);
c.setTypeRef(new QName(TEST_NS, componentName));
i.getItemComponent().add(c);
}
use of org.kie.dmn.model.v1_2.TItemDefinition 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 TItemDefinition();
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;
}
Aggregations