use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class RestFilterParserTest method testInvalidGroupType.
@Test
public void testInvalidGroupType() throws Exception {
String data = readDataFromFile("data/invalidRestFilter3.json");
MetaClass metaClass = metadata.getClass("test$TestEntity");
thrown.expect(RestFilterParseException.class);
thrown.expectMessage("Invalid conditions group type: INVALID_GROUP_TYPE");
restFilterParser.parse(data, metaClass);
}
use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class RestFilterParserTest method testOrGroup.
@Test
public void testOrGroup() throws Exception {
new StrictExpectations() {
{
RandomStringUtils.randomAlphabetic(anyInt);
result = "stringParamName";
RandomStringUtils.randomAlphabetic(anyInt);
result = "intParamName";
RandomStringUtils.randomAlphabetic(anyInt);
result = "booleanParamName";
}
};
String data = readDataFromFile("data/restFilter3.json");
MetaClass metaClass = metadata.getClass("test$TestEntity");
RestFilterParseResult parseResult = restFilterParser.parse(data, metaClass);
String expectedJpqlWhere = "(({E}.stringField <> :stringParamName or " + "{E}.intField > :intParamName) and " + "{E}.booleanField = :booleanParamName)";
assertEquals(expectedJpqlWhere, parseResult.getJpqlWhere());
Map<String, Object> queryParameters = parseResult.getQueryParameters();
assertEquals("stringValue", queryParameters.get("stringParamName"));
assertEquals(100, queryParameters.get("intParamName"));
assertEquals(true, queryParameters.get("booleanParamName"));
}
use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class RestFilterParserTest method testInvalidPropertyValue.
@Test
public void testInvalidPropertyValue() throws Exception {
String data = readDataFromFile("data/invalidRestFilter2.json");
MetaClass metaClass = metadata.getClass("test$TestEntity");
thrown.expect(RestFilterParseException.class);
thrown.expectMessage("Cannot parse property value: string");
restFilterParser.parse(data, metaClass);
}
use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class RestFilterParserTest method testNotEmptyOperator.
@Test
public void testNotEmptyOperator() throws Exception {
String data = readDataFromFile("data/restFilter7.json");
MetaClass metaClass = metadata.getClass("test$TestEntity");
RestFilterParseResult parseResult = restFilterParser.parse(data, metaClass);
String expectedJpqlWhere = "({E}.stringField is not null)";
assertEquals(expectedJpqlWhere, parseResult.getJpqlWhere());
Map<String, Object> queryParameters = parseResult.getQueryParameters();
assertEquals(0, queryParameters.size());
}
use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class RestFilterParserTest method testStartsWithOperator.
@Test
public void testStartsWithOperator() throws Exception {
new StrictExpectations() {
{
RandomStringUtils.randomAlphabetic(anyInt);
result = "paramName1";
}
};
String data = readDataFromFile("data/restFilter6.json");
MetaClass metaClass = metadata.getClass("test$TestEntity");
RestFilterParseResult parseResult = restFilterParser.parse(data, metaClass);
String expectedJpqlWhere = "({E}.stringField like :paramName1)";
assertEquals(expectedJpqlWhere, parseResult.getJpqlWhere());
Map<String, Object> queryParameters = parseResult.getQueryParameters();
assertEquals("(?i)AAA%", queryParameters.get("paramName1"));
}
Aggregations