Examples of PartTree


Examples of org.springframework.data.repository.query.parser.PartTree

  }

  @Test
  public void createsGreaterThanEqualQueryCorrectly() throws Exception {

    PartTree tree = new PartTree("findByAgeGreaterThanEqual", Person.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, 18), context);

    Query reference = query(where("age").gte(18));
    assertThat(creator.createQuery(), is(reference));
  }
View Full Code Here

Examples of org.springframework.data.repository.query.parser.PartTree

   * @see DATAMONGO-338
   */
  @Test
  public void createsExistsClauseCorrectly() {

    PartTree tree = new PartTree("findByAgeExists", Person.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, true), context);
    Query query = query(where("age").exists(true));
    assertThat(creator.createQuery(), is(query));
  }
View Full Code Here

Examples of org.springframework.data.repository.query.parser.PartTree

   * @see DATAMONGO-338
   */
  @Test
  public void createsRegexClauseCorrectly() {

    PartTree tree = new PartTree("findByFirstNameRegex", Person.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, ".*"), context);
    Query query = query(where("firstName").regex(".*"));
    assertThat(creator.createQuery(), is(query));
  }
View Full Code Here

Examples of org.springframework.data.repository.query.parser.PartTree

   * @see DATAMONGO-338
   */
  @Test
  public void createsTrueClauseCorrectly() {

    PartTree tree = new PartTree("findByActiveTrue", Person.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter), context);
    Query query = query(where("active").is(true));
    assertThat(creator.createQuery(), is(query));
  }
View Full Code Here

Examples of org.springframework.data.repository.query.parser.PartTree

   * @see DATAMONGO-338
   */
  @Test
  public void createsFalseClauseCorrectly() {

    PartTree tree = new PartTree("findByActiveFalse", Person.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter), context);
    Query query = query(where("active").is(false));
    assertThat(creator.createQuery(), is(query));
  }
View Full Code Here

Examples of org.springframework.data.repository.query.parser.PartTree

   * @see DATAMONGO-413
   */
  @Test
  public void createsOrQueryCorrectly() {

    PartTree tree = new PartTree("findByFirstNameOrAge", Person.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "Dave", 42), context);

    Query query = creator.createQuery();
    assertThat(query, is(query(new Criteria().orOperator(where("firstName").is("Dave"), where("age").is(42)))));
  }
View Full Code Here

Examples of org.springframework.data.repository.query.parser.PartTree

    User user = new User();
    com.mongodb.DBRef dbref = new com.mongodb.DBRef(null, "user", "id");
    when(converter.toDBRef(eq(user), Mockito.any(MongoPersistentProperty.class))).thenReturn(dbref);

    PartTree tree = new PartTree("findByCreator", User.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, user), context);
    Query query = creator.createQuery();

    assertThat(query, is(query(where("creator").is(dbref))));
  }
View Full Code Here

Examples of org.springframework.data.repository.query.parser.PartTree

   * @see DATAMONGO-418
   */
  @Test
  public void createsQueryWithStartingWithPredicateCorrectly() {

    PartTree tree = new PartTree("findByUsernameStartingWith", User.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "Matt"), context);
    Query query = creator.createQuery();

    assertThat(query, is(query(where("username").regex("^Matt"))));
  }
View Full Code Here

Examples of org.springframework.data.repository.query.parser.PartTree

   * @see DATAMONGO-418
   */
  @Test
  public void createsQueryWithEndingWithPredicateCorrectly() {

    PartTree tree = new PartTree("findByUsernameEndingWith", User.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "ews"), context);
    Query query = creator.createQuery();

    assertThat(query, is(query(where("username").regex("ews$"))));
  }
View Full Code Here

Examples of org.springframework.data.repository.query.parser.PartTree

   * @see DATAMONGO-418
   */
  @Test
  public void createsQueryWithContainingPredicateCorrectly() {

    PartTree tree = new PartTree("findByUsernameContaining", User.class);
    MongoQueryCreator creator = new MongoQueryCreator(tree, getAccessor(converter, "thew"), context);
    Query query = creator.createQuery();

    assertThat(query, is(query(where("username").regex(".*thew.*"))));
  }
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.