Re: [hibernate-dev] Making tests nicer with lambdas

2014-06-13 Thread Gunnar Morling
For those interested, Java 8 actually intends to allow for "optional returns" from Lambda expressions, i.e. there may be two overloaded versions of a method, one expecting a Lambda expression with a return and one without. So the previous example could actually be written like this: Foo foo =

Re: [hibernate-dev] Making tests nicer with lambdas

2014-05-16 Thread Gunnar Morling
I had envisioned inTransactionWithResult() for that purpose. This returns a value which can be used in the next lambda expression: Foo foo = inTransactionWithResult( (session, tx) -> { Foo f = new Foo(); em.persist( f ); } ); inTransaction( (session, tx) -> { Foo

Re: [hibernate-dev] Making tests nicer with lambdas

2014-05-16 Thread Emmanuel Bernard
These kind of tests are actually not in isolations between lambdas. You often want to pass an id or value between blocks to be reused. I don't think lambdas are porous enough for that. That would be surprising. Emmanuel On Fri 2014-04-25 10:41, Gunnar Morling wrote: > Hey, > > I've played around

Re: [hibernate-dev] Making tests nicer with lambdas

2014-04-26 Thread Sanne Grinovero
I love the idea, but I'm coming from a very different angle: it's important that we regularly exercise our APIs, and verify that they make sense in the new world. But can we reliably run tests compiled with Java8 but still verify our main library is going to run fine in previous JVMs? I don't ful

Re: [hibernate-dev] Making tests nicer with lambdas

2014-04-25 Thread Hardy Ferentschik
On 25 Jan 2014, at 10:41, Gunnar Morling wrote: > I've played around a bit with the idea of using Java 8 lambdas to make > tests easier to write and read. We have many tests which open a session and > TX, do some stuff, commit, open a new TX (and/or session), do some > assertions and so on: > >

[hibernate-dev] Making tests nicer with lambdas

2014-04-25 Thread Gunnar Morling
Hey, I've played around a bit with the idea of using Java 8 lambdas to make tests easier to write and read. We have many tests which open a session and TX, do some stuff, commit, open a new TX (and/or session), do some assertions and so on: Session session = openSession(); Transaction trans