|
17 | 17 | package de.danielbechler.diff.accessor; |
18 | 18 |
|
19 | 19 | import de.danielbechler.diff.accessor.exception.*; |
| 20 | +import de.danielbechler.diff.annotation.*; |
20 | 21 | import de.danielbechler.diff.mock.*; |
21 | 22 | import de.danielbechler.diff.path.*; |
22 | | -import org.fest.assertions.api.*; |
23 | 23 | import org.testng.annotations.*; |
24 | 24 |
|
25 | 25 | import java.lang.annotation.*; |
26 | 26 | import java.lang.reflect.*; |
27 | | -import java.util.*; |
28 | 27 |
|
29 | 28 | import static java.util.Arrays.*; |
30 | 29 | import static org.fest.assertions.api.Assertions.*; |
@@ -152,17 +151,39 @@ public void includes_accessor_type_in_string_representation() |
152 | 151 | } |
153 | 152 |
|
154 | 153 | @Test |
155 | | - public void returns_annotations_of_getter_as_set() throws Exception |
| 154 | + public void returns_annotations_of_property_getter() throws Exception |
156 | 155 | { |
157 | 156 | accessor = PropertyAccessorBuilder.forPropertyOf(ObjectWithAnnotatedProperty.class) |
158 | 157 | .property("value", String.class) |
159 | 158 | .readOnly(false) |
160 | 159 | .build(); |
161 | 160 | final Annotation[] expectedAnnotations = ObjectWithAnnotatedProperty.class.getMethod("getValue") |
162 | 161 | .getAnnotations(); |
163 | | - Assertions.assertThat(expectedAnnotations).hasSize(2); |
| 162 | + assertThat(expectedAnnotations).hasSize(2); |
| 163 | + assertThat(accessor.getReadMethodAnnotations()).containsAll(asList(expectedAnnotations)); |
| 164 | + } |
164 | 165 |
|
165 | | - final Set<Annotation> set = accessor.getReadMethodAnnotations(); |
166 | | - Assertions.assertThat(set).containsAll(asList(expectedAnnotations)); |
| 166 | + @Test |
| 167 | + public void returns_specific_annotation_of_property_getter() throws Exception |
| 168 | + { |
| 169 | + accessor = PropertyAccessorBuilder.forPropertyOf(ObjectWithAnnotatedProperty.class) |
| 170 | + .property("value", String.class) |
| 171 | + .readOnly(false) |
| 172 | + .build(); |
| 173 | + final ObjectDiffProperty expectedAnnotation = ObjectWithAnnotatedProperty.class.getMethod("getValue") |
| 174 | + .getAnnotation(ObjectDiffProperty.class); |
| 175 | + assertThat(expectedAnnotation).isNotNull(); |
| 176 | + final ObjectDiffProperty annotation = accessor.getReadMethodAnnotation(ObjectDiffProperty.class); |
| 177 | + assertThat(annotation).isEqualTo(expectedAnnotation); |
| 178 | + } |
| 179 | + |
| 180 | + @Test |
| 181 | + public void returns_null_if_specific_annotation_of_property_getter_does_not_exist() throws Exception |
| 182 | + { |
| 183 | + accessor = PropertyAccessorBuilder.forPropertyOf(ObjectWithAnnotatedProperty.class) |
| 184 | + .property("value", String.class) |
| 185 | + .readOnly(false) |
| 186 | + .build(); |
| 187 | + assertThat(accessor.getReadMethodAnnotation(Override.class)).isNull(); |
167 | 188 | } |
168 | 189 | } |
0 commit comments