### Question:
DecisionTree extends DelegateTree<DecisionTreeNode, DecisionTreeEdge> { public LeafNode decide(final Object obj) { return decide(obj, getRoot()); } DecisionTree(final DecisionTreeNode rootNode); ObservableGraph<DecisionTreeNode, DecisionTreeEdge> getObservableGraph(); LeafNode decide(final Object obj); DecisionTreeNode getEdgeTarget(final DecisionTreeEdge e); DecisionTreeNode getEdgeSource(final DecisionTreeEdge e); DecisionTreeEdge findMatchingEdge(final DecisionTreeNode parent, final Object value); void replaceChild(final DecisionTreeEdge edge, final DecisionTreeNode newChild); boolean equivalent(DecisionTree obj); String getLabel(Category category);  }### Answer:
@Test public void testTrivialDecision() { final DecisionTreeNode root = new LeafNode(); final DecisionTree tree = new DecisionTree(root); assertEquals(root, tree.decide("Tomato")); }
@Test public void testSimpleDecision() { final DecisionTreeNode root = new ChoiceNode(Object.class, "class"); final DecisionTree tree = new DecisionTree(root); tree.addEdge(new TypeEdge(String.class), root, new LeafNode(new Category(d_tc, "str"))); tree.addEdge(new TypeEdge(Integer.class), root, new LeafNode(new Category(d_tc, "int"))); assertEquals("str", tree.decide("Tomato").getName()); assertEquals("int", tree.decide(42).getName()); }
@Test(expected=IllegalStateException.class) public void testUnclassifiable() { final DecisionTreeNode root = new ChoiceNode(Object.class, "class"); final DecisionTree tree = new DecisionTree(root); tree.addEdge(new TypeEdge(String.class), root, new LeafNode(new Category(d_tc, "str"))); tree.addEdge(new TypeEdge(Integer.class), root, new LeafNode(new Category(d_tc, "int"))); tree.decide(3.0); }
@Test public void testMultiLevelDecision() { final DoseUnit unit = DoseUnit.createMilliGramsPerDay(); final DecisionTreeNode root = new ChoiceNode(Object.class, "class"); final DecisionTree tree = new DecisionTree(root); tree.addEdge(new TypeEdge(String.class), root, new LeafNode(new Category(d_tc, "str"))); final ChoiceNode quantityChoice = new ChoiceNode(FixedDose.class, FixedDose.PROPERTY_QUANTITY); tree.addEdge(new TypeEdge(FixedDose.class), root, quantityChoice); tree.addEdge(new RangeEdge(0.0, false, 20.0, false), quantityChoice, new LeafNode(new Category(d_tc, "low"))); tree.addEdge(new RangeEdge(20.0, true, Double.POSITIVE_INFINITY, true), quantityChoice, new LeafNode(new Category(d_tc, "high"))); assertEquals("str", tree.decide("Tomato").getName()); assertEquals("low", tree.decide(new FixedDose(20.0, unit)).getName()); assertEquals("high", tree.decide(new FixedDose(42.0, unit)).getName()); }