Skip to content

Commit

Permalink
[fix] : 수신자 bidder로 고정된 오류 해결 (#152)
Browse files Browse the repository at this point in the history
* [feat] : endDate에 시간 추가해 반환

* [fix] : receiver 구하는 메서드 오류 수정

* [test] : 경매 응답값 endDate 타입 변경 반영
  • Loading branch information
hyun2371 authored Mar 24, 2024
1 parent eb5c966 commit 1aba615
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void registerAuction() throws Exception {
.andExpect(jsonPath("$.description").value(request.description()))
.andExpect(jsonPath("$.productStatus").value(request.productStatus()))
.andExpect(jsonPath("$.tradeMethod").value(request.tradeMethod()))
.andExpect(jsonPath("$.endDate").value(request.endDate().toString()))
.andExpect(jsonPath("$.endDate").value(request.endDate().atStartOfDay().toString()))
.andExpect(jsonPath("$.initPrice").value(request.initPrice()))
.andExpect(jsonPath("$.purchaseTime").value(request.purchaseTime()))
.andExpect(jsonPath("$.productCategory").value(request.productCategory()))
Expand Down Expand Up @@ -117,7 +117,7 @@ void getAuctionDetail() throws Exception {
jsonPath("$.productCategory").value(product.getProductCategory().getValue()))
.andExpect(jsonPath("$.initPrice").value(auction.getInitPrice()))
.andExpect(jsonPath("$.currentBiddingPrice").value(auction.getCurrentBiddingPrice()))
.andExpect(jsonPath("$.endDate").value(auction.getEndDate().toString()))
.andExpect(jsonPath("$.endDate").value(auction.getEndDate().atStartOfDay().toString()))
.andExpect(jsonPath("$.productStatus").value(product.getStatus().getLabel()))
.andExpect(jsonPath("$.purchaseTime").value(product.getPurchaseTime().getLabel()))
.andExpect(jsonPath("$.description").value(product.getDescription()))
Expand Down Expand Up @@ -149,9 +149,9 @@ void getRecommendAuctionsWithFilter() throws Exception {
.andExpect(status().isOk())
.andExpect(jsonPath("$.size").value(2))
.andExpect(jsonPath("$.content[0].auctionId").value(auction2.getId()))
.andExpect(jsonPath("$.content[0].endDate").value(auction2.getEndDate().toString()))
.andExpect(jsonPath("$.content[0].endDate").value(auction2.getEndDate().atStartOfDay().toString()))
.andExpect(jsonPath("$.content[1].auctionId").value(auction1.getId()))
.andExpect(jsonPath("$.content[1].endDate").value(auction1.getEndDate().toString()))
.andExpect(jsonPath("$.content[1].endDate").value(auction1.getEndDate().atStartOfDay().toString()))
.andExpect(jsonPath("$.hasNext").value(false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static AuctionDetailResponse toAuctionDetailResponse(Auction auction) {
auction.getStatus().getLabel(),
auction.getInitPrice(),
auction.getCurrentBiddingPrice(),
auction.getEndDate().toString(),
auction.getEndDate().atStartOfDay().toString(),
product.getStatus().getLabel(),
product.getPurchaseTime().getLabel(),
product.getDescription(),
Expand Down Expand Up @@ -97,7 +97,7 @@ public static RecommendAuctionResponse toRecommendAuctionResponse(Auction auctio
auction.getBookmarkCount(),
auction.getBiddingCount(),
auction.getCreatedAt().toString(),
auction.getEndDate().toString()
auction.getEndDate().atStartOfDay().toString()
);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/dev/handsup/chat/domain/ChatRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static ChatRoom of(Long auctionId, User seller, User bidder, Long current
}

public User getReceiver(User sender) {
return this.seller.equals(sender) ? bidder : seller;
return this.seller.getId().equals(sender.getId()) ? bidder : seller;
}

public void updateCurrentBiddingId(Long currentBiddingId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ private ChatRoom getChatRoomById(Long chatRoomId) {
}

private User getReceiver(User user, ChatRoom chatRoom) {
return chatRoom.getBidder().equals(user) ? chatRoom.getSeller() : chatRoom.getBidder();
return chatRoom.getBidder().getId().equals(user.getId()) ? chatRoom.getSeller() : chatRoom.getBidder();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,11 @@ void registerAuction() {

// when
AuctionDetailResponse response = auctionService.registerAuction(request, UserFixture.user1());

// then
assertAll(
() -> assertThat(response.title()).isEqualTo(request.title()),
() -> assertThat(response.tradeMethod()).isEqualTo(request.tradeMethod()),
() -> assertThat(response.endDate()).isEqualTo(request.endDate().toString()),
() -> assertThat(response.endDate()).isEqualTo(request.endDate().atStartOfDay().toString()),
() -> assertThat(response.purchaseTime()).isEqualTo(request.purchaseTime()),
() -> assertThat(response.productCategory()).isEqualTo(request.productCategory())
);
Expand Down

0 comments on commit 1aba615

Please sign in to comment.