@Test
public void testDependentMapParentChild() throws Exception {

    List<Table> list = new ArrayList<Table>(4);
    Table t1 = new Table("1");
    Table t2 = new Table("2");
    Table t3 = new Table("3");
    
    t1.addForeignKey(new ForeignKey("2","2"));
    
    list.add(t1);
    list.add(t2);
    list.add(t3);
    
    Map<Integer, Set<Table>> dependencyMap = new HashMap<Integer, Set<Table>>();
    
    list = Database.sortByForeignKeys(list, null, dependencyMap, null);
    
    assertTrue(dependencyMap.get(1).contains(t1));
    assertTrue(dependencyMap.get(1).contains(t2));
    assertTrue(dependencyMap.get(2).contains(t3));
}