Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions spring-mvc-1/src/main/java/cholog/MemberController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cholog;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;

@Controller
public class MemberController {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 컨트롤러 이름이 변경된 이유가 있을까요?

Copy link
Contributor Author

@Choi-JJunho Choi-JJunho Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README 및 LMS 상에서 제시되고있는 컨트롤러 명이 MemberController여서 변경했습니다!

LMS

image


public Model world() {
// TODO: /hello 요청 시 resources/templates/hello.html 페이지가 응답할 수 있도록 설정한다.
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리턴타입이 String에서 Model로 변경되었네요! 혹시 이유가 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model을 활용하는 예제를 생각하다가 잘못 작성한 부분인 것 같습니다 😅
String으로 다시 변경하겠습니다!


public Person json() {
// TODO: /json 요청 시 {"name": "brown", "age": 20} 응답할 수 있도록 설정한다.
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요청 url도 변경이 발생했네요! 혹시 이유가 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 부분도 마찬가지로 README 및 LMS 상에서 제시되고있는 URL path에 맞춰서 변경했습니다!

LMS

image

이에 ResponseJsonTest 테스트에 작성된 /person 경로 또한 /json으로 변경했습니다.

}
22 changes: 0 additions & 22 deletions spring-mvc-1/src/main/java/cholog/ResponseController.java

This file was deleted.

5 changes: 2 additions & 3 deletions spring-mvc-1/src/test/java/cholog/ResponseJsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class ResponseJsonTest {
class ResponseJsonTest {

@Test
void responseJson() {
var response = RestAssured
.given().log().all()
.when().get("/person")
.when().get("/json")
.then().log().all().extract();

assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value());
assertThat(response.as(Person.class).getName()).isEqualTo("Brown");
assertThat(response.as(Person.class).getAge()).isEqualTo(20);
}

}
2 changes: 1 addition & 1 deletion spring-mvc-1/src/test/java/cholog/ResponseStaticTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class ResponseStaticTest {
class ResponseStaticTest {

@Test
void responseIndexPage() {
Expand Down
12 changes: 11 additions & 1 deletion spring-mvc-1/src/test/java/cholog/ResponseTemplatesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class ResponseTemplatesTest {
class ResponseTemplatesTest {

@Test
void responseTemplatesPage() {
Expand All @@ -20,4 +20,14 @@ void responseTemplatesPage() {
assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value());
assertThat(response.asString()).contains("Hello, Brie!");
}

@Test
void responseTemplatesHelloPage() {
var response = RestAssured
.given().log().all()
.when().get("/hello")
.then().log().all().extract();

assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로운 학습 테스트 👍

}