コード例 #1
0
  private void initializeMustMatchNotMatchCriteria() {

    Criterion criterionA = new Criterion(new Answer(questionA, Bool.TRUE), Weight.Important);
    Criterion criterionB = new Criterion(new Answer(questionB, Bool.TRUE), Weight.MustMatch);
    Criterion criterionC = new Criterion(new Answer(questionC, Bool.TRUE), Weight.Important);

    criteria.add(criterionA);
    criteria.add(criterionB);
    criteria.add(criterionC);
  }
コード例 #2
0
  /** @see DATAMONGO-445 */
  @Test
  public void shouldTakeSkipAndLimitSettingsFromGivenQuery() {

    int limit = 10;
    int skip = 5;
    NearQuery query =
        NearQuery.near(new Point(1, 1))
            .query(Query.query(Criteria.where("foo").is("bar")).limit(limit).skip(skip));

    assertThat(query.getSkip(), is(skip));
    assertThat((Integer) query.toDBObject().get("num"), is(limit));
  }
コード例 #3
0
  /** @see DATAMONGO-445 */
  @Test
  public void shouldTakeSkipAndLimitSettingsFromPageableEvenIfItWasSpecifiedOnQuery() {

    int limit = 10;
    int skip = 5;
    Pageable pageable = new PageRequest(3, 5);
    NearQuery query =
        NearQuery.near(new Point(1, 1))
            .query(Query.query(Criteria.where("foo").is("bar")).limit(limit).skip(skip))
            .with(pageable);

    assertThat(query.getSkip(), is(pageable.getPageNumber() * pageable.getPageSize()));
    assertThat(
        (Integer) query.toDBObject().get("num"),
        is((pageable.getPageNumber() + 1) * pageable.getPageSize()));
  }