Skip to content

Commit

Permalink
chore: 테스트코드 텍스트블록으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
k000927 committed Jul 31, 2024
1 parent 71b9e1b commit da87a20
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class LotteryEventController {
@PostMapping
public ResponseEntity<CustomResponse<GetCasperBot>> postCasperBot(@CookieValue String userData,
@RequestBody String body) {

return new ResponseEntity<>(CustomResponse.create(lotteryEventService.postCasperBot(userData, body)), HttpStatus.CREATED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static JGS.CasperEvent.global.response.CustomResponse.response;

@RestController
@RequestMapping("/health")
public class HealthController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ public class LotteryEventControllerTest {
@DisplayName("캐스퍼 봇 생성 성공 테스트")
void createCasperBotSuccessTest() throws Exception {
//given
String casperBotRequest = "{\n" +
"\"eyeShape\": \"2\",\n" +
"\"eyePosition\": \"1\",\n" +
"\"mouthShape\": \"4\",\n" +
"\"color\": \"2\",\n" +
"\"sticker\": \"4\",\n" +
"\"name\": \"myCasperBot\",\n" +
"\"expectation\": \"myExpectation\"\n" + "}";
String casperBotRequest = """
{
"eyeShape": "2",
"eyePosition": "1",
"mouthShape": "4",
"color": "2",
"sticker": "4",
"name": "myCasperBot",
"expectation": "myExpectation"
}""";

Cookie myCookie = new Cookie("userData", "abc");

Expand Down Expand Up @@ -64,13 +66,16 @@ void createCasperBotSuccessTest() throws Exception {
@DisplayName("캐스퍼 봇 생성 실패 테스트 - 필수 필드 없음")
void createCasperBotFailureTest_RequiredFieldNotExist() throws Exception {
//given
String casperBotRequest = "{" +
"\"eye_shape\": \"2\"," +
"\"eye_position\": \"1\"," +
"\"mouth_shape\": \"4\"," +
"\"color\": \"2\"," +
"\"sticker\": \"4\"," +
"\"expectation\": \"myExpectation\"" + "}";
String casperBotRequest = """
{
"eye_shape": "2",
"eye_position": "1",
"mouth_shape": "4",
"color": "2",
"sticker": "4",
"expectation": "myExpectation"
}
""";

Cookie myCookie = new Cookie("userData", "abc");

Expand All @@ -90,14 +95,16 @@ void createCasperBotFailureTest_RequiredFieldNotExist() throws Exception {
@DisplayName("캐스퍼 봇 생성 실패 테스트 - 잘못된 값")
void createCasperBotSuccessTest_WrongValue() throws Exception {
//given
String casperBotRequest = "{" +
"\"eyeShape\": \"15\"," +
"\"eyePosition\": \"1\"," +
"\"mouthShape\": \"4\"," +
"\"color\": \"2\"," +
"\"sticker\": \"4\"," +
"\"name\": \"myCasperBot\"," +
"\"expectation\": \"myExpectation\"" + "}";
String casperBotRequest = """
{
"eyeShape": "15",
"eyePosition": "1",
"mouthShape": "4",
"color": "2",
"sticker": "4",
"name": "myCasperBot",
"expectation": "myExpectation"
}""";
Cookie myCookie = new Cookie("userData", "abc");

//when
Expand All @@ -116,14 +123,17 @@ void createCasperBotSuccessTest_WrongValue() throws Exception {
@DisplayName("캐스퍼 봇 생성 실패 테스트 - 쿠키 없음")
void createCasperBotSuccessTest_CookieNotPresent() throws Exception {
//given
String casperBotRequest = "{" +
"\"eyeShape\": \"1\"," +
"\"eyePosition\": \"1\"," +
"\"mouthShape\": \"4\"," +
"\"color\": \"2\"," +
"\"sticker\": \"4\"," +
"\"name\": \"myCasperBot\"," +
"\"expectation\": \"myExpectation\"" + "}";
String casperBotRequest = """
{
"eyeShape": "1",
"eyePosition": "1",
"mouthShape": "4",
"color": "2",
"sticker": "4",
"name": "myCasperBot",
"expectation": "myExpectation"
}
""";

//when
ResultActions perform = mockMvc.perform(post("/event/lottery")
Expand Down

0 comments on commit da87a20

Please sign in to comment.