Skip to content

Commit

Permalink
refactor: DTO 클래스명 리팩터링
Browse files Browse the repository at this point in the history
  • Loading branch information
kunsanglee committed Jul 20, 2024
1 parent 14b730c commit a6c7b70
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package server.haengdong.application.request;

import java.util.List;

public record MemberActionsSaveAppRequest(List<MemberActionSaveAppRequest> actions) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import server.haengdong.application.MemberActionService;
import server.haengdong.presentation.request.MemberActionSaveListRequest;
import server.haengdong.presentation.request.MemberActionsSaveRequest;

@RequiredArgsConstructor
@RestController
Expand All @@ -18,7 +18,7 @@ public class MemberActionController {
@PostMapping("/api/events/{token}/actions/members")
public ResponseEntity<Void> saveMemberAction(
@PathVariable("token") String token,
@RequestBody MemberActionSaveListRequest request
@RequestBody MemberActionsSaveRequest request
) {
memberActionService.saveMemberAction(token, request.toAppRequest());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import java.util.List;
import server.haengdong.application.request.MemberActionSaveAppRequest;
import server.haengdong.application.request.MemberActionSaveListAppRequest;
import server.haengdong.application.request.MemberActionsSaveAppRequest;

public record MemberActionSaveListRequest(List<MemberActionSaveRequest> actions) {
public record MemberActionsSaveRequest(List<MemberActionSaveRequest> actions) {

public MemberActionSaveListAppRequest toAppRequest() {
public MemberActionsSaveAppRequest toAppRequest() {
List<MemberActionSaveAppRequest> appRequests = actions.stream()
.map(MemberActionSaveRequest::toAppRequest)
.toList();

return new MemberActionSaveListAppRequest(appRequests);
return new MemberActionsSaveAppRequest(appRequests);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ class EventControllerTest {
@MockBean
private EventService eventService;

@DisplayName("이벤트를 생성한다")
@DisplayName("이벤트를 생성한다.")
@Test
void saveEvent() throws Exception {
EventSaveRequest eventSaveRequest = new EventSaveRequest("test");
EventSaveRequest eventSaveRequest = new EventSaveRequest("토다리");
String requestBody = objectMapper.writeValueAsString(eventSaveRequest);
String token = "TOKEN";
EventAppResponse eventAppResponse = new EventAppResponse(token);
given(eventService.saveEvent(any(EventAppRequest.class))).willReturn(eventAppResponse);

mockMvc.perform(post("/api/events")
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
.andExpect(status().isOk())
.andExpect(MockMvcResultMatchers.redirectedUrl("events/" + token));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import server.haengdong.application.MemberActionService;
import server.haengdong.presentation.request.MemberActionSaveListRequest;
import server.haengdong.presentation.request.MemberActionSaveRequest;

import server.haengdong.presentation.request.MemberActionsSaveRequest;

@WebMvcTest(MemberActionController.class)
class MemberActionControllerTest {
Expand All @@ -30,20 +29,20 @@ class MemberActionControllerTest {
@MockBean
private MemberActionService memberActionService;

@DisplayName("참여자 행동을 추가한다")
@DisplayName("참여자 행동을 추가한다.")
@Test
void saveMemberActionTest() throws Exception {
MemberActionSaveListRequest memberActionSaveListRequest = new MemberActionSaveListRequest(List.of(
new MemberActionSaveRequest("망쵸", "IN"),
new MemberActionSaveRequest("이상", "IN"),
new MemberActionSaveRequest("백호", "IN"),
new MemberActionSaveRequest("감자", "IN")));
MemberActionsSaveRequest memberActionsSaveRequest = new MemberActionsSaveRequest(List.of(
new MemberActionSaveRequest("웨디", "IN"),
new MemberActionSaveRequest("소하", "IN"),
new MemberActionSaveRequest("토다리", "IN"),
new MemberActionSaveRequest("쿠키", "IN")));

String requestBody = objectMapper.writeValueAsString(memberActionSaveListRequest);
String requestBody = objectMapper.writeValueAsString(memberActionsSaveRequest);

mockMvc.perform(post("/api/events/TOKEN/actions/members")
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.contentType(MediaType.APPLICATION_JSON)
.content(requestBody))
.andDo(print())
.andExpect(status().isOk());
}
Expand Down

0 comments on commit a6c7b70

Please sign in to comment.