Search in sources :

Example 21 with ConstraintType

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

the class DataTypeConstraintModalTest method testSetupComponentWhenConstraintTypeIsNone.

@Test
public void testSetupComponentWhenConstraintTypeIsNone() {
    final ConstraintType type = NONE;
    final String constraint = "(1..2)";
    final String constraintValueType = "number";
    doReturn(ENUMERATION).when(modal).inferComponentType(constraint);
    doReturn(constraint).when(modal).getConstraintValue();
    doReturn(constraintValueType).when(modal).getConstraintValueType();
    when(constraintEnumeration.getElement()).thenReturn(element);
    modal.setupComponent(type);
    assertEquals(constraintEnumeration, modal.getCurrentComponent());
    final InOrder inOrder = inOrder(constraintEnumeration);
    inOrder.verify(constraintEnumeration).setConstraintValueType(constraintValueType);
    inOrder.verify(constraintEnumeration).setValue(constraint);
    verify(element).setAttribute("class", "kie-number");
}
Also used : InOrder(org.mockito.InOrder) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Test(org.junit.Test)

Example 22 with ConstraintType

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

the class DataTypeConstraintModalTest method testLoadWhenConstraintTypeIsNone.

@Test
public void testLoadWhenConstraintTypeIsNone() {
    final String expectedConstraintValueType = "string";
    final String expectedConstraintValue = "1,2,3";
    final ConstraintType expectedConstraintType = RANGE;
    doReturn(expectedConstraintType).when(modal).inferComponentType(expectedConstraintValue);
    modal.load(expectedConstraintValueType, expectedConstraintValue, NONE);
    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 23 with ConstraintType

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

the class DataTypeConstraintModalTest method testInferComponentTypeWhenItReturnsExpression.

@Test
public void testInferComponentTypeWhenItReturnsExpression() {
    final ConstraintType expectedType = EXPRESSION;
    final ConstraintType actualType = modal.inferComponentType("expression");
    assertEquals(expectedType, actualType);
}
Also used : ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Test(org.junit.Test)

Example 24 with ConstraintType

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

the class DataTypeConstraintTest method testOpenModal.

@Test
public void testOpenModal() {
    final DataTypeListItem listItem = mock(DataTypeListItem.class);
    final String constraint = "1,2,3";
    final String type = "string";
    final BiConsumer<String, ConstraintType> onShowConsumer = (s, c) -> {
    /* Nothing. */
    };
    doReturn(listItem).when(dataTypeConstraint).getListItem();
    doReturn(constraint).when(dataTypeConstraint).getValue();
    doReturn(onShowConsumer).when(dataTypeConstraint).getOnShowConsumer();
    when(listItem.getType()).thenReturn(type);
    dataTypeConstraint.openModal();
    constraintModal.load(type, constraint, ENUMERATION);
    constraintModal.show(onShowConsumer);
}
Also used : DataTypeListItem(org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem) GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ENUMERATION(org.kie.workbench.common.dmn.api.definition.model.ConstraintType.ENUMERATION) Mock(org.mockito.Mock) Assert.assertNotNull(org.junit.Assert.assertNotNull) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) RunWith(org.junit.runner.RunWith) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.spy(org.mockito.Mockito.spy) DataTypeListItem(org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem) Mockito.verify(org.mockito.Mockito.verify) Assert.assertSame(org.junit.Assert.assertSame) Assert.assertNull(org.junit.Assert.assertNull) HTMLElement(elemental2.dom.HTMLElement) Assert.assertFalse(org.junit.Assert.assertFalse) BiConsumer(java.util.function.BiConsumer) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Mockito.doReturn(org.mockito.Mockito.doReturn) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) ConstraintType(org.kie.workbench.common.dmn.api.definition.model.ConstraintType) Test(org.junit.Test)

Example 25 with ConstraintType

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

the class DataTypeConstraintTest method testDisable.

@Test
public void testDisable() {
    dataTypeConstraint.disable();
    final String actualConstraint = dataTypeConstraint.getValue();
    final ConstraintType actualConstraintType = dataTypeConstraint.getConstraintType();
    assertEquals(DataTypeConstraint.NONE, actualConstraint);
    assertEquals(ConstraintType.NONE, actualConstraintType);
    verify(view).disable();
}
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