protected void compareTreeItem(Treeitem item) throws EmulationException { Treerow row = null; for (Object obj : item.getChildren()) { if (obj instanceof Treerow) { row = (Treerow) obj; break; } } int counter = 0; for (Object obj : row.getChildren()) { if (obj instanceof Treecell) { if (counter >= _values.length) { fail( "Tree contains more items than specified in file. File: " + _reader.getFileName() + " Row: " + _row); } assertEquals( "Tree item doesn't match. File: " + _reader.getFileName() + " Row: " + _row, _values[counter++], TreeUtil.getColumnText((Treecell) obj)); } } if (counter < _values.length) { fail( "Tree contains less items than specified in file. File: " + _reader.getFileName() + " Row: " + _row); } compareTreeChildren(item); }
public static DumpNode load(String dumpSource, boolean loadHeader) throws FileNotFoundException, IOException, EmulationException { DumpNodeReader reader = new DumpNodeReader(); reader.load(dumpSource, loadHeader); DumpNode ret = new DumpNode(null, 0, 0, reader); load(ret, reader); return ret; }
protected static void load(DumpNode parent, DumpNodeReader reader) { while (reader.hasNext()) { DumpNode child = reader.next(); if (parent._level == child._level - 1) { parent._children.add(child); } else if (parent._level == child._level - 2) { reader.goBack(); load(parent._children.get(parent._children.size() - 1), reader); } else { reader.goBack(); return; } } }
public void compareTree(Tree tree) throws EmulationException { List<Treeitem> children = new ArrayList<Treeitem>(); if (tree.getTreechildren() != null && tree.getTreechildren().getChildren() != null) { children = tree.getTreechildren().getChildren(); } // assertEquals("Wrong tree items count. Dump file:" + _reader.getFileName(), // _reader.rootNodesSize(), tree.getItems().size()); assertEquals("Wrong tree rows count. Dump file:" + _reader.getFileName(), 0, tree.getRows()); assertEquals( "Wrong root children count. Dump file:" + _reader.getFileName(), _children.size(), children.size()); for (int i = 0; i < _children.size(); i++) { _children.get(i).compareTreeItem(children.get(i)); } }
protected void compareTreeChildren(Treeitem item) throws EmulationException { List<Treeitem> children = new ArrayList<Treeitem>(); if (!item.isOpen()) { new org.tsc.emulation.components.Treeitem(item).open(); } if (item.getTreechildren() != null && item.getTreechildren().getChildren() != null) { children = item.getTreechildren().getChildren(); } assertEquals( "Wrong children count at row " + _row + ". File " + _reader.getFileName(), _children.size(), children.size()); for (int i = 0; i < _children.size(); i++) { _children.get(i).compareTreeItem(children.get(i)); } }