Ejemplo n.º 1
0
  @Test
  public void testGreenmailServerImplementUIDPLUS() throws Exception {
    Email sentEmail = testUtils.sendEmailToInbox();

    testUtils.createFolders(DRAFT);

    long testErrorUidValue = -1;
    long movedEmailUid = testErrorUidValue;
    try {
      movedEmailUid =
          mailboxService.moveItem(
              udr, testUtils.mailboxPath(INBOX), testUtils.mailboxPath(DRAFT), sentEmail.getUid());
    } catch (Exception nonExpectedException) {
      Assert.fail("Greenmail should implement UIDPLUS, so no exception is expected");
    }

    Set<Email> movedEmails = testUtils.mailboxEmails(DRAFT);
    Assertions.assertThat(movedEmails).hasSize(1);
    Email movedEmail = Iterables.getOnlyElement(movedEmails);
    Assertions.assertThat(movedEmail.getUid())
        .isNotEqualTo(testErrorUidValue)
        .isEqualTo(movedEmailUid);
    Assertions.assertThat(movedEmail.isAnswered()).isEqualTo(sentEmail.isAnswered());
    Assertions.assertThat(movedEmail.isRead()).isEqualTo(sentEmail.isRead());
  }
Ejemplo n.º 2
0
 private void testEmailWithEmbeddedImage(SendEmail sendEmail) throws IOException {
   Message mimeMessage = sendEmail.getMimeMessage();
   Assertions.assertThat(mimeMessage.getMimeType()).isEqualTo("multipart/alternative");
   Body mainBody = mimeMessage.getBody();
   Assertions.assertThat(mainBody).isInstanceOf(Multipart.class);
   Multipart multipart = (Multipart) mainBody;
   Assertions.assertThat(multipart.getCount()).isEqualTo(2);
   Entity textPlain = multipart.getBodyParts().get(0);
   Entity secondPart = multipart.getBodyParts().get(1);
   Assertions.assertThat(textPlain.getMimeType()).isEqualTo("text/plain");
   Assertions.assertThat(secondPart.getMimeType()).isEqualTo("multipart/relative");
   Multipart multipartRelative = (Multipart) secondPart.getBody();
   Assertions.assertThat(multipartRelative.getCount()).isEqualTo(2);
   Entity htmlPart = multipartRelative.getBodyParts().get(0);
   Entity imagePart = multipartRelative.getBodyParts().get(1);
   Assertions.assertThat(htmlPart.getMimeType()).isEqualTo("text/html");
   Assertions.assertThat(imagePart.getMimeType()).isEqualTo("image/png");
   TextBody htmlTextBody = (TextBody) htmlPart.getBody();
   String htmlText = Joiner.on('\n').join(CharStreams.readLines(htmlTextBody.getReader()));
   Assertions.assertThat(htmlText)
       .contains("Galaxy S II")
       .contains("img src=\"cid:[email protected]\"");
   String contentId = imagePart.getHeader().getFields("content-id").get(0).getBody();
   Assertions.assertThat(contentId).isEqualTo("*****@*****.**");
 }
