use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldFilterColumnWithFourLevelsDeepPathInExpressionWithBrackets.
@Test
public final void shouldFilterColumnWithFourLevelsDeepPathInExpressionWithBrackets() throws GridComponentFilterException {
// given
DataDefinition firstBtDataDef = mock(DataDefinition.class);
FieldDefinition firstBtFieldDef = mockBelongsToField("firstBt", dataDefinition, firstBtDataDef);
DataDefinition secondBtDataDef = mock(DataDefinition.class);
mockBelongsToField("secondBt", firstBtDataDef, secondBtDataDef);
DataDefinition thirdBtDataDef = mock(DataDefinition.class);
mockBelongsToField("thirdBt", secondBtDataDef, thirdBtDataDef);
DataDefinition fourthBtDataDef = mock(DataDefinition.class);
mockBelongsToField("fourthBt", thirdBtDataDef, fourthBtDataDef);
mockFieldDefinition(TEST_FIELD, Integer.class, fourthBtDataDef);
// when
performFiltering("3", buildGridComponentColumn(TEST_COL, firstBtFieldDef, "#firstBt['secondBt'].get('thirdBt').get('fourthBt').get('" + TEST_FIELD + "')"));
// then
PowerMockito.verifyStatic();
SearchRestrictions.eq("fourthBt_a." + TEST_FIELD, 3);
PowerMockito.verifyStatic(never());
SearchRestrictions.eq(TEST_FIELD, 3);
SearchRestrictions.eq("firstBt_a." + TEST_FIELD, 3);
SearchRestrictions.eq("secondBt_a." + TEST_FIELD, 3);
SearchRestrictions.eq("thirdBt_a." + TEST_FIELD, 3);
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldNotFilterColumnWithOneLevelDeepPathInExpressionWithBracketsAndSafetyNavOp.
@Test
public final void shouldNotFilterColumnWithOneLevelDeepPathInExpressionWithBracketsAndSafetyNavOp() throws GridComponentFilterException {
// given
DataDefinition firstBtDataDef = mock(DataDefinition.class);
FieldDefinition firstBtFieldDef = mockBelongsToField("firstBt", dataDefinition, firstBtDataDef);
mockFieldDefinition(TEST_FIELD, Integer.class, firstBtDataDef);
// when
performFiltering("3", buildGridComponentColumn(TEST_COL, firstBtFieldDef, "#firstBt?['" + TEST_FIELD + "']"));
// then
PowerMockito.verifyStatic(never());
SearchRestrictions.eq("firstBt_a." + TEST_FIELD, 3);
PowerMockito.verifyStatic(never());
SearchRestrictions.eq(TEST_FIELD, 3);
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldReturnNullForUnsupportedExpression1.
@Test
public final void shouldReturnNullForUnsupportedExpression1() {
// given
final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo['secondBelongsTo'].get('thirdBelongsTo')[0].get('field')"));
// when
final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
// then
assertNull(fieldName);
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldReturnFieldNameUsingSimpleExpressionWithOneGet.
@Test
public final void shouldReturnFieldNameUsingSimpleExpressionWithOneGet() {
// given
final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo.get('field')"));
// when
final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
// then
assertEquals("belongsTo.field", fieldName);
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldFilterColumnWithOneLevelDeepPathInExpressionWithBrackets.
@Test
public final void shouldFilterColumnWithOneLevelDeepPathInExpressionWithBrackets() throws GridComponentFilterException {
// given
DataDefinition firstBtDataDef = mock(DataDefinition.class);
FieldDefinition firstBtFieldDef = mockBelongsToField("firstBt", dataDefinition, firstBtDataDef);
mockFieldDefinition(TEST_FIELD, Integer.class, firstBtDataDef);
// when
performFiltering("3", buildGridComponentColumn(TEST_COL, firstBtFieldDef, "#firstBt['" + TEST_FIELD + "']"));
// then
PowerMockito.verifyStatic();
SearchRestrictions.eq("firstBt_a." + TEST_FIELD, 3);
PowerMockito.verifyStatic(never());
SearchRestrictions.eq(TEST_FIELD, 3);
}
Aggregations