-
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
신고 관련 테스트 코드 리팩토링 #493
신고 관련 테스트 코드 리팩토링 #493
Changes from all commits
31c1ab4
4db8216
395fede
ba18a02
b340ad5
a5d89aa
db60e12
65196e5
fc040fa
567b25e
36dc854
5296422
e64eb39
77f7545
9afd2c2
5dbec3c
911e4c1
7ea3afc
94e09f1
fb2be6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
package com.ddang.ddang.report.application.fixture; | ||
|
||
import com.ddang.ddang.auction.domain.Auction; | ||
import com.ddang.ddang.auction.domain.BidUnit; | ||
import com.ddang.ddang.auction.domain.Price; | ||
import com.ddang.ddang.auction.infrastructure.persistence.JpaAuctionRepository; | ||
import com.ddang.ddang.category.domain.Category; | ||
import com.ddang.ddang.category.infrastructure.persistence.JpaCategoryRepository; | ||
import com.ddang.ddang.image.domain.AuctionImage; | ||
import com.ddang.ddang.image.domain.ProfileImage; | ||
import com.ddang.ddang.image.infrastructure.persistence.JpaAuctionImageRepository; | ||
import com.ddang.ddang.image.infrastructure.persistence.JpaProfileImageRepository; | ||
import com.ddang.ddang.report.application.dto.CreateAuctionReportDto; | ||
import com.ddang.ddang.report.domain.AuctionReport; | ||
import com.ddang.ddang.report.infrastructure.persistence.JpaAuctionReportRepository; | ||
import com.ddang.ddang.user.domain.User; | ||
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class AuctionReportServiceFixture { | ||
|
||
@Autowired | ||
private JpaCategoryRepository categoryRepository; | ||
|
||
@Autowired | ||
private JpaProfileImageRepository profileImageRepository; | ||
|
||
@Autowired | ||
private JpaUserRepository userRepository; | ||
|
||
@Autowired | ||
private JpaAuctionImageRepository auctionImageRepository; | ||
|
||
@Autowired | ||
private JpaAuctionRepository auctionRepository; | ||
|
||
@Autowired | ||
private JpaAuctionReportRepository auctionReportRepository; | ||
|
||
protected User 이미_신고한_신고자1; | ||
protected User 이미_신고한_신고자2; | ||
protected User 이미_신고한_신고자3; | ||
protected Auction 경매; | ||
|
||
protected CreateAuctionReportDto 새로운_경매_신고_요청_dto; | ||
protected CreateAuctionReportDto 존재하지_않는_사용자의_경매_신고_요청_dto; | ||
protected CreateAuctionReportDto 존재하지_않는_경매_신고_요청_dto; | ||
protected CreateAuctionReportDto 판매자가_본인의_경매_신고_요청_dto; | ||
protected CreateAuctionReportDto 삭제된_경매_신고_요청_dto; | ||
protected CreateAuctionReportDto 이미_신고한_사용자가_경매_신고_요청_dto; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
final Long 존재하지_않는_사용자_아이디 = -9999L; | ||
final Long 존재하지_않는_경매_아이디 = -9999L; | ||
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. 필수엔초는 해당 변수들을 private 필드로 두었던데 확실히 통일시킬 필요가 있어보입니다! 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. 이건 저는 굳이 통일시켜야하는지 의문이 듭니다... Fixture의 가독성을 챙겨야 할까요? 만약 그럼에도 불구하고 통일시켜야 한다면... 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. 해당 부분 역시 굳이 통일시키지 않기로 했기에 따로 수정은 진행하지 않도록 하겠습니다! |
||
|
||
final ProfileImage 프로필_이미지 = new ProfileImage("프로필.jpg", "프로필.jpg"); | ||
final User 판매자 = User.builder() | ||
.name("판매자") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12345") | ||
.build(); | ||
final User 새로운_신고자 = User.builder() | ||
.name("새로운_신고자") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12346") | ||
.build(); | ||
이미_신고한_신고자1 = User.builder() | ||
.name("신고자1") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12347") | ||
.build(); | ||
이미_신고한_신고자2 = User.builder() | ||
.name("신고자2") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12348") | ||
.build(); | ||
이미_신고한_신고자3 = User.builder() | ||
.name("신고자3") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12349") | ||
.build(); | ||
Comment on lines
+63
to
+92
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. 한글이어서 그런 거였군요... 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. 한글인것때문에 안맞추기에는 다른 곳에는 다 맞추고 있어서...그냥 테스트 환경에서는 이걸 필수보다는 선택으로 하는게 나아 보이기는 하네요 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. 정렬 단축키라는 기능에 초점을 맞춘다면 저는 일단 한글이라는 이유로 특정 환경에서는 개행을 맞추지 않는다는게 저는 상당히 이질적으로 느껴집니다 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. 해당 부분은 회의 결과 픽스처의 경우 작성자가 편한대로 진행하기로 했기에 따로 수정은 진행하지 않도록 하겠습니다! |
||
|
||
final Category 전자기기_카테고리 = new Category("전자기기"); | ||
final Category 전자기기_서브_노트북_카테고리 = new Category("노트북 카테고리"); | ||
전자기기_카테고리.addSubCategory(전자기기_서브_노트북_카테고리); | ||
final AuctionImage 경매_이미지 = new AuctionImage("경매이미지.jpg", "경매이미지.jpg"); | ||
경매 = Auction.builder() | ||
.seller(판매자) | ||
.title("경매 상품") | ||
.description("이것은 경매 상품입니다.") | ||
.subCategory(전자기기_서브_노트북_카테고리) | ||
.bidUnit(new BidUnit(1_000)) | ||
.startPrice(new Price(1_000)) | ||
.closingTime(LocalDateTime.now()) | ||
.build(); | ||
경매.addAuctionImages(List.of(경매_이미지)); | ||
|
||
final Auction 삭제된_경매 = Auction.builder() | ||
.seller(판매자) | ||
.title("삭제된 경매 상품") | ||
.description("이것은 삭제된 경매 상품입니다.") | ||
.subCategory(전자기기_서브_노트북_카테고리) | ||
.bidUnit(new BidUnit(1_000)) | ||
.startPrice(new Price(1_000)) | ||
.closingTime(LocalDateTime.now()) | ||
.build(); | ||
삭제된_경매.addAuctionImages(List.of(경매_이미지)); | ||
삭제된_경매.delete(); | ||
Comment on lines
+98
to
+119
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. 필수여기도 체이닝이..!! |
||
|
||
final AuctionReport 경매_신고1 = new AuctionReport(이미_신고한_신고자1, 경매, "신고합니다"); | ||
final AuctionReport 경매_신고2 = new AuctionReport(이미_신고한_신고자2, 경매, "신고합니다"); | ||
final AuctionReport 경매_신고3 = new AuctionReport(이미_신고한_신고자3, 경매, "신고합니다"); | ||
|
||
profileImageRepository.save(프로필_이미지); | ||
userRepository.saveAll(List.of(판매자, 새로운_신고자, 이미_신고한_신고자1, 이미_신고한_신고자2, 이미_신고한_신고자3)); | ||
|
||
categoryRepository.saveAll(List.of(전자기기_카테고리, 전자기기_서브_노트북_카테고리)); | ||
auctionImageRepository.save(경매_이미지); | ||
auctionRepository.saveAll(List.of(경매, 삭제된_경매)); | ||
|
||
auctionReportRepository.saveAll(List.of(경매_신고1, 경매_신고2, 경매_신고3)); | ||
|
||
새로운_경매_신고_요청_dto = new CreateAuctionReportDto( | ||
경매.getId(), | ||
"신고합니다", | ||
새로운_신고자.getId() | ||
); | ||
존재하지_않는_사용자의_경매_신고_요청_dto = new CreateAuctionReportDto( | ||
경매.getId(), | ||
"신고합니다", | ||
존재하지_않는_사용자_아이디 | ||
); | ||
존재하지_않는_경매_신고_요청_dto = new CreateAuctionReportDto( | ||
존재하지_않는_경매_아이디, | ||
"신고합니다", | ||
새로운_신고자.getId() | ||
); | ||
판매자가_본인의_경매_신고_요청_dto = new CreateAuctionReportDto( | ||
경매.getId(), | ||
"신고합니다", | ||
판매자.getId() | ||
); | ||
삭제된_경매_신고_요청_dto = new CreateAuctionReportDto( | ||
삭제된_경매.getId(), | ||
"신고합니다", | ||
새로운_신고자.getId() | ||
); | ||
이미_신고한_사용자가_경매_신고_요청_dto = new CreateAuctionReportDto( | ||
경매.getId(), | ||
"신고합니다", | ||
이미_신고한_신고자1.getId() | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
package com.ddang.ddang.report.application.fixture; | ||
|
||
import com.ddang.ddang.auction.domain.Auction; | ||
import com.ddang.ddang.auction.domain.BidUnit; | ||
import com.ddang.ddang.auction.domain.Price; | ||
import com.ddang.ddang.auction.infrastructure.persistence.JpaAuctionRepository; | ||
import com.ddang.ddang.category.domain.Category; | ||
import com.ddang.ddang.category.infrastructure.persistence.JpaCategoryRepository; | ||
import com.ddang.ddang.chat.domain.ChatRoom; | ||
import com.ddang.ddang.chat.infrastructure.persistence.JpaChatRoomRepository; | ||
import com.ddang.ddang.image.domain.AuctionImage; | ||
import com.ddang.ddang.image.domain.ProfileImage; | ||
import com.ddang.ddang.image.infrastructure.persistence.JpaAuctionImageRepository; | ||
import com.ddang.ddang.image.infrastructure.persistence.JpaProfileImageRepository; | ||
import com.ddang.ddang.report.application.dto.CreateChatRoomReportDto; | ||
import com.ddang.ddang.report.domain.ChatRoomReport; | ||
import com.ddang.ddang.report.infrastructure.persistence.JpaChatRoomReportRepository; | ||
import com.ddang.ddang.user.domain.User; | ||
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class ChatRoomReportServiceFixture { | ||
|
||
@Autowired | ||
private JpaCategoryRepository categoryRepository; | ||
|
||
@Autowired | ||
private JpaProfileImageRepository profileImageRepository; | ||
|
||
@Autowired | ||
private JpaUserRepository userRepository; | ||
|
||
@Autowired | ||
private JpaAuctionImageRepository auctionImageRepository; | ||
|
||
@Autowired | ||
private JpaAuctionRepository auctionRepository; | ||
|
||
@Autowired | ||
private JpaChatRoomReportRepository chatRoomReportRepository; | ||
|
||
@Autowired | ||
private JpaChatRoomRepository chatRoomRepository; | ||
|
||
protected User 이미_신고한_구매자1; | ||
protected User 이미_신고한_구매자2; | ||
protected User 이미_신고한_구매자3; | ||
protected ChatRoom 채팅방1; | ||
protected ChatRoom 채팅방2; | ||
protected ChatRoom 채팅방3; | ||
|
||
protected CreateChatRoomReportDto 채팅방_신고_요청_dto; | ||
protected CreateChatRoomReportDto 존재하지_않는_사용자의_채팅방_신고_요청_dto; | ||
protected CreateChatRoomReportDto 존재하지_않는_채팅방_신고_요청_dto; | ||
protected CreateChatRoomReportDto 참여자가_아닌_사용자의_채팅방_신고_요청_dto; | ||
protected CreateChatRoomReportDto 이미_신고한_사용자의_채팅방_신고_요청_dto; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
final Long 존재하지_않는_사용자_아이디 = -9999L; | ||
final Long 존재하지_않는_채팅방_아이디 = -9999L; | ||
|
||
final ProfileImage 프로필_이미지 = new ProfileImage("프로필.jpg", "프로필.jpg"); | ||
final User 판매자 = User.builder() | ||
.name("판매자") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12345") | ||
.build(); | ||
final User 판매자겸_아직_신고하지_않은_신고자 = 판매자; | ||
이미_신고한_구매자1 = User.builder() | ||
.name("구매자1") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12346") | ||
.build(); | ||
이미_신고한_구매자2 = User.builder() | ||
.name("구매자2") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12347") | ||
.build(); | ||
이미_신고한_구매자3 = User.builder() | ||
.name("구매자3") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12348") | ||
.build(); | ||
final User 채팅방_참여자가_아닌_사용자 = User.builder() | ||
.name("채팅방_참여자가_아닌_사용자") | ||
.profileImage(프로필_이미지) | ||
.reliability(4.7d) | ||
.oauthId("12349") | ||
.build(); | ||
|
||
final Category 전자기기_카테고리 = new Category("전자기기"); | ||
final Category 전자기기_서브_노트북_카테고리 = new Category("노트북 카테고리"); | ||
전자기기_카테고리.addSubCategory(전자기기_서브_노트북_카테고리); | ||
final AuctionImage 경매_이미지 = new AuctionImage("경매이미지.jpg", "경매이미지.jpg"); | ||
final Auction 경매1 = Auction.builder() | ||
.seller(판매자겸_아직_신고하지_않은_신고자) | ||
.title("경매 상품") | ||
.description("이것은 경매 상품입니다.") | ||
.subCategory(전자기기_서브_노트북_카테고리) | ||
.bidUnit(new BidUnit(1_000)) | ||
.startPrice(new Price(1_000)) | ||
.closingTime(LocalDateTime.now()) | ||
.build(); | ||
경매1.addAuctionImages(List.of(경매_이미지)); | ||
final Auction 경매2 = Auction.builder() | ||
.seller(판매자겸_아직_신고하지_않은_신고자) | ||
.title("경매 상품") | ||
.description("이것은 경매 상품입니다.") | ||
.subCategory(전자기기_서브_노트북_카테고리) | ||
.bidUnit(new BidUnit(1_000)) | ||
.startPrice(new Price(1_000)) | ||
.closingTime(LocalDateTime.now()) | ||
.build(); | ||
경매2.addAuctionImages(List.of(경매_이미지)); | ||
final Auction 경매3 = Auction.builder() | ||
.seller(판매자겸_아직_신고하지_않은_신고자) | ||
.title("경매 상품") | ||
.description("이것은 경매 상품입니다.") | ||
.subCategory(전자기기_서브_노트북_카테고리) | ||
.bidUnit(new BidUnit(1_000)) | ||
.startPrice(new Price(1_000)) | ||
.closingTime(LocalDateTime.now()) | ||
.build(); | ||
Comment on lines
+105
to
+133
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. 필수여기도!! |
||
경매3.addAuctionImages(List.of(경매_이미지)); | ||
|
||
채팅방1 = new ChatRoom(경매1, 이미_신고한_구매자1); | ||
채팅방2 = new ChatRoom(경매2, 이미_신고한_구매자2); | ||
채팅방3 = new ChatRoom(경매3, 이미_신고한_구매자3); | ||
|
||
final ChatRoomReport 채팅방_신고1 = new ChatRoomReport(이미_신고한_구매자1, 채팅방1, "신고합니다."); | ||
final ChatRoomReport 채팅방_신고2 = new ChatRoomReport(이미_신고한_구매자2, 채팅방2, "신고합니다."); | ||
final ChatRoomReport 채팅방_신고3 = new ChatRoomReport(이미_신고한_구매자3, 채팅방3, "신고합니다."); | ||
|
||
profileImageRepository.save(프로필_이미지); | ||
userRepository.saveAll(List.of(판매자겸_아직_신고하지_않은_신고자, 이미_신고한_구매자1, 이미_신고한_구매자2, 이미_신고한_구매자3, 채팅방_참여자가_아닌_사용자)); | ||
|
||
categoryRepository.saveAll(List.of(전자기기_카테고리, 전자기기_서브_노트북_카테고리)); | ||
auctionImageRepository.save(경매_이미지); | ||
auctionRepository.saveAll(List.of(경매1, 경매2, 경매3)); | ||
|
||
chatRoomRepository.saveAll(List.of(채팅방1, 채팅방2, 채팅방3)); | ||
|
||
chatRoomReportRepository.saveAll(List.of(채팅방_신고1, 채팅방_신고2, 채팅방_신고3)); | ||
|
||
채팅방_신고_요청_dto = new CreateChatRoomReportDto( | ||
채팅방1.getId(), | ||
"신고합니다.", | ||
판매자겸_아직_신고하지_않은_신고자.getId() | ||
); | ||
존재하지_않는_사용자의_채팅방_신고_요청_dto = new CreateChatRoomReportDto( | ||
채팅방1.getId(), | ||
"신고합니다.", | ||
존재하지_않는_사용자_아이디 | ||
); | ||
존재하지_않는_채팅방_신고_요청_dto = new CreateChatRoomReportDto( | ||
존재하지_않는_채팅방_아이디, | ||
"신고합니다.", | ||
판매자겸_아직_신고하지_않은_신고자.getId() | ||
); | ||
참여자가_아닌_사용자의_채팅방_신고_요청_dto = new CreateChatRoomReportDto( | ||
채팅방1.getId(), | ||
"신고합니다.", | ||
채팅방_참여자가_아닌_사용자.getId() | ||
); | ||
이미_신고한_사용자의_채팅방_신고_요청_dto = new CreateChatRoomReportDto( | ||
채팅방1.getId(), | ||
"신고합니다.", | ||
이미_신고한_구매자1.getId() | ||
); | ||
} | ||
} |
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.
칭찬
칭찬해요@@@@@@@@@@@@@!#!@#!@#!#!@
아니 이런 오타가 있을 줄이야..?