Search in sources :

Example 86 with ItemDefinition

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

the class ItemDefinitionCreateHandlerTest method testGetItemDefinitionSiblingsWhenParentIsNotPresent.

@Test
public void testGetItemDefinitionSiblingsWhenParentIsNotPresent() {
    final DataType reference = mock(DataType.class);
    final String parentUUID = "parentUUID";
    final Optional<ItemDefinition> absoluteParent = Optional.empty();
    final List<ItemDefinition> expectedItemDefinitions = new ArrayList<>();
    when(reference.getParentUUID()).thenReturn(parentUUID);
    when(itemDefinitionUtils.all()).thenReturn(expectedItemDefinitions);
    doReturn(absoluteParent).when(handler).lookupAbsoluteParent(parentUUID);
    final List<ItemDefinition> actualItemDefinitions = handler.getItemDefinitionSiblings(reference);
    assertEquals(expectedItemDefinitions, actualItemDefinitions);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) ArrayList(java.util.ArrayList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 87 with ItemDefinition

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

the class ItemDefinitionCreateHandlerTest method testInsertNestedItemDefinitionWhenAbsoluteParentIsPresent.

@Test
public void testInsertNestedItemDefinitionWhenAbsoluteParentIsPresent() {
    final DataType record = mock(DataType.class);
    final DataType reference = mock(DataType.class);
    final ItemDefinition relativeParent = mock(ItemDefinition.class);
    final Optional<ItemDefinition> absoluteParent = Optional.of(mock(ItemDefinition.class));
    final List<ItemDefinition> itemDefinitions = new ArrayList<>();
    final String referenceUUID = "referenceUUID";
    when(itemDefinitionStore.get(referenceUUID)).thenReturn(relativeParent);
    when(reference.getUUID()).thenReturn(referenceUUID);
    when(absoluteParent.get().getItemComponent()).thenReturn(itemDefinitions);
    doReturn(absoluteParent).when(handler).lookupAbsoluteParent(referenceUUID);
    final ItemDefinition nestedItemDefinition = handler.insertNested(record, reference);
    assertEquals(nestedItemDefinition, itemDefinitions.get(0));
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) ArrayList(java.util.ArrayList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 88 with ItemDefinition

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

the class ItemDefinitionCreateHandlerTest method testAppendItemDefinition.

@Test
public void testAppendItemDefinition() {
    when(itemDefinitionUtils.all()).thenReturn(new ArrayList<>());
    final ItemDefinition itemDefinition = handler.appendItemDefinition();
    assertTrue(itemDefinitionUtils.all().contains(itemDefinition));
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Test(org.junit.Test)

Example 89 with ItemDefinition

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

the class ItemDefinitionUpdateHandlerTest method testMakeAllowedValuesWhenDataTypeAndItemDefinitionConstraintAreEqual.

@Test
public void testMakeAllowedValuesWhenDataTypeAndItemDefinitionConstraintAreEqual() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final UnaryTests expectedAllowedValues = mock(UnaryTests.class);
    final String expectedText = "(1..20)";
    final ConstraintType expectedConstraintType = ConstraintType.RANGE;
    when(itemDefinition.getAllowedValues()).thenReturn(expectedAllowedValues);
    when(expectedAllowedValues.getConstraintType()).thenReturn(expectedConstraintType);
    when(expectedAllowedValues.getText()).thenReturn(new Text(expectedText));
    when(dataType.getConstraint()).thenReturn(expectedText);
    final UnaryTests actualAllowedValues = handler.makeAllowedValues(dataType, itemDefinition);
    assertEquals(expectedAllowedValues, actualAllowedValues);
    assertEquals(expectedConstraintType, actualAllowedValues.getConstraintType());
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) Test(org.junit.Test)

Example 90 with ItemDefinition

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

the class ItemDefinitionUpdateHandlerTest method testMakeAllowedValuesWhenDataTypeConstraintIsNull.

@Test
public void testMakeAllowedValuesWhenDataTypeConstraintIsNull() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    when(dataType.getConstraint()).thenReturn(null);
    when(dataType.getConstraintType()).thenReturn(null);
    final UnaryTests actualAllowedValues = handler.makeAllowedValues(dataType, itemDefinition);
    assertNull(actualAllowedValues);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) 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