use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalViewTest method testLoadComponent.
@Test
public void testLoadComponent() {
final ConstraintType constraintType = ENUMERATION;
final DataTypeConstraintComponent constrainComponent = mock(DataTypeConstraintComponent.class);
final Element element = mock(Element.class);
final Element previous = mock(Element.class);
componentContainer.firstChild = previous;
when(presenter.getCurrentComponent()).thenReturn(constrainComponent);
when(constrainComponent.getElement()).thenReturn(element);
when(componentContainer.removeChild(previous)).then(a -> {
componentContainer.firstChild = null;
return element;
});
view.loadComponent(constraintType);
verify(componentContainer).removeChild(previous);
verify(presenter).setupComponent(constraintType);
verify(componentContainer).appendChild(element);
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType 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.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeManagerTest method testWithConstraintType.
@Test
public void testWithConstraintType() {
final ConstraintType expectedConstraintType = ConstraintType.ENUMERATION;
final DataType dataType = manager.from(makeDataType("uuid")).withConstraintType(expectedConstraintType.value()).get();
final ConstraintType actualConstraintType = dataType.getConstraintType();
assertEquals(expectedConstraintType, actualConstraintType);
}
Aggregations