Skip to content

Commit

Permalink
refactor: 입찰 금액 변수명 수정 (#72)
Browse files Browse the repository at this point in the history
* refactor: 입찰금액 변수 이름 변경

- amount -> bidAmount 로 수정

CHZZ-120

* test: 입찰금액 변수 이름 변경으로 인한 테스트 코드 수정

- amount -> bidAmount 로 수정

CHZZ-120
  • Loading branch information
junest66 authored Oct 3, 2024
1 parent 2cc52a7 commit 414a8e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public class BidCreateRequest {
private Long auctionId;

@ThousandMultiple(message = "1,000원 단위로 입력해주세요.")
private Long amount;
private Long bidAmount;

public Bid toEntity(Auction auction, User user) {
return Bid.builder()
.auction(auction)
.bidder(user)
.amount(amount)
.amount(bidAmount)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void createBid(final BidCreateRequest bidCreateRequest, Long userId) {
bidRepository.findByAuctionAndBidder(auction, user)
.ifPresentOrElse(
// 이미 입찰을 한 경우
bid -> bid.adjustBidAmount(bidCreateRequest.getAmount()),
bid -> bid.adjustBidAmount(bidCreateRequest.getBidAmount()),
// 입찰을 처음 하는 경우
() -> auction.registerBid(bidCreateRequest.toEntity(auction, user)) // 연관관계 설정
);
Expand Down Expand Up @@ -90,7 +90,7 @@ private void validateBidConditions(BidCreateRequest bidCreateRequest, Long userI
}
auction.validateAuctionEndTime();
// 최소 금액보다 낮은 금액일 때
if (!auction.isAboveMinPrice(bidCreateRequest.getAmount())) {
if (!auction.isAboveMinPrice(bidCreateRequest.getBidAmount())) {
throw new BidException(BID_BELOW_MIN_PRICE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void setUp() {
@DisplayName("성공 - 처음 입찰 한 경우")
public void firstBid_Success() throws Exception {
//given
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).amount(1000L).build();
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).bidAmount(1000L).build();
when(userRepository.findById(2L)).thenReturn(Optional.of(user2));
when(auctionRepository.findById(bidCreateRequest.getAuctionId())).thenReturn(Optional.ofNullable(auction));
when(bidRepository.findByAuctionAndBidder(auction, user2)).thenReturn(Optional.empty());
Expand All @@ -96,7 +96,7 @@ public void firstBid_Success() throws Exception {
@DisplayName("성공 - 이미 입찰 한 경우 업데이트")
public void updateBid_Success() throws Exception {
//given
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).amount(2000L).build();
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).bidAmount(2000L).build();
Bid bid = Bid.builder().id(1L).auction(auction).bidder(user2).amount(1000L).build();
when(userRepository.findById(2L)).thenReturn(Optional.of(user2));
when(auctionRepository.findById(bidCreateRequest.getAuctionId())).thenReturn(Optional.ofNullable(auction));
Expand All @@ -115,7 +115,7 @@ public void updateBid_Success() throws Exception {
@DisplayName("실패 - 경매 등록자가 입찰할 때 예외 발생")
public void ownerBid_ThrowsException() throws Exception {
// given
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).amount(1000L).build();
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).bidAmount(1000L).build();
when(userRepository.findById(1L)).thenReturn(Optional.of(user));
when(auctionRepository.findById(bidCreateRequest.getAuctionId())).thenReturn(Optional.ofNullable(auction));

Expand All @@ -130,7 +130,7 @@ public void ownerBid_ThrowsException() throws Exception {
@DisplayName("실패 - 경매가 상태가 진행이 아닐 때 예외 발생")
public void notProceeding_ThrowsException() throws Exception {
//given
bidCreateRequest = BidCreateRequest.builder().auctionId(2L).amount(1000L).build();
bidCreateRequest = BidCreateRequest.builder().auctionId(2L).bidAmount(1000L).build();
when(userRepository.findById(2L)).thenReturn(Optional.of(user2));
when(auctionRepository.findById(bidCreateRequest.getAuctionId())).thenReturn(
Optional.ofNullable(completeAuction));
Expand All @@ -147,7 +147,7 @@ public void notProceeding_ThrowsException() throws Exception {
@DisplayName("실패 - 입찰 시각이 종료시각을 지날 때 예외 발생")
public void auctionEnded_ThrowsException() throws Exception {
//given
bidCreateRequest = BidCreateRequest.builder().auctionId(3L).amount(1000L).build();
bidCreateRequest = BidCreateRequest.builder().auctionId(3L).bidAmount(1000L).build();
when(userRepository.findById(2L)).thenReturn(Optional.of(user2));
when(auctionRepository.findById(bidCreateRequest.getAuctionId())).thenReturn(Optional.ofNullable(endAuction));

Expand All @@ -162,7 +162,7 @@ public void auctionEnded_ThrowsException() throws Exception {
@DisplayName("실패 - 최소 금액보다 낮은 입찰 금액일때 예외 발생")
public void bidBelowMinPrice_ThrowsException() throws Exception {
//given
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).amount(500L).build();
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).bidAmount(500L).build();
when(userRepository.findById(2L)).thenReturn(Optional.of(user2));
when(auctionRepository.findById(bidCreateRequest.getAuctionId())).thenReturn(Optional.ofNullable(auction));

Expand All @@ -178,7 +178,7 @@ public void bidBelowMinPrice_ThrowsException() throws Exception {
public void bidCountZeroOrLess_ThrowsException() throws Exception {
//given
Bid bid = Bid.builder().id(1L).auction(auction).bidder(user2).amount(1000L).count(0).build();
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).amount(5000L).build();
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).bidAmount(5000L).build();
when(userRepository.findById(2L)).thenReturn(Optional.of(user2));
when(auctionRepository.findById(bidCreateRequest.getAuctionId())).thenReturn(Optional.ofNullable(auction));
when(bidRepository.findByAuctionAndBidder(auction, user2)).thenReturn(Optional.of(bid));
Expand All @@ -194,7 +194,7 @@ public void bidCountZeroOrLess_ThrowsException() throws Exception {
@DisplayName("실패 - 기존 입찰 금액과 동일한 입찰 금액인 경우")
public void asd() throws Exception {
//given
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).amount(1000L).build();
bidCreateRequest = BidCreateRequest.builder().auctionId(1L).bidAmount(1000L).build();
Bid bid = Bid.builder().id(1L).auction(auction).bidder(user2).amount(1000L).build();
when(userRepository.findById(2L)).thenReturn(Optional.of(user2));
when(auctionRepository.findById(bidCreateRequest.getAuctionId())).thenReturn(Optional.ofNullable(auction));
Expand Down

0 comments on commit 414a8e7

Please sign in to comment.