Search in sources :

Example 71 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class DMNDiagramHelperTest method testGetItemDefinitionsByDiagram.

@Test
public void testGetItemDefinitionsByDiagram() {
    final Definitions definitions = mock(Definitions.class);
    final List<ItemDefinition> expectedItemDefinitions = asList(mock(ItemDefinition.class), mock(ItemDefinition.class));
    when(definitions.getItemDefinition()).thenReturn(expectedItemDefinitions);
    when(dmnDiagramUtils.getDefinitions(diagram)).thenReturn(definitions);
    final List<ItemDefinition> actualItemDefinitions = helper.getItemDefinitions(diagram);
    assertEquals(expectedItemDefinitions, actualItemDefinitions);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Test(org.junit.Test)

Example 72 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionPropertyConverterTest method testSetItemComponent.

@Test
public void testSetItemComponent() {
    final String id = "id";
    final String name = "name";
    final String typeLanguage = "typeLanguage";
    final boolean isCollection = true;
    final boolean isOnlyVisualChanges = false;
    final String description = "description";
    final ItemDefinition expectedWbChild = new ItemDefinition(new Id(id), new Description(description), new Name(name), null, null, null, typeLanguage, isCollection, isOnlyVisualChanges);
    final ItemDefinition wb = new ItemDefinition();
    final org.kie.dmn.model.api.ItemDefinition dmn = mock(org.kie.dmn.model.api.ItemDefinition.class);
    final org.kie.dmn.model.api.ItemDefinition dmnChild = mock(org.kie.dmn.model.api.ItemDefinition.class);
    when(dmnChild.getId()).thenReturn(id);
    when(dmnChild.getName()).thenReturn(name);
    when(dmnChild.getTypeLanguage()).thenReturn(typeLanguage);
    when(dmnChild.isIsCollection()).thenReturn(isCollection);
    when(dmnChild.getDescription()).thenReturn(description);
    when(dmnChild.getTypeRef()).thenReturn(null);
    when(dmn.getItemComponent()).thenReturn(singletonList(dmnChild));
    setItemComponent(wb, dmn);
    final List<ItemDefinition> expectedItemDefinitions = singletonList(expectedWbChild);
    final List<ItemDefinition> actualItemDefinitions = wb.getItemComponent();
    assertEquals(expectedItemDefinitions, actualItemDefinitions);
    assertEquals(wb, actualItemDefinitions.get(0).getParent());
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Test(org.junit.Test)

Example 73 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionPropertyConverterTest method testWbChildFromDMNWhenWbChildIsNotNull.

@Test
public void testWbChildFromDMNWhenWbChildIsNotNull() {
    final String id = "id";
    final String name = "name";
    final String typeLanguage = "typeLanguage";
    final boolean isCollection = true;
    final boolean isOnlyVisualChanges = false;
    final String description = "description";
    final ItemDefinition expectedWbParent = new ItemDefinition();
    final ItemDefinition expectedWbChild = new ItemDefinition(new Id(id), new Description(description), new Name(name), null, null, null, typeLanguage, isCollection, isOnlyVisualChanges);
    final org.kie.dmn.model.api.ItemDefinition dmnChild = mock(org.kie.dmn.model.api.ItemDefinition.class);
    when(dmnChild.getId()).thenReturn(id);
    when(dmnChild.getName()).thenReturn(name);
    when(dmnChild.getTypeLanguage()).thenReturn(typeLanguage);
    when(dmnChild.isIsCollection()).thenReturn(isCollection);
    when(dmnChild.getDescription()).thenReturn(description);
    when(dmnChild.getTypeRef()).thenReturn(null);
    final ItemDefinition actualWbChild = wbChildFromDMN(expectedWbParent, dmnChild);
    final ItemDefinition actualParent = (ItemDefinition) actualWbChild.getParent();
    assertEquals(expectedWbChild, actualWbChild);
    assertEquals(expectedWbParent, actualParent);
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Test(org.junit.Test)

Example 74 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionPropertyConverterTest method testWbChildFromDMNWhenWbChildIsNull.

@Test
public void testWbChildFromDMNWhenWbChildIsNull() {
    final ItemDefinition expectedWbParent = new ItemDefinition();
    final org.kie.dmn.model.api.ItemDefinition dmnChild = null;
    final ItemDefinition actualWbChild = wbChildFromDMN(expectedWbParent, dmnChild);
    assertNull(actualWbChild);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Test(org.junit.Test)

Example 75 with ItemDefinition

use of org.kie.workbench.common.dmn.api.definition.model.ItemDefinition in project kie-wb-common by kiegroup.

the class ItemDefinitionPropertyConverterTest method testSetUnaryTestsWhenUnaryTestsIsNotNull.

@Test
public void testSetUnaryTestsWhenUnaryTestsIsNotNull() {
    final ItemDefinition wb = mock(ItemDefinition.class);
    final ArgumentCaptor<UnaryTests> argument = ArgumentCaptor.forClass(UnaryTests.class);
    final org.kie.dmn.model.api.ItemDefinition dmn = mock(org.kie.dmn.model.api.ItemDefinition.class);
    final org.kie.dmn.model.api.UnaryTests dmnAllowedValues = mock(org.kie.dmn.model.api.UnaryTests.class);
    when(dmn.getAllowedValues()).thenReturn(dmnAllowedValues);
    setUnaryTests(wb, dmn);
    verify(wb).setAllowedValues(argument.capture());
    assertEquals(wb, argument.getValue().getParent());
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) ItemDefinitionPropertyConverter.setUnaryTests(org.kie.workbench.common.dmn.backend.definition.v1_1.ItemDefinitionPropertyConverter.setUnaryTests) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) Test(org.junit.Test)

Aggregations

ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)119 Test (org.junit.Test)86 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)39 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)37 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)36 ArrayList (java.util.ArrayList)18 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)16 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)9 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)8 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)7 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)7 JSITItemDefinition (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITItemDefinition)7 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)6 DataTypeManager (org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager)6 QName (javax.xml.namespace.QName)4 Import (org.kie.workbench.common.dmn.api.definition.model.Import)4 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)4 RefreshDataTypesListEvent (org.kie.workbench.common.dmn.client.editors.types.common.events.RefreshDataTypesListEvent)4 DMNGraphUtils (org.kie.workbench.common.dmn.client.graph.DMNGraphUtils)4 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)3