|
18 | 18 |
|
19 | 19 | import de.danielbechler.diff.accessor.*; |
20 | 20 | import de.danielbechler.diff.path.*; |
| 21 | +import org.fest.assertions.api.*; |
21 | 22 | import org.hamcrest.core.*; |
22 | 23 | import org.testng.annotations.*; |
23 | 24 |
|
| 25 | +import java.lang.annotation.*; |
24 | 26 | import java.util.*; |
25 | 27 |
|
26 | 28 | import static org.fest.assertions.api.Assertions.assertThat; |
@@ -163,4 +165,30 @@ public void testAddChild_changes_node_state_to_changed_if_changed_child_node_get |
163 | 165 | node.addChild(nodeMock); |
164 | 166 | NodeAssertions.assertThat(node).root().hasState(Node.State.CHANGED); |
165 | 167 | } |
| 168 | + |
| 169 | + @Test |
| 170 | + public void testShould_return_property_annotations_of_property_accessor() throws Exception |
| 171 | + { |
| 172 | + final PropertyAccessor propertyAccessor = mock(PropertyAccessor.class); |
| 173 | + final Annotation annotation = mock(Annotation.class); |
| 174 | + when(propertyAccessor.getReadMethodAnnotations()).thenReturn(new LinkedHashSet<Annotation>(Arrays.asList(annotation))); |
| 175 | + final Node node = new DefaultNode(propertyAccessor, Object.class); |
| 176 | + |
| 177 | + final Set<Annotation> annotations = node.getPropertyAnnotations(); |
| 178 | + |
| 179 | + Assertions.assertThat(annotations).containsAll(Arrays.asList(annotation)); |
| 180 | + } |
| 181 | + |
| 182 | + @Test |
| 183 | + public void testShould_return_empty_set_of_property_annotations_if_accessor_is_not_property_accessor() throws Exception |
| 184 | + { |
| 185 | + final PropertyAccessor propertyAccessor = mock(PropertyAccessor.class); |
| 186 | + final Annotation annotation = mock(Annotation.class); |
| 187 | + when(propertyAccessor.getReadMethodAnnotations()).thenReturn(new LinkedHashSet<Annotation>(Arrays.asList(annotation))); |
| 188 | + final Node node = new DefaultNode(propertyAccessor, Object.class); |
| 189 | + |
| 190 | + final Set<Annotation> annotations = node.getPropertyAnnotations(); |
| 191 | + |
| 192 | + Assertions.assertThat(annotations).containsAll(Arrays.asList(annotation)); |
| 193 | + } |
166 | 194 | } |
0 commit comments