use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldFilterColumnWithOneLevelDeepPathInExpressionWithSafetyNavOp.
@Test
public final void shouldFilterColumnWithOneLevelDeepPathInExpressionWithSafetyNavOp() 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?.get('" + TEST_FIELD + "')"));
// then
PowerMockito.verifyStatic();
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 shouldReturnNullForUnsupportedExpression3.
@Test
public final void shouldReturnNullForUnsupportedExpression3() {
// given
final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo['field1'] + ' ' + #belongsTo['field2']"));
// 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 shouldReturnFieldNameUsingSimpleExpressionWithOneGetStringField.
@Test
public final void shouldReturnFieldNameUsingSimpleExpressionWithOneGetStringField() {
// given
final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo.getStringField('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 shouldReturnNullForUnsupportedExpression4.
@Test
public final void shouldReturnNullForUnsupportedExpression4() {
// given
final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo == null ? '' : #belongsTo['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 shouldReturnFieldDefinitionForFourLevelsDeepPath.
@Test
public final void shouldReturnFieldDefinitionForFourLevelsDeepPath() {
// given
DataDefinition firstBtDataDef = mock(DataDefinition.class);
mockBelongsToField("firstBelongsTo", dataDefinition, firstBtDataDef);
DataDefinition secondBtDataDef = mock(DataDefinition.class);
mockBelongsToField("secondBelongsTo", firstBtDataDef, secondBtDataDef);
DataDefinition thirdBtDataDef = mock(DataDefinition.class);
mockBelongsToField("thirdBelongsTo", secondBtDataDef, thirdBtDataDef);
DataDefinition fourthBtDataDef = mock(DataDefinition.class);
mockBelongsToField("fourthBelongsTo", thirdBtDataDef, fourthBtDataDef);
FieldDefinition fieldDefinition = mockFieldDefinition("fieldName", String.class, fourthBtDataDef);
String field = "firstBelongsTo.secondBelongsTo.thirdBelongsTo.fourthBelongsTo.fieldName";
// when
final FieldDefinition res = GridComponentFilterUtils.getFieldDefinition(dataDefinition, field);
// then
assertEquals(fieldDefinition, res);
}
Aggregations