|
24 | 24 | import org.mockito.stubbing.*; |
25 | 25 | import org.testng.annotations.*; |
26 | 26 |
|
| 27 | +import java.math.BigDecimal; |
| 28 | + |
27 | 29 | import static org.fest.assertions.api.Assertions.assertThat; |
28 | 30 | import static org.hamcrest.MatcherAssert.assertThat; |
29 | 31 | import static org.hamcrest.core.Is.*; |
@@ -98,6 +100,35 @@ public void testIsIgnoredWithCategory() throws Exception |
98 | 100 | assertThat(configuration.isIgnored(node), is(true)); |
99 | 101 | } |
100 | 102 |
|
| 103 | + @SuppressWarnings({"unchecked"}) |
| 104 | + @Test |
| 105 | + public void testIsCompareToOnlyWithConfiguredPropertyType() throws Exception |
| 106 | + { |
| 107 | + final Class aClass = ObjectWithStringAndCompareTo.class; |
| 108 | + when(node.getType()).thenReturn(aClass); |
| 109 | + configuration.withCompareToOnlyType(aClass); |
| 110 | + assertThat(configuration.isCompareToOnly(node), is(true)); |
| 111 | + } |
| 112 | + |
| 113 | + @SuppressWarnings({"unchecked"}) |
| 114 | + @Test |
| 115 | + public void testIsCompareToOnlyWithConfiguredPropertyTypeNotComparable() throws Exception |
| 116 | + { |
| 117 | + final Class aClass = ObjectWithString.class; |
| 118 | + when(node.getType()).thenReturn(aClass); |
| 119 | + configuration.withCompareToOnlyType(aClass); |
| 120 | + assertThat(configuration.isCompareToOnly(node), is(false)); |
| 121 | + } |
| 122 | + |
| 123 | + @SuppressWarnings({"unchecked"}) |
| 124 | + @Test |
| 125 | + public void testIsCompareToOnlyWithComparableType() throws Exception |
| 126 | + { |
| 127 | + final Class aClass = BigDecimal.class; |
| 128 | + when(node.getType()).thenReturn(aClass); |
| 129 | + assertThat(configuration.isCompareToOnly(node), is(true)); |
| 130 | + } |
| 131 | + |
101 | 132 | @Test |
102 | 133 | public void testIsEqualsOnlyWithConfiguredPropertyPath() throws Exception |
103 | 134 | { |
@@ -142,13 +173,6 @@ public void testIsEqualsOnlyWithTypeThatShouldNotBeComparedUsingEquals() throws |
142 | 173 | assertThat(configuration.isEqualsOnly(node), is(false)); |
143 | 174 | } |
144 | 175 |
|
145 | | - @Test |
146 | | - public void testIsIntrospectibleWithEqualsOnlyNodeReturnsFalse() |
147 | | - { |
148 | | - when(node.getType()).then(returnClass(String.class)); |
149 | | - assertThat(configuration.isIntrospectible(node)).isFalse(); |
150 | | - } |
151 | | - |
152 | 176 | @Test |
153 | 177 | public void testIsIntrospectibleWithUntouchedNonEqualsOnlyNodeReturnsFalse() |
154 | 178 | { |
@@ -189,7 +213,7 @@ public void testIsIntrospectibleReturnsFalseForRemovedNodeIfChildrenOfRemovedNod |
189 | 213 | assertThat(configuration.isIntrospectible(node)).isFalse(); |
190 | 214 | } |
191 | 215 |
|
192 | | - @SuppressWarnings({"TypeMayBeWeakened"}) |
| 216 | + @SuppressWarnings({"TypeMayBeWeakened"}) |
193 | 217 | private static <T> Answer<Class<T>> returnClass(final Class<T> aClass) |
194 | 218 | { |
195 | 219 | return new Answer<Class<T>>() |
|
0 commit comments