@@ -1203,6 +1203,29 @@ examples:
12031203 language: java
12041204 ---
12051205type : specs.openrewrite.org/v1beta/example
1206+ recipeName : org.openrewrite.java.testing.cleanup.AssertEqualsIntegralDeltaToAssertEquals
1207+ examples :
1208+ - description : ' `AssertEqualsIntegralDeltaToAssertEqualsTest#removeIntDelta`'
1209+ sources :
1210+ - before : |
1211+ import static org.junit.jupiter.api.Assertions.assertEquals;
1212+
1213+ public class Test {
1214+ void test() {
1215+ assertEquals(1, 2, 0);
1216+ }
1217+ }
1218+ after: |
1219+ import static org.junit.jupiter.api.Assertions.assertEquals;
1220+
1221+ public class Test {
1222+ void test() {
1223+ assertEquals(1, 2);
1224+ }
1225+ }
1226+ language: java
1227+ ---
1228+ type : specs.openrewrite.org/v1beta/example
12061229recipeName : org.openrewrite.java.testing.cleanup.AssertLiteralBooleanRemovedRecipe
12071230examples :
12081231- description : ' `AssertLiteralBooleanRemovedTest#assertWithStaticImports`'
@@ -4722,6 +4745,43 @@ examples:
47224745 language: java
47234746 ---
47244747type : specs.openrewrite.org/v1beta/example
4748+ recipeName : org.openrewrite.java.testing.mockito.PowerMockitoDoStubbingToMockito
4749+ examples :
4750+ - description : ' `PowerMockitoDoStubbingToMockitoTest#doNothingWithStringMethodName`'
4751+ sources :
4752+ - before : |
4753+ import org.junit.jupiter.api.BeforeEach;
4754+ import org.powermock.api.mockito.PowerMockito;
4755+ import java.util.Calendar;
4756+
4757+ class MyTest {
4758+
4759+ private Calendar calendarSpy;
4760+
4761+ @BeforeEach
4762+ void setUp() throws Exception {
4763+ calendarSpy = PowerMockito.spy(Calendar.getInstance());
4764+ PowerMockito.doNothing().when(calendarSpy, "clear");
4765+ }
4766+ }
4767+ after: |
4768+ import org.junit.jupiter.api.BeforeEach;
4769+ import org.powermock.api.mockito.PowerMockito;
4770+ import java.util.Calendar;
4771+
4772+ class MyTest {
4773+
4774+ private Calendar calendarSpy;
4775+
4776+ @BeforeEach
4777+ void setUp() throws Exception {
4778+ calendarSpy = PowerMockito.spy(Calendar.getInstance());
4779+ PowerMockito.doNothing().when(calendarSpy).clear();
4780+ }
4781+ }
4782+ language: java
4783+ ---
4784+ type : specs.openrewrite.org/v1beta/example
47254785recipeName : org.openrewrite.java.testing.mockito.PowerMockitoMockStaticToMockito
47264786examples :
47274787- description : ' `PowerMockitoMockStaticToMockitoTest#prepareForTestAnnotationIsReplacedBySingleField`'
@@ -4773,6 +4833,53 @@ examples:
47734833 language: java
47744834 ---
47754835type : specs.openrewrite.org/v1beta/example
4836+ recipeName : org.openrewrite.java.testing.mockito.RemoveDoNothingForDefaultMocks
4837+ examples :
4838+ - description : ' `RemoveDoNothingForDefaultMocksTest#removesDoNothingOnMockVoidMethod`'
4839+ sources :
4840+ - before : |
4841+ import org.junit.Test;
4842+ import org.junit.runner.RunWith;
4843+ import org.mockito.Mock;
4844+ import org.mockito.junit.MockitoJUnitRunner;
4845+ import java.io.BufferedWriter;
4846+ import java.io.IOException;
4847+
4848+ import static org.mockito.Mockito.doNothing;
4849+ import static org.mockito.ArgumentMatchers.anyString;
4850+
4851+ @RunWith(MockitoJUnitRunner.class)
4852+ class MyTest {
4853+ @Mock
4854+ private BufferedWriter bufferedWriter;
4855+
4856+ @Test
4857+ public void test() throws IOException {
4858+ doNothing().when(bufferedWriter).write(anyString());
4859+ }
4860+ }
4861+ after: |
4862+ import org.junit.Test;
4863+ import org.junit.runner.RunWith;
4864+ import org.mockito.Mock;
4865+ import org.mockito.junit.MockitoJUnitRunner;
4866+ import java.io.BufferedWriter;
4867+ import java.io.IOException;
4868+
4869+ import static org.mockito.ArgumentMatchers.anyString;
4870+
4871+ @RunWith(MockitoJUnitRunner.class)
4872+ class MyTest {
4873+ @Mock
4874+ private BufferedWriter bufferedWriter;
4875+
4876+ @Test
4877+ public void test() throws IOException {
4878+ }
4879+ }
4880+ language: java
4881+ ---
4882+ type : specs.openrewrite.org/v1beta/example
47764883recipeName : org.openrewrite.java.testing.mockito.RemoveInitMocksIfRunnersSpecified
47774884examples :
47784885- description : ' `RemoveInitMocksIfRunnersSpecifiedTest#removeInitMocksInJUnit5`'
@@ -4807,6 +4914,24 @@ examples:
48074914 language: java
48084915 ---
48094916type : specs.openrewrite.org/v1beta/example
4917+ recipeName : org.openrewrite.java.testing.mockito.RemovePowerMockClassExtensions
4918+ examples :
4919+ - description : ' `RemovePowerMockClassExtensionsTest#extensionOfPowerMockTestCaseGetsRemoved`'
4920+ sources :
4921+ - before : |
4922+ import org.powermock.modules.testng.PowerMockTestCase;
4923+
4924+ public class MyPowerMockTestCase extends PowerMockTestCase {}
4925+ after: |
4926+ public class MyPowerMockTestCase {}
4927+ language: java
4928+ - before : |
4929+ package org.powermock.modules.testng;
4930+
4931+ public class PowerMockTestCase {}
4932+ language: java
4933+ ---
4934+ type : specs.openrewrite.org/v1beta/example
48104935recipeName : org.openrewrite.java.testing.mockito.RemoveTimesZeroAndOne
48114936examples :
48124937- description : ' `RemoveTimesZeroAndOneTest#replaceTimesZero`'
@@ -5029,6 +5154,29 @@ examples:
50295154 language: java
50305155 ---
50315156type : specs.openrewrite.org/v1beta/example
5157+ recipeName : org.openrewrite.java.testing.mockito.ThenThrowCheckedExceptionToRuntimeException
5158+ examples :
5159+ - description : ' `ThenThrowCheckedExceptionToRuntimeExceptionTest#replacesUndeclaredCheckedExceptionWithRuntimeException`'
5160+ sources :
5161+ - before : |
5162+ import static org.mockito.Mockito.when;
5163+
5164+ class MyTest {
5165+ void test(MyService service) {
5166+ when(service.execute("a", "b")).thenThrow(Exception.class);
5167+ }
5168+ }
5169+ after: |
5170+ import static org.mockito.Mockito.when;
5171+
5172+ class MyTest {
5173+ void test(MyService service) {
5174+ when(service.execute("a", "b")).thenThrow(RuntimeException.class);
5175+ }
5176+ }
5177+ language: java
5178+ ---
5179+ type : specs.openrewrite.org/v1beta/example
50325180recipeName : org.openrewrite.java.testing.mockito.VerifyZeroToNoMoreInteractions
50335181examples :
50345182- description : ' `VerifyZeroToNoMoreInteractionsTest#shouldReplaceToNoMoreInteractions`'
0 commit comments