use of cz.jirutka.rsql.parser.RSQLParser 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)));
}
use of cz.jirutka.rsql.parser.RSQLParser in project molgenis by molgenis.
the class MolgenisRSQLTest method beforeMethod.
@BeforeMethod
public void beforeMethod() {
molgenisRSQL = new MolgenisRSQL(new RSQLParser());
when(entityType.getId()).thenReturn("Person").getMock();
Attribute nameAttr = when(mock(Attribute.class).getName()).thenReturn("name").getMock();
when(nameAttr.getDataType()).thenReturn(STRING);
Attribute ageAttr = when(mock(Attribute.class).getName()).thenReturn("age").getMock();
when(ageAttr.getDataType()).thenReturn(INT);
when(entityType.getAttribute("name")).thenReturn(nameAttr);
when(entityType.getAttribute("age")).thenReturn(ageAttr);
when(genderEntityType.getId()).thenReturn("Gender").getMock();
Attribute genderIdAttribute = when(mock(Attribute.class).getName()).thenReturn("id").getMock();
when(genderIdAttribute.getDataType()).thenReturn(INT);
when(genderEntityType.getIdAttribute()).thenReturn(genderIdAttribute);
Attribute genderAttr = when(mock(Attribute.class).getName()).thenReturn("gender").getMock();
when(genderAttr.getDataType()).thenReturn(XREF);
when(genderAttr.getRefEntity()).thenReturn(genderEntityType);
when(entityType.getAttribute("gender")).thenReturn(genderAttr);
}
use of cz.jirutka.rsql.parser.RSQLParser 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)));
}
Aggregations