private static Sort toSort(String jmapSort) { Preconditions.checkNotNull(jmapSort); List<String> splitToList = Splitter.on(SEPARATOR).splitToList(jmapSort); checkField(splitToList); return new SearchQuery.Sort(getSortClause(splitToList.get(0)), isReverse(splitToList)); }
@Test public void convertToSortsShouldSupportSize() { assertThat(SortConverter.convertToSorts(ImmutableList.of("size desc"))) .containsExactly(new Sort(SortClause.Size, Order.REVERSE)); } }
@Test public void convertToSortsShouldSupportSubject() { assertThat(SortConverter.convertToSorts(ImmutableList.of("subject desc"))) .containsExactly(new Sort(SortClause.BaseSubject, Order.REVERSE)); }
@Test public void convertToSortsShouldSupportTo() { assertThat(SortConverter.convertToSorts(ImmutableList.of("to desc"))) .containsExactly(new Sort(SortClause.MailboxTo, Order.REVERSE)); }
@Test public void convertToSortsShouldSupportDate() { assertThat(SortConverter.convertToSorts(ImmutableList.of("date desc"))) .containsExactly(new Sort(SortClause.SentDate, Order.REVERSE)); }
@Test public void convertToSortsShouldSupportFrom() { assertThat(SortConverter.convertToSorts(ImmutableList.of("from desc"))) .containsExactly(new Sort(SortClause.MailboxFrom, Order.REVERSE)); }
@Test public void convertToSortsShouldSupportAscOrder() { assertThat(SortConverter.convertToSorts(ImmutableList.of("date asc"))) .containsExactly(new Sort(SortClause.SentDate, Order.NATURAL)); }
@Test public void convertToSortsShouldBeDescWhenNoOrderClause() { assertThat(SortConverter.convertToSorts(ImmutableList.of("date"))) .containsExactly(new Sort(SortClause.SentDate, Order.REVERSE)); }
@Test public void convertToSortsShouldSupportId() { assertThat(SortConverter.convertToSorts(ImmutableList.of("id desc"))) .containsExactly(new Sort(SortClause.Id, Order.REVERSE)); }