/** * Tests the formatting as a tree, with control on the indentation. */ @Test public void testTreeFormat() { final DefaultTreeTable.Node root = new DefaultTreeTable.Node("Node #1"); final DefaultTreeTable.Node branch = new DefaultTreeTable.Node("Node #2"); root.getChildren().add(branch); root.getChildren().add(new DefaultTreeTable.Node("Node #3")); branch.getChildren().add(new DefaultTreeTable.Node("Node #4")); final TreeTableFormat tf = new TreeTableFormat(null, null); tf.setVerticalLinePosition(2); assertMultilinesEquals( "Node #1\n" + " ├─Node #2\n" + " │ └─Node #4\n" + " └─Node #3\n", tf.format(new DefaultTreeTable(root))); }
/** * Tests the parsing of a tree. This method parses and reformats a tree, * and performs its check on the assumption that the tree formatting is * accurate. * * @throws ParseException if the parsing failed. */ @Test @DependsOnMethod("testTreeFormat") public void testTreeParse() throws ParseException { final TreeTableFormat tf = new TreeTableFormat(null, null); tf.setVerticalLinePosition(0); final String text = "Node #1\n" + "├───Node #2\n" + "│ └───Node #4\n" + "└───Node #3\n"; final TreeTable table = tf.parseObject(text); assertMultilinesEquals(text, tf.format(table)); }
tf.setVerticalLinePosition(1); assertMultilinesEquals( "Value #1\n" +
/** * Tests the parsing of a tree table. This method parses and reformats a tree table, * and performs its check on the assumption that the tree table formatting is accurate. * * @throws ParseException if the parsing failed. */ @Test @DependsOnMethod("testTreeTableFormat") public void testTreeTableParse() throws ParseException { final TableColumn<Integer> valueA = new TableColumn<>(Integer.class, "value #1"); final TableColumn<String> valueB = new TableColumn<>(String .class, "value #2"); final TreeTableFormat tf = new TreeTableFormat(null, null); tf.setColumns(NAME, valueA, valueB); tf.setVerticalLinePosition(1); final String text = "Node #1………………………… 10…… Value #1B\n" + " ├──Node #2……………… 20\n" + " │ └──Node #4…… 40…… Value #4B\n" + " └──Node #3……………… ………… Value #3B\n"; final TreeTable table = tf.parseObject(text); assertMultilinesEquals(text, tf.format(table)); }
tf.setVerticalLinePosition(1); assertMultilinesEquals( "Node #1………………………… 10…… Value #1B\n" +
assertEquals("?……[…] ", tf.getColumnSeparatorPattern()); tf.setColumns(NAME, valueA, valueB); tf.setVerticalLinePosition(1);