Inverted Index - java coding needed

profilecompSci
binarytreetest.java

import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; /** * BinaryTreeTest tests to see if Binary Tree functions as expected. * @author tai-lanhirabayashi * */ public class BinaryTreeTest { BinaryTree t; /** * before sets up a base case. */ @Before public void before(){ t= new BinaryTree(null, "head", null); t.setLeftChild(new BinaryTree(null,"second",null)); t.getLeftChild().setLeftChild(new BinaryTree(null, "third", null)); } /** * testSetup makes sure the test has been initialized. */ @Test public void testSetup() { assertEquals(t.getValue(), "head"); } /** * tests the getLeft function */ @Test public void testGetLeft(){ assertEquals(t.getLeftChild().getValue(),"second"); } /** * Tests the get right function */ @Test public void testGetRight(){ assertEquals(t.getRightChild(),null); } /** * Tests the isLeaf function. */ @Test public void isLeaf(){ assertEquals(t.getLeftChild().getLeftChild().isLeaf(),true); } /** * Tests the setLeft function */ @SuppressWarnings("unchecked") @Test public void setLeft(){ t.setLeftChild(new BinaryTree(null,"replace", null)); assertEquals(t.getLeftChild().getValue(),"replace"); } /** * tests the setRightChild function */ @SuppressWarnings("unchecked") @Test public void setRight(){ t.setRightChild(new BinaryTree(null,"right", null)); assertEquals(t.getRightChild().getValue(),"right"); } /** * Tests the setValue function. */ @Test public void setValue(){ t.getLeftChild().setValue("reset"); assertEquals(t.getLeftChild().getValue(),"reset"); } }