Search in sources :

Example 11 with FieldDefinition

use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.

the class GridComponentFilterUtilsTest method shouldReturnFieldNameUsingExpressionWithTwoGet.

@Test
public final void shouldReturnFieldNameUsingExpressionWithTwoGet() {
    // 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('field')"));
    // when
    final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
    // then
    assertEquals("belongsTo.secondBelongsTo.field", fieldName);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with FieldDefinition

use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.

the class GridComponentFilterUtilsTest method shouldReturnNullForUnsupportedExpression2.

@Test
public final void shouldReturnNullForUnsupportedExpression2() {
    // given
    final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
    final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "'some' + ' concatenated ' + 'value'"));
    // when
    final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
    // then
    assertNull(fieldName);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with FieldDefinition

use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.

the class GridComponentFilterUtilsTest method shouldReturnFieldNameUsingSimpleExpressionWithOneGetBelongsToField.

@Test
public final void shouldReturnFieldNameUsingSimpleExpressionWithOneGetBelongsToField() {
    // given
    final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
    final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo.getBelongsToField('field')"));
    // when
    final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
    // then
    assertEquals("belongsTo.field", fieldName);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with FieldDefinition

use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.

the class GridComponentFilterUtilsTest method shouldReturnFieldNameUsingSimpleExpressionWithOneGetBooleanField.

@Test
public final void shouldReturnFieldNameUsingSimpleExpressionWithOneGetBooleanField() {
    // given
    final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
    final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo.getBooleanField('field')"));
    // when
    final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
    // then
    assertEquals("belongsTo.field", fieldName);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with FieldDefinition

use of com.qcadoo.model.api.FieldDefinition in project qcadoo by qcadoo.

the class GridComponentFilterUtilsTest method shouldReturnFieldNameUsingSimpleExpressionWithOneGetManyToManyField.

@Test
public final void shouldReturnFieldNameUsingSimpleExpressionWithOneGetManyToManyField() {
    // given
    final FieldDefinition fieldDefinition = mockFieldDefinition(TEST_FIELD, Object.class);
    final Map<String, GridComponentColumn> columns = ImmutableMap.of(TEST_COL, buildGridComponentColumn(TEST_COL, fieldDefinition, "#belongsTo.getManyToManyField('field')"));
    // when
    final String fieldName = GridComponentFilterUtils.getFieldNameByColumnName(columns, TEST_COL);
    // then
    assertEquals("belongsTo.getManyToManyField('field", fieldName);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

FieldDefinition (com.qcadoo.model.api.FieldDefinition)142 Test (org.junit.Test)92 DataDefinition (com.qcadoo.model.api.DataDefinition)49 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)48 Entity (com.qcadoo.model.api.Entity)32 BelongsToType (com.qcadoo.model.api.types.BelongsToType)19 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)15 InternalDataDefinition (com.qcadoo.model.internal.api.InternalDataDefinition)13 InternalFieldDefinition (com.qcadoo.model.internal.api.InternalFieldDefinition)12 TextInputComponentPattern (com.qcadoo.view.internal.components.TextInputComponentPattern)11 HasManyType (com.qcadoo.model.api.types.HasManyType)9 StringType (com.qcadoo.model.internal.types.StringType)9 JSONObject (org.json.JSONObject)8 Map (java.util.Map)7 Matchers.anyString (org.mockito.Matchers.anyString)7 SearchCriterion (com.qcadoo.model.api.search.SearchCriterion)6 DefaultEntity (com.qcadoo.model.internal.DefaultEntity)6 WindowComponentPattern (com.qcadoo.view.internal.components.window.WindowComponentPattern)6 Before (org.junit.Before)6 EntityList (com.qcadoo.model.api.EntityList)5