-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from maeil-mail/173
์ํค ๋ฐ ๋ต๋ณ ์ญ์ ๊ธฐ๋ฅ์ ๊ตฌํํ๋ค.
- Loading branch information
Showing
15 changed files
with
347 additions
and
57 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
29 changes: 0 additions & 29 deletions
29
maeil-wiki/src/main/java/maeilwiki/comment/CommentApi.java
This file was deleted.
Oops, something went wrong.
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
7 changes: 3 additions & 4 deletions
7
maeil-wiki/src/main/java/maeilwiki/comment/CommentRequest.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,11 +1,10 @@ | ||
package maeilwiki.comment; | ||
|
||
import maeilwiki.member.Member; | ||
import maeilwiki.wiki.Wiki; | ||
|
||
record CommentRequest(String answer, boolean isAnonymous) { | ||
public record CommentRequest(String answer, boolean isAnonymous) { | ||
|
||
public Comment toComment(Member member, Wiki wiki) { | ||
return new Comment(answer, isAnonymous, member, wiki); | ||
public Comment toComment(Member member, Long wikiId) { | ||
return new Comment(answer, isAnonymous, member, wikiId); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package maeilwiki.wiki; | ||
|
||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface WikiRepository extends JpaRepository<Wiki, Long> { | ||
|
||
Optional<Wiki> findByIdAndDeletedAtIsNull(Long id); | ||
} |
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
60 changes: 60 additions & 0 deletions
60
maeil-wiki/src/test/java/maeilwiki/comment/CommentRepositoryTest.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,60 @@ | ||
package maeilwiki.comment; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertAll; | ||
|
||
import java.util.UUID; | ||
import maeilwiki.member.Member; | ||
import maeilwiki.member.MemberRepository; | ||
import maeilwiki.support.IntegrationTestSupport; | ||
import maeilwiki.wiki.Wiki; | ||
import maeilwiki.wiki.WikiRepository; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
class CommentRepositoryTest extends IntegrationTestSupport { | ||
|
||
@Autowired | ||
private WikiRepository wikiRepository; | ||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@Autowired | ||
private CommentRepository commentRepository; | ||
|
||
@Test | ||
@DisplayName("์ฃผ์ด์ง ์ํค์ ์ํ๋ ๋ต๋ณ์ด ์กด์ฌํ๋์ง ์กฐํํ๋ค.") | ||
void existsComment() { | ||
Member member = createMember(); | ||
Wiki wiki = createWiki(member); | ||
Wiki noCommentWiki = createWiki(member); | ||
createComment(member, wiki); | ||
Comment comment = createComment(member, noCommentWiki); | ||
comment.remove(); | ||
|
||
assertAll( | ||
() -> assertThat(commentRepository.existsByWikiIdAndDeletedAtIsNull(wiki.getId())).isTrue(), | ||
() -> assertThat(commentRepository.existsByWikiIdAndDeletedAtIsNull(noCommentWiki.getId())).isFalse() | ||
); | ||
} | ||
|
||
private Member createMember() { | ||
Member member = new Member(UUID.randomUUID().toString(), UUID.randomUUID().toString(), "GITHUB"); | ||
|
||
return memberRepository.save(member); | ||
} | ||
|
||
private Wiki createWiki(Member member) { | ||
Wiki wiki = new Wiki("question", "backend", false, member); | ||
|
||
return wikiRepository.save(wiki); | ||
} | ||
|
||
private Comment createComment(Member member, Wiki wiki) { | ||
Comment comment = new Comment("answer", false, member, wiki.getId()); | ||
|
||
return commentRepository.save(comment); | ||
} | ||
} |
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
Oops, something went wrong.