@BeforeClass public static void init() throws Exception { MailboxTestUtil.initServer(); Provisioning prov = Provisioning.getInstance(); prov.createAccount("*****@*****.**", "secret", new HashMap<String, Object>()); Provisioning.setInstance(prov); }
@BeforeClass public static void init() throws Exception { MailboxTestUtil .initServer(); // TODO: allow paths to be specified so we can run tests outside of // ZimbraServer MailboxManager.setInstance( new MailboxManager() { @Override protected Mailbox instantiateMailbox(MailboxData data) { // mock the behaviors we need to test in DesktopMailbox return new Mailbox(data) { @Override protected boolean needRedo(OperationContext octxt, RedoableOp recorder) { return false; } }; } // TODO: eventually move this into ZimbraOffline and implement all of the provisioning // needed for real DesktopMailbox // try { // return new DesktopMailbox(data) { // }; // } catch (ServiceException e) { // throw new RuntimeException(e); // } }); Provisioning prov = Provisioning.getInstance(); prov.createAccount("*****@*****.**", "secret", new HashMap<String, Object>()); }
@Test public void existsInContacts() throws Exception { Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID); mbox.createContact( null, new ParsedContact(Collections.singletonMap(ContactConstants.A_email, "*****@*****.**")), Mailbox.ID_FOLDER_CONTACTS, null); MailboxTestUtil.index(mbox); Assert.assertTrue( mbox.index.existsInContacts( ImmutableList.of( new InternetAddress("Test <*****@*****.**>"), new InternetAddress("Test <*****@*****.**>")))); Assert.assertFalse( mbox.index.existsInContacts( ImmutableList.of( new InternetAddress("Test <*****@*****.**>"), new InternetAddress("Test <*****@*****.**>")))); }
@Before public void setUp() throws Exception { MailboxTestUtil.clearData(); }