-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Weekly/11/Test/like] Like리팩터링 및 Event Unit Test 수정 (#97)
* test: Event Unit Test 리팩터링 * feat: Like 리팩터링
- Loading branch information
Showing
8 changed files
with
98 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...dyouin/like/application/LikeResponse.java → ...in/like/application/dto/LikeResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/org/ktc2/cokaen/wouldyouin/like/application/dto/LikeToggleResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.ktc2.cokaen.wouldyouin.like.application.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.ktc2.cokaen.wouldyouin.member.persist.LikeableMember; | ||
|
||
@Getter | ||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Builder | ||
public class LikeToggleResponse { | ||
private final boolean isLiked; | ||
|
||
public static LikeToggleResponse from(boolean state) { | ||
return LikeToggleResponse.builder() | ||
.isLiked(state) | ||
.build(); | ||
} | ||
} |
14 changes: 12 additions & 2 deletions
14
src/main/java/org/ktc2/cokaen/wouldyouin/like/persist/LikeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
package org.ktc2.cokaen.wouldyouin.like.persist; | ||
|
||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import org.ktc2.cokaen.wouldyouin.member.persist.LikeableMember; | ||
import org.ktc2.cokaen.wouldyouin.member.persist.Member; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.NoRepositoryBean; | ||
|
||
@NoRepositoryBean | ||
public interface LikeRepository <LikeType extends Like<? extends LikeableMember>> extends JpaRepository<LikeType, Long> { | ||
|
||
Optional<LikeType> findByMemberAndLikeableMember(Member member, LikeableMember likeableMember); | ||
List<LikeType> findAllByMember(Member member); | ||
|
||
@Query("SELECT l FROM #{#entityName} l " + | ||
"JOIN FETCH l.member m " + | ||
"JOIN FETCH l.likeableMember lm " + | ||
"WHERE l.member.id = :member " + | ||
"AND l.id < :lastId " + | ||
"ORDER BY l.id DESC") | ||
Slice<LikeType> findAllByMember(Member member, Long lastId, Pageable pageable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/test/java/org/ktc2/cokaen/wouldyouin/like/LikeControllerUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.ktc2.cokaen.wouldyouin.like; | ||
|
||
public class LikeControllerUnitTest | ||
{ | ||
|
||
} |