use of org.eclipse.scout.rt.ui.html.UiException in project scout.rt by eclipse.
the class JsonTreeTest method testGetVsOpt.
@Test
public void testGetVsOpt() {
List<ITreeNode> nodes = new ArrayList<ITreeNode>();
nodes.add(new TreeNode());
nodes.add(new TreeNode());
nodes.add(new TreeNode());
ITree tree = createTree(nodes);
JsonTree<ITree> jsonTree = m_uiSession.createJsonAdapter(tree, null);
String node0Id = jsonTree.getOrCreateNodeId(nodes.get(0));
assertNotNull(node0Id);
assertEquals(node0Id, jsonTree.optNodeId(nodes.get(0)));
assertEquals(node0Id, jsonTree.getNodeId(nodes.get(0)));
assertNotNull(jsonTree.optTreeNodeForNodeId(node0Id));
assertNotNull(jsonTree.getTreeNodeForNodeId(node0Id));
String nonExistingNodeId = "bla";
ITreeNode nonExistingTreeNode = new TreeNode();
assertNull(jsonTree.optNodeId(nonExistingTreeNode));
try {
jsonTree.getNodeId(nonExistingTreeNode);
fail("Expected UiException");
} catch (UiException e) {
// ok
}
assertNull(jsonTree.optTreeNodeForNodeId(nonExistingNodeId));
try {
jsonTree.getTreeNodeForNodeId(nonExistingNodeId);
fail("Expected UiException");
} catch (UiException e) {
// ok
}
}
Aggregations