Search in sources :

Example 11 with ConstraintType

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();
}
Also used : ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Test(org.junit.Test)

Example 12 with ConstraintType

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);
}
Also used : JQuerySelectPickerEvent(org.uberfire.client.views.pfly.selectpicker.JQuerySelectPickerEvent) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) JQuerySelectPickerTarget(org.uberfire.client.views.pfly.selectpicker.JQuerySelectPickerTarget) Test(org.junit.Test)

Example 13 with 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());
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) Test(org.junit.Test)

Example 14 with ConstraintType

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);
    }
}
Also used : ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType)

Example 15 with ConstraintType

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;
}
Also used : QName(javax.xml.namespace.QName) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) OutputClauseUnaryTests(org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests)

Aggregations

ConstraintType (org.kie.workbench.common.dmn.api.definition.model.ConstraintType)28 Test (org.junit.Test)19 QName (javax.xml.namespace.QName)8 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)7 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)6 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)4 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)4 InOrder (org.mockito.InOrder)4 HTMLElement (elemental2.dom.HTMLElement)2 InputClauseUnaryTests (org.kie.workbench.common.dmn.api.definition.model.InputClauseUnaryTests)2 IsUnaryTests (org.kie.workbench.common.dmn.api.definition.model.IsUnaryTests)2 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)2 OutputClauseUnaryTests (org.kie.workbench.common.dmn.api.definition.model.OutputClauseUnaryTests)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 ExpressionLanguage (org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage)2 DataTypeListItem (org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem)2 JSITUnaryTests (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests)2 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 Element (elemental2.dom.Element)1 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)1