MailProvider { public Observable<List<Mail>> getMailsOfLabel(final String l) { return getFilteredMailList(new Func1<Mail, Boolean>() { @Override public Boolean call(Mail mail) { return mail.getLabel().equals(l); } }); } MailProvider(AccountManager accountManager, MailGenerator genrator); Observable<List<Label>> getLabels(); Observable<Mail> getMail(final int id); Observable<List<Mail>> getMailsOfLabel(final String l); Observable<Mail> markAsRead(final Mail mail, final boolean read); Observable<Mail> starMail(int mailId, final boolean star); Observable<Mail> addMailWithDelay(final Mail mail); Observable<Mail> addMail(final Mail mail); Observable<Mail> setLabel(Mail mail, final String label); Observable<Mail> setLabel(int mailId, final String label); Observable<List<Mail>> searchForMails(String query, final int limit); Observable<List<Mail>> searchForOlderMails(final String query, final Date olderAs,
      final int limit); Observable<List<Mail>> getMailsSentBy(final int personId); Observable<MailStatistics> getStatistics(); static int DELAY; static int authExceptionEach; static int errorEach; static final Label INBOX_LABEL; }
@Test public void getMailsByLabel() { String[] labels = { Label.INBOX, Label.SENT, Label.TRASH, Label.SPAM }; for (String label : labels) { final AtomicBoolean sucessful = new AtomicBoolean(false); mailProvider.getMailsOfLabel(label).subscribe(new Subscriber<List<Mail>>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { e.printStackTrace(); Assert.fail("excption thrown" + e.getMessage()); } @Override public void onNext(List<Mail> mails) { Assert.assertEquals(TestMailGenerator.MAILS_PER_LABEL, mails.size()); sucessful.set(true); } }); Assert.assertTrue(sucessful.get()); } }