-
Notifications
You must be signed in to change notification settings - Fork 4
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
Q&A 관련 인프라 리팩토링 #686
Merged
Merged
Q&A 관련 인프라 리팩토링 #686
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b3cf424
feat: 도메인 영역에 질문 repository 추가
JJ503 19f99f5
refactor: EntityGraph를 jpql로 변경
JJ503 af41d6a
refactor: 사용하지 않는 클래스 제거
JJ503 ff3fc35
refactor: 잘못된 쿼리문 수정
JJ503 d29d1ec
feat: 도메인 영역에 질문 repository 구현체 추가
JJ503 a066181
refactor: service에서 도메인 영역의 질문 repository를 사용하도록 변경
JJ503 1adb983
test: 테스트에서 도메인 영역의 질문 repository를 사용하도록 변경
JJ503 e7869ed
refactor: 사용하지 않는 메서드 제거
JJ503 02cdd72
refactor: 쿼리문 명령는 대문자로 수정
JJ503 f9fb8e2
feat: 도메인 영역에 답변 repository 추가
JJ503 9ffb98c
feat: 도메인 영역에 답변 repository 구현체 추가
JJ503 7a9bc17
test: 테스트에서 도메인 영역의 답변 repository를 사용하도록 변경
JJ503 972cbd8
test: 테스트 실패 문제 해결
JJ503 0f9544b
fix: 잘못된 쿼리 조건 수정
JJ503 25cad81
test: 불필요한 로직 제거
JJ503 3ba1e67
refactor: final 누락 추가
JJ503 901e3f3
ci: 브랜치 최신화
JJ503 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 0 additions & 20 deletions
20
backend/ddang/src/main/java/com/ddang/ddang/qna/application/dto/QuestionDto.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
backend/ddang/src/main/java/com/ddang/ddang/qna/domain/repository/AnswerRepository.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,14 @@ | ||
package com.ddang.ddang.qna.domain.repository; | ||
|
||
import com.ddang.ddang.qna.domain.Answer; | ||
|
||
import java.util.Optional; | ||
|
||
public interface AnswerRepository { | ||
|
||
Answer save(final Answer answer); | ||
|
||
boolean existsByQuestionId(Long questionId); | ||
|
||
Optional<Answer> findById(final Long id); | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/ddang/src/main/java/com/ddang/ddang/qna/domain/repository/QuestionRepository.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,15 @@ | ||
package com.ddang.ddang.qna.domain.repository; | ||
|
||
import com.ddang.ddang.qna.domain.Question; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface QuestionRepository { | ||
|
||
Question save(final Question question); | ||
|
||
Optional<Question> findById(final Long id); | ||
|
||
List<Question> findAllByAuctionId(final Long auctionId); | ||
} |
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
31 changes: 31 additions & 0 deletions
31
backend/ddang/src/main/java/com/ddang/ddang/qna/infrastructure/QuestionRepositoryImpl.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,31 @@ | ||
package com.ddang.ddang.qna.infrastructure; | ||
|
||
import com.ddang.ddang.qna.domain.Question; | ||
import com.ddang.ddang.qna.domain.repository.QuestionRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class QuestionRepositoryImpl implements QuestionRepository { | ||
|
||
private final JpaQuestionRepository jpaQuestionRepository; | ||
|
||
@Override | ||
public Question save(final Question question) { | ||
return jpaQuestionRepository.save(question); | ||
} | ||
|
||
@Override | ||
public Optional<Question> findById(final Long id) { | ||
return jpaQuestionRepository.findByIdAndDeletedIsFalse(id); | ||
} | ||
|
||
@Override | ||
public List<Question> findAllByAuctionId(final Long auctionId) { | ||
return jpaQuestionRepository.findAllByAuctionId(auctionId); | ||
} | ||
} |
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
83 changes: 83 additions & 0 deletions
83
...nd/ddang/src/test/java/com/ddang/ddang/qna/infrastructure/QuestionRepositoryImplTest.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,83 @@ | ||
package com.ddang.ddang.qna.infrastructure; | ||
|
||
import com.ddang.ddang.configuration.JpaConfiguration; | ||
import com.ddang.ddang.configuration.QuerydslConfiguration; | ||
import com.ddang.ddang.qna.domain.Question; | ||
import com.ddang.ddang.qna.domain.repository.QuestionRepository; | ||
import com.ddang.ddang.qna.infrastructure.fixture.QuestionRepositoryImplFixture; | ||
import org.assertj.core.api.SoftAssertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
import org.junit.jupiter.api.DisplayNameGenerator; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.context.annotation.Import; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@DataJpaTest | ||
@Import({JpaConfiguration.class, QuerydslConfiguration.class}) | ||
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) | ||
@SuppressWarnings("NonAsciiCharacters") | ||
class QuestionRepositoryImplTest extends QuestionRepositoryImplFixture { | ||
|
||
QuestionRepository questionRepository; | ||
|
||
@BeforeEach | ||
void setUp(@Autowired final JpaQuestionRepository jpaQuestionRepository) { | ||
questionRepository = new QuestionRepositoryImpl(jpaQuestionRepository); | ||
} | ||
|
||
@Test | ||
void 질문을_저장한다() { | ||
// given | ||
final Question question = new Question(경매, 질문자, 질문_내용); | ||
|
||
// when | ||
final Question actual = questionRepository.save(question); | ||
|
||
// then | ||
assertThat(actual.getId()).isPositive(); | ||
} | ||
|
||
@Test | ||
void 삭제된_질문은_조회되지_않는다() { | ||
// when | ||
final Optional<Question> actual = questionRepository.findById(삭제된_질문.getId()); | ||
|
||
// then | ||
assertThat(actual).isEmpty(); | ||
} | ||
|
||
@Test | ||
void 삭제되지_않은_질문은_조회된다() { | ||
// when | ||
final Optional<Question> actual = questionRepository.findById(질문1.getId()); | ||
|
||
// then | ||
assertThat(actual).contains(질문1); | ||
} | ||
|
||
@Test | ||
void 경매_아이디를_통해_질문과_답변들을_모두_조회한다() { | ||
// when | ||
final List<Question> actual = questionRepository.findAllByAuctionId(질문이_3개_답변이_2개인_경매.getId()); | ||
|
||
System.out.println(actual.size()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 필수디버깅의 흔적이군요..ㅠㅠ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 으악 지웠습니다 |
||
|
||
// then | ||
SoftAssertions.assertSoftly(softAssertions -> { | ||
softAssertions.assertThat(actual).hasSize(3); | ||
softAssertions.assertThat(actual.get(0)).isEqualTo(질문1); | ||
softAssertions.assertThat(actual.get(0).getAnswer()).isEqualTo(답변1); | ||
softAssertions.assertThat(actual.get(1)).isEqualTo(질문2); | ||
softAssertions.assertThat(actual.get(1).getAnswer()).isEqualTo(답변2); | ||
softAssertions.assertThat(actual.get(2)).isEqualTo(질문3); | ||
softAssertions.assertThat(actual.get(2).getAnswer()).isNull(); | ||
}); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
필수
final이 누락되었습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
추가해두었습니다. 감사합니다.