use of com.qcadoo.view.internal.components.grid.GridComponentOrderColumn in project qcadoo by qcadoo.
the class GridComponentStateTest method shouldInitializeWithoutData.
@Test
@SuppressWarnings("unchecked")
public void shouldInitializeWithoutData() throws Exception {
// given
GridComponentPattern pattern = mock(GridComponentPattern.class);
given(pattern.getColumns()).willReturn(columns);
given(pattern.getBelongsToFieldDefinition()).willReturn(null);
given(pattern.isActivable()).willReturn(false);
given(pattern.isWeakRelation()).willReturn(false);
ApplicationContext applicationContext = mock(ApplicationContext.class);
setField(pattern, "applicationContext", applicationContext);
SecurityRolesService securityRolesService = mock(SecurityRolesService.class);
given(applicationContext.getBean(SecurityRolesService.class)).willReturn(securityRolesService);
grid = new GridComponentState(productDataDefinition, pattern);
grid.setDataDefinition(substituteDataDefinition);
JSONObject json = new JSONObject(Collections.singletonMap(AbstractComponentState.JSON_CONTENT, new JSONObject()));
// when
grid.initialize(json, Locale.ENGLISH);
// then
assertNull(getField(grid, "belongsToFieldDefinition"));
assertNull(getField(grid, "selectedEntityId"));
assertNull(getField(grid, "belongsToEntityId"));
assertNull(getField(grid, "entities"));
assertEquals(0, getField(grid, "totalEntities"));
assertEquals(0, getField(grid, "firstResult"));
assertEquals(Integer.MAX_VALUE, getField(grid, "maxResults"));
assertTrue((Boolean) getField(grid, "filtersEnabled"));
List<GridComponentOrderColumn> orderColumns = (List<GridComponentOrderColumn>) getField(grid, "orderColumns");
assertEquals(0, orderColumns.size());
Map<String, String> filters = (Map<String, String>) getField(grid, "filters");
assertEquals(0, filters.size());
}
Aggregations