Search in sources :

Example 56 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class ReferencedDataTypeWarningMessageTest method testGetErrorElementSelector.

@Test
public void testGetErrorElementSelector() {
    final DataType dataType = mock(DataType.class);
    when(dataType.getUUID()).thenReturn("1111-1111-1111-1111");
    final String expectedSelector = "[data-row-uuid=\"1111-1111-1111-1111\"] select";
    final String actualSelector = new ReferencedDataTypeWarningMessage(translationService).getErrorElementSelector(dataType);
    assertEquals(expectedSelector, actualSelector);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 57 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType 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 58 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeListItemTest method testDiscardDataTypeProperties.

@Test
public void testDiscardDataTypeProperties() {
    final DataType dataType = spy(makeDataType());
    final String expectedName = "name";
    final String expectedType = "type";
    final String expectedConstraint = "constraint";
    final String expectedConstraintType = "enumeration";
    final boolean expectedIsList = true;
    doReturn(dataType).when(listItem).getDataType();
    doReturn(expectedName).when(listItem).getOldName();
    doReturn(expectedType).when(listItem).getOldType();
    doReturn(expectedConstraint).when(listItem).getOldConstraint();
    doReturn(expectedIsList).when(listItem).getOldIsList();
    doReturn(expectedConstraintType).when(listItem).getOldConstraintType();
    listItem.discardDataTypeProperties();
    assertEquals(expectedName, dataType.getName());
    assertEquals(expectedType, dataType.getType());
    assertEquals(expectedConstraint, dataType.getConstraint());
    assertEquals(expectedIsList, dataType.isList());
    assertEquals(expectedConstraintType, dataType.getConstraintType().value());
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 59 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeListItemTest method testIsIndirectTypeOfWhenIsStructureRecursive.

@Test
public void testIsIndirectTypeOfWhenIsStructureRecursive() {
    // some(tIndirectType) -> tIndirectType(tIndirectStructure) -> tIndirectStructure(Structure)
    final String indirectType = "tIndirectType";
    final String tIndirectStructure = "tIndirectStructure";
    final DataType dataType1 = mock(DataType.class);
    final DataType dataType2 = mock(DataType.class);
    final List<DataType> customDataTypes = asList(dataType1, dataType2);
    when(dataType1.getName()).thenReturn(indirectType);
    when(dataType1.getType()).thenReturn(tIndirectStructure);
    when(dataType2.getName()).thenReturn(tIndirectStructure);
    when(dataType2.getType()).thenReturn(structure);
    when(dataTypeSelectComponent.getValue()).thenReturn(indirectType);
    when(dataTypeSelectComponent.getCustomDataTypes()).thenReturn(customDataTypes);
    final boolean actual = listItem.isIndirectCanNotHaveConstraintType();
    assertTrue(actual);
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 60 with DataType

use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.

the class DataTypeListItemTest method testSetupView.

@Test
public void testSetupView() {
    final DataType dataType = mock(DataType.class);
    when(listItem.getDataType()).thenReturn(dataType);
    doNothing().when(listItem).setupIndentationLevel();
    doNothing().when(listItem).hideTooltips();
    listItem.setupView();
    verify(view).setupSelectComponent(dataTypeSelectComponent);
    verify(view).setupConstraintComponent(dataTypeConstraintComponent);
    verify(view).setupListComponent(dataTypeListComponent);
    verify(view).setDataType(dataType);
    verify(listItem).setupIndentationLevel();
    verify(listItem).hideTooltips();
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Aggregations

DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)274 Test (org.junit.Test)245 HTMLElement (elemental2.dom.HTMLElement)44 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)39 Element (elemental2.dom.Element)30 ArrayList (java.util.ArrayList)26 DOMTokenList (elemental2.dom.DOMTokenList)24 DataTypeListItem (org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem)14 HTMLDivElement (elemental2.dom.HTMLDivElement)13 HTMLButtonElement (elemental2.dom.HTMLButtonElement)12 Command (org.uberfire.mvp.Command)12 FlashMessage (org.kie.workbench.common.dmn.client.editors.common.messages.FlashMessage)9 DataTypeManager (org.kie.workbench.common.dmn.client.editors.types.common.DataTypeManager)9 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)8 DNDListComponent (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListComponent)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)6 HTMLInputElement (elemental2.dom.HTMLInputElement)6 DataObject (org.kie.workbench.common.dmn.api.editors.types.DataObject)6