Search in sources :

Example 46 with DataType

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

the class DataTypeListHighlightHelperTest method testGetDataTypeListItemWhenListItemIsNotPresent.

@Test
public void testGetDataTypeListItemWhenListItemIsNotPresent() {
    final String uuid1 = "uuid1";
    final String uuid2 = "uuid2";
    final String uuid3 = "uuid3";
    final DataTypeListItem listItem1 = mock(DataTypeListItem.class);
    final DataTypeListItem listItem2 = mock(DataTypeListItem.class);
    final DataTypeListItem listItem3 = mock(DataTypeListItem.class);
    final DataType dataType1 = mock(DataType.class);
    final DataType dataType2 = mock(DataType.class);
    final DataType dataType3 = mock(DataType.class);
    final List<DataTypeListItem> listItems = asList(listItem1, listItem2, listItem3);
    when(dataTypeList.getItems()).thenReturn(listItems);
    when(listItem1.getDataType()).thenReturn(dataType1);
    when(listItem2.getDataType()).thenReturn(dataType2);
    when(listItem3.getDataType()).thenReturn(dataType3);
    when(dataType1.getUUID()).thenReturn(uuid1);
    when(dataType2.getUUID()).thenReturn(uuid2);
    when(dataType3.getUUID()).thenReturn(uuid3);
    final Optional<DataTypeListItem> dataTypeListItem = helper.getDataTypeListItem("1234");
    assertFalse(dataTypeListItem.isPresent());
}
Also used : DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 47 with DataType

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

the class DataTypeListHighlightHelperTest method testHighlightLevel.

@Test
public void testHighlightLevel() {
    final DataTypeListItem personListItem = mock(DataTypeListItem.class);
    final DataTypeListItem personNameListItem = mock(DataTypeListItem.class);
    final DataTypeListItem parsonAgeListItem = mock(DataTypeListItem.class);
    final DataType personDataType = mock(DataType.class);
    final DataType personNameDataType = mock(DataType.class);
    final DataType parsonAgeDataType = mock(DataType.class);
    final String personUUID = "0000";
    final String personNameUUID = "1111";
    final String parsonAgeUUID = "2222";
    final HTMLElement personElement = mock(HTMLElement.class);
    final HTMLElement personNameElement = mock(HTMLElement.class);
    final HTMLElement parsonAgeElement = mock(HTMLElement.class);
    doReturn(Optional.of(personListItem)).when(helper).getDataTypeListItem(personUUID);
    doReturn(Optional.of(personNameListItem)).when(helper).getDataTypeListItem(personNameUUID);
    doReturn(Optional.of(parsonAgeListItem)).when(helper).getDataTypeListItem(parsonAgeUUID);
    doNothing().when(helper).cleanLevelHighlightClass();
    doNothing().when(helper).appendBackgroundLine(any(), any());
    personElement.classList = mock(DOMTokenList.class);
    personNameElement.classList = mock(DOMTokenList.class);
    parsonAgeElement.classList = mock(DOMTokenList.class);
    when(personElement.getAttribute(UUID_ATTR)).thenReturn(personUUID);
    when(personNameElement.getAttribute(UUID_ATTR)).thenReturn(personNameUUID);
    when(parsonAgeElement.getAttribute(UUID_ATTR)).thenReturn(parsonAgeUUID);
    when(personDataType.getUUID()).thenReturn(personUUID);
    when(personNameDataType.getUUID()).thenReturn(personNameUUID);
    when(parsonAgeDataType.getUUID()).thenReturn(parsonAgeUUID);
    when(personDataType.isTopLevel()).thenReturn(true);
    when(personNameDataType.isTopLevel()).thenReturn(false);
    when(parsonAgeDataType.isTopLevel()).thenReturn(false);
    when(personListItem.getDataType()).thenReturn(personDataType);
    when(personNameListItem.getDataType()).thenReturn(personNameDataType);
    when(parsonAgeListItem.getDataType()).thenReturn(parsonAgeDataType);
    when(personListItem.getDragAndDropElement()).thenReturn(personElement);
    when(personNameListItem.getDragAndDropElement()).thenReturn(personNameElement);
    when(parsonAgeListItem.getDragAndDropElement()).thenReturn(parsonAgeElement);
    when(personDataType.getSubDataTypes()).thenReturn(asList(personNameDataType, parsonAgeDataType));
    when(dataTypeUtils.getTopLevelParent(personNameDataType)).thenReturn(personDataType);
    helper.highlightLevel(personNameElement);
    verify(helper).cleanLevelHighlightClass();
    verify(helper, times(1)).appendBackgroundLine(personDataType, personElement);
    verify(personElement.classList).add(LEVEL_HIGHLIGHT);
    verify(personNameElement.classList).add(LEVEL_HIGHLIGHT);
    verify(parsonAgeElement.classList).add(LEVEL_HIGHLIGHT);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) HTMLElement(elemental2.dom.HTMLElement) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 48 with DataType

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

