Search in sources :

Example 11 with DataType

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

the class DataTypeListItem method discardNewDataType.

void discardNewDataType() {
    final DataType oldDataType = discardDataTypeProperties();
    view.setDataType(oldDataType);
    setupListComponent();
    setupSelectComponent();
    setupConstraintComponent();
    setupIndentationLevel();
    refreshSubDataTypes();
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType)

Example 12 with DataType

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

the class DataTypeListTest method testInsertBelow.

@Test
public void testInsertBelow() {
    final DataType dataType = mock(DataType.class);
    final DataType reference = mock(DataType.class);
    final DataTypeListItem listItem = mock(DataTypeListItem.class);
    doReturn(listItem).when(dataTypeList).makeListItem(dataType);
    when(listItem.getDataType()).thenReturn(dataType);
    dataTypeList.insertBelow(dataType, reference);
    verify(view).insertBelow(listItem, reference);
    verify(dataTypeList).refreshItemsByUpdatedDataTypes(singletonList(dataType));
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 13 with DataType

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

the class DataTypeListTest method testDisableEditModeForChildren.

@Test
public void testDisableEditModeForChildren() {
    final DataTypeListItem dataTypeListItem = mock(DataTypeListItem.class);
    final DataType dataType = mock(DataType.class);
    final String uuid = "uuid";
    final String innerUuid = "inner";
    final String deepUuid = "deep";
    final DataType notChildDataType = mock(DataType.class);
    final DataTypeListItem notChildItem = mock(DataTypeListItem.class);
    final DataType childDataType1 = mock(DataType.class);
    final DataTypeListItem child1 = mock(DataTypeListItem.class);
    final DataType childDataType2 = mock(DataType.class);
    final DataTypeListItem child2 = mock(DataTypeListItem.class);
    final DataType innerDataType = mock(DataType.class);
    final DataTypeListItem innerDataTypeListItem = mock(DataTypeListItem.class);
    final DataType deepDataType = mock(DataType.class);
    final DataTypeListItem deepDataTypeListItem = mock(DataTypeListItem.class);
    when(deepDataType.getUUID()).thenReturn(deepUuid);
    when(deepDataType.getParentUUID()).thenReturn(innerUuid);
    when(deepDataTypeListItem.getDataType()).thenReturn(deepDataType);
    when(innerDataType.getUUID()).thenReturn(innerUuid);
    when(innerDataType.getParentUUID()).thenReturn(uuid);
    when(innerDataTypeListItem.getDataType()).thenReturn(innerDataType);
    when(notChildDataType.getParentUUID()).thenReturn("other_uuid");
    when(notChildItem.getDataType()).thenReturn(notChildDataType);
    when(child1.getDataType()).thenReturn(childDataType1);
    when(childDataType1.getParentUUID()).thenReturn(uuid);
    when(child2.getDataType()).thenReturn(childDataType2);
    when(childDataType2.getParentUUID()).thenReturn(uuid);
    when(dataType.getUUID()).thenReturn(uuid);
    when(dataTypeListItem.getDataType()).thenReturn(dataType);
    final List<DataTypeListItem> list = asList(child1, notChildItem, child2, innerDataTypeListItem, deepDataTypeListItem);
    doReturn(list).when(dataTypeList).getItems();
    dataTypeList.disableEditModeForChildren(dataTypeListItem);
    verify(child1).disableEditMode();
    verify(child2).disableEditMode();
    verify(innerDataTypeListItem).disableEditMode();
    verify(deepDataTypeListItem).disableEditMode();
    verify(notChildItem, never()).disableEditMode();
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 14 with DataType

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

the class DataTypeListTest method makeDataType.

private DataType makeDataType(final String name, final String type, final DataType... subDataTypes) {
    final DataType dataType = makeDataType("default", name, TOP_LEVEL_PARENT_UUID);
    when(dataType.getType()).thenReturn(type);
    when(dataType.getSubDataTypes()).thenReturn(asList(subDataTypes));
    return dataType;
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType)

Example 15 with DataType

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

the class DataTypeListTest method testCreateNewDataTypeFromDataObject.

@Test
public void testCreateNewDataTypeFromDataObject() {
    final DataObject dataObject = mock(DataObject.class);
    final DataType dataType = mock(DataType.class);
    final String structure = "structure";
    final String classType = "classType";
    when(dataObject.getClassType()).thenReturn(classType);
    when(dataTypeManager.structure()).thenReturn(structure);
    when(dataTypeManager.fromNew()).thenReturn(dataTypeManager);
    when(dataTypeManager.withType(structure)).thenReturn(dataTypeManager);
    when(dataTypeManager.get()).thenReturn(dataType);
    final DataType actual = dataTypeList.createNewDataType(dataObject);
    assertEquals(dataType, actual);
    verify(dataType).setName(classType);
}
Also used : DataObject(org.kie.workbench.common.dmn.api.editors.types.DataObject) 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