Example #1
0
  /** @throws Exception */
  @Test
  public void sortInMemoryForEnumWhenDescending() throws Exception {
    List<Hoge> list = new ArrayList<Hoge>();
    Hoge hoge = new Hoge();
    hoge.setMyEnum(SortDirection.ASCENDING);
    list.add(hoge);
    hoge = new Hoge();
    hoge.setMyEnum(SortDirection.DESCENDING);
    list.add(hoge);

    List<Hoge> sorted =
        DatastoreUtil.sortInMemory(list, Arrays.asList((InMemorySortCriterion) meta.myEnum.desc));
    assertThat(sorted.size(), is(2));
    assertThat(sorted.get(0).getMyEnum(), is(SortDirection.DESCENDING));
    assertThat(sorted.get(1).getMyEnum(), is(SortDirection.ASCENDING));
  }
Example #2
0
  /** @throws Exception */
  @Test
  public void filterInMemoryForEnum() throws Exception {
    List<Hoge> list = new ArrayList<Hoge>();
    Hoge hoge = new Hoge();
    hoge.setMyEnum(SortDirection.ASCENDING);
    list.add(hoge);
    hoge = new Hoge();
    hoge.setMyEnum(SortDirection.DESCENDING);
    list.add(hoge);

    List<Hoge> filtered =
        DatastoreUtil.filterInMemory(
            list, Arrays.asList(meta.myEnum.equal(SortDirection.ASCENDING)));
    assertThat(filtered.size(), is(1));
    assertThat(filtered.get(0).getMyEnum(), is(SortDirection.ASCENDING));
  }