Skip to content

Commit 8145e8b

Browse files
committed
Apply formatter to PowerMockitoMockStaticToMockito
1 parent fb81b3e commit 8145e8b

File tree

2 files changed

+77
-75
lines changed

2 files changed

+77
-75
lines changed

src/main/java/org/openrewrite/java/testing/mockito/PowerMockitoMockStaticToMockito.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ private static class PowerMockitoToMockitoVisitor extends JavaVisitor<ExecutionC
6969
private static final MethodMatcher DYNAMIC_WHEN_METHOD_MATCHER = new MethodMatcher("org.mockito.Mockito when(java.lang.Class, String, ..)");
7070
private static final String MOCK_PREFIX = "mocked";
7171
private static final String TEST_GROUP = "testGroup";
72+
7273
private String setUpMethodAnnotationSignature;
7374
private String setUpMethodAnnotation;
7475
private String tearDownMethodAnnotationSignature;

src/test/java/org/openrewrite/java/testing/mockito/PowerMockitoMockStaticToMockitoTest.java

Lines changed: 76 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void testStaticMethod() {
7878
import org.mockito.MockedStatic;
7979
8080
public class MyTest {
81-
81+
8282
private MockedStatic<Calendar> mockedCalendar;
8383
8484
@BeforeEach
@@ -219,38 +219,38 @@ void tearDownMethodOfTestNGHasAnnotationWithArgument() {
219219
java(
220220
"""
221221
import java.util.Calendar;
222-
222+
223223
import org.testng.annotations.Test;
224224
import org.powermock.core.classloader.annotations.PrepareForTest;
225-
225+
226226
@PrepareForTest({Calendar.class})
227227
public class MyTest {
228-
228+
229229
@Test
230230
void testSomething() { }
231-
231+
232232
}
233233
""",
234234
"""
235235
import java.util.Calendar;
236-
236+
237237
import org.testng.annotations.AfterMethod;
238238
import org.testng.annotations.BeforeMethod;
239239
import org.testng.annotations.Test;
240-
240+
241241
public class MyTest {
242-
242+
243243
@BeforeMethod
244244
void setUpStaticMocks() {
245245
}
246-
246+
247247
@AfterMethod(alwaysRun = true)
248248
void tearDownStaticMocks() {
249249
}
250-
250+
251251
@Test
252252
void testSomething() { }
253-
253+
254254
}
255255
"""
256256
)
@@ -264,41 +264,41 @@ void tearDownMethodOfTestNGWithAnnotationRemainsUntouched() {
264264
java(
265265
"""
266266
import java.util.Calendar;
267-
267+
268268
import org.testng.annotations.AfterMethod;
269269
import org.testng.annotations.Test;
270270
import org.powermock.core.classloader.annotations.PrepareForTest;
271-
271+
272272
@PrepareForTest({Calendar.class})
273273
public class MyTest {
274-
274+
275275
@AfterMethod(groups = "irrelevant")
276276
void tearDown() {}
277-
277+
278278
@Test
279279
void testSomething() { }
280-
280+
281281
}
282282
""",
283283
"""
284284
import java.util.Calendar;
285-
285+
286286
import org.testng.annotations.AfterMethod;
287287
import org.testng.annotations.BeforeMethod;
288288
import org.testng.annotations.Test;
289-
289+
290290
public class MyTest {
291-
291+
292292
@AfterMethod(groups = "irrelevant")
293293
void tearDown() {}
294-
294+
295295
@BeforeMethod
296296
void setUpStaticMocks() {
297297
}
298-
298+
299299
@Test
300300
void testSomething() { }
301-
301+
302302
}
303303
"""
304304
)
@@ -312,22 +312,22 @@ void tearDownMethodOfTestNGHasAnnotationWithSameArgumentsAsTheTestThatCallsMockS
312312
java(
313313
"""
314314
import java.util.Calendar;
315-
315+
316316
import static org.mockito.Mockito.*;
317-
317+
318318
import org.testng.annotations.AfterMethod;
319319
import org.testng.annotations.BeforeMethod;
320320
import org.testng.annotations.Test;
321321
import org.powermock.core.classloader.annotations.PrepareForTest;
322-
322+
323323
@PrepareForTest({Calendar.class})
324324
public class MyTest {
325-
325+
326326
private Calendar calendarMock;
327-
327+
328328
@Test(groups = "irrelevant")
329329
void testSomethingIrrelevantForCheckin() { }
330-
330+
331331
@Test(groups = "checkin")
332332
void testStaticMethod() {
333333
calendarMock = mock(Calendar.class);
@@ -338,33 +338,33 @@ void testStaticMethod() {
338338
""",
339339
"""
340340
import java.util.Calendar;
341-
341+
342342
import static org.mockito.Mockito.*;
343-
343+
344344
import org.mockito.MockedStatic;
345345
import org.testng.annotations.AfterMethod;
346346
import org.testng.annotations.BeforeMethod;
347347
import org.testng.annotations.Test;
348-
348+
349349
public class MyTest {
350-
350+
351351
private MockedStatic<Calendar> mockedCalendar;
352-
352+
353353
private Calendar calendarMock;
354-
354+
355355
@BeforeMethod(groups = "checkin")
356356
void setUpStaticMocks() {
357357
mockedCalendar = mockStatic(Calendar.class);
358358
}
359-
359+
360360
@AfterMethod(groups = "checkin")
361361
void tearDownStaticMocks() {
362362
mockedCalendar.closeOnDemand();
363363
}
364-
364+
365365
@Test(groups = "irrelevant")
366366
void testSomethingIrrelevantForCheckin() { }
367-
367+
368368
@Test(groups = "checkin")
369369
void testStaticMethod() {
370370
calendarMock = mock(Calendar.class);
@@ -383,19 +383,19 @@ void argumentOfWhenOnStaticMethodWithParametersIsReplacedByLambda() {
383383
java(
384384
"""
385385
import static org.mockito.Mockito.*;
386-
386+
387387
import java.util.Calendar;
388388
import java.util.Locale;
389-
389+
390390
import org.junit.jupiter.api.Test;
391391
import org.mockito.MockedStatic;
392-
392+
393393
public class MyTest {
394-
394+
395395
private MockedStatic<Calendar> mockedCalendar;
396-
396+
397397
private Calendar calendarMock = mock(Calendar.class);
398-
398+
399399
@Test
400400
void testStaticMethod() {
401401
when(Calendar.getInstance(Locale.ENGLISH)).thenReturn(calendarMock);
@@ -404,19 +404,19 @@ void testStaticMethod() {
404404
""",
405405
"""
406406
import static org.mockito.Mockito.*;
407-
407+
408408
import java.util.Calendar;
409409
import java.util.Locale;
410-
410+
411411
import org.junit.jupiter.api.Test;
412412
import org.mockito.MockedStatic;
413-
413+
414414
public class MyTest {
415-
415+
416416
private MockedStatic<Calendar> mockedCalendar;
417-
417+
418418
private Calendar calendarMock = mock(Calendar.class);
419-
419+
420420
@Test
421421
void testStaticMethod() {
422422
mockedCalendar.when(() -> Calendar.getInstance(Locale.ENGLISH)).thenReturn(calendarMock);
@@ -434,16 +434,16 @@ void argumentOfWhenOnInstanceMethodsAreNotReplaced() {
434434
java(
435435
"""
436436
import static org.mockito.Mockito.*;
437-
437+
438438
import java.util.Calendar;
439439
import java.util.Locale;
440-
440+
441441
import org.junit.jupiter.api.Test;
442-
442+
443443
public class MyTest {
444-
444+
445445
private Calendar calendarMock = mock(Calendar.class);
446-
446+
447447
@Test
448448
void testStaticMethod() {
449449
when(calendarMock.toString()).thenReturn(null);
@@ -461,19 +461,19 @@ void argumentOfVerifyOnParameterlessStaticMethodIsReplacedBySimpleLambda() {
461461
java(
462462
"""
463463
import static org.mockito.Mockito.*;
464-
464+
465465
import java.util.Currency;
466466
import java.util.Locale;
467-
467+
468468
import org.junit.jupiter.api.Test;
469469
import org.mockito.MockedStatic;
470-
470+
471471
public class MyTest {
472-
472+
473473
private MockedStatic<Currency> mockedCurrency;
474-
474+
475475
private Currency currencyMock = mock(Currency.class);
476-
476+
477477
@Test
478478
void testStaticMethod() {
479479
verify(Currency.getInstance(Locale.ENGLISH), never());
@@ -483,19 +483,19 @@ void testStaticMethod() {
483483
""",
484484
"""
485485
import static org.mockito.Mockito.*;
486-
486+
487487
import java.util.Currency;
488488
import java.util.Locale;
489-
489+
490490
import org.junit.jupiter.api.Test;
491491
import org.mockito.MockedStatic;
492-
492+
493493
public class MyTest {
494-
494+
495495
private MockedStatic<Currency> mockedCurrency;
496-
496+
497497
private Currency currencyMock = mock(Currency.class);
498-
498+
499499
@Test
500500
void testStaticMethod() {
501501
mockedCurrency.verify(() -> Currency.getInstance(Locale.ENGLISH), never());
@@ -519,13 +519,13 @@ public interface MyInterface {
519519
}
520520
""")
521521
, java(
522-
"""
522+
"""
523523
public abstract class MyAbstractClass {
524-
524+
525525
public boolean isItTrue() { return true; }
526-
526+
527527
public abstract boolean isItImplemented();
528-
528+
529529
}
530530
"""
531531
));
@@ -537,14 +537,14 @@ void extensionOfPowerMockTestCaseGetsRemoved() {
537537
rewriteRun(java(
538538
"""
539539
package org.powermock.modules.testng;
540-
540+
541541
public class PowerMockTestCase {}
542542
"""
543543
),
544544
java(
545545
"""
546546
import org.powermock.modules.testng.PowerMockTestCase;
547-
547+
548548
public class MyPowerMockTestCase extends PowerMockTestCase {}
549549
""",
550550
"""
@@ -560,14 +560,14 @@ void extensionOfPowerMockConfigurationGetsRemoved() {
560560
java(
561561
"""
562562
package org.powermock.configuration;
563-
563+
564564
public class PowerMockConfiguration {}
565565
"""
566566
),
567567
java(
568568
"""
569569
import org.powermock.configuration.PowerMockConfiguration;
570-
570+
571571
public class MyPowerMockConfiguration extends PowerMockConfiguration {}
572572
""",
573573
"""
@@ -608,6 +608,7 @@ void doesNotExplodeOnTopLevelMethodDeclaration() {
608608
rewriteRun(
609609
groovy(
610610
"def myFun() { }"
611-
));
611+
)
612+
);
612613
}
613614
}

0 commit comments

Comments
 (0)