use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class InputClauseUnaryTestsPropertyConverter method wbFromDMN.
public static InputClauseUnaryTests 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 InputClauseUnaryTests result = new InputClauseUnaryTests(id, new Text(dmn.getText()), constraint);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class UnaryTestsPropertyConverter method wbFromDMN.
public static UnaryTests wbFromDMN(final org.kie.dmn.model.api.UnaryTests dmn) {
if (dmn == null) {
return null;
}
final Id id = new Id(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final ExpressionLanguage expressionLanguage = ExpressionLanguagePropertyConverter.wbFromDMN(dmn.getExpressionLanguage());
final ConstraintType constraintTypeField;
final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
if (dmn.getAdditionalAttributes().containsKey(key)) {
constraintTypeField = ConstraintTypeFieldPropertyConverter.wbFromDMN(dmn.getAdditionalAttributes().get(key));
} else {
constraintTypeField = NONE;
}
final UnaryTests result = new UnaryTests(id, description, new Text(dmn.getText()), expressionLanguage, constraintTypeField);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalTest method testLoadWhenConstraintTypeIsNotNone.
@Test
public void testLoadWhenConstraintTypeIsNotNone() {
final String expectedConstraintValueType = "string";
final String expectedConstraintValue = "1,2,3";
final ConstraintType expectedConstraintType = ENUMERATION;
modal.load(expectedConstraintValueType, expectedConstraintValue, expectedConstraintType);
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 DataTypeConstraintTest method testInit.
@Test
public void testInit() {
final DataTypeListItem expectedListItem = mock(DataTypeListItem.class);
final DataType datatype = mock(DataType.class);
final String expectedConstraint = "constraint";
final ConstraintType expectedType = mock(ConstraintType.class);
when(expectedListItem.getDataType()).thenReturn(datatype);
when(datatype.getConstraint()).thenReturn(expectedConstraint);
when(datatype.getConstraintType()).thenReturn(expectedType);
dataTypeConstraint.init(expectedListItem);
final DataTypeListItem actualListItem = dataTypeConstraint.getListItem();
final String actualConstraint = dataTypeConstraint.getValue();
final ConstraintType actualType = dataTypeConstraint.getConstraintType();
assertEquals(expectedType, actualType);
assertEquals(expectedListItem, actualListItem);
assertEquals(expectedConstraint, actualConstraint);
verify(dataTypeConstraint).refreshView();
}
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();
}
Aggregations