### Question:
UIPagedData extends UIComponentBase { @Override public void encodeEnd(FacesContext context) throws IOException { createPagedDataInRequestMap(context); super.encodeEnd(context); }  @Override String getFamily(); String getVar(); void setVar(String var); int getPageSize(); void setPageSize(int pageSize); String getSortColumn(); void setSortColumn(String sortColumn); Boolean getSortAscending(); void setSortAscending(Boolean sortAscending); @Override void restoreState(FacesContext context, Object state); @Override void encodeEnd(FacesContext context); static final String COMPONENT_FAMILY; }### Answer:
@Test public void shouldSetupPageDataOnEncodeEnd() throws Exception { this.uiPagedData.encodeEnd(this.context); assertThat(this.requestMap, hasKey("pagedData")); }
@Test @SuppressWarnings("rawtypes") public void shouldResorePreviouslySetPageRequest() throws Exception { this.requestMap.put("pageRequest", "custom"); this.uiPagedData.setValueExpression("value", mockExpression(Collections.singletonList("a"))); this.uiPagedData.encodeEnd(this.context); PagedDataRows rows = (PagedDataRows) this.requestMap.get("pagedData"); rows.setRowIndex(0); rows.getRowData(); assertThat(this.requestMap.get("pageRequest"), is(equalTo((Object) "custom"))); assertThat(this.pageRequest, is(not(nullValue()))); }
@Test @SuppressWarnings("rawtypes") public void shouldSupportPrimeFaces() throws Exception { this.uiPagedData.setValueExpression("value", mockExpression(Collections.singletonList("a"))); this.uiPagedData.setValueExpression("rowCount", mockExpression(100)); this.uiPagedData.encodeEnd(this.context); PagedDataRows rows = (PagedDataRows) this.requestMap.get("pagedData"); assertThat(rows, is(PrimeFacesPagedDataModel.class)); }
@Test @SuppressWarnings("rawtypes") public void shouldFailIfNullReturnedFromValueExpression() throws Exception { this.uiPagedData.setValueExpression("value", mockExpression(null)); this.uiPagedData.encodeEnd(this.context); PagedDataRows rows = (PagedDataRows) this.requestMap.get("pagedData"); rows.setRowIndex(0); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage("UIPageData value returned null result"); rows.getRowData(); }