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());
}
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);
}
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);
}
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");
}
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);
}
Aggregations