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);
}
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));
}
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));
}
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());
}
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);
}
Aggregations