Skip to content

Commit

Permalink
Merge pull request #66 from softeerbootcamp4th/feat/#41-admin-create
Browse files Browse the repository at this point in the history
Feat/#41 admin create
  • Loading branch information
wjddn2165 authored Aug 7, 2024
2 parents c56ce21 + 7c2cf98 commit 85188b8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import JGS.CasperEvent.domain.event.dto.RequestDto.AdminRequestDto;
import JGS.CasperEvent.domain.event.service.AdminService.AdminService;
import JGS.CasperEvent.global.response.ResponseDto;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
Expand All @@ -19,7 +20,7 @@ public AdminController(AdminService adminService) {
}

@PostMapping("/join")
public ResponseEntity<String> postAdmin(@RequestBody @Valid AdminRequestDto adminRequestDto){
public ResponseEntity<ResponseDto> postAdmin(@RequestBody @Valid AdminRequestDto adminRequestDto){
return ResponseEntity
.status(HttpStatus.CREATED)
.body(adminService.postAdmin(adminRequestDto));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import JGS.CasperEvent.global.enums.Role;
import JGS.CasperEvent.global.error.exception.CustomException;
import JGS.CasperEvent.global.jwt.dto.AdminLoginDto;
import JGS.CasperEvent.global.response.ResponseDto;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

Expand All @@ -21,9 +22,7 @@ public Admin verifyAdmin(AdminLoginDto adminLoginDto) {
return adminRepository.findById(adminLoginDto.getId()).orElseThrow(NoSuchElementException::new);
}

public String postAdmin(AdminRequestDto adminRequestDto) {


public ResponseDto postAdmin(AdminRequestDto adminRequestDto) {
String adminId = adminRequestDto.getAdminId();
//Todo: 비밀번호 암호화 필요
String password = adminRequestDto.getPassword();
Expand All @@ -33,6 +32,6 @@ public String postAdmin(AdminRequestDto adminRequestDto) {
if (admin != null) throw new CustomException("이미 등록된 ID입니다.", CustomErrorCode.CONFLICT);
adminRepository.save(new Admin(adminId, password, Role.ADMIN));

return "admin Created";
return ResponseDto.of("관리자 생성 성공");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class AdminControllerTest {
private MockMvc mockMvc;

@Nested
@DisplayName("캐스퍼 봇 생성 테스트")
@DisplayName("어드민 테스트")
class AdminTest{
@Test
@DisplayName("어드민 생성 성공 테스트")
Expand All @@ -48,7 +48,7 @@ void createAdminSuccessTest() throws Exception {
//then
perform
.andExpect(status().isCreated())
.andExpect(jsonPath("$.message").value("관리자 생성 완료"))
.andExpect(jsonPath("$.message").value("관리자 생성 성공"))
.andDo(print());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void createCasperBotSuccessTest() throws Exception {
""";

//when
ResultActions perform = mockMvc.perform(post("/event/lottery")
ResultActions perform = mockMvc.perform(post("/event/lottery/casperBot")
.contentType(MediaType.APPLICATION_JSON)
.content(casperBotRequest)
.header("Authorization", accessToken));
Expand Down Expand Up @@ -105,7 +105,7 @@ void createCasperBotFailureTest_RequiredFieldNotExist() throws Exception {


//when
ResultActions perform = mockMvc.perform(post("/event/lottery")
ResultActions perform = mockMvc.perform(post("/event/lottery/casperBot")
.contentType(MediaType.APPLICATION_JSON)
.content(casperBotRequest)
.header("Authorization", accessToken));
Expand Down Expand Up @@ -134,7 +134,7 @@ void createCasperBotSuccessTest_WrongValue() throws Exception {
}""";

//when
ResultActions perform = mockMvc.perform(post("/event/lottery")
ResultActions perform = mockMvc.perform(post("/event/lottery/casperBot")
.contentType(MediaType.APPLICATION_JSON)
.content(casperBotRequest)
.header("Authorization", accessToken));
Expand Down Expand Up @@ -162,7 +162,7 @@ void createCasperBotSuccessTest_CookieNotPresent() throws Exception {
""";

//when
ResultActions perform = mockMvc.perform(post("/event/lottery")
ResultActions perform = mockMvc.perform(post("/event/lottery/casperBot")
.contentType(MediaType.APPLICATION_JSON)
.content(casperBotRequest));

Expand Down Expand Up @@ -193,7 +193,7 @@ void userHasAppliedCasperBotSuccessTest_PresentUser() throws Exception {
}
""";
//when
mockMvc.perform(post("/event/lottery")
mockMvc.perform(post("/event/lottery/casperBot")
.contentType(MediaType.APPLICATION_JSON)
.content(casperBotRequest)
.header("Authorization", accessToken));
Expand Down

0 comments on commit 85188b8

Please sign in to comment.