Ejemplo n.º 3
0
  @Test
  public void testMoveFromAndToSubMailbox() throws Exception {
    Email sentEmail = testUtils.sendEmailToInbox();

    String fromSubMailbox = "ANYMAILBOX.SUBMAILBOX";
    String toOtherSubMailbox = "ANYMAILBOX.SUBMAILBOX.SUBSUBMAILBOX";
    testUtils.createFolders(fromSubMailbox, toOtherSubMailbox);

    mailboxService.moveItem(
        udr,
        testUtils.mailboxPath(INBOX),
        testUtils.mailboxPath(fromSubMailbox),
        sentEmail.getUid());
    Email emailInSubMailbox = testUtils.emailInMailbox(fromSubMailbox);

    mailboxService.moveItem(
        udr,
        testUtils.mailboxPath(fromSubMailbox),
        testUtils.mailboxPath(toOtherSubMailbox),
        emailInSubMailbox.getUid());

    Set<Email> fromEmails = testUtils.mailboxEmails(fromSubMailbox);
    Set<Email> movedEmails = testUtils.mailboxEmails(toOtherSubMailbox);
    Assertions.assertThat(fromEmails).isEmpty();
    Assertions.assertThat(movedEmails).hasSize(1);
    Email movedEmail = Iterables.getOnlyElement(movedEmails);
    Assertions.assertThat(movedEmail.isAnswered()).isEqualTo(sentEmail.isAnswered());
    Assertions.assertThat(movedEmail.isRead()).isEqualTo(sentEmail.isRead());
  }
  @Test
  public void testWithPermissionsFromGroupFromGroup() {
    // Given a new user without permissions nor Groups
    Permission p1 = new Permission("permission1");
    Permission p2 = new Permission("permission2");
    Permission p3 = new Permission("permission3");

    User u = new User();
    Group g1 = new Group();
    u.getGroups().add(g1);
    Group g2 = new Group();
    g1.getGroups().add(g2);

    List<Permission> lp = u.getPermissions();
    lp.add(p1);

    lp = g1.getPermissions();
    lp.add(p2);

    lp = g2.getPermissions();
    lp.add(p3);

    // When we retrieve InheritedPermission
    lp = PermissionsOwnerTools.getInheritedPermission(u);

    // There is no permissions
    Assertions.assertThat(lp.size() == 3).isTrue();
    Assertions.assertThat(lp.contains(p1)).isTrue();
    Assertions.assertThat(lp.contains(p2)).isTrue();
    Assertions.assertThat(lp.contains(p3)).isTrue();
  }
 public StringAssert asString() {
   Assertions.assertThat(actual.getValue())
       .overridingErrorMessage(
           "Unable to convert processInstance processVariable '%s' to an instance of class '%s'",
           actual.getName(), String.class)
       .isInstanceOf(String.class);
   return Assertions.assertThat((String) actual.getValue());
 }
 @Test
 public void testCreateResource() {
   Sample r = new Sample("toto");
   Response response = this.request("service-based").xmlPost(r);
   r = (Sample) response.resource(r.getClass());
   Assertions.assertThat(r).isNotNull();
   Assertions.assertThat(r.getName()).isEqualTo("toto");
 }
 @Test(expectedExceptions = {NotImplementedClientException.class})
 public void testFindAllResourcesUnpaginated() {
   this.request("service-based").jsonPost(new Sample("toto"));
   this.request("service-based").jsonPost(new Sample("toto"));
   Response r = this.request("service-based").setQueryParameter("page", "no").getXml();
   Assertions.assertThat(r).isNotNull();
   Assertions.assertThat(r.getStatus()).isEqualTo(Http.NOT_IMPLEMENTED);
 }
 @Test
 public void testPhotoListManagerDidFinish_withNoPhotos_ShowsToast() {
   List emptyFlickrPhotoList = new ArrayList<FlickrPhoto>();
   subject.photoListManagerDidFinish(emptyFlickrPhotoList);
   Toast actualToast = ShadowToast.getLatestToast();
   Assertions.assertThat(actualToast).isNotNull();
   String actualToastText = ShadowToast.getTextOfLatestToast();
   Assertions.assertThat(actualToastText).isEqualTo("Flickr api response malformed");
 }
 @Test
 public void testFullListJson() {
   List<Book> books = this.request("book").jsonGet().resource(new TypeReference<List<Book>>() {});
   Assertions.assertThat(books).isNotNull();
   Assertions.assertThat(books.size()).isEqualTo(2);
   Assertions.assertThat(books)
       .contains(new Book("Effective Java", "Joshua Bloch", "Essential", 1));
   Assertions.assertThat(books)
       .contains(new Book("Breaking Dawn", "Stephanie Myers", "Just terrible", 2));
 }
