Search in sources :

Example 11 with DataDefinition

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

the class GridComponentFilterUtilsTest method shouldFilterColumnWithTwoLevelsDeepPathInExpression.

@Test
public final void shouldFilterColumnWithTwoLevelsDeepPathInExpression() 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.get('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);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) DataDefinition(com.qcadoo.model.api.DataDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 12 with DataDefinition

use of com.qcadoo.model.api.DataDefinition 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);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) DataDefinition(com.qcadoo.model.api.DataDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 13 with DataDefinition

use of com.qcadoo.model.api.DataDefinition 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);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) DataDefinition(com.qcadoo.model.api.DataDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with DataDefinition

use of com.qcadoo.model.api.DataDefinition 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);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) DataDefinition(com.qcadoo.model.api.DataDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with DataDefinition

use of com.qcadoo.model.api.DataDefinition 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);
}
Also used : FieldDefinition(com.qcadoo.model.api.FieldDefinition) DataDefinition(com.qcadoo.model.api.DataDefinition) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DataDefinition (com.qcadoo.model.api.DataDefinition)415 Entity (com.qcadoo.model.api.Entity)285 Test (org.junit.Test)165 BigDecimal (java.math.BigDecimal)53 FieldDefinition (com.qcadoo.model.api.FieldDefinition)48 List (java.util.List)32 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)32 Service (org.springframework.stereotype.Service)31 Autowired (org.springframework.beans.factory.annotation.Autowired)27 Date (java.util.Date)26 Map (java.util.Map)26 Collectors (java.util.stream.Collectors)26 FormComponent (com.qcadoo.view.api.components.FormComponent)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)23 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)22 IOException (java.io.IOException)21 Objects (java.util.Objects)21 GridComponent (com.qcadoo.view.api.components.GridComponent)20 InternalViewDefinition (com.qcadoo.view.internal.api.InternalViewDefinition)20 Lists (com.google.common.collect.Lists)16