|
15 | 15 | */ |
16 | 16 | package org.openrewrite.java.testing.mockito; |
17 | 17 |
|
| 18 | +import org.junit.jupiter.api.Disabled; |
18 | 19 | import org.junit.jupiter.api.Test; |
19 | 20 | import org.openrewrite.DocumentExample; |
20 | 21 | import org.openrewrite.InMemoryExecutionContext; |
@@ -121,65 +122,6 @@ void usingAnnotationBasedMock() { |
121 | 122 | ); |
122 | 123 | } |
123 | 124 |
|
124 | | - /** |
125 | | - * Replaces org.mockito.Matchers with org.mockito.ArgumentMatchers |
126 | | - */ |
127 | | - @Test |
128 | | - void replacesMatchers() { |
129 | | - //language=java |
130 | | - rewriteRun( |
131 | | - java( |
132 | | - """ |
133 | | - package mockito.example; |
134 | | - |
135 | | - import java.util.List; |
136 | | - |
137 | | - import static org.mockito.Mockito.*; |
138 | | - |
139 | | - public class MockitoArgumentMatchersTest { |
140 | | - static class Foo { |
141 | | - boolean bool(String str, int i, Object obj) { return false; } |
142 | | - int in(boolean b, List<String> strs) { return 0; } |
143 | | - int bar(byte[] bytes, String[] s, int i) { return 0; } |
144 | | - boolean baz(String ... strings) { return true; } |
145 | | - } |
146 | | -
|
147 | | - public void usesMatchers() { |
148 | | - Foo mockFoo = mock(Foo.class); |
149 | | - when(mockFoo.bool(anyString(), anyInt(), any(Object.class))).thenReturn(true); |
150 | | - when(mockFoo.bool(eq("false"), anyInt(), any(Object.class))).thenReturn(false); |
151 | | - when(mockFoo.in(anyBoolean(), anyList())).thenReturn(10); |
152 | | - } |
153 | | - } |
154 | | - """, |
155 | | - """ |
156 | | - package mockito.example; |
157 | | - |
158 | | - import java.util.List; |
159 | | - |
160 | | - import static org.mockito.ArgumentMatchers.nullable; |
161 | | - import static org.mockito.Mockito.*; |
162 | | - |
163 | | - public class MockitoArgumentMatchersTest { |
164 | | - static class Foo { |
165 | | - boolean bool(String str, int i, Object obj) { return false; } |
166 | | - int in(boolean b, List<String> strs) { return 0; } |
167 | | - int bar(byte[] bytes, String[] s, int i) { return 0; } |
168 | | - boolean baz(String ... strings) { return true; } |
169 | | - } |
170 | | -
|
171 | | - public void usesMatchers() { |
172 | | - Foo mockFoo = mock(Foo.class); |
173 | | - when(mockFoo.bool(nullable(String.class), anyInt(), nullable(Object.class))).thenReturn(true); |
174 | | - when(mockFoo.bool(eq("false"), anyInt(), nullable(Object.class))).thenReturn(false); |
175 | | - when(mockFoo.in(anyBoolean(), anyList())).thenReturn(10); |
176 | | - } |
177 | | - } |
178 | | - """ |
179 | | - ) |
180 | | - ); |
181 | | - } |
182 | | - |
183 | 125 | /** |
184 | 126 | * Mockito 1 used Matchers.anyVararg() to match the arguments to a variadic function. |
185 | 127 | * Mockito 2+ uses Matchers.any() to match anything including the arguments to a variadic function. |
|
0 commit comments