Skip to content

Commit 658eaf8

Browse files
author
smgfreeman
committed
renamed SamePropertyValuesAs
1 parent 0843ca9 commit 658eaf8

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

hamcrest-library/src/main/java/org/hamcrest/beans/WithSamePropertyValuesAs.java renamed to hamcrest-library/src/main/java/org/hamcrest/beans/SamePropertyValuesAs.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
import org.hamcrest.TypeSafeDiagnosingMatcher;
1818
import org.hamcrest.core.IsEqual;
1919

20-
public class WithSamePropertyValuesAs<T> extends TypeSafeDiagnosingMatcher<T> {
20+
public class SamePropertyValuesAs<T> extends TypeSafeDiagnosingMatcher<T> {
2121
private final T expectedBean;
2222
private final Set<String> propertyNames;
2323
private final List<PropertyMatcher> propertyMatchers;
2424

2525

26-
public WithSamePropertyValuesAs(T expectedBean) {
26+
public SamePropertyValuesAs(T expectedBean) {
2727
PropertyDescriptor[] descriptors = propertyDescriptorsFor(expectedBean, Object.class);
2828
this.expectedBean = expectedBean;
2929
this.propertyNames = propertyNamesFrom(descriptors);
@@ -66,7 +66,7 @@ private boolean hasMatchingValues(T item, Description mismatchDescription) {
6666
}
6767

6868
public void describeTo(Description description) {
69-
description.appendText("with same property values as " + expectedBean.getClass().getSimpleName())
69+
description.appendText("same property values as " + expectedBean.getClass().getSimpleName())
7070
.appendList(" [", ", ", "]", propertyMatchers);
7171
}
7272

@@ -121,8 +121,8 @@ private static Object readProperty(Method method, Object target) {
121121
}
122122

123123
@Factory
124-
public static <T> Matcher<T> withSamePropertyValuesAs(T expectedBean) {
125-
return new WithSamePropertyValuesAs<T>(expectedBean);
124+
public static <T> Matcher<T> samePropertyValuesAs(T expectedBean) {
125+
return new SamePropertyValuesAs<T>(expectedBean);
126126
}
127127

128128
}

hamcrest-unit-test/src/main/java/org/hamcrest/beans/WithSamePropertyValuesAsTest.java renamed to hamcrest-unit-test/src/main/java/org/hamcrest/beans/SamePropertyValuesAsTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,52 @@
22
*/
33
package org.hamcrest.beans;
44

5-
import static org.hamcrest.beans.WithSamePropertyValuesAs.withSamePropertyValuesAs;
5+
import static org.hamcrest.beans.SamePropertyValuesAs.samePropertyValuesAs;
66

77
import org.hamcrest.AbstractMatcherTest;
88
import org.hamcrest.Matcher;
99

10-
public class WithSamePropertyValuesAsTest extends AbstractMatcherTest {
10+
public class SamePropertyValuesAsTest extends AbstractMatcherTest {
1111
private static final Value aValue = new Value("expected");
1212
private static final ExampleBean expectedBean = new ExampleBean("same", 1, aValue);
1313
private static final ExampleBean actualBean = new ExampleBean("same", 1, aValue);
1414

1515

1616
@Override
1717
protected Matcher<?> createMatcher() {
18-
return withSamePropertyValuesAs(expectedBean);
18+
return samePropertyValuesAs(expectedBean);
1919
}
2020

2121
public void testReportsMatchWhenAllPropertiesMatch() {
22-
assertMatches("matched properties", withSamePropertyValuesAs(expectedBean), actualBean);
22+
assertMatches("matched properties", samePropertyValuesAs(expectedBean), actualBean);
2323
}
2424

2525
public void testReportsMismatchWhenActualTypeIsNotAssignableToExpectedType() {
2626
assertMismatchDescription("is incompatible type: ExampleBean",
27-
withSamePropertyValuesAs((Object)aValue), actualBean);
27+
samePropertyValuesAs((Object)aValue), actualBean);
2828
}
2929

3030
public void testReportsMisatchOnFirstPropertyDifference() {
3131
assertMismatchDescription("string was \"different\"",
32-
withSamePropertyValuesAs(expectedBean), new ExampleBean("different", 1, aValue));
32+
samePropertyValuesAs(expectedBean), new ExampleBean("different", 1, aValue));
3333
assertMismatchDescription("int was <2>",
34-
withSamePropertyValuesAs(expectedBean), new ExampleBean("same", 2, aValue));
34+
samePropertyValuesAs(expectedBean), new ExampleBean("same", 2, aValue));
3535
assertMismatchDescription("value was <Value other>",
36-
withSamePropertyValuesAs(expectedBean), new ExampleBean("same", 1, new Value("other")));
36+
samePropertyValuesAs(expectedBean), new ExampleBean("same", 1, new Value("other")));
3737
}
3838

3939
public void testMatchesBeansWithInheritanceButNoExtraProperties() {
4040
assertMatches("sub type with same properties",
41-
withSamePropertyValuesAs(expectedBean), new SubBeanWithNoExtraProperties("same", 1, aValue));
41+
samePropertyValuesAs(expectedBean), new SubBeanWithNoExtraProperties("same", 1, aValue));
4242
}
4343

4444
public void testRejectsSubTypeThatHasExtraProperties() {
4545
assertMismatchDescription("has extra properties called [extra]",
46-
withSamePropertyValuesAs(expectedBean), new SubBeanWithExtraProperty("same", 1, aValue));
46+
samePropertyValuesAs(expectedBean), new SubBeanWithExtraProperty("same", 1, aValue));
4747
}
4848

4949
public void testDescribesItself() {
50-
assertDescription("with same property values as ExampleBean [int: <1>, string: \"same\", value: <Value expected>]", withSamePropertyValuesAs(expectedBean));
50+
assertDescription("same property values as ExampleBean [int: <1>, string: \"same\", value: <Value expected>]", samePropertyValuesAs(expectedBean));
5151
}
5252

5353
public static class Value {

matchers.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<!-- Beans -->
5252
<factory class="org.hamcrest.beans.HasProperty"/>
5353
<factory class="org.hamcrest.beans.HasPropertyWithValue"/>
54-
<factory class="org.hamcrest.beans.WithSamePropertyValuesAs"/>
54+
<factory class="org.hamcrest.beans.SamePropertyValuesAs"/>
5555

5656
<!-- XML -->
5757
<factory class="org.hamcrest.xml.HasXPath"/>

0 commit comments

Comments
 (0)