use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class UnaryTestsPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.UnaryTests dmnFromWB(final IsUnaryTests wb) {
if (wb == null) {
return null;
}
final org.kie.dmn.model.api.UnaryTests result = new org.kie.dmn.model.v1_2.TUnaryTests();
result.setId(wb.getId().getValue());
result.setText(wb.getText().getValue());
final ConstraintType constraint = wb.getConstraintType();
if (isNotNone(constraint)) {
final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
result.getAdditionalAttributes().put(key, constraint.value());
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalTest method testSetupComponentWhenConstraintTypeIsRangeAndValueIsEmpty.
@Test
public void testSetupComponentWhenConstraintTypeIsRangeAndValueIsEmpty() {
final ConstraintType type = RANGE;
final String constraint = "";
final String constraintValueType = "number";
doReturn(constraint).when(modal).getConstraintValue();
doReturn(constraintValueType).when(modal).getConstraintValueType();
when(constraintRange.getElement()).thenReturn(element);
modal.setupComponent(type);
assertEquals(constraintRange, modal.getCurrentComponent());
final InOrder inOrder = inOrder(constraintRange);
inOrder.verify(constraintRange).setConstraintValueType(constraintValueType);
inOrder.verify(constraintRange).setValue(constraint);
verify(modal, never()).enableOkButton();
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 testInferComponentTypeWhenItReturnsRange.
@Test
public void testInferComponentTypeWhenItReturnsRange() {
final ConstraintType expectedType = RANGE;
final ConstraintType actualType = modal.inferComponentType("(1..3]");
assertEquals(expectedType, actualType);
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalTest method testSetupComponentWhenConstraintTypeIsRange.
@Test
public void testSetupComponentWhenConstraintTypeIsRange() {
final ConstraintType type = RANGE;
final String constraint = "(1..2)";
final String constraintValueType = "number";
doReturn(constraint).when(modal).getConstraintValue();
doReturn(constraintValueType).when(modal).getConstraintValueType();
when(constraintRange.getElement()).thenReturn(element);
modal.setupComponent(type);
assertEquals(constraintRange, modal.getCurrentComponent());
final InOrder inOrder = inOrder(constraintRange);
inOrder.verify(constraintRange).setConstraintValueType(constraintValueType);
inOrder.verify(constraintRange).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 testDoSave.
@Test
public void testDoSave() {
final String expectedConstraint = "1,2,3";
final ConstraintType expectedConstraintType = ENUMERATION;
final BiConsumer<String, ConstraintType> onSave = mock(BiConsumer.class);
doNothing().when(modal).hide();
doReturn(onSave).when(modal).getOnSave();
modal.setConstraintType(expectedConstraintType);
modal.doSave(expectedConstraint);
final String actualConstraint = modal.getConstraintValue();
assertEquals(expectedConstraint, actualConstraint);
verify(onSave).accept(expectedConstraint, expectedConstraintType);
verify(modal).hide();
}
Aggregations