Ejemplo n.º 10
0
 @Test
 public void testMailHasNoFrom() throws MimeException, IOException {
   Message message = loadMimeMessage("plainTextNoFrom.eml");
   String defaultFrom = "*****@*****.**";
   SendEmail sendEmail = new SendEmail(defaultFrom, message);
   Assertions.assertThat(sendEmail.getFrom()).isEqualTo(defaultFrom);
   Assertions.assertThat(sendEmail.getMimeMessage().getFrom()).isEqualTo(from(defaultFrom));
   Assertions.assertThat(sendEmail.getCc()).isEmpty();
   Assertions.assertThat(sendEmail.getCci()).isEmpty();
 }
 @Test
 public void testUpdate() {
   Sample r1 = new Sample("toto");
   r1 = this.request("service-based").xmlPost(r1).resource(r1.getClass());
   Sample r2 = new Sample(r1);
   r2.setName("titi");
   r2 = this.request("service-based/" + r1.getId()).xmlPut(r2).resource(r2.getClass());
   Assertions.assertThat(r1).isNotEqualTo(r2);
   Assertions.assertThat(r1.getName()).contains("toto");
   Assertions.assertThat(r2.getName()).contains("titi");
 }
  @Test(expectedExceptions = {NotFoundClientException.class})
  public void testDeleteResource() {
    Sample r = new Sample("toto");
    r = this.request("service-based").xmlPost(r).resource(r.getClass());
    Assertions.assertThat(r).isNotNull();

    Response response = this.request("service-based/" + r.getId()).delete();
    Assertions.assertThat(response.getStatus()).isEqualTo(Http.NO_CONTENT);

    this.request("service-based/" + r.getId()).get();
  }
 @Test
 public void testSummaryPageableListJson() {
   PageResponse<Book> books =
       this.request("book/summaries")
           .setQueryParameter("page", "1")
           .jsonGet()
           .resource(new TypeReference<PageResponse<Book>>() {});
   Assertions.assertThat(books).isNotNull();
   Assertions.assertThat(books.getContent().size()).isEqualTo(2);
   Assertions.assertThat(books.getContent()).contains(new Book(null, "Joshua Bloch", null, 1));
   Assertions.assertThat(books.getContent()).contains(new Book(null, "Stephanie Myers", null, 2));
 }
Ejemplo n.º 14
0
  @Test
  public void testMoveToInbox() throws Exception {
    Email sentEmail = testUtils.sendEmailToInbox();

    mailboxService.moveItem(
        udr, testUtils.mailboxPath(INBOX), testUtils.mailboxPath(INBOX), sentEmail.getUid());

    Set<Email> inboxEmails = testUtils.mailboxEmails(INBOX);
    Assertions.assertThat(inboxEmails).hasSize(1);
    Email movedEmail = Iterables.getOnlyElement(inboxEmails);
    Assertions.assertThat(movedEmail.isAnswered()).isEqualTo(sentEmail.isAnswered());
    Assertions.assertThat(movedEmail.isRead()).isEqualTo(sentEmail.isRead());
  }
Ejemplo n.º 15
0
  @Test
  public void testICalendarConverterDailyEventWithIntervalAndWorkingDays()
      throws IOException, ParserException {
    ICalendar icalendar = icalendar("recur_event_freq-daily_interval_workingdays.zimbra.ics");
    MSMeetingRequest msMeetingRequest = icalendarConverter.convertToMSMeetingRequest(icalendar);

    Assertions.assertThat(msMeetingRequest)
        .isEqualTo(
            new MSMeetingRequest.MsMeetingRequestBuilder()
                .startTime(new DateTime("2012-04-24T07:00:00").toDate())
                .dtStamp(new DateTime("2012-04-23T15:04:23Z").toDate())
                .endTime(new DateTime("2012-04-24T07:15:00").toDate())
                .organizer("*****@*****.**")
                .location("Lyon")
                .instanceType(MSMeetingRequestInstanceType.MASTER_RECURRING)
                .timeZone(TimeZone.getTimeZone("Europe/Brussels"))
                .msEventExtId(new MSEventExtId("f28d13af-a5b5-44cf-83c9-3e76aa743179"))
                .reponseRequested(true)
                .recurrenceId(new DateTime("2012-04-24T07:00:00").toDate())
                .recurrences(
                    Lists.newArrayList(
                        MSMeetingRequestRecurrence.builder()
                            .interval(1)
                            .type(MSMeetingRequestRecurrenceType.DAILY)
                            .dayOfWeek(
                                Lists.newArrayList(
                                    MSMeetingRequestRecurrenceDayOfWeek.MONDAY,
                                    MSMeetingRequestRecurrenceDayOfWeek.TUESDAY,
                                    MSMeetingRequestRecurrenceDayOfWeek.WEDNESDAY,
                                    MSMeetingRequestRecurrenceDayOfWeek.THURSDAY,
                                    MSMeetingRequestRecurrenceDayOfWeek.FRIDAY))
                            .build()))
                .build());
  }
