Code example for AbstractTransactionalTestNGSpringContextTests

Methods: assertTrue

0
        allowedBranchesIds.add(posts.get(0).getTopic().getBranch().getId()); 
 
        Page<Post> postsPage = dao.getUserPosts(author, pageRequest, allowedBranchesIds); 
 
        boolean asc = false; 
        assertTrue(isPostListSortedByDate(postsPage.getContent(), asc)); 
    } 
 
 
    private boolean isPostListSortedByDate(List<Post> postList, boolean asc) { 
        boolean result = false; 
        for (int i = 1; i < postList.size(); i++) { 
            DateTime creationDatePrevious = postList.get(i - 1).getCreationDate(); 
            DateTime creationDate = postList.get(i).getCreationDate(); 
            if (asc) { 
                result = creationDatePrevious.compareTo(creationDate) <= 0; 
                if (!result) break; 
            } else { 
                result = creationDatePrevious.compareTo(creationDate) >= 0; 
                if (!result) break;