Search in sources :

Example 1 with TItemDefinition

use of org.kie.dmn.model.v1_4.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);
}
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 2 with TItemDefinition

use of org.kie.dmn.model.v1_4.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;
}
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 3 with TItemDefinition

use of org.kie.dmn.model.v1_4.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);
}
Also used : QName(javax.xml.namespace.QName) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) ItemDefinition(org.kie.dmn.model.api.ItemDefinition) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition)

Example 4 with TItemDefinition

use of org.kie.dmn.model.v1_4.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());
}
Also used : Import(org.kie.dmn.model.api.Import) QName(javax.xml.namespace.QName) Definitions(org.kie.dmn.model.api.Definitions) TItemDefinition(org.kie.dmn.model.v1_2.TItemDefinition) TItemDefinition(org.kie.dmn.model.v1_2.TItemDefinition) ItemDefinition(org.kie.dmn.model.api.ItemDefinition) Test(org.junit.Test)

Example 5 with TItemDefinition

use of org.kie.dmn.model.v1_4.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;
}
Also used : Logger(org.slf4j.Logger) Collection(java.util.Collection) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) HashSet(java.util.HashSet) List(java.util.List) ItemDefinition(org.kie.dmn.model.api.ItemDefinition) QName(javax.xml.namespace.QName) Parameterized(org.junit.runners.Parameterized) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) TItemDefinition(org.kie.dmn.model.v1_1.TItemDefinition) ItemDefinition(org.kie.dmn.model.api.ItemDefinition)

Aggregations

ItemDefinition (org.kie.dmn.model.api.ItemDefinition)6 QName (javax.xml.namespace.QName)5 TItemDefinition (org.kie.dmn.model.v1_1.TItemDefinition)5 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 TItemDefinition (org.kie.dmn.model.v1_2.TItemDefinition)2 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 RunWith (org.junit.runner.RunWith)1 Parameterized (org.junit.runners.Parameterized)1 Definitions (org.kie.dmn.model.api.Definitions)1 Import (org.kie.dmn.model.api.Import)1 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1