Package org.springframework.data.repository.query.parser

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


   * @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


   * @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

   * @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

   * @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

    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

   * @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

   * @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

   * @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

  private void assertBindsDistanceToQuery(Point point, Distance distance, Query reference) throws Exception {

    when(converter.convertToMongoType("Dave")).thenReturn("Dave");

    PartTree tree = new PartTree("findByLocationNearAndFirstname",
        org.springframework.data.mongodb.repository.Person.class);
    Method method = PersonRepository.class.getMethod("findByLocationNearAndFirstname", Point.class, Distance.class,
        String.class);
    MongoQueryMethod queryMethod = new MongoQueryMethod(method, new DefaultRepositoryMetadata(PersonRepository.class),
        new MongoMappingContext());
View Full Code Here

   * @see DATAMONGO-770
   */
  @Test
  public void createsQueryWithFindByIgnoreCaseCorrectly() {

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

    Query query = creator.createQuery();
    assertThat(query, is(query(where("firstName").regex("^dave$", "i"))));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.repository.query.parser.PartTree$Predicate

Copyright © 2018 www.massapicom. 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.