コード例 #1
0
  public void testGetContainerRowKey() throws IntrospectionException {
    TreeModel model = createModel();
    int[] testPath1 = {0, 1};
    _followPath(model, testPath1);
    Object path1 = model.getRowKey();

    int[] testPath2 = {0, 1, 1};
    _followPath(model, testPath2);
    Object path2 = model.getRowKey();

    model.setRowKey(null);
    assertEquals("getContainerRowKey(key)", path1, model.getContainerRowKey(path2));
  }
コード例 #2
0
  public void testGetSetRowKey() throws IntrospectionException {
    TreeModel model = createModel();

    Bean root = _ROOTS.get(0);
    Bean sub = root.getKids().get(1);

    int[] testPath = {0, 1};
    _followPath(model, testPath);
    Object key = model.getRowKey();
    model.setRowKey(null);
    _testTree(model, _ROOTS);

    model.setRowKey(key);
    _testTree(model, sub);
  }
コード例 #3
0
  /**
   * Tests getRowData, isContainer, enterContainer, exitContainer, getRowCount, setRowIndex,
   * getRowIndex, getContainerRowKey
   */
  private void _testTree(TreeModel model, Bean bean) {
    assertEquals("rowData", bean, model.getRowData());

    List<Bean> kids = bean.getKids();
    boolean hasChildren = (kids != null);
    assertEquals("isContainer", hasChildren, model.isContainer());

    if (hasChildren) {
      Object parentKey = model.getRowKey();
      model.enterContainer();
      assertEquals("getContainerRowKey", parentKey, model.getContainerRowKey());

      _testTree(model, kids);
      model.exitContainer();
      assertEquals("rowData after exit", bean, model.getRowData());
      assertEquals("isContainer after exit", hasChildren, model.isContainer());
    }
  }