Ejemplo n.º 16
0
  @Test
  public void testICalendarConverterYearlyEventByMonthDayAndByMonth()
      throws IOException, ParserException {
    ICalendar icalendar =
        icalendar("recur_event_freq-yearly_interval_bymonthday_bymonth.zimbra.ics");
    MSMeetingRequest msMeetingRequest = icalendarConverter.convertToMSMeetingRequest(icalendar);

    Assertions.assertThat(msMeetingRequest)
        .isEqualTo(
            new MSMeetingRequest.MsMeetingRequestBuilder()
                .startTime(new DateTime("2012-07-10T07:00:00").toDate())
                .dtStamp(new DateTime("2012-04-24T08:08:09Z").toDate())
                .endTime(new DateTime("2012-07-10T07:15:00").toDate())
                .organizer("*****@*****.**")
                .location("Lyon")
                .instanceType(MSMeetingRequestInstanceType.MASTER_RECURRING)
                .timeZone(TimeZone.getTimeZone("Europe/Brussels"))
                .msEventExtId(new MSEventExtId("f28d13af-a5b5-44cf-83c9-3e76aa743179"))
                .reponseRequested(true)
                .recurrenceId(new DateTime("2012-07-10T07:00:00").toDate())
                .recurrences(
                    Lists.newArrayList(
                        MSMeetingRequestRecurrence.builder()
                            .interval(1)
                            .type(MSMeetingRequestRecurrenceType.YEARLY)
                            .dayOfMonth(10)
                            .monthOfYear(7)
                            .build()))
                .build());
  }
Ejemplo n.º 17
0
 public MenuAssert hasNoVisibleItems() {
   isNotNull();
   Assertions.assertThat(actual.hasVisibleItems()) //
       .overridingErrorMessage("Expected to have no visible items but had visible items.") //
       .isFalse();
   return this;
 }
Ejemplo n.º 18
0
  @Test
  public void testICalendarConverterMonthlyEventWithByDayNumber()
      throws IOException, ParserException {
    ICalendar icalendar = icalendar("recur_event_freq-weekly_interval_byday-1.zimbra.ics");
    MSMeetingRequest msMeetingRequest = icalendarConverter.convertToMSMeetingRequest(icalendar);

    Assertions.assertThat(msMeetingRequest)
        .isEqualTo(
            new MSMeetingRequest.MsMeetingRequestBuilder()
                .startTime(new DateTime("2012-07-10T07:00:00").toDate())
                .dtStamp(new DateTime("2012-04-24T07:57:07Z").toDate())
                .endTime(new DateTime("2012-07-10T07:15:00").toDate())
                .organizer("*****@*****.**")
                .location("Lyon")
                .instanceType(MSMeetingRequestInstanceType.MASTER_RECURRING)
                .timeZone(TimeZone.getTimeZone("Europe/Brussels"))
                .msEventExtId(new MSEventExtId("f28d13af-a5b5-44cf-83c9-3e76aa743179"))
                .reponseRequested(true)
                .recurrenceId(new DateTime("2012-07-10T07:00:00").toDate())
                .recurrences(
                    Lists.newArrayList(
                        MSMeetingRequestRecurrence.builder()
                            .interval(1)
                            .type(MSMeetingRequestRecurrenceType.MONTHLY_NTH_DAY)
                            .dayOfMonth(2)
                            .dayOfWeek(
                                Lists.newArrayList(MSMeetingRequestRecurrenceDayOfWeek.TUESDAY))
                            .build()))
                .build());
  }
 @Test
 public void testFullXml() {
   Book book = this.request("book/1").xmlGet().resource(Book.class);
   Assertions.assertThat(book)
       .isNotNull()
       .isEqualTo(new Book("Effective Java", "Joshua Bloch", "Essential", 1));
 }
Ejemplo n.º 20
0
 public ViewGroupAssert hasTextViewWithCompoundDrawableId(int resId) {
   isNotNull();
   boolean found = walkTree(actual, new TextViewCompoundDrawableCondition(resId));
   Assertions.assertThat(found)
       .overridingErrorMessage("Expected ViewGroup to have a TextView with resId <%d>", resId)
       .isTrue();
   return this;
 }
  @Test
  public void testFindResource() {
    Sample r = new Sample("toto");
    r = (Sample) this.request("service-based").xmlPost(r).resource(r.getClass());

    Response response = this.request("service-based/" + r.getId()).get();
    Assertions.assertThat(response.getStatus()).isEqualTo(Http.OK);
  }
