there's a back ground issue from our project here:
fabric8io/fabric8#5925
the general idea is we want to generate helper methods in the generated Assert classes to aid navigation through deeply nested models. The background is the Kubernetes model is very deeply nested.
For a complex model where you want to write assertions like:
assertThat(foo.getBar().getThing()).isNotNull()
the problem is the getBar() could return null as could the getThing().
So we wanna do this instead...
assertThat(foo).bar().thing().isNotNull();
where each property method bar() and thing() are kinda like the hasBar() function thats generated OOTB, only it returns the assertThat() of the value. So the last assertion - .isNotNull() could be anything really; isEqualTo() or whatever.
e.g. we generate functions like this:
class FooAssert ... {
public BarAssert bar() {
isNotNull();
return (BarAssert) assertThat(actual.getBar()).describedAs(toString() + ".bar");
}
}
I've managed to implement the above in our project using the extensible templates (thanks for that!) - but to do so I needed to add the above 2 properties to the templates. Actually as of writing only the 2nd one is required but figured I may as well submit a PR for both ;)
there's a back ground issue from our project here:
fabric8io/fabric8#5925
the general idea is we want to generate helper methods in the generated Assert classes to aid navigation through deeply nested models. The background is the Kubernetes model is very deeply nested.
For a complex model where you want to write assertions like:
the problem is the getBar() could return null as could the getThing().
So we wanna do this instead...
where each property method
bar()andthing()are kinda like thehasBar()function thats generated OOTB, only it returns the assertThat() of the value. So the last assertion -.isNotNull()could be anything really;isEqualTo()or whatever.e.g. we generate functions like this:
I've managed to implement the above in our project using the extensible templates (thanks for that!) - but to do so I needed to add the above 2 properties to the templates. Actually as of writing only the 2nd one is required but figured I may as well submit a PR for both ;)