use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class OutputClauseUnaryTestsPropertyConverter method wbFromDMN.
/**
* Returns a non-null instance of OutputClauseUnaryTestsPropertyConverter. The Properties Panel needs
* non-null objects to bind therefore a concrete object must always be returned.
* @param dmn
* @return
*/
public static OutputClauseUnaryTests wbFromDMN(final JSITUnaryTests dmn) {
if (Objects.isNull(dmn)) {
return new OutputClauseUnaryTests();
}
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
final Map<QName, String> otherAttributes = JSITUnaryTests.getOtherAttributesMap(dmn);
final String constraintString = otherAttributes.getOrDefault(key, "");
final ConstraintType constraint = ConstraintType.fromString(constraintString);
final OutputClauseUnaryTests result = new OutputClauseUnaryTests(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 DataTypeConstraintModalTest method testSetupComponentWhenConstraintTypeIsExpression.
@Test
public void testSetupComponentWhenConstraintTypeIsExpression() {
final ConstraintType type = EXPRESSION;
final String constraint = "expression";
final String constraintValueType = "string";
doReturn(constraint).when(modal).getConstraintValue();
doReturn(constraintValueType).when(modal).getConstraintValueType();
when(constraintExpression.getElement()).thenReturn(element);
modal.setupComponent(type);
assertEquals(constraintExpression, modal.getCurrentComponent());
final InOrder inOrder = inOrder(constraintExpression);
inOrder.verify(constraintExpression).setConstraintValueType(constraintValueType);
inOrder.verify(constraintExpression).setValue(constraint);
verify(modal).enableOkButton();
verify(element).setAttribute("class", "kie-string");
}
use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.
the class DataTypeConstraintModalTest method testInferComponentTypeWhenItReturnsEnumeration.
@Test
public void testInferComponentTypeWhenItReturnsEnumeration() {
final ConstraintType expectedType = ENUMERATION;
final ConstraintType actualType = modal.inferComponentType("1,2,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 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();
}
Aggregations