|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Pojo matcherHi,
is a Pojo matcher available somewhere? I have a data object with 10 attributes. In the expected and the invoked object are 8 attributes equal an 2 differs. I don't need a complete printout of expected and the invoked object. This is is a bit confusing and unclear. What I like to have is an output like: Objects are not the same: attribute a and b are different. Is this already available? wkr Thomas --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Pojo matcherIf your object conforms to bean properties, you can use
samePropertyValuesAs() S. On 4 Jun 2009, at 11:38, Thomas Richter wrote: > Hi, > is a Pojo matcher available somewhere? > I have a data object with 10 attributes. > In the expected and the invoked object are 8 attributes equal an 2 > differs. > I don't need a complete printout of expected and the invoked object. > This is > is a bit confusing and unclear. > What I like to have is an output like: > Objects are not the same: attribute a and b are different. > Is this already available? Steve Freeman Winner of the Agile Alliance Gordon Pask award 2006 http://www.m3p.co.uk M3P Limited. Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. Company registered in England & Wales. Number 03689627 --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Pojo matcherHi,
with JMock1.2 it would probably work, if I had no list ... one(mocked).method(with(aPropertyValuesAsMatcher(expected))); @Factory public Matcher<List<Entity>> aPropertyValuesAsMatcher( final List<Entity> expected) { return new SamePropertyValuesAs<List<Entity>>(expected); } some Ideas? wkr T. (Thomas) --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Pojo matcherI'm confused. You want to match a list of entity objects?
S. On 4 Jun 2009, at 14:12, Thomas Richter wrote: > Hi, > with JMock1.2 it would probably work, if I had no list ... > > one(mocked).method(with(aPropertyValuesAsMatcher(expected))); > > @Factory > public Matcher<List<Entity>> aPropertyValuesAsMatcher( > final List<Entity> expected) { > return new SamePropertyValuesAs<List<Entity>>(expected); > } > > some Ideas? > > wkr T. (Thomas) > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > Steve Freeman Winner of the Agile Alliance Gordon Pask award 2006 http://www.m3p.co.uk M3P Limited. Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. Company registered in England & Wales. Number 03689627 --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Pojo matcher2009/6/4 Thomas Richter <tricpod@...>:
> Hi, > with JMock1.2 it would probably work, if I had no list ... I mean hamcrest1.2 ... --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Pojo matcherHi,
This should work: one(mocked).method(with(aPropertyValuesAsMatcher(expected))); @Factory public Matcher<Entity> aPropertyValuesAsMatcher( final Entity expected) { return new SamePropertyValuesAs<Entity>(expected); } but not this: one(mocked).method(with(aPropertyValuesAsMatcher(expected))); @Factory public Matcher<List<Entity>> aPropertyValuesAsMatcher( final List<Entity> expected) { return new SamePropertyValuesAs<List<Entity>>(expected); } I got java.lang.NoSuchMethodError: org.hamcrest.beans.PropertyUtil.propertyDescriptorsFor(Ljava/lang/Object;Ljava/lang/Class;)[Ljava/beans/PropertyDescriptor; at org.hamcrest.beans.SamePropertyValuesAs.<init>(SamePropertyValuesAs.java:27) I know java.util.List is not a Bean .... wkr Thomas --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Pojo matcherYes. A matcher intended for a bean will not work with a list.
How about you tell us what you're actually trying to test, then we can help you. S. On 5 Jun 2009, at 09:08, Thomas Richter wrote: > Hi, > > This should work: > one(mocked).method(with(aPropertyValuesAsMatcher(expected))); > > @Factory > public Matcher<Entity> aPropertyValuesAsMatcher( > final Entity expected) { > return new SamePropertyValuesAs<Entity>(expected); > } > > but not this: > > one(mocked).method(with(aPropertyValuesAsMatcher(expected))); > > @Factory > public Matcher<List<Entity>> aPropertyValuesAsMatcher( > final List<Entity> expected) { > return new SamePropertyValuesAs<List<Entity>>(expected); > } Steve Freeman Winner of the Agile Alliance Gordon Pask award 2006 http://www.m3p.co.uk M3P Limited. Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. Company registered in England & Wales. Number 03689627 --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Pojo matcher2009/6/5 Steve Freeman <steve@...>:
> Yes. A matcher intended for a bean will not work with a list. > > How about you tell us what you're actually trying to test, then we can help > you. Very nice. :-) I want to compare a List of Entity. Your first idea was SamePropertyValuesAs. But this don't works for list. Something like: If list size is the same check with SamePropertyValuesAs each entity. >> >> @Factory >> public Matcher<List<Entity>> aPropertyValuesAsMatcher( >> final List<Entity> expected) { >> return new SamePropertyValuesAs<List<Entity>>(expected); >> } wkr Thomas --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Pojo matcherOn 22 Jun 2009, at 18:13, Thomas Richter wrote:
> 2009/6/5 Steve Freeman <steve@...>: >> Yes. A matcher intended for a bean will not work with a list. >> >> How about you tell us what you're actually trying to test, then we >> can help >> you. > > Very nice. :-) > > I want to compare a List of Entity. Your first idea was > SamePropertyValuesAs. > But this don't works for list. > > Something like: > If list size is the same check with SamePropertyValuesAs each entity. How large is this list? If it's in a unit test, it should only be a couple of elements? S. Steve Freeman Winner of the Agile Alliance Gordon Pask award 2006 http://www.m3p.co.uk M3P Limited. Registered office. 2 Church Street, Burnham, Bucks, SL1 7HZ. Company registered in England & Wales. Number 03689627 --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |