Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 수신 메시지가 없는 경우 메시지함 조회 Edge case 대응 #93

Merged
merged 2 commits into from
Sep 30, 2024
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 @@ -9,7 +9,7 @@

public interface RollingPaperRepository extends JpaRepository<RollingPaper, Long> {

@Query("SELECT r FROM RollingPaper r WHERE r.member.id IN :memberIds AND r.id < :targetId ORDER BY r.id DESC")
@Query("SELECT r FROM RollingPaper r WHERE r.member.id IN :memberIds AND r.id >= :targetId ORDER BY r.id DESC")
List<RollingPaper> findAllByMembersAfterCursor(@Param("memberIds") List<Long> memberIds,
@Param("targetId") Long targetId,
Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public ToyouResponse<RollingPaperResponse> findById(@UserAuthentication Long use

@GetMapping("/rollingpapers")
public ToyouResponse<List<RollingPaperResponse>> findReceivedRollingPapers(@UserAuthentication Long userId,
@RequestParam Long groupId,
@RequestParam Long targetId,
@RequestParam(required = false) Long groupId,
@RequestParam(defaultValue = "0") Long targetId,
@RequestParam(defaultValue = "10") int limit) {
return ToyouResponse.from(rollingPaperService.findReceivedRollingPapers(userId, groupId, targetId, limit));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;

import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
Expand All @@ -14,13 +12,11 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.transaction.annotation.Transactional;
import slvtwn.khu.toyouserver.domain.Group;
import slvtwn.khu.toyouserver.domain.Member;
import slvtwn.khu.toyouserver.domain.RollingPaper;
import slvtwn.khu.toyouserver.domain.User;
import slvtwn.khu.toyouserver.dto.CoverRequest;
import slvtwn.khu.toyouserver.dto.RollingPaperRequest;
import slvtwn.khu.toyouserver.dto.RollingPaperResponse;

Expand Down Expand Up @@ -125,7 +121,7 @@ class RollingPaperServiceTest {

// when
List<RollingPaperResponse> response = rollingPaperService.findReceivedRollingPapers(user.getId(), group.getId(),
rollingPaper.getId() + 1, 10);
0L, 10);

// then
assertThat(response).usingRecursiveComparison()
Expand Down Expand Up @@ -155,7 +151,7 @@ class RollingPaperServiceTest {
List<RollingPaperResponse> responseWithoutGroupId = rollingPaperService.findReceivedRollingPapers(
user.getId(),
null,
anotherRollingPaper.getId() + 1, 10);
0L, 10);

// then
assertThat(responseWithoutGroupId).usingRecursiveComparison()
Expand Down Expand Up @@ -188,7 +184,7 @@ class RollingPaperServiceTest {
List<RollingPaperResponse> responseWithGroupId = rollingPaperService.findReceivedRollingPapers(
user.getId(),
group1.getId(),
rollingPaper.getId() + 1, 10);
0L, 10);

// then
assertThat(responseWithGroupId).usingRecursiveComparison()
Expand Down Expand Up @@ -217,13 +213,11 @@ class RollingPaperServiceTest {
entityManager.persist(rollingPaper2);
entityManager.persist(rollingPaper3);

long totalRollingPapersCount = rollingPaper3.getId() + 1;

// when
List<RollingPaperResponse> response = rollingPaperService.findReceivedRollingPapers(
user.getId(),
group1.getId(),
totalRollingPapersCount, 10);
0L, 10);

// then
List<RollingPaperResponse> expectedResponse = List.of(
Expand Down Expand Up @@ -257,7 +251,7 @@ class RollingPaperServiceTest {
List<RollingPaperResponse> response = rollingPaperService.findReceivedRollingPapers(
user.getId(),
group.getId(),
rollingPaper3.getId() + 1, 10);
0L, 10);

// then
List<RollingPaperResponse> expectedResponse = List.of(
Expand Down