use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldFilterColumnWithOneLevelDeepPathInExpression.
@Test
public final void shouldFilterColumnWithOneLevelDeepPathInExpression() 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 shouldReturnFieldNameUsingExpressionWithSaveNavOperator5.
@Test
public final void shouldReturnFieldNameUsingExpressionWithSaveNavOperator5() {
// given
final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo?.get('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 shouldFilterColumnWithThreeLevelsDeepPathInExpressionWithSafetyNavOp.
@Test
public final void shouldFilterColumnWithThreeLevelsDeepPathInExpressionWithSafetyNavOp() 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);
mockFieldDefinition(TEST_FIELD, Integer.class, thirdBtDataDef);
// when
performFiltering("3", buildGridComponentColumn(TEST_COL, firstBtFieldDef, "#firstBt?.get('secondBt')?.get('thirdBt')?.get('" + TEST_FIELD + "')"));
// then
PowerMockito.verifyStatic();
SearchRestrictions.eq("thirdBt_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);
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldFilterColumnWithThreeLevelsDeepPathInExpression.
@Test
public final void shouldFilterColumnWithThreeLevelsDeepPathInExpression() 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);
mockFieldDefinition(TEST_FIELD, Integer.class, thirdBtDataDef);
// when
performFiltering("3", buildGridComponentColumn(TEST_COL, firstBtFieldDef, "#firstBt.get('secondBt').get('thirdBt').get('" + TEST_FIELD + "')"));
// then
PowerMockito.verifyStatic();
SearchRestrictions.eq("thirdBt_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);
}
use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.
the class GridComponentFilterUtilsTest method shouldReturnFieldDefinitionForThreeLevelsDeepPath.
@Test
public final void shouldReturnFieldDefinitionForThreeLevelsDeepPath() {
// 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);
FieldDefinition fieldDefinition = mockFieldDefinition("fieldName", String.class, thirdBtDataDef);
String field = "firstBelongsTo.secondBelongsTo.thirdBelongsTo.fieldName";
// when
final FieldDefinition res = GridComponentFilterUtils.getFieldDefinition(dataDefinition, field);
// then
assertEquals(fieldDefinition, res);
}
Aggregations