diff --git a/server/src/main/java/server/haengdong/application/BillActionDetailService.java b/server/src/main/java/server/haengdong/application/BillActionDetailService.java index 5d4cf335a..aadddc00e 100644 --- a/server/src/main/java/server/haengdong/application/BillActionDetailService.java +++ b/server/src/main/java/server/haengdong/application/BillActionDetailService.java @@ -27,7 +27,7 @@ public BillActionDetailsAppResponse findBillActionDetails(String token, Long act BillAction billAction = billActionRepository.findByAction_Id(actionId) .orElseThrow(() -> new HaengdongException(HaengdongErrorCode.BILL_ACTION_NOT_FOUND)); validateToken(token, billAction); - + List<BillActionDetail> billActionDetails = billActionDetailRepository.findAllByBillAction(billAction); return BillActionDetailsAppResponse.of(billActionDetails); @@ -52,6 +52,7 @@ public void updateBillActionDetails(String token, Long actionId, BillActionDetai .orElseThrow(() -> new HaengdongException(HaengdongErrorCode.BILL_ACTION_DETAIL_NOT_FOUND)); detailToUpdate.updatePrice(updateRequest.price()); + detailToUpdate.updateIsFixed(updateRequest.isFixed()); } } diff --git a/server/src/main/java/server/haengdong/application/BillActionService.java b/server/src/main/java/server/haengdong/application/BillActionService.java index 95717d825..bf0e9e05c 100644 --- a/server/src/main/java/server/haengdong/application/BillActionService.java +++ b/server/src/main/java/server/haengdong/application/BillActionService.java @@ -57,7 +57,7 @@ private Action createStartAction(Event event) { private void saveBillActionDetails(BillAction billAction, CurrentMembers currentMembers) { long pricePerMember = billAction.getPrice() / currentMembers.size(); currentMembers.getMembers().stream() - .map(memberName -> new BillActionDetail(billAction, memberName, pricePerMember)) + .map(memberName -> new BillActionDetail(billAction, memberName, pricePerMember, false)) .forEach(billActionDetailRepository::save); } diff --git a/server/src/main/java/server/haengdong/application/MemberActionService.java b/server/src/main/java/server/haengdong/application/MemberActionService.java index 47d336c60..b5215688a 100644 --- a/server/src/main/java/server/haengdong/application/MemberActionService.java +++ b/server/src/main/java/server/haengdong/application/MemberActionService.java @@ -1,6 +1,8 @@ package server.haengdong.application; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -86,26 +88,49 @@ public void deleteMemberAction(String token, Long actionId) { .orElseThrow(() -> new HaengdongException(HaengdongErrorCode.MEMBER_ACTION_NOT_FOUND)); memberActionRepository.deleteAllByMemberNameAndMinSequence(memberAction.getMemberName(), - memberAction.getSequence()); + memberAction.getSequence()); List<BillAction> billActions = billActionRepository.findByEventAndGreaterThanSequence(event, - action.getSequence()); + action.getSequence()); billActions.forEach(billAction -> resetBillAction(event, billAction)); } private void resetBillAction(Event event, BillAction billAction) { List<MemberAction> memberActions = memberActionRepository.findByEventAndSequence(event, - billAction.getSequence()); + billAction.getSequence()); CurrentMembers currentMembers = CurrentMembers.of(memberActions); billActionDetailRepository.deleteAllByBillAction(billAction); if (currentMembers.isNotEmpty()) { - Long eachPrice = billAction.getPrice() / currentMembers.size(); - for (String member : currentMembers.getMembers()) { - BillActionDetail billActionDetail = new BillActionDetail(billAction, member, eachPrice); - billActionDetailRepository.save(billActionDetail); - } + Long price = billAction.getPrice(); + int currentMemberCount = currentMembers.size(); + long eachPrice = price / currentMemberCount; + long remainder = price % currentMemberCount; + List<BillActionDetail> billActionDetails = getBillActionDetails( + billAction, + currentMembers, + eachPrice, + remainder + ); + billActionDetailRepository.saveAll(billActionDetails); } } + + private List<BillActionDetail> getBillActionDetails( + BillAction billAction, + CurrentMembers currentMembers, + long eachPrice, + long remainder + ) { + List<String> members = currentMembers.getMembers().stream().toList(); + List<BillActionDetail> billActionDetails = IntStream.range(0, members.size() - 1) + .mapToObj(index -> new BillActionDetail(billAction, members.get(index), eachPrice, false)) + .collect(Collectors.toList()); + BillActionDetail lastBillActionDetail = new BillActionDetail(billAction, members.get(members.size() - 1), + eachPrice + remainder, false); + billActionDetails.add(lastBillActionDetail); + + return billActionDetails; + } } diff --git a/server/src/main/java/server/haengdong/application/request/BillActionDetailUpdateAppRequest.java b/server/src/main/java/server/haengdong/application/request/BillActionDetailUpdateAppRequest.java index a815e4afa..e514aee81 100644 --- a/server/src/main/java/server/haengdong/application/request/BillActionDetailUpdateAppRequest.java +++ b/server/src/main/java/server/haengdong/application/request/BillActionDetailUpdateAppRequest.java @@ -2,6 +2,7 @@ public record BillActionDetailUpdateAppRequest( String name, - Long price + Long price, + boolean isFixed ) { } diff --git a/server/src/main/java/server/haengdong/application/response/BillActionDetailAppResponse.java b/server/src/main/java/server/haengdong/application/response/BillActionDetailAppResponse.java index 1ddb51671..3efc7ac9d 100644 --- a/server/src/main/java/server/haengdong/application/response/BillActionDetailAppResponse.java +++ b/server/src/main/java/server/haengdong/application/response/BillActionDetailAppResponse.java @@ -4,10 +4,15 @@ public record BillActionDetailAppResponse( String name, - Long price + Long price, + boolean isFixed ) { public static BillActionDetailAppResponse of(BillActionDetail billActionDetail) { - return new BillActionDetailAppResponse(billActionDetail.getMemberName(), billActionDetail.getPrice()); + return new BillActionDetailAppResponse( + billActionDetail.getMemberName(), + billActionDetail.getPrice(), + billActionDetail.isFixed() + ); } } diff --git a/server/src/main/java/server/haengdong/domain/action/BillActionDetail.java b/server/src/main/java/server/haengdong/domain/action/BillActionDetail.java index 06847c2bb..ad13e6ab2 100644 --- a/server/src/main/java/server/haengdong/domain/action/BillActionDetail.java +++ b/server/src/main/java/server/haengdong/domain/action/BillActionDetail.java @@ -26,26 +26,21 @@ public class BillActionDetail { private Long price; - public BillActionDetail(String memberName, Long price) { - this.memberName = memberName; - this.price = price; - } + private boolean isFixed; - public BillActionDetail(BillAction billAction, String memberName, Long price) { + public BillActionDetail(BillAction billAction, String memberName, Long price, boolean isFixed) { this.billAction = billAction; this.memberName = memberName; this.price = price; + this.isFixed = isFixed; } - public BillActionDetail(Long id, BillAction billAction, String memberName, Long price) { - this.id = id; - this.billAction = billAction; - this.memberName = memberName; + public void updatePrice(Long price) { this.price = price; } - public void updatePrice(Long price) { - this.price = price; + public void updateIsFixed(boolean isFixed) { + this.isFixed = isFixed; } public boolean hasMemberName(String memberName) { diff --git a/server/src/main/java/server/haengdong/presentation/request/BillActionDetailUpdateRequest.java b/server/src/main/java/server/haengdong/presentation/request/BillActionDetailUpdateRequest.java index 2988f2ace..21c4bd60f 100644 --- a/server/src/main/java/server/haengdong/presentation/request/BillActionDetailUpdateRequest.java +++ b/server/src/main/java/server/haengdong/presentation/request/BillActionDetailUpdateRequest.java @@ -10,9 +10,12 @@ public record BillActionDetailUpdateRequest( String name, @NotNull(message = "지출 금액은 공백일 수 없습니다.") - Long price + Long price, + + @NotNull(message = "지출 금액은 공백일 수 없습니다.") + boolean isFixed ) { public BillActionDetailUpdateAppRequest toAppRequest() { - return new BillActionDetailUpdateAppRequest(this.name, this.price); + return new BillActionDetailUpdateAppRequest(this.name, this.price, this.isFixed); } } diff --git a/server/src/main/java/server/haengdong/presentation/response/BillActionDetailResponse.java b/server/src/main/java/server/haengdong/presentation/response/BillActionDetailResponse.java index 46d56438c..10f71b82e 100644 --- a/server/src/main/java/server/haengdong/presentation/response/BillActionDetailResponse.java +++ b/server/src/main/java/server/haengdong/presentation/response/BillActionDetailResponse.java @@ -4,10 +4,15 @@ public record BillActionDetailResponse( String name, - Long price + Long price, + boolean isFixed ) { public static BillActionDetailResponse of(BillActionDetailAppResponse billActionDetailAppResponse) { - return new BillActionDetailResponse(billActionDetailAppResponse.name(), billActionDetailAppResponse.price()); + return new BillActionDetailResponse( + billActionDetailAppResponse.name(), + billActionDetailAppResponse.price(), + billActionDetailAppResponse.isFixed() + ); } } diff --git a/server/src/test/java/server/haengdong/application/ActionServiceTest.java b/server/src/test/java/server/haengdong/application/ActionServiceTest.java index 389b426df..ee979b278 100644 --- a/server/src/test/java/server/haengdong/application/ActionServiceTest.java +++ b/server/src/test/java/server/haengdong/application/ActionServiceTest.java @@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.tuple; import static server.haengdong.domain.action.MemberActionStatus.IN; import static server.haengdong.domain.action.MemberActionStatus.OUT; +import static server.haengdong.support.fixture.Fixture.BILL_ACTION; import java.util.List; import org.junit.jupiter.api.DisplayName; @@ -54,15 +55,15 @@ void getMemberBillReports() { ); billActions.get(0).addDetails( List.of( - new BillActionDetail("소하", 10_000L), - new BillActionDetail("감자", 40_000L), - new BillActionDetail("쿠키", 10_000L) + new BillActionDetail(BILL_ACTION, "소하", 10_000L, false), + new BillActionDetail(BILL_ACTION, "감자", 40_000L, true), + new BillActionDetail(BILL_ACTION, "쿠키", 10_000L, false) ) ); billActions.get(1).addDetails( List.of( - new BillActionDetail("소하", 5_000L), - new BillActionDetail("쿠키", 15_000L) + new BillActionDetail(BILL_ACTION, "소하", 5_000L, true), + new BillActionDetail(BILL_ACTION, "쿠키", 15_000L, true) ) ); memberActionRepository.saveAll(memberActions); diff --git a/server/src/test/java/server/haengdong/application/BillActionDetailServiceTest.java b/server/src/test/java/server/haengdong/application/BillActionDetailServiceTest.java index 3e7aee56e..7074ce846 100644 --- a/server/src/test/java/server/haengdong/application/BillActionDetailServiceTest.java +++ b/server/src/test/java/server/haengdong/application/BillActionDetailServiceTest.java @@ -44,8 +44,8 @@ void findBillActionDetailsTest() { Action action = new Action(event1, 1L); BillAction billAction = new BillAction(action, "뽕족", 10000L); billActionRepository.save(billAction); - BillActionDetail billActionDetail1 = new BillActionDetail(1L, billAction, "토다리", 6000L); - BillActionDetail billActionDetail2 = new BillActionDetail(2L, billAction, "쿠키", 4000L); + BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "토다리", 6000L, true); + BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "쿠키", 4000L, true); billActionDetailRepository.saveAll(List.of(billActionDetail1, billActionDetail2)); BillActionDetailsAppResponse response = billActionDetailService.findBillActionDetails( @@ -67,13 +67,13 @@ void updateBillActionDetailsTest1() { Action action = new Action(event1, 1L); BillAction billAction = new BillAction(action, "뽕족", 10000L); billActionRepository.save(billAction); - BillActionDetail billActionDetail1 = new BillActionDetail(1L, billAction, "토다리", 5000L); - BillActionDetail billActionDetail2 = new BillActionDetail(2L, billAction, "쿠키", 5000L); + BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "토다리", 5000L, false); + BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "쿠키", 5000L, false); billActionDetailRepository.saveAll(List.of(billActionDetail1, billActionDetail2)); BillActionDetailsUpdateAppRequest request = new BillActionDetailsUpdateAppRequest(List.of( - new BillActionDetailUpdateAppRequest("토다리", 3000L), - new BillActionDetailUpdateAppRequest("쿠키", 4000L) + new BillActionDetailUpdateAppRequest("토다리", 3000L, true), + new BillActionDetailUpdateAppRequest("쿠키", 4000L, true) )); assertThatCode( () -> billActionDetailService.updateBillActionDetails(event1.getToken(), action.getId(), request)) @@ -89,13 +89,13 @@ void updateBillActionDetailsTest2() { Action action = new Action(event1, 1L); BillAction billAction = new BillAction(action, "뽕족", 10000L); billActionRepository.save(billAction); - BillActionDetail billActionDetail1 = new BillActionDetail(1L, billAction, "토다리", 5000L); - BillActionDetail billActionDetail2 = new BillActionDetail(2L, billAction, "쿠키", 5000L); + BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "토다리", 5000L, false); + BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "쿠키", 5000L, false); billActionDetailRepository.saveAll(List.of(billActionDetail1, billActionDetail2)); BillActionDetailsUpdateAppRequest request = new BillActionDetailsUpdateAppRequest(List.of( - new BillActionDetailUpdateAppRequest("토다리", 3000L), - new BillActionDetailUpdateAppRequest("쿠키", 7000L) + new BillActionDetailUpdateAppRequest("토다리", 3000L, true), + new BillActionDetailUpdateAppRequest("쿠키", 7000L, true) )); billActionDetailService.updateBillActionDetails(event1.getToken(), action.getId(), request); diff --git a/server/src/test/java/server/haengdong/application/BillActionServiceTest.java b/server/src/test/java/server/haengdong/application/BillActionServiceTest.java index c0e588288..39e52f80c 100644 --- a/server/src/test/java/server/haengdong/application/BillActionServiceTest.java +++ b/server/src/test/java/server/haengdong/application/BillActionServiceTest.java @@ -161,10 +161,10 @@ void updateBillAction2() { Event savedEvent = eventRepository.save(event); Action action = Action.createFirst(savedEvent); BillAction billAction = new BillAction(action, "뽕족", 10_000L); - BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "감자", 3000L); - BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "고구마", 2000L); - BillActionDetail billActionDetail3 = new BillActionDetail(billAction, "당근", 3000L); - BillActionDetail billActionDetail4 = new BillActionDetail(billAction, "양파", 2000L); + BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "감자", 3000L, true); + BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "고구마", 2000L, true); + BillActionDetail billActionDetail3 = new BillActionDetail(billAction, "당근", 3000L, true); + BillActionDetail billActionDetail4 = new BillActionDetail(billAction, "양파", 2000L, true); billAction.addDetails(List.of(billActionDetail1, billActionDetail2, billActionDetail3, billActionDetail4)); BillAction savedBillAction = billActionRepository.save(billAction); @@ -208,8 +208,8 @@ void deleteBillActionTest1() { MemberAction memberAction1 = new MemberAction(new Action(event, 1L), "백호", MemberActionStatus.IN, 1L); MemberAction memberAction2 = new MemberAction(new Action(event, 2L), "망쵸", MemberActionStatus.IN, 2L); BillAction billAction = new BillAction(new Action(event, 3L), "커피", 50_900L); - BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "백호", 25_450L); - BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "망쵸", 25_450L); + BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "백호", 25_450L, false); + BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "망쵸", 25_450L, false); memberActionRepository.saveAll(List.of(memberAction1, memberAction2)); billActionRepository.save(billAction); billActionDetailRepository.saveAll(List.of(billActionDetail1, billActionDetail2)); diff --git a/server/src/test/java/server/haengdong/application/MemberActionServiceTest.java b/server/src/test/java/server/haengdong/application/MemberActionServiceTest.java index 06368a9fb..b6d29444c 100644 --- a/server/src/test/java/server/haengdong/application/MemberActionServiceTest.java +++ b/server/src/test/java/server/haengdong/application/MemberActionServiceTest.java @@ -146,10 +146,12 @@ void deleteMember1() { ); BillAction billAction = new BillAction(new Action(event, 6L), "뽕족", 100_000L); billActionRepository.save(billAction); - BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "쿠키", 40_000L); - BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "웨디", 30_000L); - BillActionDetail billActionDetail3 = new BillActionDetail(billAction, "감자", 30_000L); + BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "쿠키", 40_000L, true); + BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "웨디", 30_000L, false); + BillActionDetail billActionDetail3 = new BillActionDetail(billAction, "감자", 30_000L, false); billActionDetailRepository.saveAll(List.of(billActionDetail1, billActionDetail2, billActionDetail3)); + List<BillActionDetail> allByBillAction = billActionDetailRepository.findAllByBillAction(billAction); + System.out.println("allByBillAction = " + allByBillAction.isEmpty()); memberActionService.deleteMember(event.getToken(), "쿠키"); @@ -220,9 +222,9 @@ void deleteMemberAction1() { ); BillAction billAction = new BillAction(new Action(event, 6L), "뽕족", 100_000L); billActionRepository.save(billAction); - BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "쿠키", 40_000L); - BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "웨디", 30_000L); - BillActionDetail billActionDetail3 = new BillActionDetail(billAction, "감자", 30_000L); + BillActionDetail billActionDetail1 = new BillActionDetail(billAction, "쿠키", 40_000L, true); + BillActionDetail billActionDetail2 = new BillActionDetail(billAction, "웨디", 30_000L, false); + BillActionDetail billActionDetail3 = new BillActionDetail(billAction, "감자", 30_000L, false); billActionDetailRepository.saveAll(List.of(billActionDetail1, billActionDetail2, billActionDetail3)); memberActionService.deleteMemberAction(event.getToken(), targetAction.getId()); diff --git a/server/src/test/java/server/haengdong/docs/BillActionDetailControllerDocsTest.java b/server/src/test/java/server/haengdong/docs/BillActionDetailControllerDocsTest.java index 3116cba5e..f492195f3 100644 --- a/server/src/test/java/server/haengdong/docs/BillActionDetailControllerDocsTest.java +++ b/server/src/test/java/server/haengdong/docs/BillActionDetailControllerDocsTest.java @@ -47,7 +47,7 @@ protected Object initController() { @Test void findBillActionDetailsTest() throws Exception { BillActionDetailsAppResponse appResponse = new BillActionDetailsAppResponse( - List.of(new BillActionDetailAppResponse("토다리", 1000L))); + List.of(new BillActionDetailAppResponse("토다리", 1000L, false))); given(billActionDetailService.findBillActionDetails(anyString(), anyLong())) .willReturn(appResponse); @@ -58,6 +58,7 @@ void findBillActionDetailsTest() throws Exception { .andExpect(jsonPath("$.members").isArray()) .andExpect(jsonPath("$.members[0].name").value("토다리")) .andExpect(jsonPath("$.members[0].price").value(1000L)) + .andExpect(jsonPath("$.members[0].isFixed").value(false)) .andDo( document("findBillActionDetailsTest", preprocessRequest(prettyPrint()), @@ -73,7 +74,9 @@ void findBillActionDetailsTest() throws Exception { fieldWithPath("members[0].name").type(JsonFieldType.STRING) .description("참여자 이름"), fieldWithPath("members[0].price").type(JsonFieldType.NUMBER) - .description("참여자 정산 금액") + .description("참여자 정산 금액"), + fieldWithPath("members[0].isFixed").type(JsonFieldType.BOOLEAN) + .description("참여자 정산 금액 수정 여부") ) ) ); @@ -83,8 +86,8 @@ void findBillActionDetailsTest() throws Exception { @Test void updateBillActionDetailsTest() throws Exception { List<BillActionDetailUpdateRequest> billActionDetailUpdateRequests = List.of( - new BillActionDetailUpdateRequest("소하", 10000L), - new BillActionDetailUpdateRequest("웨디", 20000L) + new BillActionDetailUpdateRequest("소하", 10000L, true), + new BillActionDetailUpdateRequest("웨디", 20000L, true) ); BillActionDetailsUpdateRequest request = new BillActionDetailsUpdateRequest( billActionDetailUpdateRequests); @@ -114,7 +117,9 @@ void updateBillActionDetailsTest() throws Exception { fieldWithPath("members[0].name").type(JsonFieldType.STRING) .description("참여자 이름"), fieldWithPath("members[0].price").type(JsonFieldType.NUMBER) - .description("참여자 정산 금액") + .description("참여자 정산 금액"), + fieldWithPath("members[0].isFixed").type(JsonFieldType.BOOLEAN) + .description("참여자 정산 금액 수정 여부") ) ) ); diff --git a/server/src/test/java/server/haengdong/domain/action/BillActionTest.java b/server/src/test/java/server/haengdong/domain/action/BillActionTest.java index f95558606..ba1ab36f2 100644 --- a/server/src/test/java/server/haengdong/domain/action/BillActionTest.java +++ b/server/src/test/java/server/haengdong/domain/action/BillActionTest.java @@ -3,6 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertAll; +import static server.haengdong.support.fixture.Fixture.BILL_ACTION; import static server.haengdong.support.fixture.Fixture.EVENT1; import java.util.List; @@ -64,8 +65,8 @@ void isFixed1() { BillAction fixedBillAction = new BillAction(new Action(EVENT1, 1L), "인생네컷", 2_000L); List<BillActionDetail> unfixedBillActionDetails = List.of( - new BillActionDetail("감자", 1_000L), - new BillActionDetail("고구마", 1_000L) + new BillActionDetail(BILL_ACTION, "감자", 1_000L, false), + new BillActionDetail(BILL_ACTION, "고구마", 1_000L, false) ); fixedBillAction.addDetails(unfixedBillActionDetails); @@ -78,8 +79,8 @@ void isFixed2() { BillAction fixedBillAction = new BillAction(new Action(EVENT1, 1L), "인생네컷", 5_000L); List<BillActionDetail> unfixedBillActionDetails = List.of( - new BillActionDetail("감자", 4_000L), - new BillActionDetail("고구마", 1_000L) + new BillActionDetail(BILL_ACTION, "감자", 4_000L, true), + new BillActionDetail(BILL_ACTION, "고구마", 1_000L, true) ); fixedBillAction.addDetails(unfixedBillActionDetails); diff --git a/server/src/test/java/server/haengdong/domain/action/MemberBillReportTest.java b/server/src/test/java/server/haengdong/domain/action/MemberBillReportTest.java index 12451435b..02070a537 100644 --- a/server/src/test/java/server/haengdong/domain/action/MemberBillReportTest.java +++ b/server/src/test/java/server/haengdong/domain/action/MemberBillReportTest.java @@ -3,6 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static server.haengdong.domain.action.MemberActionStatus.IN; import static server.haengdong.domain.action.MemberActionStatus.OUT; +import static server.haengdong.support.fixture.Fixture.BILL_ACTION; import java.util.List; import java.util.Map; @@ -23,15 +24,15 @@ void createByActions() { ); billActions.get(0).addDetails( List.of( - new BillActionDetail("소하", 10_000L), - new BillActionDetail("감자", 40_000L), - new BillActionDetail("쿠키", 10_000L) + new BillActionDetail(BILL_ACTION, "소하", 10_000L, false), + new BillActionDetail(BILL_ACTION, "감자", 40_000L, true), + new BillActionDetail(BILL_ACTION, "쿠키", 10_000L, false) ) ); billActions.get(1).addDetails( List.of( - new BillActionDetail("소하", 5_000L), - new BillActionDetail("쿠키", 15_000L) + new BillActionDetail(BILL_ACTION, "소하", 5_000L, true), + new BillActionDetail(BILL_ACTION, "쿠키", 15_000L, true) ) ); List<MemberAction> memberActions = List.of( diff --git a/server/src/test/java/server/haengdong/presentation/BillActionDetailControllerTest.java b/server/src/test/java/server/haengdong/presentation/BillActionDetailControllerTest.java index f098153d4..6b595ee27 100644 --- a/server/src/test/java/server/haengdong/presentation/BillActionDetailControllerTest.java +++ b/server/src/test/java/server/haengdong/presentation/BillActionDetailControllerTest.java @@ -24,7 +24,7 @@ class BillActionDetailControllerTest extends ControllerTestSupport { @Test void findBillActionDetails() throws Exception { BillActionDetailsAppResponse appResponse = new BillActionDetailsAppResponse( - List.of(new BillActionDetailAppResponse("토다리", 1000L))); + List.of(new BillActionDetailAppResponse("토다리", 1000L, false))); given(billActionDetailService.findBillActionDetails(anyString(), anyLong())) .willReturn(appResponse); @@ -39,8 +39,8 @@ void findBillActionDetails() throws Exception { @Test void updateBillActionDetailsTest() throws Exception { List<BillActionDetailUpdateRequest> billActionDetailUpdateRequests = List.of( - new BillActionDetailUpdateRequest("소하", 10000L), - new BillActionDetailUpdateRequest("웨디", 20000L) + new BillActionDetailUpdateRequest("소하", 10000L, true), + new BillActionDetailUpdateRequest("웨디", 20000L, true) ); BillActionDetailsUpdateRequest request = new BillActionDetailsUpdateRequest( billActionDetailUpdateRequests); diff --git a/server/src/test/java/server/haengdong/support/fixture/Fixture.java b/server/src/test/java/server/haengdong/support/fixture/Fixture.java index fea2bd69a..6844915d9 100644 --- a/server/src/test/java/server/haengdong/support/fixture/Fixture.java +++ b/server/src/test/java/server/haengdong/support/fixture/Fixture.java @@ -1,6 +1,8 @@ package server.haengdong.support.fixture; import jakarta.servlet.http.Cookie; +import server.haengdong.domain.action.Action; +import server.haengdong.domain.action.BillAction; import server.haengdong.domain.event.Event; public class Fixture { @@ -8,4 +10,6 @@ public class Fixture { public static final Event EVENT1 = new Event("쿠키", "1234", "TOKEN1"); public static final Event EVENT2 = new Event("웨디", "1234", "TOKEN2"); public static final Cookie EVENT_COOKIE = new Cookie("eventToken", "토큰토큰"); + public static final Action ACTION = new Action(EVENT1, 1L); + public static final BillAction BILL_ACTION = new BillAction(ACTION, "뽕족", 30_000L); }