강의

멘토링

커뮤니티

Inflearn Community Q&A

junu07231360's profile image
junu07231360

asked

Spring Data JPA

Spring Data Common 13. Web Features Part 3 Pageable and Sort

JsonPathResultMatchers -> ResultMatcher

Written on

·

570

4

(혹시라도 Java 8이 아닌 상위버전으로 학습하시는 분들을 위하여...)

28. 스프링 데이터 Common: Web 2부 마지막 부분에 나오는

test 코드 중에

```

.andExpect(jsonPath("$.content[0].title", is("bbb")))

```

부분을 아래와 같이 수정해야 할 것 같습니다.

```

.andExpect(result -> {

                    jsonPath("$.content[0].title", is("bbb"));

                });

```

Java 버전이 올라가면서 변경된 부분인 것 같아요. 

.andExpect가 ResultMatcher만 파라미터로 받는 것 같네요.

JPAjavaspring

Answer 2

1

.andExpect(result -> {

                    jsonPath("$.content[0].title", is("bbb"));

                }); 

사용해야지만 테스트 통과가 되네요

관련 에러로 구글링하다가 이 방법 사용해서 해결했습니다. 감사합니다.

 

1

whiteship님의 프로필 이미지
whiteship
Instructor

흠.. 그럴리가요. 자바 버전이 올라갔다고 스프링이 제공하는 andExcpect 메소드가 하위 호환성을 깨트리고 바뀌는 일은 없을거라고 생각하는데요. 나중에 한번 확인해 보겠습니다.

junu07231360's profile image
junu07231360

asked

Ask a question