Skip to content

Commit e6efc8c

Browse files
committed
Remove deprecated test method usages
1 parent a56fa70 commit e6efc8c

11 files changed

Lines changed: 49 additions & 47 deletions

File tree

‎AndroidAnnotations/androidannotations-core/androidannotations-test/src/test/java/org/androidannotations/test/ThreadActivityTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import org.junit.Before;
3838
import org.junit.Test;
3939
import org.junit.runner.RunWith;
40-
import org.mockito.Matchers;
40+
import org.mockito.ArgumentMatchers;
4141
import org.mockito.internal.util.MockUtil;
4242
import org.robolectric.Robolectric;
4343
import org.robolectric.RobolectricTestRunner;
@@ -106,7 +106,7 @@ public void backgroundDelegatesToExecutor() {
106106

107107
activity.emptyBackgroundMethod();
108108

109-
verify(executor).execute(Matchers.<Runnable> any());
109+
verify(executor).execute(ArgumentMatchers.<Runnable> any());
110110
}
111111

112112
/**

‎AndroidAnnotations/androidannotations-core/androidannotations-test/src/test/java/org/androidannotations/test/TransactionalActivityTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.androidannotations.test;
1717

1818
import static org.junit.Assert.fail;
19-
import static org.mockito.Matchers.anyString;
19+
import static org.mockito.ArgumentMatchers.anyString;
2020
import static org.mockito.Mockito.inOrder;
2121
import static org.mockito.Mockito.mock;
2222
import static org.mockito.Mockito.never;

‎AndroidAnnotations/androidannotations-core/androidannotations-test/src/test/java/org/androidannotations/test/preference/PreferenceAnnotationsFragmentTest.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import org.junit.Before;
2323
import org.junit.Test;
2424
import org.junit.runner.RunWith;
25+
import org.robolectric.Robolectric;
2526
import org.robolectric.RobolectricTestRunner;
26-
import org.robolectric.util.FragmentTestUtil;
2727

2828
import android.preference.Preference;
2929

@@ -34,8 +34,7 @@ public class PreferenceAnnotationsFragmentTest {
3434

3535
@Before
3636
public void setUp() {
37-
fragment = new PreferenceAnnotationsFragment_();
38-
FragmentTestUtil.startFragment(fragment);
37+
fragment = Robolectric.buildFragment(PreferenceAnnotationsFragment_.class).create().start().resume().get();
3938
}
4039

4140
@Test

‎AndroidAnnotations/androidannotations-core/androidannotations-test/src/test/java/org/androidannotations/test/preference/PreferenceScreenFragmentTest.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import org.junit.Before;
2222
import org.junit.Test;
2323
import org.junit.runner.RunWith;
24+
import org.robolectric.Robolectric;
2425
import org.robolectric.RobolectricTestRunner;
25-
import org.robolectric.util.FragmentTestUtil;
2626

2727
@RunWith(RobolectricTestRunner.class)
2828
public class PreferenceScreenFragmentTest {
@@ -31,8 +31,7 @@ public class PreferenceScreenFragmentTest {
3131

3232
@Before
3333
public void setUp() {
34-
fragment = new PreferenceScreenFragment_();
35-
FragmentTestUtil.startFragment(fragment);
34+
fragment = Robolectric.buildFragment(PreferenceScreenFragment_.class).create().start().resume().get();
3635
}
3736

3837
@Test

‎AndroidAnnotations/androidannotations-core/androidannotations-test/src/test/java/org/androidannotations/test/receiver/FragmentWithReceiverTest.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
package org.androidannotations.test.receiver;
1818

1919
import static org.junit.Assert.assertTrue;
20-
import static org.robolectric.util.FragmentTestUtil.startFragment;
2120

2221
import org.junit.Before;
2322
import org.junit.Test;
2423
import org.junit.runner.RunWith;
24+
import org.robolectric.Robolectric;
2525
import org.robolectric.RobolectricTestRunner;
2626
import org.robolectric.RuntimeEnvironment;
2727

@@ -35,8 +35,7 @@ public class FragmentWithReceiverTest {
3535

3636
@Before
3737
public void setUp() {
38-
fragment = new FragmentWithReceiver_();
39-
startFragment(fragment);
38+
fragment = Robolectric.buildFragment(FragmentWithReceiver_.class).create().start().resume().get();
4039
}
4140

4241
@Test

‎AndroidAnnotations/androidannotations-core/androidannotations/src/test/java/org/androidannotations/helper/ValidatorParameterHelperTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import static org.junit.Assert.assertFalse;
1919
import static org.junit.Assert.assertTrue;
20-
import static org.mockito.Matchers.any;
20+
import static org.mockito.ArgumentMatchers.any;
2121
import static org.mockito.Mockito.doAnswer;
2222
import static org.mockito.Mockito.doReturn;
2323
import static org.mockito.Mockito.mock;

‎AndroidAnnotations/androidannotations-rest-spring/rest-spring-test/src/test/java/org/androidannotations/rest/spring/test/HttpMethodServiceTest.java‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import org.junit.Test;
2323
import org.junit.runner.RunWith;
24-
import org.mockito.Matchers;
24+
import org.mockito.ArgumentMatchers;
2525
import org.robolectric.RobolectricTestRunner;
2626
import org.springframework.http.HttpEntity;
2727
import org.springframework.http.HttpHeaders;
@@ -41,7 +41,8 @@ public void useDeleteHttpMethod() {
4141

4242
service.delete();
4343

44-
verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod> eq(HttpMethod.DELETE), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any());
44+
verify(restTemplate).exchange(ArgumentMatchers.anyString(), ArgumentMatchers.<HttpMethod> eq(HttpMethod.DELETE), ArgumentMatchers.<HttpEntity<?>> any(),
45+
ArgumentMatchers.<Class<Object>> any());
4546
}
4647

4748
@Test
@@ -53,7 +54,7 @@ public void useGetHttpMethod() {
5354

5455
service.get();
5556

56-
verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod> eq(HttpMethod.GET), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any());
57+
verify(restTemplate).exchange(ArgumentMatchers.anyString(), ArgumentMatchers.<HttpMethod> eq(HttpMethod.GET), ArgumentMatchers.<HttpEntity<?>> any(), ArgumentMatchers.<Class<Object>> any());
5758
}
5859

5960
@Test
@@ -63,13 +64,14 @@ public void useHeadHttpMethod() {
6364

6465
RestTemplate restTemplate = mock(RestTemplate.class);
6566
ResponseEntity<Object> response = mock(ResponseEntity.class);
66-
when(restTemplate.exchange(Matchers.anyString(), Matchers.<HttpMethod> eq(HttpMethod.HEAD), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any())).thenReturn(response);
67+
when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.<HttpMethod> eq(HttpMethod.HEAD), ArgumentMatchers.<HttpEntity<?>> any(), ArgumentMatchers.<Class<Object>> any()))
68+
.thenReturn(response);
6769

6870
service.setRestTemplate(restTemplate);
6971

7072
service.head();
7173

72-
verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod> eq(HttpMethod.HEAD), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any());
74+
verify(restTemplate).exchange(ArgumentMatchers.anyString(), ArgumentMatchers.<HttpMethod> eq(HttpMethod.HEAD), ArgumentMatchers.<HttpEntity<?>> any(), ArgumentMatchers.<Class<Object>> any());
7375
}
7476

7577
@Test
@@ -79,15 +81,17 @@ public void useOptionsHttpMethod() {
7981

8082
RestTemplate restTemplate = mock(RestTemplate.class);
8183
ResponseEntity<Object> response = mock(ResponseEntity.class);
82-
when(restTemplate.exchange(Matchers.anyString(), Matchers.<HttpMethod> eq(HttpMethod.OPTIONS), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any())).thenReturn(response);
84+
when(restTemplate.exchange(ArgumentMatchers.anyString(), ArgumentMatchers.<HttpMethod> eq(HttpMethod.OPTIONS), ArgumentMatchers.<HttpEntity<?>> any(), ArgumentMatchers.<Class<Object>> any()))
85+
.thenReturn(response);
8386
HttpHeaders headers = mock(HttpHeaders.class);
8487
when(response.getHeaders()).thenReturn(headers);
8588

8689
service.setRestTemplate(restTemplate);
8790

8891
service.options();
8992

90-
verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod> eq(HttpMethod.OPTIONS), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any());
93+
verify(restTemplate).exchange(ArgumentMatchers.anyString(), ArgumentMatchers.<HttpMethod> eq(HttpMethod.OPTIONS), ArgumentMatchers.<HttpEntity<?>> any(),
94+
ArgumentMatchers.<Class<Object>> any());
9195
}
9296

9397
@Test
@@ -99,7 +103,7 @@ public void usePostHttpMethod() {
99103

100104
service.post();
101105

102-
verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod> eq(HttpMethod.POST), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any());
106+
verify(restTemplate).exchange(ArgumentMatchers.anyString(), ArgumentMatchers.<HttpMethod> eq(HttpMethod.POST), ArgumentMatchers.<HttpEntity<?>> any(), ArgumentMatchers.<Class<Object>> any());
103107
}
104108

105109
@Test
@@ -111,7 +115,7 @@ public void usePutHttpMethod() {
111115

112116
service.put();
113117

114-
verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod> eq(HttpMethod.PUT), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any());
118+
verify(restTemplate).exchange(ArgumentMatchers.anyString(), ArgumentMatchers.<HttpMethod> eq(HttpMethod.PUT), ArgumentMatchers.<HttpEntity<?>> any(), ArgumentMatchers.<Class<Object>> any());
115119
}
116120

117121
}

‎AndroidAnnotations/androidannotations-rest-spring/rest-spring-test/src/test/java/org/androidannotations/rest/spring/test/MyServiceTest.java‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
package org.androidannotations.rest.spring.test;
1818

1919
import static org.junit.Assert.assertEquals;
20-
import static org.mockito.Matchers.argThat;
21-
import static org.mockito.Matchers.eq;
22-
import static org.mockito.Matchers.startsWith;
20+
import static org.mockito.ArgumentMatchers.argThat;
21+
import static org.mockito.ArgumentMatchers.eq;
22+
import static org.mockito.ArgumentMatchers.startsWith;
2323
import static org.mockito.Mockito.mock;
2424
import static org.mockito.Mockito.verify;
2525

@@ -32,7 +32,7 @@
3232
import org.junit.Test;
3333
import org.junit.runner.RunWith;
3434
import org.mockito.ArgumentMatcher;
35-
import org.mockito.Matchers;
35+
import org.mockito.ArgumentMatchers;
3636
import org.robolectric.RobolectricTestRunner;
3737
import org.robolectric.shadows.httpclient.FakeHttp;
3838
import org.springframework.http.HttpEntity;
@@ -70,7 +70,8 @@ public void canOverrideRootUrl() {
7070

7171
myService.removeEvent(42);
7272

73-
verify(restTemplate).exchange(startsWith("http://newRootUrl"), Matchers.<HttpMethod> any(), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any(), Matchers.<Map<String, ?>> any());
73+
verify(restTemplate).exchange(startsWith("http://newRootUrl"), (HttpMethod) ArgumentMatchers.any(), ArgumentMatchers.<HttpEntity<?>> any(), ArgumentMatchers.<Class<Object>> any(),
74+
ArgumentMatchers.<Map<String, ?>> any());
7475
}
7576

7677
@Test
@@ -193,7 +194,7 @@ public void manualFullUrl() {
193194
addPendingResponse("fancyHeaderToken");
194195
myService.setHttpBasicAuth("fancyUser", "fancierPassword");
195196
myService.ping();
196-
verify(restTemplate).exchange(eq("http://company.com/client/ping"), Matchers.<HttpMethod> any(), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any());
197+
verify(restTemplate).exchange(eq("http://company.com/client/ping"), ArgumentMatchers.<HttpMethod> any(), ArgumentMatchers.<HttpEntity<?>> any(), ArgumentMatchers.<Class<Object>> any());
197198
}
198199

199200
@Test
@@ -230,7 +231,7 @@ public boolean matches(HttpEntity<Void> argument) {
230231
urlVariables.put("location", locationValue);
231232
urlVariables.put("year", yearValue);
232233
urlVariables.put("xt", xtValue);
233-
verify(restTemplate).exchange(Matchers.anyString(), Matchers.<HttpMethod> any(), argThat(matcher), Matchers.<Class<Object>> any(), eq(urlVariables));
234+
verify(restTemplate).exchange(ArgumentMatchers.anyString(), ArgumentMatchers.<HttpMethod> any(), argThat(matcher), ArgumentMatchers.<Class<Object>> any(), eq(urlVariables));
234235
}
235236

236237
@Test

‎AndroidAnnotations/androidannotations-rest-spring/rest-spring-test/src/test/java/org/androidannotations/rest/spring/test/PathRestServiceTest.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
*/
1717
package org.androidannotations.rest.spring.test;
1818

