2222import de .danielbechler .diff .collection .CollectionItemElementSelector ;
2323import de .danielbechler .diff .helper .NodeAssertions ;
2424import de .danielbechler .diff .mock .ObjectDiffTest ;
25- import org .fest . assertions . api . Assertions ;
25+ import org .hamcrest . MatcherAssert ;
2626import org .hamcrest .core .Is ;
27+ import org .mockito .Mockito ;
28+ import org .mockito .MockitoAnnotations ;
2729import org .testng .annotations .BeforeMethod ;
2830import org .testng .annotations .Test ;
2931
3436import java .util .Set ;
3537
3638import static org .fest .assertions .api .Assertions .assertThat ;
37- import static org .hamcrest .MatcherAssert .assertThat ;
38- import static org .mockito .Mockito .mock ;
39- import static org .mockito .Mockito .times ;
40- import static org .mockito .Mockito .verify ;
41- import static org .mockito .Mockito .when ;
4239import static org .mockito .MockitoAnnotations .Mock ;
43- import static org .mockito .MockitoAnnotations .initMocks ;
4440
4541/**
4642 * @author Daniel Bechler
@@ -53,55 +49,55 @@ public class DiffNodeTest
5349 @ BeforeMethod
5450 public void setUp ()
5551 {
56- initMocks (this );
52+ MockitoAnnotations . initMocks (this );
5753 }
5854
5955 @ Test
6056 public void hasChanges_returns_false_when_untouched ()
6157 {
6258 final DiffNode node = new DiffNode (String .class );
6359 node .setState (DiffNode .State .UNTOUCHED );
64- assertThat (node .hasChanges (), Is .is (false ));
60+ MatcherAssert . assertThat (node .hasChanges (), Is .is (false ));
6561 }
6662
6763 @ Test
6864 public void hasChanges_returns_false_when_ignored ()
6965 {
7066 final DiffNode node = new DiffNode (String .class );
7167 node .setState (DiffNode .State .IGNORED );
72- assertThat (node .hasChanges (), Is .is (false ));
68+ MatcherAssert . assertThat (node .hasChanges (), Is .is (false ));
7369 }
7470
7571 @ Test
7672 public void hasChanges_returns_false_when_circular ()
7773 {
7874 final DiffNode node = new DiffNode (String .class );
7975 node .setState (DiffNode .State .CIRCULAR );
80- assertThat (node .hasChanges (), Is .is (false ));
76+ MatcherAssert . assertThat (node .hasChanges (), Is .is (false ));
8177 }
8278
8379 @ Test
8480 public void hasChanges_returns_true_when_changed ()
8581 {
8682 final DiffNode node = new DiffNode (String .class );
8783 node .setState (DiffNode .State .CHANGED );
88- assertThat (node .hasChanges (), Is .is (true ));
84+ MatcherAssert . assertThat (node .hasChanges (), Is .is (true ));
8985 }
9086
9187 @ Test
9288 public void hasChanges_returns_true_when_removed ()
9389 {
9490 final DiffNode node = new DiffNode (String .class );
9591 node .setState (DiffNode .State .REMOVED );
96- assertThat (node .hasChanges (), Is .is (true ));
92+ MatcherAssert . assertThat (node .hasChanges (), Is .is (true ));
9793 }
9894
9995 @ Test
10096 public void hasChanges_returns_true_when_added ()
10197 {
10298 final DiffNode node = new DiffNode (String .class );
10399 node .setState (DiffNode .State .ADDED );
104- assertThat (node .hasChanges (), Is .is (true ));
100+ MatcherAssert . assertThat (node .hasChanges (), Is .is (true ));
105101 }
106102
107103 @ Test
@@ -111,14 +107,14 @@ public void hasChanges_returns_true_when_child_has_changed()
111107 final DiffNode child = new DiffNode (root , new CollectionItemAccessor ("foo" ), String .class );
112108 root .addChild (child );
113109 child .setState (DiffNode .State .ADDED );
114- assertThat (root .hasChanges (), Is .is (true ));
110+ MatcherAssert . assertThat (root .hasChanges (), Is .is (true ));
115111 }
116112
117113 @ Test
118114 public void getPropertyPath_with_parent_node_should_return_canonical_path ()
119115 {
120116 final DiffNode parentNode = new DiffNode (RootAccessor .getInstance (), String .class );
121- when (accessor .getElementSelector ()).thenReturn (new BeanPropertyElementSelector ("foo" ));
117+ Mockito . when (accessor .getElementSelector ()).thenReturn (new BeanPropertyElementSelector ("foo" ));
122118
123119 final DiffNode root = new DiffNode (parentNode , accessor , Object .class );
124120
@@ -182,44 +178,44 @@ public void addChild_changes_node_state_to_changed_if_changed_child_node_gets_ad
182178 @ Test
183179 public void should_return_property_annotations_of_property_accessor () throws Exception
184180 {
185- final BeanPropertyAccessor propertyAccessor = mock (BeanPropertyAccessor .class );
186- final Annotation annotation = mock (Annotation .class );
187- when (propertyAccessor .getReadMethodAnnotations ()).thenReturn (new LinkedHashSet <Annotation >(Arrays .asList (annotation )));
181+ final BeanPropertyAccessor propertyAccessor = Mockito . mock (BeanPropertyAccessor .class );
182+ final Annotation annotation = Mockito . mock (Annotation .class );
183+ Mockito . when (propertyAccessor .getReadMethodAnnotations ()).thenReturn (new LinkedHashSet <Annotation >(Arrays .asList (annotation )));
188184 final DiffNode node = new DiffNode (propertyAccessor , Object .class );
189185
190186 final Set <Annotation > annotations = node .getPropertyAnnotations ();
191187
192- Assertions . assertThat (annotations ).containsAll (Arrays .asList (annotation ));
188+ assertThat (annotations ).containsAll (Arrays .asList (annotation ));
193189 }
194190
195191 @ Test
196192 public void should_return_empty_set_of_property_annotations_if_accessor_is_not_property_accessor () throws Exception
197193 {
198- final BeanPropertyAccessor propertyAccessor = mock (BeanPropertyAccessor .class );
199- final Annotation annotation = mock (Annotation .class );
200- when (propertyAccessor .getReadMethodAnnotations ()).thenReturn (new LinkedHashSet <Annotation >(Arrays .asList (annotation )));
194+ final BeanPropertyAccessor propertyAccessor = Mockito . mock (BeanPropertyAccessor .class );
195+ final Annotation annotation = Mockito . mock (Annotation .class );
196+ Mockito . when (propertyAccessor .getReadMethodAnnotations ()).thenReturn (new LinkedHashSet <Annotation >(Arrays .asList (annotation )));
201197 final DiffNode node = new DiffNode (propertyAccessor , Object .class );
202198
203199 final Set <Annotation > annotations = node .getPropertyAnnotations ();
204200
205- Assertions . assertThat (annotations ).containsAll (Arrays .asList (annotation ));
201+ assertThat (annotations ).containsAll (Arrays .asList (annotation ));
206202 }
207203
208204 @ Test
209205 public void getPropertyAnnotation_should_delegate_call_to_property_accessor ()
210206 {
211- final BeanPropertyAccessor propertyAccessor = mock (BeanPropertyAccessor .class );
212- when (propertyAccessor .getReadMethodAnnotation (ObjectDiffTest .class )).thenReturn (null );
207+ final BeanPropertyAccessor propertyAccessor = Mockito . mock (BeanPropertyAccessor .class );
208+ Mockito . when (propertyAccessor .getReadMethodAnnotation (ObjectDiffTest .class )).thenReturn (null );
213209
214210 new DiffNode (propertyAccessor , Object .class ).getPropertyAnnotation (ObjectDiffTest .class );
215211
216- verify (propertyAccessor , times (1 )).getReadMethodAnnotation (ObjectDiffTest .class );
212+ Mockito . verify (propertyAccessor , Mockito . times (1 )).getReadMethodAnnotation (ObjectDiffTest .class );
217213 }
218214
219215 @ Test
220216 public void getPropertyAnnotation_should_return_null_if_accessor_is_not_property_accessor ()
221217 {
222- final Accessor propertyAccessor = mock (Accessor .class );
218+ final Accessor propertyAccessor = Mockito . mock (Accessor .class );
223219
224220 final ObjectDiffTest annotation = new DiffNode (propertyAccessor , Object .class ).getPropertyAnnotation (ObjectDiffTest .class );
225221
@@ -230,8 +226,8 @@ public void getPropertyAnnotation_should_return_null_if_accessor_is_not_property
230226 public void getPropertyName_returns_name_from_PropertyAwareAccessor ()
231227 {
232228 final String expectedPropertyName = "foo" ;
233- final PropertyAwareAccessor accessor = mock (PropertyAwareAccessor .class );
234- when (accessor .getPropertyName ()).thenReturn (expectedPropertyName );
229+ final PropertyAwareAccessor accessor = Mockito . mock (PropertyAwareAccessor .class );
230+ Mockito . when (accessor .getPropertyName ()).thenReturn (expectedPropertyName );
235231
236232 final DiffNode diffNode = new DiffNode (accessor , Object .class );
237233 final String actualPropertyName = diffNode .getPropertyName ();
@@ -244,27 +240,27 @@ public void getPropertyName_returns_name_from_parentNode()
244240 {
245241 final String expectedPropertyName = "foo" ;
246242
247- final PropertyAwareAccessor propertyAwareAccessor = mock (PropertyAwareAccessor .class );
248- when (propertyAwareAccessor .getPropertyName ()).thenReturn (expectedPropertyName );
243+ final PropertyAwareAccessor propertyAwareAccessor = Mockito . mock (PropertyAwareAccessor .class );
244+ Mockito . when (propertyAwareAccessor .getPropertyName ()).thenReturn (expectedPropertyName );
249245
250246 final DiffNode parentNodeWithPropertyAwareAccessor = new DiffNode (propertyAwareAccessor , Object .class );
251- final DiffNode node = new DiffNode (parentNodeWithPropertyAwareAccessor , mock (Accessor .class ), Object .class );
247+ final DiffNode node = new DiffNode (parentNodeWithPropertyAwareAccessor , Mockito . mock (Accessor .class ), Object .class );
252248
253249 assertThat (node .getPropertyName ()).isEqualTo (expectedPropertyName );
254250 }
255251
256252 @ Test
257253 public void getPropertyName_returns_null_when_property_name_can_not_be_resolved ()
258254 {
259- final DiffNode node = new DiffNode (mock (Accessor .class ), Object .class );
255+ final DiffNode node = new DiffNode (Mockito . mock (Accessor .class ), Object .class );
260256
261257 assertThat (node .getPropertyName ()).isNull ();
262258 }
263259
264260 @ Test
265261 public void isPropertyAware_returns_true ()
266262 {
267- final PropertyAwareAccessor propertyAwareAccessor = mock (PropertyAwareAccessor .class );
263+ final PropertyAwareAccessor propertyAwareAccessor = Mockito . mock (PropertyAwareAccessor .class );
268264 final DiffNode node = new DiffNode (propertyAwareAccessor , Object .class );
269265
270266 assertThat (node .isPropertyAware ()).isTrue ();
@@ -273,7 +269,7 @@ public void isPropertyAware_returns_true()
273269 @ Test
274270 public void isPropertyAware_returns_false ()
275271 {
276- final Accessor notAPropertyAwareAccessor = mock (Accessor .class );
272+ final Accessor notAPropertyAwareAccessor = Mockito . mock (Accessor .class );
277273
278274 final DiffNode node = new DiffNode (notAPropertyAwareAccessor , Object .class );
279275
0 commit comments