Search in sources :

Example 1 with PagingJsonResult

use of com.diboot.core.vo.PagingJsonResult in project diboot by dibo-software.

the class JsonTest method testJsonResult.

@Test
public void testJsonResult() {
    User user = new User();
    user.setId(123L);
    user.setUsername("zhangs").setCreateTime(new Date());
    user.setBirthdate(D.convert2Date("1988-09-12 12:34"));
    List<User> userList = new ArrayList<>();
    userList.add(user);
    Pagination pagination = new Pagination();
    pagination.setTotalCount(100).setPageIndex(2);
    JsonResult jsonResult = JsonResult.OK(userList).bindPagination(pagination);
    String jsonStr = JSON.toJSONString(jsonResult);
    PagingJsonResult pagingJsonResult = JSON.toJavaObject(jsonStr, PagingJsonResult.class);
    Assert.assertTrue(pagingJsonResult.getPage().getPageIndex() == 2);
    List<User> userList1 = (List<User>) pagingJsonResult.getData();
    Assert.assertTrue(userList1 != null && userList1.size() == 1);
}
Also used : Pagination(com.diboot.core.vo.Pagination) User(diboot.core.test.binder.entity.User) PagingJsonResult(com.diboot.core.vo.PagingJsonResult) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Date(java.util.Date) PagingJsonResult(com.diboot.core.vo.PagingJsonResult) JsonResult(com.diboot.core.vo.JsonResult) Test(org.junit.Test)

Aggregations

JsonResult (com.diboot.core.vo.JsonResult)1 Pagination (com.diboot.core.vo.Pagination)1 PagingJsonResult (com.diboot.core.vo.PagingJsonResult)1 User (diboot.core.test.binder.entity.User)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Test (org.junit.Test)1