Search in sources :

Example 6 with UiException

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
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) TreeNode(org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeNode) ArrayList(java.util.ArrayList) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) UiException(org.eclipse.scout.rt.ui.html.UiException) Test(org.junit.Test)

Aggregations

UiException (org.eclipse.scout.rt.ui.html.UiException)6 Test (org.junit.Test)3 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)2 JSONObject (org.json.JSONObject)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Method (java.lang.reflect.Method)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)1 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)1 ITableRowFilter (org.eclipse.scout.rt.client.ui.basic.table.ITableRowFilter)1 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)1 TreeEvent (org.eclipse.scout.rt.client.ui.basic.tree.TreeEvent)1 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)1 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)1 DefaultExceptionTranslator (org.eclipse.scout.rt.platform.exception.DefaultExceptionTranslator)1