19-
import static org.mockito.Matchers.anyString;
20-
import static org.mockito.Matchers.eq;
19+
import static org.mockito.ArgumentMatchers.anyString;
20+
import static org.mockito.ArgumentMatchers.eq;
2121
import static org.mockito.Mockito.mock;
2222
import static org.mockito.Mockito.verify;
2323

2424
import java.util.HashMap;
2525

2626
import org.junit.Test;
2727
import org.junit.runner.RunWith;
28-
import org.mockito.Matchers;
28+
import org.mockito.ArgumentMatchers;
2929
import org.robolectric.RobolectricTestRunner;
3030
import org.springframework.http.HttpEntity;
3131
import org.springframework.http.HttpMethod;
@@ -49,7 +49,7 @@ public void useAnnotationValueForUrlVariable() {
4949
urlVariables.put("parameterName", "last");
5050
urlVariables.put("bye", "second");
5151

52-
verify(restTemplate).exchange(anyString(), eq(HttpMethod.GET), Matchers.<HttpEntity<?>> any(), Matchers.<Class<Object>> any(), eq(urlVariables));
52+
verify(restTemplate).exchange(anyString(), eq(HttpMethod.GET), ArgumentMatchers.<HttpEntity<?>> any(), ArgumentMatchers.<Class<Object>> any(), eq(urlVariables));
5353
}
5454

