use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.
the class DecisionNavigatorTreeViewTest method testTreeItemUpdateCSSClassWhenItemHasChildren.
@Test
public void testTreeItemUpdateCSSClassWhenItemHasChildren() {
final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
final DecisionNavigatorItem child = mock(DecisionNavigatorItem.class);
final TreeSet<DecisionNavigatorItem> children = new TreeSet<DecisionNavigatorItem>() {
{
add(child);
}
};
final org.jboss.errai.common.client.dom.DOMTokenList classList = mock(org.jboss.errai.common.client.dom.DOMTokenList.class);
final HTMLElement element = mock(HTMLElement.class);
final String cssClass = "css-class";
doReturn(item).when(treeItem).getItem();
doReturn(element).when(treeItem).getElement();
doReturn(cssClass).when(treeItem).getCSSClass(item);
when(element.getClassList()).thenReturn(classList);
when(item.getChildren()).thenReturn(children);
when(item.isEditable()).thenReturn(true);
treeItem.updateCSSClass();
verify(classList).add(cssClass);
verify(classList).add("parent-node");
verify(classList).add("editable");
}
use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.
the class DecisionNavigatorTreeViewTest method testSave.
@Test
public void testSave() {
final HTMLElement element = mock(HTMLElement.class);
final DecisionNavigatorItem item = mock(DecisionNavigatorItem.class);
final org.jboss.errai.common.client.dom.DOMTokenList tokenList = mock(org.jboss.errai.common.client.dom.DOMTokenList.class);
doNothing().when(treeItem).updateLabel();
doReturn(element).when(treeItem).getElement();
doReturn(item).when(treeItem).getItem();
when(element.getClassList()).thenReturn(tokenList);
treeItem.save();
verify(item).setLabel(inputText.value);
verify(tokenList).remove("editing");
verify(treeItem).updateLabel();
verify(item).onUpdate();
verify(locker).fire(any());
}
use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.
the class DecisionNavigatorBaseItemFactory method makeItem.
public DecisionNavigatorItem makeItem(final Node<View, Edge> node, final DecisionNavigatorItem.Type type) {
final String uuid = node.getUUID();
final String label = getLabel(node);
final Command onClick = makeOnClickCommand(node);
final List<DecisionNavigatorItem> nestedItems = makeNestedItems(node);
final DecisionNavigatorItem item = navigatorItemBuilder().withUUID(uuid).withLabel(label).withType(type).withOnClick(onClick).build();
nestedItems.forEach(item::addChild);
return item;
}
use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.
the class DecisionNavigatorNestedItemFactoryTest method testMakeItem.
@Test
public void testMakeItem() {
final String uuid = "uuid";
final String label = "label";
final DecisionNavigatorItem.Type type = DECISION_TABLE;
final Command command = mock(Command.class);
final String parentUUID = "parentUUID";
when(node.getUUID()).thenReturn(parentUUID);
doReturn(uuid).when(factory).getUUID(node);
doReturn(label).when(factory).getLabel(node);
doReturn(type).when(factory).getType(node);
doReturn(command).when(factory).makeOnClickCommand(node, parentUUID);
final DecisionNavigatorItem item = factory.makeItem(node);
assertTrue(item.getOnClick().isPresent());
assertEquals(command, item.getOnClick().get());
assertEquals(uuid, item.getUUID());
assertEquals(label, item.getLabel());
assertEquals(type, item.getType());
assertEquals(parentUUID, item.getParentUUID());
}
use of org.kie.workbench.common.dmn.client.docks.navigator.DecisionNavigatorItem in project kie-wb-common by kiegroup.
the class DecisionNavigatorTreePresenterTest method testListIndex.
@Test
public void testListIndex() {
final DecisionNavigatorItem item1 = mock(DecisionNavigatorItem.class);
final DecisionNavigatorItem item2 = mock(DecisionNavigatorItem.class);
final List<DecisionNavigatorItem> items = Arrays.asList(item1, item2);
presenter.index(items);
verify(presenter).index(item1);
verify(presenter).index(item2);
}
Aggregations