åé¡
WebTestClient.BodySpec
ã®isEqualTo
ã¡ã½ãããå¼ã³åºãã¨ãã¬ãã½ãã
webTestClient.get() .exchange() .expectBody(MyApiBody::class.java).isEqualTo<Nothing>(expectedBody)
isEqualTo
ãå¼ã³åºãããã«ã¯ããã®åå¼æ°ã¨ãã¦Nothing
ãæå®ããå¿
è¦ãããï¼ããããªãã¨ãã³ã³ãã¤ã«ãéããªãï¼ã
ãããå®è¡ããã¨NullPointerException
ãçºçããã
解決æ¹æ³
æ¡å¼µé¢æ°ã®expectBody
ã使ç¨ããã
ãã ããIDEã¯ãã®æ¡å¼µé¢æ°ããµã¸ã§ã¹ããã¦ãããªãã®ã§ãèªåã§ã¤ã³ãã¼ãããï¼ãµã¸ã§ã¹ããããã¦ããã¦ããã°ããã¾ãæ©ã¾ãã«æ¸ãã ã®ã«...ï¼ã
// ãããã¤ã³ãã¼ã import org.springframework.test.web.reactive.server.expectBody
webTestClient.get()
.exchange()
.expectBody<MyApiBody>().isEqualTo(expectedBody)
ã³ã¼ãã®è¦ãç®ãKotlinãããã¹ãããªãããã¹ããã¡ããã¨å®è¡ãããã
åè: [SPR-15692] Kotlin unable to inherit type for WebTestClient#BodySpec - Spring JIRA
ãã¼ã¾ãKotlinã®ã¸ã§ããªã¯ã¹ã¾ããã®ãã°è¸ãã ã£ã½ã...
— ããã (@ngsw_taro) August 20, 2018