5555
}

‎AndroidAnnotations/androidannotations-rest-spring/rest-spring-test/src/test/java/org/androidannotations/rest/spring/test/PostRestServiceTest.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
*/
1717
package org.androidannotations.rest.spring.test;
1818

19-
import static org.mockito.Matchers.anyString;
20-
import static org.mockito.Matchers.argThat;
21-
import static org.mockito.Matchers.eq;
19+
import static org.mockito.ArgumentMatchers.anyString;
20+
import static org.mockito.ArgumentMatchers.argThat;
21+
import static org.mockito.ArgumentMatchers.eq;
2222
import static org.mockito.Mockito.mock;
2323
import static org.mockito.Mockito.verify;
2424

2525
import org.junit.Before;
2626
import org.junit.Test;
2727
import org.junit.runner.RunWith;
2828
import org.mockito.ArgumentMatcher;
29-
import org.mockito.Matchers;
29+
import org.mockito.ArgumentMatchers;
3030
import org.robolectric.RobolectricTestRunner;
3131
import org.springframework.http.HttpEntity;
3232
import org.springframework.http.HttpMethod;
@@ -69,7 +69,7 @@ private void verifyPostParametersAdded() {
6969

7070
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<LinkedMultiValueMap<String, Object>>(postParameters);
7171

72-
verify(restTemplate).exchange(anyString(), eq(HttpMethod.POST), argThat(equals(requestEntity)), Matchers.<Class<Object>> any());
72+
verify(restTemplate).exchange(anyString(), eq(HttpMethod.POST), argThat(equals(requestEntity)), ArgumentMatchers.<Class<Object>> any());
7373
}
7474

7575
private static <T> ArgumentMatcher<HttpEntity<T>> equals(final HttpEntity<T> expected) {

0 commit comments

Comments
 (0)