@@ -0,0 +1,2144 @@
+package org.flymine.sql.precompute;%0A%0Aimport junit.framework.*;%0Aimport org.flymine.sql.query.*;%0A%0Apublic class BestQueryStorerTest extends TestCase%0A%7B%0A    private Query q1, q2;%0A%0A    public BestQueryStorerTest(String arg1) %7B%0A        super(arg1);%0A    %7D%0A%0A    public void setUp() %7B%0A        q1 = new Query();%0A        Table t = new Table(%22mytable%22);%0A        Constant c = new Constant(%221%22);%0A        Field f = new Field(%22a%22, t);%0A        SelectValue sv = new SelectValue(f, null);%0A        q1.addFrom(t);%0A        q1.addSelect(sv);%0A        q1.addWhere(new Constraint(f, Constraint.EQ, c));%0A%0A        q2 = new Query();%0A        Table t1 = new Table(%22mytable%22);%0A        Table t2 = new Table(%22mytable%22);%0A        Field f1 = new Field(%22a%22, t1);%0A        Field f2 = new Field(%22b%22, t2);%0A        sv = new SelectValue(f1, null);%0A        q2.addFrom(t1);%0A        q2.addFrom(t2);%0A        q2.addSelect(sv);%0A        q2.addWhere(new Constraint(f1, Constraint.EQ, c));%0A        q2.addWhere(new Constraint(f2, Constraint.EQ, c));%0A    %7D%0A%0A    public void testNoQueriesForNoneAdded() throws Exception %7B%0A        BestQueryStorer bq = new BestQueryStorer();%0A        assertEquals(0, bq.getQueries().size());%0A    %7D%0A%0A    public void testAddNull() throws Exception %7B%0A        BestQueryStorer bq = new BestQueryStorer();%0A        try %7B%0A            bq.add(null);%0A            fail(%22Expected: NullPointerException%22);%0A        %7D%0A        catch (NullPointerException e) %7B%0A        %7D%0A    %7D%0A%0A    public void testReturnFirst() throws Exception %7B%0A        BestQueryStorer bq = new BestQueryStorer();%0A        bq.add(q1);%0A        assertTrue(bq.getQueries().contains(q1));%0A    %7D%0A%0A    public void testReturnBest() throws Exception %7B%0A        BestQueryStorer bq = new BestQueryStorer();%0A        bq.add(q1);%0A        bq.add(q2);%0A        assertEquals(2, bq.getQueries().size());%0A        assertTrue(bq.getQueries().contains(q1));%0A        assertTrue(bq.getQueries().contains(q2));%0A%0A        bq = new BestQueryStorer();%0A        bq.add(q2);%0A        bq.add(q1);%0A        assertEquals(2, bq.getQueries().size());%0A        assertTrue(bq.getQueries().contains(q1));%0A        assertTrue(bq.getQueries().contains(q2));%0A    %7D%0A%0A%7D%0A

Test for BestQueryStorer