use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method mockBelongsToField.
private FieldDefinition mockBelongsToField(final String fieldName, final DataDefinition sourceDataDefinition, final DataDefinition targetDataDefinition) {
final FieldDefinition belongsToField = mock(FieldDefinition.class);
given(belongsToField.getName()).willReturn(fieldName);
final BelongsToType belongsToType = mock(BelongsToType.class);
given(belongsToField.getType()).willReturn(belongsToType);
given(belongsToType.getDataDefinition()).willReturn(targetDataDefinition);
given(sourceDataDefinition.getField(fieldName)).willReturn(belongsToField);
return belongsToField;
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldFilterColumnWithTwoLevelsDeepPathInExpressionWithBracketsAndSafetyNavOp.
@Test
public final void shouldFilterColumnWithTwoLevelsDeepPathInExpressionWithBracketsAndSafetyNavOp() throws GridComponentFilterException {
// given
DataDefinition firstBtDataDef = mock(DataDefinition.class);
FieldDefinition firstBtFieldDef = mockBelongsToField("firstBt", dataDefinition, firstBtDataDef);
DataDefinition secondBtDataDef = mock(DataDefinition.class);
mockBelongsToField("secondBt", firstBtDataDef, secondBtDataDef);
mockFieldDefinition(TEST_FIELD, Integer.class, secondBtDataDef);
// when
performFiltering("3", buildGridComponentColumn(TEST_COL, firstBtFieldDef, "#firstBt['secondBt']?.get('" + TEST_FIELD + "')"));
// then
PowerMockito.verifyStatic();
SearchRestrictions.eq("secondBt_a." + TEST_FIELD, 3);
PowerMockito.verifyStatic(never());
SearchRestrictions.eq(TEST_FIELD, 3);
SearchRestrictions.eq("firstBt_a." + TEST_FIELD, 3);
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldReturnFieldNameUsingExpressionWithSquareBracketAndTwoGet.
@Test
public final void shouldReturnFieldNameUsingExpressionWithSquareBracketAndTwoGet() {
// 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').get('field')"));
// when
final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
// then
assertEquals("belongsTo.secondBelongsTo.thirdBelongsTo.field", fieldName);
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldReturnFieldNameUsingExpressionWithSaveNavOperator4.
@Test
public final void shouldReturnFieldNameUsingExpressionWithSaveNavOperator4() {
// 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')?.get('field')"));
// when
final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
// then
assertEquals("belongsTo.secondBelongsTo.thirdBelongsTo.field", fieldName);
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldReturnFieldNameUsingSimpleExpressionWithOneGetDateField.
@Test
public final void shouldReturnFieldNameUsingSimpleExpressionWithOneGetDateField() {
// given
final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo.getDateField('field')"));
// when
final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
// then
assertEquals("belongsTo.field", fieldName);
}
Aggregations