the class DMNDataTypesSubIndexTest method testHighlight.

@Test
public void testHighlight() {
    final DataTypeListItem listItem = mock(DataTypeListItem.class);
    final DataTypeListItem parentListItem = mock(DataTypeListItem.class);
    final DataType dataType = mock(DataType.class);
    final DataType parent = mock(DataType.class);
    final HTMLElement htmlElement = mock(HTMLElement.class);
    final String parentUUID = "parentUUID";
    final String dataTypeUUID = "dataTypeUUID";
    when(listItem.getDataType()).thenReturn(dataType);
    when(parentListItem.getDataType()).thenReturn(parent);
    when(listItem.getDragAndDropElement()).thenReturn(htmlElement);
    when(dataType.getParentUUID()).thenReturn(parentUUID);
    when(dataType.getUUID()).thenReturn(dataTypeUUID);
    when(parent.getUUID()).thenReturn(parentUUID);
    when(dataTypeStore.get(parentUUID)).thenReturn(parent);
    when(dataTypeStore.get(dataTypeUUID)).thenReturn(dataType);
    when(dataTypeList.getItems()).thenReturn(asList(listItem, parentListItem));
    index.highlight(listItem);
    verify(listItem).expand();
    verify(parentListItem).expand();
    verify(dataTypeShortcuts).highlight(htmlElement);
}
Also used : DataTypeListItem(org.kie.workbench.common.dmn.client.editors.types.listview.DataTypeListItem) HTMLElement(elemental2.dom.HTMLElement) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 49 with DataType

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

the class DataTypeListItemViewTest method testSetupReadOnlyCSSClassWhenDataTypeDoesNotHaveSubDataTypes.

@Test
public void testSetupReadOnlyCSSClassWhenDataTypeDoesNotHaveSubDataTypes() {
    final DataType dataType = mock(DataType.class);
    dragAndDropElement.classList = mock(DOMTokenList.class);
    when(dataType.isReadOnly()).thenReturn(false);
    view.setupReadOnlyCSSClass(dataType);
    verify(dragAndDropElement.classList).remove("read-only");
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 50 with DataType

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

the class DataTypeListItemViewTest method testDisableFocusMode.

@Test
public void testDisableFocusMode() {
    final DataType parentDataType = mock(DataType.class);
    final String parentDataTypeUUID = "parentDataTypeUUID";
    final Element parentElement = mock(Element.class);
    final Element child1 = makeChildElement("child1UUID");
    final Element child2 = makeChildElement("child2UUID");
    final NodeList<Element> children = spy(new NodeList<>());
    when(parentDataType.getUUID()).thenReturn(parentDataTypeUUID);
    when(parentElement.getAttribute("data-row-uuid")).thenReturn(parentDataTypeUUID);
    doReturn(parentDataType).when(view).getDataType();
    doReturn(child1).when(children).getAt(0);
    doReturn(child2).when(children).getAt(1);
    mockDOMElementByUUID(parentDataTypeUUID, parentElement);
    mockDOMElementsByParentUUID(parentDataTypeUUID, children);
    children.length = 2;
    parentElement.classList = mock(DOMTokenList.class);
    view.disableFocusMode();
    verify(parentElement.classList).remove(FOCUSED_CSS_CLASS);
    verify(child1.classList).remove(FOCUSED_CSS_CLASS);
    verify(child2.classList).remove(FOCUSED_CSS_CLASS);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) 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