Package org.hamcrest.beans
Class SamePropertyValuesAs<T>
java.lang.Object
org.hamcrest.BaseMatcher<T>
org.hamcrest.DiagnosingMatcher<T>
org.hamcrest.beans.SamePropertyValuesAs<T>
- Type Parameters:
- T- the matcher value type.
- All Implemented Interfaces:
- Matcher<T>,- SelfDescribing
A matcher that checks if a given bean has the same property values
 as an example bean.
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionSamePropertyValuesAs(T expectedBean, List<String> ignoredProperties) Constructor, best called fromsamePropertyValuesAs(Object, String...).
- 
Method SummaryModifier and TypeMethodDescriptionvoiddescribeTo(Description description) Generates a description of the object.protected booleanmatches(Object actual, Description mismatch) Evaluates the matcher for argument item.static <B> Matcher<B> samePropertyValuesAs(B expectedBean, String... ignoredProperties) Creates a matcher that matches when the examined object has values for all of its JavaBean properties that are equal to the corresponding values of the specified bean.Methods inherited from class org.hamcrest.DiagnosingMatcherdescribeMismatch, matchesMethods inherited from class org.hamcrest.BaseMatcher_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
- 
Constructor Details- 
SamePropertyValuesAsConstructor, best called fromsamePropertyValuesAs(Object, String...).- Parameters:
- expectedBean- the bean object with the expected values
- ignoredProperties- list of property names that should be excluded from the match
 
 
- 
- 
Method Details- 
matchesDescription copied from class:DiagnosingMatcherEvaluates the matcher for argument item.- Specified by:
- matchesin class- DiagnosingMatcher<T>
- Parameters:
- actual- the value to check
- mismatch- the description for the matcher
- Returns:
- trueif item matches, otherwise- false.
 
- 
describeToDescription copied from interface:SelfDescribingGenerates a description of the object. The description may be part of a description of a larger object of which this is just a component, so it should be worded appropriately.- Parameters:
- description- The description to be built or appended to.
 
- 
samePropertyValuesAsCreates a matcher that matches when the examined object has values for all of its JavaBean properties that are equal to the corresponding values of the specified bean. If any properties are marked as ignored, they will be dropped from both the expected and actual bean. Note that the ignored properties use JavaBean display names, for example " For example:age" rather than method names such as "getAge".assertThat(myBean, samePropertyValuesAs(myExpectedBean)) assertThat(myBean, samePropertyValuesAs(myExpectedBean), "age", "height")- Type Parameters:
- B- the matcher value type.
- Parameters:
- expectedBean- the bean against which examined beans are compared
- ignoredProperties- do not check any of these named properties.
- Returns:
- The matcher.
 
 
-