Skip to content

Commit

Permalink
Merge pull request #93 from Princess-in-silvertown/fix/92
Browse files Browse the repository at this point in the history
Fix: μˆ˜μ‹  λ©”μ‹œμ§€κ°€ μ—†λŠ” 경우 λ©”μ‹œμ§€ν•¨ 쑰회 Edge case λŒ€μ‘
  • Loading branch information
loveysuby authored Sep 30, 2024
2 parents a68fd59 + 59bad16 commit c50606a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
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

0 comments on commit c50606a

Please sign in to comment.