assertEquals("6: search should have returned no results", 0, ids.size());
assertFalse("6: contains message 1", ids.contains(new Integer(mMessage1.getId()))); assertFalse("6: contains message 2", ids.contains(new Integer(mMessage2.getId()))); assertFalse("6: contains message 3", ids.contains(new Integer(mMessage3.getId()))); assertFalse("6: contains message 4", ids.contains(new Integer(mMessage4.getId())));
    public void testFlagSearch()    throws Exception {        ZimbraLog.test.debug("testFlagSearch()");        // Look up flags        Flag replied = mMbox.getFlagById(Flag.ID_FLAG_REPLIED);        Flag flagged = mMbox.getFlagById(Flag.ID_FLAG_FLAGGED);        Flag forwarded = mMbox.getFlagById(Flag.ID_FLAG_FORWARDED);        // First assign T1 to the entire conversation, then remove it from M2-M4        mMbox.alterTag(null, mConv.getId(), mConv.getType(), replied.getId(), true);        mMbox.alterTag(null, mMessage2.getId(), mMessage2.getType(), replied.getId(), false);        mMbox.alterTag(null, mMessage3.getId(), mMessage3.getType(), replied.getId(), false);        mMbox.alterTag(null, mMessage4.getId(), mMessage4.getType(), replied.getId(), false);                // Assign tags:        //   M1: replied        //   M2: flagged        //   M3: flagged, forwarded        //   M4: no flags        mMbox.alterTag(null, mMessage2.getId(), mMessage2.getType(), flagged.getId(), true);        mMbox.alterTag(null, mMessage3.getId(), mMessage3.getType(), flagged.getId(), true);        mMbox.alterTag(null, mMessage3.getId(), mMessage3.getType(), forwarded.getId(), true);        refresh();                // is:replied -> (M1,...)        Set ids = search("is:replied", MailItem.TYPE_MESSAGE);        assertTrue("1: no message 1", ids.contains(new Integer(mMessage1.getId())));        assertFalse("1: message 2 found", ids.contains(new Integer(mMessage2.getId())));        assertFalse("1: message 3 found", ids.contains(new Integer(mMessage3.getId())));        assertFalse("1: message 4 found", ids.contains(new Integer(mMessage4.getId())));                // is:replied is:flagged -> (M1,M2,...)        ids = search("is:replied is:flagged", MailItem.TYPE_MESSAGE);        assertTrue("2: no message 1", ids.contains(new Integer(mMessage1.getId())));        assertTrue("2: no message 2", ids.contains(new Integer(mMessage2.getId())));        assertTrue("2: no message 3", ids.contains(new Integer(mMessage3.getId())));        assertFalse("2: message 4 found", ids.contains(new Integer(mMessage4.getId())));                        // not is:replied -> (M2,M3,M4,...)        ids = search("not is:replied", MailItem.TYPE_MESSAGE);        assertFalse("3: message 1 found", ids.contains(new Integer(mMessage1.getId())));        assertTrue("3: no message 2", ids.contains(new Integer(mMessage2.getId())));        assertTrue("3: no message 3", ids.contains(new Integer(mMessage3.getId())));        assertTrue("3: no message 4", ids.contains(new Integer(mMessage4.getId())));                // not is:flagged not is:forwarded -> (M1,M4,...)        ids = search("not is:flagged not is:forwarded", MailItem.TYPE_MESSAGE);        assertTrue("4: no message 1", ids.contains(new Integer(mMessage1.getId())));        assertFalse("4: contains message 2", ids.contains(new Integer(mMessage2.getId())));        assertFalse("4: contains message 3", ids.contains(new Integer(mMessage3.getId())));        assertTrue("4: no message 4", ids.contains(new Integer(mMessage4.getId())));                // is:flagged not is:forwarded -> (M2)        ids = search("is:flagged not is:forwarded", MailItem.TYPE_MESSAGE);        assertFalse("5: message 1 found", ids.contains(new Integer(mMessage1.getId())));        assertTrue("5: no message 2", ids.contains(new Integer(mMessage2.getId())));        assertFalse("5: contains message 3", ids.contains(new Integer(mMessage3.getId())));        assertFalse("5: contains message 4", ids.contains(new Integer(mMessage4.getId())));                // tag:\Deleted -> ()        ids = search("tag:\\Deleted", MailItem.TYPE_MESSAGE);        assertEquals("6: search should have returned no results", 0, ids.size());    }