Skip to content

Commit

Permalink
refactor: API 엔드포인트 수정 (#200)
Browse files Browse the repository at this point in the history
* refactor: 멤버 액션, 지출 액션 관련 API 엔드포인트 수정

* refactor: 요청 url에 token을 eventId로 수정

---------

Co-authored-by: 3juhwan <[email protected]>
Co-authored-by: Arachne <[email protected]>
  • Loading branch information
3 people authored Aug 5, 2024
1 parent 135fdd6 commit 475ca1b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BillActionController {

private final BillActionService billActionService;

@PostMapping("/api/events/{eventId}/actions/bills")
@PostMapping("/api/events/{eventId}/bill-actions")
public ResponseEntity<Void> saveAllBillAction(
@PathVariable("eventId") String token,
@RequestBody @Valid BillActionsSaveRequest request
Expand All @@ -30,7 +30,7 @@ public ResponseEntity<Void> saveAllBillAction(
.build();
}

@PutMapping("/api/events/{eventId}/actions/bills/{actionId}")
@PutMapping("/api/events/{eventId}/bill-actions/{actionId}")
public ResponseEntity<Void> updateBillAction(
@PathVariable("eventId") String token,
@PathVariable("actionId") Long actionId,
Expand All @@ -42,7 +42,7 @@ public ResponseEntity<Void> updateBillAction(
.build();
}

@DeleteMapping("/api/events/{eventId}/actions/{actionId}/bills")
@DeleteMapping("/api/events/{eventId}/bill-actions/{actionId}")
public ResponseEntity<Void> deleteBillAction(
@PathVariable("eventId") String token,
@PathVariable("actionId") Long actionId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class MemberActionController {

private final MemberActionService memberActionService;

@PostMapping("/api/events/{eventId}/actions/members")
@PostMapping("/api/events/{eventId}/member-actions")
public ResponseEntity<Void> saveMemberAction(
@PathVariable("eventId") String token,
@RequestBody MemberActionsSaveRequest request
Expand Down Expand Up @@ -48,7 +48,7 @@ public ResponseEntity<Void> deleteMember(
return ResponseEntity.ok().build();
}

@DeleteMapping("/api/events/{eventId}/actions/{actionId}/members")
@DeleteMapping("/api/events/{eventId}/member-actions/{actionId}")
public ResponseEntity<Void> deleteMemberAction(
@PathVariable("eventId") String token,
@PathVariable("actionId") Long actionId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void getMemberBillReports() throws Exception {

given(actionService.getMemberBillReports(any())).willReturn(memberBillReportAppResponses);

mockMvc.perform(get("/api/events/{token}/actions/reports", "token")
mockMvc.perform(get("/api/events/{eventId}/actions/reports", "망쵸토큰")
.accept(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ void saveAllBillAction() throws Exception {
)
);
String requestBody = objectMapper.writeValueAsString(request);
String token = "TOKEN";
String eventId = "쿠키토큰";

mockMvc.perform(post("/api/events/{token}/actions/bills", token)
mockMvc.perform(post("/api/events/{eventId}/bill-actions", eventId)
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
Expand All @@ -65,9 +65,9 @@ void saveAllBillAction1() throws Exception {
)
);
String requestBody = objectMapper.writeValueAsString(request);
String token = "TOKEN";
String eventId = "소하토큰";

mockMvc.perform(post("/api/events/{token}/actions/bills", token)
mockMvc.perform(post("/api/events/{eventId}/bill-actions", eventId)
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
Expand All @@ -80,9 +80,9 @@ void updateBillAction() throws Exception {
BillActionUpdateRequest request = new BillActionUpdateRequest("뽕족", 10_000L);

String requestBody = objectMapper.writeValueAsString(request);
String token = "TOKEN";
String eventId = "웨디토큰";

mockMvc.perform(put("/api/events/{token}/actions/bills/{actionId}", token, 1L)
mockMvc.perform(put("/api/events/{eventId}/bill-actions/{actionId}", eventId, 1L)
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
Expand All @@ -92,21 +92,21 @@ void updateBillAction() throws Exception {
@DisplayName("지출 내역을 삭제한다.")
@Test
void deleteBillAction() throws Exception {
String token = "토다리토큰";
String eventId = "토다리토큰";

mockMvc.perform(delete("/api/events/{token}/actions/{actionId}/bills", token, 1))
mockMvc.perform(delete("/api/events/{eventId}/bill-actions/{actionId}", eventId, 1))
.andDo(print())
.andExpect(status().isOk());
}

@DisplayName("존재하지 않는 행사에 대한 지출 내역을 삭제할 수 없다.")
@Test
void deleteBillAction1() throws Exception {
String token = "TOKEN19348";
String eventId = "이상해토큰";
doThrow(new HaengdongException(HaengdongErrorCode.NOT_FOUND_EVENT))
.when(billActionService).deleteBillAction(any(String.class), any(Long.class));

mockMvc.perform(delete("/api/events/{token}/actions/{actionId}/bills", token, 1))
mockMvc.perform(delete("/api/events/{eventId}/bill-actions/{actionId}", eventId, 1))
.andDo(print())
.andExpect(status().isBadRequest());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ class EventControllerTest {
void saveEvent() throws Exception {
EventSaveRequest eventSaveRequest = new EventSaveRequest("토다리");
String requestBody = objectMapper.writeValueAsString(eventSaveRequest);
String token = "TOKEN";
EventAppResponse eventAppResponse = new EventAppResponse(token);
String eventId = "망쵸토큰";
EventAppResponse eventAppResponse = new EventAppResponse(eventId);
given(eventService.saveEvent(any(EventAppRequest.class))).willReturn(eventAppResponse);

mockMvc.perform(post("/api/events")
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.eventId").value("TOKEN"));
.andExpect(jsonPath("$.eventId").value("망쵸토큰"));
}

@DisplayName("토큰으로 행사를 조회한다.")
@Test
void findEventTest() throws Exception {
String token = "TOKEN";
String eventId = "망쵸토큰";
EventDetailAppResponse eventDetailAppResponse = new EventDetailAppResponse("행동대장 회식");
given(eventService.findEvent(token)).willReturn(eventDetailAppResponse);
given(eventService.findEvent(eventId)).willReturn(eventDetailAppResponse);

mockMvc.perform(get("/api/events/" + token))
mockMvc.perform(get("/api/events/{eventId}", eventId))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.eventName").value("행동대장 회식"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void saveMemberActionTest() throws Exception {

String requestBody = objectMapper.writeValueAsString(memberActionsSaveRequest);

mockMvc.perform(post("/api/events/TOKEN/actions/members")
mockMvc.perform(post("/api/events/{eventId}/member-actions", "망쵸토큰")
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
Expand All @@ -58,7 +58,7 @@ void getCurrentMembers() throws Exception {

given(memberActionService.getCurrentMembers(any())).willReturn(currentMemberAppResponses);

mockMvc.perform(get("/api/events/{token}/members/current", "token")
mockMvc.perform(get("/api/events/{eventId}/members/current", "망쵸토큰")
.accept(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk())
Expand All @@ -69,18 +69,18 @@ void getCurrentMembers() throws Exception {
@DisplayName("이벤트에 속한 멤버 액션을 삭제하면 이후에 기록된 해당 참여자의 모든 멤버 액션을 삭제한다.")
@Test
void deleteMemberAction() throws Exception {
String token = "TOKEN";
String eventId = "망쵸토큰";
Long actionId = 2L;

mockMvc.perform(delete("/api/events/{token}/actions/{actionId}/members", token, actionId))
mockMvc.perform(delete("/api/events/{eventId}/member-actions/{actionId}", eventId, actionId))
.andDo(print())
.andExpect(status().isOk());
}

@DisplayName("행사의 전체 참여자 중에서 특정 참여자의 맴버 액션을 전부 삭제한다.")
@Test
void deleteMember() throws Exception {
String eventId = "TOKEN";
String eventId = "망쵸토큰";
String memberName = "행동대장";

mockMvc.perform(delete("/api/events/{eventId}/members/{memberName}", eventId, memberName))
Expand Down

0 comments on commit 475ca1b

Please sign in to comment.