Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -55,7 +56,7 @@ public PostDto findOne(Long postId) {

//todo: fetch join (양방향 연관관계)
public PostListResponse findPosts(Long categoryId, Long hashTagId, int pageNum, int pageSize) {
Pageable pageable = PageRequest.of(pageNum, pageSize);
Pageable pageable = PageRequest.of(pageNum, pageSize, Sort.by("createAt").descending());
List<Long> categoryIds = null;
if (categoryId != null) {
Category category = categoryService.findOne(categoryId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class PostServiceTest {
//then
assertThat(response.getPosts()).hasSize(2);
assertThat(response.getPosts()).extracting("title").containsExactlyInAnyOrder("title1", "title2");
assertThat(response.getPosts().get(0).getHashTags()).extracting("name").containsExactly("tag1");
assertThat(response.getPosts().get(1).getHashTags()).extracting("name").containsExactly("tag1");
}

@Test
Expand Down