I found myself in a similar situation, wanting to check the field of the object passed to the layout. Instead of using an invader, as Mark shows, I tried what I consider more convenient for JMock. Code adjusted for your use case:
mockery.checking(new Expectations() {{ oneOf(emailService.getJavaMailSender()).send( with(Matchers.<SimpleMailMessage>hasProperty("body", equal("Hello world!")))); }});
I understand that this has limitations, but in most cases, controllers should be able to check the object in question. Hope this helps.
bm1729
source share