Search in sources :

Example 6 with Node

use of cz.jirutka.rsql.parser.ast.Node in project tutorials by eugenp.

the class RsqlIntegrationTest method givenMinAge_whenGettingListOfUsers_thenCorrect.

@Test
public void givenMinAge_whenGettingListOfUsers_thenCorrect() {
    final Node rootNode = new RSQLParser().parse("age>25");
    final Specification<User> spec = rootNode.accept(new CustomRsqlVisitor<User>());
    final List<User> results = repository.findAll(spec);
    assertThat(userTom, isIn(results));
    assertThat(userJohn, not(isIn(results)));
}
Also used : User(org.baeldung.persistence.model.User) RSQLParser(cz.jirutka.rsql.parser.RSQLParser) Node(cz.jirutka.rsql.parser.ast.Node) Test(org.junit.Test)

Example 7 with Node

use of cz.jirutka.rsql.parser.ast.Node in project tutorials by eugenp.

the class RsqlIntegrationTest method givenFirstAndLastName_whenGettingListOfUsers_thenCorrect.

@Test
public void givenFirstAndLastName_whenGettingListOfUsers_thenCorrect() {
    final Node rootNode = new RSQLParser().parse("firstName==john;lastName==doe");
    final Specification<User> spec = rootNode.accept(new CustomRsqlVisitor<User>());
    final List<User> results = repository.findAll(spec);
    assertThat(userJohn, isIn(results));
    assertThat(userTom, not(isIn(results)));
}
Also used : User(org.baeldung.persistence.model.User) RSQLParser(cz.jirutka.rsql.parser.RSQLParser) Node(cz.jirutka.rsql.parser.ast.Node) Test(org.junit.Test)

Example 8 with Node

use of cz.jirutka.rsql.parser.ast.Node in project tutorials by eugenp.

the class RsqlIntegrationTest method givenFirstNamePrefix_whenGettingListOfUsers_thenCorrect.

@Test
public void givenFirstNamePrefix_whenGettingListOfUsers_thenCorrect() {
    final Node rootNode = new RSQLParser().parse("firstName==jo*");
    final Specification<User> spec = rootNode.accept(new CustomRsqlVisitor<User>());
    final List<User> results = repository.findAll(spec);
    assertThat(userJohn, isIn(results));
    assertThat(userTom, not(isIn(results)));
}
Also used : User(org.baeldung.persistence.model.User) RSQLParser(cz.jirutka.rsql.parser.RSQLParser) Node(cz.jirutka.rsql.parser.ast.Node) Test(org.junit.Test)

Aggregations

Node (cz.jirutka.rsql.parser.ast.Node)8 RSQLParser (cz.jirutka.rsql.parser.RSQLParser)6 User (org.baeldung.persistence.model.User)6 Test (org.junit.Test)5 ComparisonNode (cz.jirutka.rsql.parser.ast.ComparisonNode)1 LogicalNode (cz.jirutka.rsql.parser.ast.LogicalNode)1 ArrayList (java.util.ArrayList)1 MyUser (org.baeldung.persistence.model.MyUser)1 Specifications (org.springframework.data.jpa.domain.Specifications)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1