use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalTest method testSetupComponentWhenConstraintTypeIsNone.
@Test
public void testSetupComponentWhenConstraintTypeIsNone() {
final ConstraintType type = NONE;
final String constraint = "(1..2)";
final String constraintValueType = "number";
doReturn(ENUMERATION).when(modal).inferComponentType(constraint);
doReturn(constraint).when(modal).getConstraintValue();
doReturn(constraintValueType).when(modal).getConstraintValueType();
when(constraintEnumeration.getElement()).thenReturn(element);
modal.setupComponent(type);
assertEquals(constraintEnumeration, modal.getCurrentComponent());
final InOrder inOrder = inOrder(constraintEnumeration);
inOrder.verify(constraintEnumeration).setConstraintValueType(constraintValueType);
inOrder.verify(constraintEnumeration).setValue(constraint);
verify(element).setAttribute("class", "kie-number");
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalTest method testLoadWhenConstraintTypeIsNone.
@Test
public void testLoadWhenConstraintTypeIsNone() {
final String expectedConstraintValueType = "string";
final String expectedConstraintValue = "1,2,3";
final ConstraintType expectedConstraintType = RANGE;
doReturn(expectedConstraintType).when(modal).inferComponentType(expectedConstraintValue);
modal.load(expectedConstraintValueType, expectedConstraintValue, NONE);
final String actualConstraintValueType = modal.getConstraintValueType();
final String actualConstraintValue = modal.getConstraintValue();
final ConstraintType actualConstraintType = modal.getConstraintType();
verify(modal).prepareView();
assertEquals(expectedConstraintValueType, actualConstraintValueType);
assertEquals(expectedConstraintValue, actualConstraintValue);
assertEquals(expectedConstraintType, actualConstraintType);
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalTest method testInferComponentTypeWhenItReturnsExpression.
@Test
public void testInferComponentTypeWhenItReturnsExpression() {
final ConstraintType expectedType = EXPRESSION;
final ConstraintType actualType = modal.inferComponentType("expression");
assertEquals(expectedType, actualType);
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintTest method testOpenModal.
@Test
public void testOpenModal() {
final DataTypeListItem listItem = mock(DataTypeListItem.class);
final String constraint = "1,2,3";
final String type = "string";
final BiConsumer<String, ConstraintType> onShowConsumer = (s, c) -> {
/* Nothing. */
};
doReturn(listItem).when(dataTypeConstraint).getListItem();
doReturn(constraint).when(dataTypeConstraint).getValue();
doReturn(onShowConsumer).when(dataTypeConstraint).getOnShowConsumer();
when(listItem.getType()).thenReturn(type);
dataTypeConstraint.openModal();
constraintModal.load(type, constraint, ENUMERATION);
constraintModal.show(onShowConsumer);
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintTest method testDisable.
@Test
public void testDisable() {
dataTypeConstraint.disable();
final String actualConstraint = dataTypeConstraint.getValue();
final ConstraintType actualConstraintType = dataTypeConstraint.getConstraintType();
assertEquals(DataTypeConstraint.NONE, actualConstraint);
assertEquals(ConstraintType.NONE, actualConstraintType);
verify(view).disable();
}
Aggregations