use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DNDDataTypesHandlerTest method testOnDropDataTypeWhenReferenceIsNotPresent.
@Test
public void testOnDropDataTypeWhenReferenceIsNotPresent() {
final Element currentElement = mock(Element.class);
final Element hoverElement = mock(Element.class);
final DataType current = mock(DataType.class);
final DNDDataTypesHandlerContext context = mock(DNDDataTypesHandlerContext.class);
doNothing().when(handler).logError(Mockito.<String>any());
doReturn(context).when(handler).makeDndContext(currentElement, hoverElement);
when(context.getCurrentDataType()).thenReturn(Optional.of(current));
when(context.getReference()).thenReturn(Optional.empty());
handler.onDropDataType(currentElement, hoverElement);
verify(handler, never()).shiftCurrentByReference(any(), any(), any());
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DNDDataTypesHandlerTest method testGetReferenceWhenDNDListComponentIsNotInitialized.
@Test
public void testGetReferenceWhenDNDListComponentIsNotInitialized() {
final Element currentElement = mock(Element.class);
final Element hoverElement = mock(Element.class);
final Element previousElement = mock(Element.class);
final Optional<DataType> previousDataType = Optional.of(mock(DataType.class));
final String uuid = "0000-1111-2222-3333";
when(dndListComponent.getPreviousElement(any(), any())).thenReturn(Optional.of(previousElement));
when(dataTypeStore.get(uuid)).thenReturn(previousDataType.get());
when(previousElement.getAttribute(UUID_ATTR)).thenReturn(uuid);
when(dataTypeList.getDNDListComponent()).thenReturn(null);
assertThatThrownBy(() -> handler.makeDndContext(currentElement, hoverElement).getReference()).isInstanceOf(UnsupportedOperationException.class).hasMessage("'DNDDataTypesHandler' must be initialized with a 'DNDListComponent' instance.");
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DNDDataTypesHandlerTest method testOnDropDataType.
@Test
public void testOnDropDataType() {
final Element currentElement = mock(Element.class);
final Element hoverElement = mock(Element.class);
final DataType current = mock(DataType.class);
final DataType reference = mock(DataType.class);
final DNDDataTypesHandlerContext context = mock(DNDDataTypesHandlerContext.class);
final DNDDataTypesHandlerShiftStrategy strategy = INSERT_INTO_HOVERED_DATA_TYPE;
doNothing().when(handler).logError(Mockito.<String>any());
doReturn(context).when(handler).makeDndContext(currentElement, hoverElement);
when(context.getCurrentDataType()).thenReturn(Optional.of(current));
when(context.getReference()).thenReturn(Optional.of(reference));
when(context.getStrategy()).thenReturn(strategy);
handler.onDropDataType(currentElement, hoverElement);
verify(handler).shiftCurrentByReference(current, reference, strategy);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListViewTest method testShowArrowIconIfDataTypeHasChildrenWhenDataTypeDoesNotHaveChildren.
@Test
public void testShowArrowIconIfDataTypeHasChildrenWhenDataTypeDoesNotHaveChildren() {
final DataType dataType = mock(DataType.class);
final NodeList<Element> elementNodeList = new NodeList<>();
final Element dataTypeRow = mock(Element.class);
final Element dataTypeRowArrow = mock(Element.class);
final DOMTokenList arrowClassList = mock(DOMTokenList.class);
final String uuid = "uuid";
dataTypeRowArrow.classList = arrowClassList;
elementNodeList.length = 0;
when(dataType.getUUID()).thenReturn(uuid);
when(listItems.querySelectorAll("[" + PARENT_UUID_ATTR + "=\"uuid\"]")).thenReturn(elementNodeList);
when(listItems.querySelector("[" + UUID_ATTR + "=\"uuid\"]")).thenReturn(dataTypeRow);
when(dataTypeRow.querySelector(ARROW_BUTTON_SELECTOR)).thenReturn(dataTypeRowArrow);
view.showArrowIconIfDataTypeHasChildren(dataType);
verify(arrowClassList).add(HIDDEN_CSS_CLASS);
}
use of org.kie.workbench.common.dmn.client.editors.types.common.DataType in project kie-wb-common by kiegroup.
the class DataTypeListViewTest method testInsertBelow.
@Test
public void testInsertBelow() {
final DataTypeListItem listItem = mock(DataTypeListItem.class);
final DataType reference = mock(DataType.class);
final HTMLElement listItemElement = mock(HTMLElement.class);
final Element lastElement = spy(new Element());
final Element parentElement = mock(Element.class);
final Element siblingElement = mock(Element.class);
lastElement.parentNode = parentElement;
lastElement.nextSibling = siblingElement;
when(listItem.getDragAndDropElement()).thenReturn(listItemElement);
doReturn(lastElement).when(view).getLastSubDataTypeElement(reference);
view.insertBelow(listItem, reference);
verify(parentElement).insertBefore(listItemElement, siblingElement);
verify(view).setNewElementYPosition(lastElement, listItemElement);
}
Aggregations