public void testSortWithRussianCharacters() {
    testRealm.beginTransaction();
    testRealm.clear(AllTypes.class);
    AllTypes at1 = testRealm.createObject(AllTypes.class);
    at1.setColumnString("Санкт-Петербург");
    AllTypes at2 = testRealm.createObject(AllTypes.class);
    at2.setColumnString("Москва");
    AllTypes at3 = testRealm.createObject(AllTypes.class);
    at3.setColumnString("Новороссийск");
    testRealm.commitTransaction();

    RealmResults<AllTypes> result = testRealm.allObjects(AllTypes.class);
    RealmResults<AllTypes> sortedResult = result.where().findAll();
    sortedResult.sort(FIELD_STRING);

    assertEquals(3, sortedResult.size());
    assertEquals("Москва", sortedResult.first().getColumnString());
    assertEquals("Москва", sortedResult.get(0).getColumnString());
    assertEquals("Новороссийск", sortedResult.get(1).getColumnString());
    assertEquals("Санкт-Петербург", sortedResult.get(2).getColumnString());

    RealmResults<AllTypes> reverseResult = result.where().findAll();
    reverseResult.sort(FIELD_STRING, RealmResults.SORT_ORDER_DESCENDING);
    assertEquals(3, reverseResult.size());
    assertEquals("Москва", reverseResult.last().getColumnString());
    assertEquals("Санкт-Петербург", reverseResult.get(0).getColumnString());
    assertEquals("Новороссийск", reverseResult.get(1).getColumnString());
    assertEquals("Москва", reverseResult.get(2).getColumnString());
  }
 private void check(Realm realm) {
   RealmResults<Student> realmResults = realm.allObjects(Student.class);
   if (realmResults.size() != numberOfObjects) {
     throw new RuntimeException(
         String.format("Error in number of objectss.", realmResults.size(), numberOfObjects));
   }
 }
  public void testSortByLong() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    RealmResults<AllTypes> sortedList = testRealm.allObjects(AllTypes.class);
    sortedList.sort(FIELD_LONG, RealmResults.SORT_ORDER_DESCENDING);
    assertEquals("Should have same size", resultList.size(), sortedList.size());
    assertEquals(TEST_DATA_SIZE, sortedList.size());
    assertEquals(
        "First excepted to be last",
        resultList.first().getColumnLong(),
        sortedList.last().getColumnLong());

    RealmResults<AllTypes> reverseList = sortedList;
    reverseList.sort(FIELD_LONG, RealmResults.SORT_ORDER_ASCENDING);
    assertEquals(TEST_DATA_SIZE, reverseList.size());
    assertEquals(
        "First excepted to be first",
        resultList.first().getColumnLong(),
        reverseList.first().getColumnLong());
    assertEquals(
        "Last excepted to be last",
        resultList.last().getColumnLong(),
        reverseList.last().getColumnLong());

    RealmResults<AllTypes> reserveSortedList = reverseList;
    reverseList.sort(FIELD_LONG, RealmResults.SORT_ORDER_DESCENDING);
    assertEquals(TEST_DATA_SIZE, reserveSortedList.size());
  }
  public void testSortWithDanishCharacters() {
    testRealm.beginTransaction();
    testRealm.clear(AllTypes.class);
    AllTypes at1 = testRealm.createObject(AllTypes.class);
    at1.setColumnString("Æble");
    AllTypes at2 = testRealm.createObject(AllTypes.class);
    at2.setColumnString("Øl");
    AllTypes at3 = testRealm.createObject(AllTypes.class);
    at3.setColumnString("Århus");
    testRealm.commitTransaction();

    RealmResults<AllTypes> result = testRealm.allObjects(AllTypes.class);
    RealmResults<AllTypes> sortedResult = result.where().findAll();
    sortedResult.sort(FIELD_STRING);

    assertEquals(3, sortedResult.size());
    assertEquals("Æble", sortedResult.first().getColumnString());
    assertEquals("Æble", sortedResult.get(0).getColumnString());
    assertEquals("Øl", sortedResult.get(1).getColumnString());
    assertEquals("Århus", sortedResult.get(2).getColumnString());

    RealmResults<AllTypes> reverseResult = result.where().findAll();
    reverseResult.sort(FIELD_STRING, Sort.DESCENDING);
    assertEquals(3, reverseResult.size());
    assertEquals("Æble", reverseResult.last().getColumnString());
    assertEquals("Århus", reverseResult.get(0).getColumnString());
    assertEquals("Øl", reverseResult.get(1).getColumnString());
    assertEquals("Æble", reverseResult.get(2).getColumnString());
  }
  // No sorting order defined. There are Korean, Arabic and Chinese characters.
  public void testSortWithManyDifferentCharacters() {
    testRealm.beginTransaction();
    testRealm.clear(AllTypes.class);
    AllTypes at1 = testRealm.createObject(AllTypes.class);
    at1.setColumnString("단위");
    AllTypes at2 = testRealm.createObject(AllTypes.class);
    at2.setColumnString("테스트");
    AllTypes at3 = testRealm.createObject(AllTypes.class);
    at3.setColumnString("وحدة");
    AllTypes at4 = testRealm.createObject(AllTypes.class);
    at4.setColumnString("اختبار");
    AllTypes at5 = testRealm.createObject(AllTypes.class);
    at5.setColumnString("单位");
    AllTypes at6 = testRealm.createObject(AllTypes.class);
    at6.setColumnString("试验");
    AllTypes at7 = testRealm.createObject(AllTypes.class);
    at7.setColumnString("單位");
    AllTypes at8 = testRealm.createObject(AllTypes.class);
    at8.setColumnString("測試");
    testRealm.commitTransaction();

    RealmResults<AllTypes> result = testRealm.allObjects(AllTypes.class);
    RealmResults<AllTypes> sortedResult = result.where().findAll();
    sortedResult.sort(FIELD_STRING);

    assertEquals(8, sortedResult.size());

    @SuppressWarnings("UnnecessaryLocalVariable")
    RealmResults<AllTypes> reverseResult = result;
    reverseResult.sort(FIELD_STRING, RealmResults.SORT_ORDER_DESCENDING);
    assertEquals(8, reverseResult.size());
  }
  public void testSortWithGreekCharacters() {
    testRealm.beginTransaction();
    testRealm.clear(AllTypes.class);
    AllTypes at1 = testRealm.createObject(AllTypes.class);
    at1.setColumnString("αύριο");
    AllTypes at2 = testRealm.createObject(AllTypes.class);
    at2.setColumnString("ημέρες");
    AllTypes at3 = testRealm.createObject(AllTypes.class);
    at3.setColumnString("δοκιμές");
    testRealm.commitTransaction();

    RealmResults<AllTypes> result = testRealm.allObjects(AllTypes.class);
    RealmResults<AllTypes> sortedResult = result.where().findAll();
    sortedResult.sort(FIELD_STRING);

    assertEquals(3, sortedResult.size());
    assertEquals("αύριο", sortedResult.first().getColumnString());
    assertEquals("αύριο", sortedResult.get(0).getColumnString());
    assertEquals("δοκιμές", sortedResult.get(1).getColumnString());
    assertEquals("ημέρες", sortedResult.get(2).getColumnString());

    RealmResults<AllTypes> reverseResult = result.where().findAll();
    reverseResult.sort(FIELD_STRING, RealmResults.SORT_ORDER_DESCENDING);
    assertEquals(3, reverseResult.size());
    assertEquals("αύριο", reverseResult.last().getColumnString());
    assertEquals("ημέρες", reverseResult.get(0).getColumnString());
    assertEquals("δοκιμές", reverseResult.get(1).getColumnString());
    assertEquals("αύριο", reverseResult.get(2).getColumnString());
  }
  public void testRemoveLastEmptyList() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    testRealm.beginTransaction();
    resultList.clear();
    assertEquals(0, resultList.size());
    resultList.removeLast();
    testRealm.commitTransaction();

    assertEquals(0, resultList.size());
  }
  // void clear(Class<?> classSpec)
  public void testClearEmptiesTable() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    assertEquals(TEST_DATA_SIZE, resultList.size());

    testRealm.beginTransaction();
    resultList.clear();
    testRealm.commitTransaction();

    assertEquals(0, resultList.size());
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ImageLoaderConfiguration conf = new ImageLoaderConfiguration.Builder(getActivity()).build();
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.init(conf);

    adapter = new FriendsArrayAdapter(getActivity(), R.layout.row_friends, imageLoader, this);
    setListAdapter(adapter);

    realm = Realm.getInstance(getActivity());

    RealmResults<Friend> results = realm.allObjects(Friend.class); // TODO: Run async

    if (results.size() > 0) {
      if (!compact) {
        getListView().setVisibility(View.VISIBLE);
        progressBar.setVisibility(View.GONE);
      }
      adapter.update(results);
    }

    refreshFriends(); // TODO: Timeout on the refresh rate?
  }
  /**
   * *********************************************************************************************
   * VOD시청
   */
  public void addWatchVod(Date watchDate, String assetId, String title) {
    // Realm Database **********************************************************************
    // Obtain a Realm instance
    Realm realm = Realm.getInstance(mContext);
    RealmResults<WatchVodObject> results = realm.where(WatchVodObject.class).findAll();
    long iSeq = 0;
    if (results == null) {
      //
    } else {
      if (results.size() == 0) {
        iSeq = 0;
      } else {
        iSeq = realm.where(WatchVodObject.class).maximumInt("iSeq") + 1;
      }
    }

    WatchVodObject obj = new WatchVodObject();
    obj.setiSeq((int) iSeq);
    obj.setdDate(watchDate);
    obj.setsAssetId(assetId);
    obj.setsTitle(title);
    realm.beginTransaction();
    WatchVodObject obj2 = realm.copyToRealm(obj);
    realm.commitTransaction();
    // Realm Database **********************************************************************
  }
  /**
   * getWishList로 전체 찜 목록을 가져왔을때 호출되는 함수. 기존의 Wish들을 삭제하고, 파라메터의 어레이로 다시 채운다.
   *
   * @param arr
   */
  public void setAllWishList(JSONArray arr) {
    // Realm Database **********************************************************************
    // Obtain a Realm instance
    Realm realm = Realm.getInstance(mContext);

    // remove all
    realm.beginTransaction();
    realm.allObjects(WishObject.class).clear();
    for (int i = 0; i < arr.length(); i++) {
      try {
        JSONObject jo = arr.getJSONObject(i);
        JSONObject asset = jo.getJSONObject("asset");
        String assetId = asset.getString("assetId");
        RealmResults<WishObject> results =
            mRealm.where(WishObject.class).equalTo("sAssetId", assetId).findAll();
        if (results.size() > 0) {
          // skip
        } else {
          // 객체를 생성하거나 데이터를 수정하는 작업을 수행한다.
          WishObject wish = realm.createObject(WishObject.class); // Create a new object
          wish.setsAssetId(assetId);
          wish.setsPhoneNumber(jo.getString("phoneNumber"));
          wish.setsUserId(jo.getString("userId"));
        }
      } catch (JSONException e) {
        e.printStackTrace();
      }
    }
    // 트랜잭션 종료
    realm.commitTransaction();
    // Realm Database **********************************************************************
  }
 public void testSortSingleField() {
   RealmResults<AllTypes> sortedList = testRealm.allObjects(AllTypes.class);
   sortedList.sort(new String[] {FIELD_LONG}, new boolean[] {RealmResults.SORT_ORDER_DESCENDING});
   assertEquals(TEST_DATA_SIZE, sortedList.size());
   assertEquals(TEST_DATA_SIZE - 1, sortedList.first().getColumnLong());
   assertEquals(0, sortedList.last().getColumnLong());
 }
 public void testGetItemId() {
   RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
   RealmAdapter realmAdapter = new RealmAdapter(getContext(), resultList, automaticUpdate);
   for (int i = 0; i < resultList.size(); i++) {
     assertEquals(i, realmAdapter.getItemId(i));
   }
 }
  // 2016-03-29 시청예약시 데이타베이스 처리를 programId 로 하는데 서버에서 programId를 중복으로 보내고 있다
  // 그래서 시청시간을 추가함.
  public void removeWatchTvReserveAlarmWithProgramIdAndStartTime(
      String programId, String startTime) {
    int iSeq = 0;
    Realm realm = Realm.getInstance(mContext);
    realm.beginTransaction();
    RealmResults<WatchTvObject> results =
        mRealm
            .where(WatchTvObject.class)
            .equalTo("sProgramId", programId)
            .equalTo("sProgramBroadcastingStartTime", startTime)
            .findAll();
    if (results.size() > 0) {
      WatchTvObject obj = results.get(0);
      iSeq = obj.getiSeq();
      obj.removeFromRealm();
    } else {
      //
    }
    realm.commitTransaction();

    AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(mContext, WatchTvAlarmBroadcastReceiver.class);
    PendingIntent pendingIntent =
        PendingIntent.getBroadcast(mContext, iSeq, intent, PendingIntent.FLAG_NO_CREATE);
    if (pendingIntent != null) {
      alarmManager.cancel(pendingIntent);
      pendingIntent.cancel();
    }
  }
