Search in sources :

Example 1 with ConstraintType

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

Example 2 with ConstraintType

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

Example 3 with ConstraintType

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

Example 4 with ConstraintType

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

Example 5 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)

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