mp911de
10/24/2017, 1:35 PMLucas
10/24/2017, 3:56 PMWebTestClient
? The code below shows error is similar to a test from the framework code base but IDE says Type inferece failed
.
<http://client.post|client.post>().uri("/person")
.body(fromObject("""{ "name": "The Bride" }"""))
.exchange()
.expectHeader().contentType(MediaType.APPLICATION_JSON)
.expectStatus().is2xxSuccessful
.expectBody(Person::class.java)
.isEqualTo(Person("The Bride"))
Lucas
10/24/2017, 3:56 PMsdeleuze
10/24/2017, 4:10 PMsdeleuze
10/24/2017, 4:12 PMWebClient
+ Reactor testing capabilities like thatsdeleuze
10/24/2017, 4:13 PMwebclient
.get()
.uri("/foo")
.retrieve()
.bodyToMono<String>()
.test()
.consumeNextWith {
assertThat(it)...
}
.verifyComplete()
sdeleuze
10/24/2017, 4:14 PMsdeleuze
10/24/2017, 4:14 PMLucas
10/24/2017, 4:16 PMLucas
10/24/2017, 4:16 PM<http://client.post|client.post>().uri("/person")
.body(fromObject("""{ "name": "The Bride" }"""))
.exchange()
.expectHeader().contentType(MediaType.APPLICATION_JSON)
.expectStatus().is2xxSuccessful
.expectBody()
.jsonPath("$['name']").isEqualTo(Person("The Bride"))
Lucas
10/24/2017, 4:17 PMsdeleuze
10/24/2017, 4:18 PMsdeleuze
10/25/2017, 7:48 AMveiset
10/25/2017, 8:34 AMsdeleuze
10/25/2017, 8:39 AMsdeleuze
10/25/2017, 8:39 AMveiset
10/25/2017, 8:43 AMmp911de
10/25/2017, 8:44 AMveiset
10/25/2017, 8:44 AMdiesieben07
10/26/2017, 11:28 AMKotlinReflectionParameterNameDiscoverer
ignores the extension receiver parameter. But from a Java standpoint, that parameter is a "normal method parameter" and omitting it causes `ArrayIndexOutOfBoundsException`s to be thrown by e.g. Hibernate Validator.diesieben07
10/26/2017, 11:28 AMdiesieben07
10/26/2017, 11:29 AMsdeleuze
10/26/2017, 11:43 AMdiesieben07
10/26/2017, 11:47 AMLucas
10/26/2017, 1:46 PMbeans { }
, GenericApplicationContext { }
, WebHttpHandlerBuilder
, etc) is it possible to use @EnableWebFluxSecurity
or @EnableReactiveMongoRepositories
?Lucas
10/26/2017, 1:47 PMalternative
.sdeleuze
10/26/2017, 1:53 PMbeans { }
with sandalone WebFlux application or Boot + @EnableXxx
, you can use both together via the tip I give in the SO answer but that's concidered as experimentalLucas
10/26/2017, 2:06 PMmp
10/27/2017, 8:35 AMkotlin
class AuthFilter(
@Value("\${microsoft.api.keyHeaderName}") val keyHeaderName: String,
@Value("\${microsoft.api.keyHeaderValue}") val keyHeaderValue: String
): ZuulFilter() {
override fun shouldFilter() = true
override fun filterType() = "pre"
override fun filterOrder() = 7
override fun run() {
with(RequestContext.getCurrentContext()) {
addZuulRequestHeader(keyHeaderName, keyHeaderValue)
}
}
}
This class looks like template inside the project - e.g. I want create few pre filter for Zuul. So I thought that I can move it to the kotlin function
kotlin
fun preFilter(filter: () -> Any): ZuulFilter {
return object : ZuulFilter() {
override fun run() = filter
override fun shouldFilter() = true
override fun filterType() = "pre"
override fun filterOrder() = 7
}
}
and define each new bean with calls that should looks like
kotlin
@Bean
fun authFilter() = preFilter({
with(RequestContext.getCurrentContext()) {
addZuulRequestHeader(keyHeaderName, keyHeaderValue)
}
})
But this way doesn't apply adding headers and I don't understand why.(1st snippet works fine)
Maybe I have some conceptual misunderstanding
update
Yes I've had! I forgot to use invoke method - with invoke it works
fun preFilter(filter: () -> Any): ZuulFilter {
return object : ZuulFilter() {
override fun run() = filter.invoke()
...
}