Luis Munoz
03/04/2020, 10:11 PM@WebFluxTest
but I don't like how it is loading the Spring Boot Context, when I try to use
@WebMvcTest
I get an error saying I don't have WebMvcTest dependencies, I suppose becasue I am using Flux I wouldn't add those, right? Is there a way to do the WebFluxTest without including the Spring Boot Context?Gopal S Akshintala
03/25/2020, 2:36 PMCzar
03/29/2020, 12:42 PM@Configuration
classes. This options seems to be no longer available.
So presently the only option that I see is configuring whole thing by hand, effectively manually copying what auto-configuration does, bean by bean.cpe
03/31/2020, 9:37 AM@RestController
. Has anyone an idea on how to include the endpoints and mappings automatically? Or is there any other solution/workaround?
For the moment I need to add the whole documentation in the openAPI bean explicitly.Max Tan
04/05/2020, 9:39 AMnicholasnet
04/05/2020, 2:24 PMTimur Atakishiev
04/28/2020, 4:21 AMhooliooo
04/28/2020, 1:30 PMList<Post> posts = doInJPA(entityManager -> {
List<Post> _posts = entityManager
.createQuery(
"select distinct p " +
"from Post p " +
"left join fetch p.comments " +
"where p.id between :minId and :maxId ", Post.class)
.setParameter("minId", 1L)
.setParameter("maxId", 50L)
.setHint(QueryHints.PASS_DISTINCT_THROUGH, false)
.getResultList();
_posts = entityManager
.createQuery(
"select distinct p " +
"from Post p " +
"left join fetch p.tags t " +
"where p in :posts ", Post.class)
.setParameter("posts", _posts)
.setHint(QueryHints.PASS_DISTINCT_THROUGH, false)
.getResultList();
return _posts;
});
assertEquals(POST_COUNT, posts.size());
for(Post post : posts) {
assertEquals(POST_COMMENT_COUNT, post.getComments().size());
assertEquals(TAG_COUNT, post.getTags().size());
}
And explains the following:
Now, we have to fetch the Post entities along with their associated Tag entities, and, thanks to the Persistence Context, Hibernate will set the tags collection of the previously fetched Post entities.
But when I use the logic in Kotlin:
val companiesWithAddresses = entityManager.createQuery(
"""
SELECT t from ProjectCompany t
LEFT JOIN FETCH t.addresses
ORDER BY t.id ASC
""",
ProjectCompany::class.java
)
.setHint(QueryHints.PASS_DISTINCT_THROUGH, false)
.resultList
val companies = entityManager.createQuery(
"""
SELECT t from ProjectCompany t
LEFT JOIN FETCH t.contactPersons persons
WHERE t in :companies
ORDER BY t.id ASC
""",
ProjectCompany::class.java
)
.setParameter("companies", companiesWithAddresses)
.setHint(QueryHints.PASS_DISTINCT_THROUGH, false)
.resultList
return PageImpl(companies, pageable, companies.size.toLong())
I get this error:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ProjectCompany.addresses, could not initialize proxy - no Session
Dariusz Kuc
04/28/2020, 4:43 PMWebFluxTest
? e.g. I’d like to avoid starting up the whole app using @SpringBootTest
, e.g.
@ExtendWith(SpringExtension::class)
@ContextConfiguration(classes = [MyRouteConfiguration::class])
@WebFluxTest
class RouteConfigurationIT(@Autowired val context: ApplicationContext) {
private lateinit var webClient: WebTestClient
@BeforeEach
fun setUp() {
webClient = WebTestClient.bindToApplicationContext(context).build()
}
// some tests here
}
Above works fine for testing the routes but I want to also verify that my webfilter that redirects health path to /actuator/health
actually works. With the above setup actuator is not setup so I’m getting 404. Any ideas?Dennis Schröder
05/04/2020, 10:54 AM@Component
class ContentClientHealthIndicator(private val contentJsonClient: ContentJsonClient) : ReactiveHealthIndicator {
private val logger = KotlinLogging.logger { }
private val pagesToCheck = listOf("home")
override fun health(): Mono<Health> =
mono(Dispatchers.Unconfined) {
pagesToCheck.map { contentJsonClient.getPage(it) }
Health.up().build()
}.onErrorResume(Exception::class.java) { exception ->
logger.error(exception) { "ContentClient health check failed" }
Health.down(exception).build().let { Mono.just(it) }
}
}
Ben
05/07/2020, 4:41 PMcoRouter
filter? If I use ServerResponse.from
to create a builder I can't seem to get the body anymore?corneil
05/09/2020, 12:34 PMiari
05/11/2020, 8:24 AMFrodrigues
05/25/2020, 7:25 PMGonçalo Marques
05/26/2020, 8:49 AMDsittel
05/26/2020, 1:58 PMreq.bodyToMono(DataClass::class.java).awaitFirst()
Dsittel
05/26/2020, 1:58 PMiari
05/27/2020, 5:57 AMfun sendSimpleMessage(
op: SimpleMailMessage.() -> Unit
) {
val message = SimpleMailMessage().apply(op)
mailSender.send(message)
}
A part of the MailMessage interface is the method:
public void setSubject(String subject)
So now on the calling site I have
mail.sendSimpleMessage {
setTo(address)
subject = "Test Email" // compiler warning
//setSubject("Test Email") <--- this does work though
....
}
And the comp0iler says:
Val cannot be reassignedBut this isn't a val - the compiler should translate it to setSubject - thats also what the IDE suggests (ctrl-click brings me to the interface method) I don't understand, what the compiler thinks that 'subject' is supposed to be .... certainly not a val, since this shouldn't be kotlin code Any hints what could be going on there?
sdeleuze
05/28/2020, 1:02 PMkqr
05/28/2020, 10:42 PMkenkyee
05/29/2020, 2:17 AMsdeleuze
05/29/2020, 3:05 PMkqr
05/29/2020, 3:37 PMAaron
05/31/2020, 1:41 AMspring-devtool
and graphql-kotlin-spring-server
when hot-swapping code? The full detail is here https://github.com/ExpediaGroup/graphql-kotlin/issues/730. Essentially it would work fine the first time around, but after you make some changes or just add a simple println
I get this error DataFetchingException: Object is not an instance of declaring class
. Would love to know if anyone encounter this and know how to fix this 🙂Mgkaki
06/05/2020, 1:00 PMsandjelkovic
06/05/2020, 1:19 PMComponent
, and hook into destroy events or create destroy handlers to close.
Another is to use a CommandLineRunner
instead of a Component. This also has the benefit of being invoked after the context is initialized. Here’s an example for a Reactive Kafka consumer and can used this way.