Search in sources :

Example 26 with ConstraintType

use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.

the class DataTypeConstraintModalViewTest method testLoadComponent.

@Test
public void testLoadComponent() {
    final ConstraintType constraintType = ENUMERATION;
    final DataTypeConstraintComponent constrainComponent = mock(DataTypeConstraintComponent.class);
    final Element element = mock(Element.class);
    final Element previous = mock(Element.class);
    componentContainer.firstChild = previous;
    when(presenter.getCurrentComponent()).thenReturn(constrainComponent);
    when(constrainComponent.getElement()).thenReturn(element);
    when(componentContainer.removeChild(previous)).then(a -> {
        componentContainer.firstChild = null;
        return element;
    });
    view.loadComponent(constraintType);
    verify(componentContainer).removeChild(previous);
    verify(presenter).setupComponent(constraintType);
    verify(componentContainer).appendChild(element);
}
Also used : Element(elemental2.dom.Element) HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) DataTypeConstraintComponent(org.kie.workbench.common.dmn.client.editors.types.listview.constraint.common.DataTypeConstraintComponent) Test(org.junit.Test)

Example 27 with ConstraintType

use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.

the class ItemDefinitionUpdateHandlerTest method testMakeAllowedValuesWhenDataTypeAndItemDefinitionConstraintAreEqual.

@Test
public void testMakeAllowedValuesWhenDataTypeAndItemDefinitionConstraintAreEqual() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    final UnaryTests expectedAllowedValues = mock(UnaryTests.class);
    final String expectedText = "(1..20)";
    final ConstraintType expectedConstraintType = ConstraintType.RANGE;
    when(itemDefinition.getAllowedValues()).thenReturn(expectedAllowedValues);
    when(expectedAllowedValues.getConstraintType()).thenReturn(expectedConstraintType);
    when(expectedAllowedValues.getText()).thenReturn(new Text(expectedText));
    when(dataType.getConstraint()).thenReturn(expectedText);
    final UnaryTests actualAllowedValues = handler.makeAllowedValues(dataType, itemDefinition);
    assertEquals(expectedAllowedValues, actualAllowedValues);
    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) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) Test(org.junit.Test)

Example 28 with ConstraintType

use of org.kie.workbench.common.dmn.api.definition.model.ConstraintType in project kie-wb-common by kiegroup.

the class DataTypeManagerTest method testWithConstraintType.

@Test
public void testWithConstraintType() {
    final ConstraintType expectedConstraintType = ConstraintType.ENUMERATION;
    final DataType dataType = manager.from(makeDataType("uuid")).withConstraintType(expectedConstraintType.value()).get();
    final ConstraintType actualConstraintType = dataType.getConstraintType();
    assertEquals(expectedConstraintType, actualConstraintType);
}
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