Ejemplo n.º 22
0
 public MenuAssert hasSize(int size) {
   isNotNull();
   int actualSize = actual.size();
   Assertions.assertThat(actualSize) //
       .overridingErrorMessage("Expected size <%s> but was <%s>.", size, actualSize) //
       .isEqualTo(size);
   return this;
 }
Ejemplo n.º 23
0
 public ViewGroupAssert hasTextViewWithText(String text) {
   isNotNull();
   boolean found = walkTree(actual, new TextMatcher(text));
   Assertions.assertThat(found)
       .overridingErrorMessage("Expected ViewGroup to have a TextView with text <%s>", text)
       .isTrue();
   return this;
 }
 @Test
 public void testOnCreate_setsUpProgressBar() {
   ANDROID.assertThat(subject).isNotNull();
   ProgressBar progressBarSpinner = subject.getProgressBarSpinner();
   ANDROID.assertThat(progressBarSpinner).isNotNull();
   int visibility = progressBarSpinner.getVisibility();
   Assertions.assertThat(visibility).isEqualTo(View.VISIBLE);
 }
  @Test
  public void setDetailsShouldWorkIfAllFieldsAreSet() throws BankAccountException {
    // given an account without detail
    final String iban =
        this.createAccountService.create(this.accountHelper.getEmptyAccount(), this.accountRule);

    // when
    this.accountDetailsService.update(
        iban, this.accountHelper.getDetails(this.detailsBuilder, this.accountDetailsRule));

    // then
    final AccountDetails details = this.accountDetailsService.view(iban);
    Assertions.assertThat(this.findAccountService.find(iban)).isEqualTo(iban);
    Assertions.assertThat(details).isNotNull();
    Assertions.assertThat(details.getSwiftCode()).isNotNull();
    Assertions.assertThat(this.accountDetailsRule.hasCorrectSwiftCode(details.getSwiftCode()))
        .isTrue();
  }
  public ProcessVariableAssert exists() {
    isNotNull();

    Assertions.assertThat(actual.getValue())
        .overridingErrorMessage(
            "Unable to find processInstance processVariable '%s'", actual.getName())
        .isNotNull();

    return this;
  }
Ejemplo n.º 27
0
  @Test
  public void reminderZero() {
    ICalendarEvent iCalendarEvent = EasyMock.createMock(ICalendarEvent.class);
    EasyMock.expect(iCalendarEvent.firstAlarmInSeconds()).andReturn(0l).once();
    EasyMock.replay(iCalendarEvent);

    Long reminder = icalendarConverter.reminder(iCalendarEvent);

    EasyMock.verify(iCalendarEvent);
    Assertions.assertThat(reminder).isEqualTo(0);
  }
Ejemplo n.º 28
0
  @Test
  public void testRetrieveMonthForNullTimeZone() {
    VEvent vEvent = new VEvent(new Date(DateUtils.date("2013-01-01T01:00:00+00")), "event summary");
    TimeZone iCalendarTimeZone = null;

    Integer retreiveMonthFromStartTime =
        icalendarConverter.retrieveMonthFromStartTime(
            new ICalendarEvent(vEvent), iCalendarTimeZone);

    Assertions.assertThat(retreiveMonthFromStartTime).isEqualTo(1);
  }
Ejemplo n.º 29
0
  @Test
  public void reminderAfterStartDateGetsNullValue() {
    ICalendarEvent iCalendarEvent = EasyMock.createMock(ICalendarEvent.class);
    EasyMock.expect(iCalendarEvent.firstAlarmInSeconds()).andReturn(600l).once();
    EasyMock.replay(iCalendarEvent);

    Long reminder = icalendarConverter.reminder(iCalendarEvent);

    EasyMock.verify(iCalendarEvent);
    Assertions.assertThat(reminder).isNull();
  }
Ejemplo n.º 30
0
  @Test
  public void testICalendarConverterYearlyWithoutBYMONTHGetTheStartDateOne()
      throws IOException, ParserException {
    ICalendar icalendar = icalendar("recur_event_freq-yearly_bymonth_unset.ics");

    MSMeetingRequest msMeetingRequest = icalendarConverter.convertToMSMeetingRequest(icalendar);

    int julyMonthIndex = 7;
    MSMeetingRequestRecurrence recurrence =
        Iterables.getOnlyElement(msMeetingRequest.getRecurrences());
    Assertions.assertThat(recurrence.getMonthOfYear()).isEqualTo(julyMonthIndex);
  }