Exemple #15
0
  public void getFromDatabase() {
    mEntityList.clear();

    RealmResults<RealmZcool> zcoolRealmResults = mRealm.where(RealmZcool.class).findAll();
    for (int i = zcoolRealmResults.size() - 1; i >= 0; i--) {
      mEntityList.add(zcoolRealmResults.get(i).toEntity());
    }
  }
  @Override
  public View getView(int position, View view, ViewGroup parent) {

    LayoutInflater inflater = activity.getLayoutInflater();
    Type type = realmResults.get(position);

    // check which markers are available
    Boolean available = false;
    RealmResults<Marker> markers =
        Utils.realm.where(Marker.class).equalTo("city.id", Utils.city_id).findAll();
    for (int i = 0; i < markers.size(); i++) {
      Marker thisMarker = markers.get(i);
      if (thisMarker.getType() == type.getType()) {
        available = true;
      }
    }

    // marker type is available show in list
    if (available) {
      rowView = inflater.inflate(R.layout.custom_filter_list, null, true);

      TextView filterName = (TextView) rowView.findViewById(R.id.FilterName);
      TextView filterType = (TextView) rowView.findViewById(R.id.FilterType);
      ImageView filterIcon = (ImageView) rowView.findViewById(R.id.TypeIcon);
      Switch filterDisplay = (Switch) rowView.findViewById(R.id.DisplayToggle);

      // set label depending on language set
      Utils.language = Utils.preferences.getInt("language", 0);
      if (Utils.language == 0) {
        filterName.setText(type.getName_nl());
      } else if (Utils.language == 1) {
        filterName.setText(type.getName_en());
      } else if (Utils.language == 2) {
        filterName.setText(type.getName_es());
      } else {
        filterName.setText("int: " + Utils.language);
      }

      filterType.setText(String.format("%d", type.getType()));

      Context context = filterIcon.getContext();
      int id =
          context
              .getResources()
              .getIdentifier(type.getImage(), "drawable", context.getPackageName());
      Bitmap icon = BitmapFactory.decodeResource(context.getResources(), id);
      filterIcon.setImageBitmap(icon);

      filterDisplay.setChecked(type.getDisplay());

      rowView.setTag(type);

    } else {
      rowView = inflater.inflate(R.layout.custom_empty_list, null, true);
    }

    return rowView;
  }
 public void testManyConditions() {
   RealmQuery<AllTypes> query = testRealm.where(AllTypes.class);
   query.equalTo(FIELD_LONG, 0);
   for (int i = 1; i < TEST_DATA_SIZE; i++) {
     query.or().equalTo(FIELD_LONG, i);
   }
   RealmResults<AllTypes> allTypesRealmResults = query.findAll();
   assertEquals(TEST_DATA_SIZE, allTypesRealmResults.size());
 }
  public void testSortByDouble() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    RealmResults<AllTypes> sortedList = resultList.where().findAll();
    sortedList.sort(FIELD_DOUBLE, Sort.DESCENDING);
    assertEquals(resultList.size(), sortedList.size());
    assertEquals(TEST_DATA_SIZE, sortedList.size());
    assertEquals(resultList.first().getColumnDouble(), sortedList.last().getColumnDouble());

    RealmResults<AllTypes> reverseList = sortedList.where().findAll();
    reverseList.sort(FIELD_DOUBLE, Sort.ASCENDING);
    assertEquals(TEST_DATA_SIZE, reverseList.size());
    assertEquals(resultList.first().getColumnDouble(), reverseList.first().getColumnDouble());
    assertEquals(resultList.last().getColumnDouble(), reverseList.last().getColumnDouble());

    RealmResults<AllTypes> reverseSortedList = reverseList.where().findAll();
    reverseSortedList.sort(FIELD_DOUBLE, Sort.DESCENDING);
    assertEquals(TEST_DATA_SIZE, reverseSortedList.size());
  }
  private void doTestSortOnColumnWithPartialNullValues(String fieldName) {
    RealmResults<NullTypes> resultList = testRealm.where(NullTypes.class).findAll();
    // Ascending
    RealmResults<NullTypes> sortedList = testRealm.allObjects(NullTypes.class);
    sortedList.sort(fieldName, RealmResults.SORT_ORDER_ASCENDING);
    assertEquals("Should have same size", resultList.size(), sortedList.size());
    // Null should always be the first one in the ascending sorted list
    assertEquals(2, sortedList.first().getId());
    assertEquals(1, sortedList.last().getId());

    // Descending
    sortedList = testRealm.allObjects(NullTypes.class);
    sortedList.sort(fieldName, RealmResults.SORT_ORDER_DESCENDING);
    assertEquals("Should have same size", resultList.size(), sortedList.size());
    assertEquals(1, sortedList.first().getId());
    // Null should always be the last one in the descending sorted list
    assertEquals(2, sortedList.last().getId());
  }
  public void testSortByFloat() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    RealmResults<AllTypes> sortedList = resultList.where().findAll();
    sortedList.sort(FIELD_FLOAT, RealmResults.SORT_ORDER_DESCENDING);
    assertEquals(resultList.size(), sortedList.size());
    assertEquals(TEST_DATA_SIZE, sortedList.size());
    assertEquals(resultList.first().getColumnFloat(), sortedList.last().getColumnFloat());

    RealmResults<AllTypes> reverseList = sortedList.where().findAll();
    reverseList.sort(FIELD_FLOAT, RealmResults.SORT_ORDER_ASCENDING);
    assertEquals(TEST_DATA_SIZE, reverseList.size());
    assertEquals(resultList.first().getColumnFloat(), reverseList.first().getColumnFloat());
    assertEquals(resultList.last().getColumnFloat(), reverseList.last().getColumnFloat());

    RealmResults<AllTypes> reverseSortedList = reverseList.where().findAll();
    reverseSortedList.sort(FIELD_FLOAT, RealmResults.SORT_ORDER_DESCENDING);
    assertEquals(TEST_DATA_SIZE, reverseSortedList.size());
  }
  public void testQueryResult() {
    RealmResults<AllTypes> allTypes = testRealm.where(AllTypes.class).findAll();
    assertEquals(TEST_DATA_SIZE, allTypes.size());

    // querying a RealmResults should find objects that fulfill the condition
    RealmResults<AllTypes> onedigits = allTypes.where().lessThan(FIELD_LONG, 10).findAll();
    assertEquals(Math.min(10, TEST_DATA_SIZE), onedigits.size());

    // if no objects fulfill conditions, the result has zero objects
    RealmResults<AllTypes> none =
        allTypes.where().greaterThan(FIELD_LONG, TEST_DATA_SIZE).findAll();
    assertEquals(0, none.size());

    // querying a result with zero objects must give zero objects
    RealmResults<AllTypes> stillNone =
        none.where().greaterThan(FIELD_LONG, TEST_DATA_SIZE).findAll();
    assertEquals(0, stillNone.size());
  }
  public void testRemoveLast() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    testRealm.beginTransaction();
    resultList.removeLast();
    testRealm.commitTransaction();

    assertEquals(
        "ResultList.removeLast did not remove record", TEST_DATA_SIZE - 1, resultList.size());

    AllTypes allTypes = resultList.get(resultList.size() - 1);
    assertEquals(
        "ResultList.removeLast unexpected last record",
        TEST_DATA_SIZE - 2,
        allTypes.getColumnLong());

    RealmResults<AllTypes> resultListCheck = testRealm.where(AllTypes.class).findAll();
    assertEquals("ResultList.removeLast not committed", TEST_DATA_SIZE - 1, resultListCheck.size());
  }
 public boolean isBookmarkChannelWithChannelId(String channelId) {
   RealmResults<BookmarkChannelObject> results =
       mRealm.where(BookmarkChannelObject.class).equalTo("sChannelId", channelId).findAll();
   if (results.size() > 0) {
     return true;
   } else {
     return false;
   }
 }
 public boolean isWatchTvReserveWithProgramId(String programId) {
   RealmResults<WatchTvObject> results =
       mRealm.where(WatchTvObject.class).equalTo("sProgramId", programId).findAll();
   if (results.size() > 0) {
     return true;
   } else {
     return false;
   }
 }
 public boolean isWishAsset(String assetId) {
   RealmResults<WishObject> results =
       mRealm.where(WishObject.class).equalTo("sAssetId", assetId).findAll();
   if (results.size() > 0) {
     return true;
   } else {
     return false;
   }
 }
  public void testGetItem() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    RealmAdapter realmAdapter = new RealmAdapter(getContext(), resultList, automaticUpdate);

    assertEquals(resultList.get(0).getColumnString(), realmAdapter.getItem(0).getColumnString());
    assertEquals(resultList.size(), realmAdapter.getRealmResults().size());
    assertEquals(
        resultList.last().getColumnString(),
        realmAdapter.getRealmResults().last().getColumnString());
  }
 public MainCategoryObject getMainCategoryObject(int i) {
   String sSortNo = String.valueOf(i);
   RealmResults<MainCategoryObject> results =
       mRealm.where(MainCategoryObject.class).equalTo("sSortNo", sSortNo).findAll();
   if (results.size() > 0) {
     return results.get(0);
   } else {
     return null;
   }
 }
  public void testFindAllSorted() {
    RealmResults<AllTypes> allTypes =
        testRealm.where(AllTypes.class).findAllSorted(FIELD_LONG, Sort.ASCENDING);
    assertEquals(TEST_DATA_SIZE, allTypes.size());
    assertEquals(0, allTypes.first().getColumnLong());
    assertEquals(TEST_DATA_SIZE - 1, allTypes.last().getColumnLong());

    RealmResults<AllTypes> reverseList =
        testRealm.where(AllTypes.class).findAllSorted(FIELD_LONG, Sort.DESCENDING);
    assertEquals(TEST_DATA_SIZE, reverseList.size());
    assertEquals(0, reverseList.last().getColumnLong());
    assertEquals(TEST_DATA_SIZE - 1, reverseList.first().getColumnLong());

    try {
      testRealm.where(AllTypes.class).findAllSorted("invalid", Sort.DESCENDING);
      fail();
    } catch (IllegalArgumentException ignored) {
    }
  }
  public void testSortWithAdapter() {
    RealmResults<AllTypes> resultList = testRealm.where(AllTypes.class).findAll();
    resultList.sort(FIELD_STRING, RealmResults.SORT_ORDER_DESCENDING);
    RealmAdapter realmAdapter = new RealmAdapter(getContext(), resultList, automaticUpdate);
    assertEquals(
        resultList.first().getColumnString(),
        realmAdapter.getRealmResults().first().getColumnString());
    assertEquals(resultList.size(), realmAdapter.getRealmResults().size());

    resultList.sort(FIELD_STRING);

    assertEquals(
        resultList.last().getColumnString(),
        realmAdapter.getRealmResults().last().getColumnString());
    assertEquals(
        resultList.get(TEST_DATA_SIZE / 2).getColumnString(),
        realmAdapter.getRealmResults().get(TEST_DATA_SIZE / 2).getColumnString());
    assertEquals(resultList.size(), realmAdapter.getRealmResults().size());
  }
  public void testQueryDateField() {
    RealmQuery<AllTypes> query =
        testRealm.where(AllTypes.class).equalTo(FIELD_DATE, new Date(YEAR_MILLIS * 5));
    RealmResults<AllTypes> all = query.findAll();
    assertEquals(1, query.count());
    assertEquals(1, all.size());

    // before 1901
    query = testRealm.where(AllTypes.class).equalTo(FIELD_DATE, new Date(YEAR_MILLIS * -100));
    all = query.findAll();
    assertEquals(1, query.count());
    assertEquals(1, all.size());

    // after 2038
    query = testRealm.where(AllTypes.class).equalTo(FIELD_DATE, new Date(YEAR_MILLIS * 100));
    all = query.findAll();
    assertEquals(1, query.count());
    assertEquals(1, all.size());
  }