Search in sources :

Example 1 with TItemDefinition

use of org.kie.dmn.model.v1_1.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_1.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_1.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_1.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_1.TItemDefinition in project kie-wb-common by kiegroup.

the class ImportedItemDefinitionConverterTest method testWbFromDMN.

@Test
public void testWbFromDMN() {
    final org.kie.dmn.model.api.ItemDefinition itemDefinition = new TItemDefinition();
    final org.kie.dmn.model.api.ItemDefinition itemComponent1 = new TItemDefinition();
    final org.kie.dmn.model.api.ItemDefinition itemComponent2 = new TItemDefinition();
    final org.kie.dmn.model.api.ItemDefinition itemComponent3 = new TItemDefinition();
    itemDefinition.setName("tPerson");
    itemDefinition.setTypeRef(null);
    itemDefinition.getItemComponent().addAll(asList(itemComponent1, itemComponent2, itemComponent3));
    itemComponent1.setName("id");
    itemComponent1.setTypeRef(new QName("tUUID"));
    itemComponent2.setName("name");
    itemComponent2.setTypeRef(new QName("string"));
    itemComponent3.setName("age");
    itemComponent3.setTypeRef(new QName("number"));
    final ItemDefinition actualItemDefinition = ImportedItemDefinitionConverter.wbFromDMN(itemDefinition, "model");
    assertEquals("model.tPerson", actualItemDefinition.getName().getValue());
    assertNull(actualItemDefinition.getTypeRef());
    assertTrue(actualItemDefinition.isAllowOnlyVisualChange());
    assertEquals(3, actualItemDefinition.getItemComponent().size());
    final ItemDefinition actualItemDefinition1 = actualItemDefinition.getItemComponent().get(0);
    assertEquals("model.id", actualItemDefinition1.getName().getValue());
    assertEquals("model.tUUID", actualItemDefinition1.getTypeRef().getLocalPart());
    assertTrue(actualItemDefinition1.isAllowOnlyVisualChange());
    final ItemDefinition actualItemDefinition2 = actualItemDefinition.getItemComponent().get(1);
    assertEquals("model.name", actualItemDefinition2.getName().getValue());
    assertEquals("string", actualItemDefinition2.getTypeRef().getLocalPart());
    assertTrue(actualItemDefinition2.isAllowOnlyVisualChange());
    final ItemDefinition actualItemDefinition3 = actualItemDefinition.getItemComponent().get(2);
    assertEquals("model.age", actualItemDefinition3.getName().getValue());
    assertEquals("number", actualItemDefinition3.getTypeRef().getLocalPart());
    assertTrue(actualItemDefinition3.isAllowOnlyVisualChange());
}
Also used : QName(javax.xml.namespace.QName) TItemDefinition(org.kie.dmn.model.v1_2.TItemDefinition) TItemDefinition(org.kie.dmn.model.v1_2.TItemDefinition) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Test(org.junit.Test)

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