use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintTest method testGetOnShowConsumer.
@Test
public void testGetOnShowConsumer() {
final String expectedConstraint = "1,2,3";
final ConstraintType expectedConstraintType = ENUMERATION;
dataTypeConstraint.getOnShowConsumer().accept(expectedConstraint, ENUMERATION);
final String actualConstraint = dataTypeConstraint.getValue();
final ConstraintType actualConstraintType = dataTypeConstraint.getConstraintType();
assertEquals(expectedConstraint, actualConstraint);
assertEquals(expectedConstraintType, actualConstraintType);
verify(dataTypeConstraint).refreshView();
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalViewTest method testOnSelectChangeWhenValueIsNotBlank.
@Test
public void testOnSelectChangeWhenValueIsNotBlank() {
final JQuerySelectPickerEvent jQueryEvent = mock(JQuerySelectPickerEvent.class);
final JQuerySelectPickerTarget pickerTarget = mock(JQuerySelectPickerTarget.class);
final ConstraintType constraintType = ENUMERATION;
doNothing().when(view).loadComponent(ENUMERATION);
jQueryEvent.target = pickerTarget;
pickerTarget.value = constraintType.value();
view.onSelectChange(jQueryEvent);
verify(view).loadComponent(constraintType);
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class ItemDefinitionUpdateHandlerTest method testMakeAllowedValuesWhenDataTypeAndItemDefinitionConstraintAreNotEqual.
@Test
public void testMakeAllowedValuesWhenDataTypeAndItemDefinitionConstraintAreNotEqual() {
final DataType dataType = mock(DataType.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
final String expectedText = "(1..20)";
final ConstraintType expectedConstraintType = ConstraintType.RANGE;
when(dataType.getConstraint()).thenReturn(expectedText);
when(dataType.getConstraintType()).thenReturn(expectedConstraintType);
final UnaryTests actualAllowedValues = handler.makeAllowedValues(dataType, itemDefinition);
assertNotNull(actualAllowedValues.getId());
assertNotNull(actualAllowedValues.getDescription());
assertEquals(expectedText, actualAllowedValues.getText().getValue());
assertNull(actualAllowedValues.getExpressionLanguage());
assertEquals(expectedConstraintType, actualAllowedValues.getConstraintType());
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalView method onSelectChange.
void onSelectChange(final JQuerySelectPickerEvent event) {
final String constraintType = event.target.value;
if (!isEmpty(constraintType)) {
final ConstraintType constraint = ConstraintType.fromString(constraintType);
loadComponent(constraint);
presenter.setConstraintType(constraint);
}
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class OutputClauseUnaryTestsPropertyConverter method wbFromDMN.
public static OutputClauseUnaryTests wbFromDMN(final org.kie.dmn.model.api.UnaryTests dmn) {
if (dmn == null) {
return null;
}
final Id id = new Id(dmn.getId());
final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
final String constraintString = dmn.getAdditionalAttributes().getOrDefault(key, "");
final ConstraintType constraint = ConstraintType.fromString(constraintString);
final OutputClauseUnaryTests result = new OutputClauseUnaryTests(id, new Text(dmn.getText()), constraint);
return result;
}
Aggregations