Skip to content

Commit

Permalink
Fix trailing whitespace in text blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Philzen committed Jun 22, 2024
1 parent 721d215 commit ddc2016
Showing 1 changed file with 72 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,30 @@ public void defaults(RecipeSpec spec) {
.recipe(new MigrateDataProvider());
}

@Nested class WrapDataProvider {

@Nested
class WrapDataProvider {
@Test
void withName() {
@Test void withName() {
@Language("java") String is = """
package de.boeg.tst.provider;
import org.testng.annotations.DataProvider;
public class BoxPrimitiveDataProvider {
@DataProvider(name = "anotherBoxPrimitiveDataProvider")
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
}
""";
@Language("java") String should = """
package de.boeg.tst.provider;
import org.junit.jupiter.params.provider.Arguments;
import java.util.Arrays;
import java.util.stream.Stream;
public class BoxPrimitiveDataProvider {
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
public static Stream<Arguments> anotherBoxPrimitiveDataProvider() {
return Arrays.stream(boxPrimitiveDataProvider()).map(Arguments::of);
}
Expand All @@ -63,12 +61,11 @@ public static Stream<Arguments> anotherBoxPrimitiveDataProvider() {
rewriteRun(java(is, should));
}

@Test
void withDefaultName() {
@Test void withDefaultName() {
@Language("java") String is = """
package de.boeg.tst.provider;
import org.testng.annotations.DataProvider;
public class BoxPrimitiveDataProvider {
@DataProvider
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
Expand All @@ -77,48 +74,46 @@ public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
@Language("java") String should = """
package de.boeg.tst.provider;
import org.junit.jupiter.params.provider.Arguments;
import java.util.Arrays;
import java.util.stream.Stream;
public class BoxPrimitiveDataProvider {
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
public static Stream<Arguments> boxPrimitiveDataProvider() {
return Arrays.stream(boxPrimitiveDataProvider()).map(Arguments::of);
}
}
""";
rewriteRun(java(is, should));
}

}

@Nested
class NewTests {
@Test
void fullMigrate() {
@Nested class NewTests {

@Test void fullMigrate() {
rewriteRun(
java(
"""
package de.boeg.tst.provider;
import org.testng.annotations.DataProvider;
public class BoxPrimitiveDataProvider {
public class BoxPrimitiveDataProvider {
@DataProvider
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
}
""",
"""
package de.boeg.tst.provider;
import org.junit.jupiter.params.provider.Arguments;
import java.util.Arrays;
import java.util.stream.Stream;
public class BoxPrimitiveDataProvider {
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
public static Stream<Arguments> boxPrimitiveDataProvider() {
return Arrays.stream(boxPrimitiveDataProvider()).map(Arguments::of);
}
Expand All @@ -129,9 +124,9 @@ public static Stream<Arguments> boxPrimitiveDataProvider() {
"""
package de.boeg.tst.real;
import org.testng.annotations.Test;
import de.boeg.tst.provider.BoxPrimitiveDataProvider;
public class HotSpotConstantReflectionProviderTest {
@Test(dataProvider = "boxPrimitiveDataProvider", dataProviderClass = BoxPrimitiveDataProvider.class)
public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
Expand All @@ -141,9 +136,9 @@ public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.testng.annotations.Test;
import de.boeg.tst.provider.BoxPrimitiveDataProvider;
public class HotSpotConstantReflectionProviderTest {
@Test
@ParameterizedTest
Expand All @@ -154,29 +149,28 @@ public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
));
}

@Test
void WrapOnlyDataprovider() {
@Test void WrapOnlyDataprovider() {
rewriteRun(
java(
"""
package de.boeg.tst.provider;
import org.testng.annotations.DataProvider;
public class BoxPrimitiveDataProvider {
public class BoxPrimitiveDataProvider {
@DataProvider
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
}
""",
"""
package de.boeg.tst.provider;
import org.junit.jupiter.params.provider.Arguments;
import java.util.Arrays;
import java.util.stream.Stream;
public class BoxPrimitiveDataProvider {
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
public static Stream<Arguments> boxPrimitiveDataProvider() {
return Arrays.stream(boxPrimitiveDataProvider()).map(Arguments::of);
}
Expand All @@ -187,14 +181,14 @@ public static Stream<Arguments> boxPrimitiveDataProvider() {
"""
package de.boeg.tst.real;
import org.testng.annotations.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import de.boeg.tst.provider.BoxPrimitiveDataProvider;
class BoxPrimitiveDataProvider {}
public class HotSpotConstantReflectionProviderTest {
@Test
@MethodSource("de.boeg.tst.provider.BoxPrimitiveDataProvider#boxPrimitiveDataProvider")
Expand All @@ -205,20 +199,18 @@ public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
));
}

@Test
void addsParameterizedTest() {
rewriteRun(
java(
@Test void addsParameterizedTest() {
rewriteRun(java(
"""
package de.boeg.tst.provider;
import org.junit.jupiter.params.provider.Arguments;
import java.util.Arrays;
import java.util.stream.Stream;
public class BoxPrimitiveDataProvider {
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
public static Stream<Arguments> boxPrimitiveDataProvider() {
return Arrays.stream(boxPrimitiveDataProvider()).map(Arguments::of);
}
Expand All @@ -230,9 +222,9 @@ public static Stream<Arguments> boxPrimitiveDataProvider() {
package de.boeg.tst.real;
import org.testng.annotations.Test;
import org.junit.jupiter.params.provider.MethodSource;
import de.boeg.tst.provider.BoxPrimitiveDataProvider;
public class HotSpotConstantReflectionProviderTest {
@Test(dataProvider = "boxPrimitiveDataProvider", dataProviderClass = BoxPrimitiveDataProvider.class)
@MethodSource("de.boeg.tst.provider.BoxPrimitiveDataProvider#boxPrimitiveDataProvider")
Expand All @@ -243,9 +235,9 @@ public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
import org.testng.annotations.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import de.boeg.tst.provider.BoxPrimitiveDataProvider;
public class HotSpotConstantReflectionProviderTest {
@Test
@MethodSource("de.boeg.tst.provider.BoxPrimitiveDataProvider#boxPrimitiveDataProvider")
Expand All @@ -256,20 +248,19 @@ public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
));
}

@Test
void addsMethodSource() {
@Test void addsMethodSource() {
rewriteRun(
java(
"""
package de.boeg.tst.provider;
import org.junit.jupiter.params.provider.Arguments;
import java.util.Arrays;
import java.util.stream.Stream;
public class BoxPrimitiveDataProvider {
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
public static Stream<Arguments> boxPrimitiveDataProvider() {
return Arrays.stream(boxPrimitiveDataProvider()).map(Arguments::of);
}
Expand All @@ -280,25 +271,26 @@ public static Stream<Arguments> boxPrimitiveDataProvider() {
"""
package de.boeg.tst.real;
import org.testng.annotations.Test;
import org.junit.jupiter.params.ParameterizedTest;
import de.boeg.tst.provider.BoxPrimitiveDataProvider;
public class HotSpotConstantReflectionProviderTest {
@Test(dataProvider = "boxPrimitiveDataProvider", dataProviderClass = BoxPrimitiveDataProvider.class)
@ParameterizedTest
public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
}
""", """
""",
"""
package de.boeg.tst.real;
import org.junit.jupiter.params.provider.MethodSource;
import org.testng.annotations.Test;
import org.junit.jupiter.params.ParameterizedTest;
import de.boeg.tst.provider.BoxPrimitiveDataProvider;
public class HotSpotConstantReflectionProviderTest {
@Test
@ParameterizedTest
Expand All @@ -309,20 +301,19 @@ public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
));
}

@Test
void removesTestNgAnnotationArguments() {
@Test void removesTestNgAnnotationArguments() {
rewriteRun(
java(
"""
package de.boeg.tst.provider;
import org.junit.jupiter.params.provider.Arguments;
import java.util.Arrays;
import java.util.stream.Stream;
public class BoxPrimitiveDataProvider {
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
public static Stream<Arguments> boxPrimitiveDataProvider() {
return Arrays.stream(boxPrimitiveDataProvider()).map(Arguments::of);
}
Expand All @@ -333,11 +324,11 @@ public static Stream<Arguments> boxPrimitiveDataProvider() {
"""
package de.boeg.tst.real;
import org.testng.annotations.Test;
import org.junit.jupiter.params.ParameterizedTest;
import de.boeg.tst.provider.BoxPrimitiveDataProvider;
public class HotSpotConstantReflectionProviderTest {
@Test(dataProvider = "boxPrimitiveDataProvider", dataProviderClass = BoxPrimitiveDataProvider.class)
@ParameterizedTest
Expand All @@ -347,11 +338,11 @@ public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
package de.boeg.tst.real;
import org.junit.jupiter.params.provider.MethodSource;
import org.testng.annotations.Test;
import org.junit.jupiter.params.ParameterizedTest;
import de.boeg.tst.provider.BoxPrimitiveDataProvider;
public class HotSpotConstantReflectionProviderTest {
@Test
@ParameterizedTest
Expand All @@ -362,20 +353,18 @@ public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
));
}

@Test
void doNothingIfNameMissing() {
rewriteRun(
java(
@Test void doNothingIfNameMissing() {
rewriteRun(java(
"""
package de.boeg.tst.provider;
import org.junit.jupiter.params.provider.Arguments;
import java.util.Arrays;
import java.util.stream.Stream;
public class BoxPrimitiveDataProvider {
public static Object[][] boxPrimitiveDataProvider() { /*...*/ }
public static Stream<Arguments> boxPrimitiveDataProvider() {
return Arrays.stream(boxPrimitiveDataProvider()).map(Arguments::of);
}
Expand All @@ -386,7 +375,7 @@ public static Stream<Arguments> boxPrimitiveDataProvider() {
"""
package de.boeg.tst.real;
import org.testng.annotations.Test;
public class HotSpotConstantReflectionProviderTest {
@Test(enabled = false)
public void testUnboxPrimitive(Object constant, Object expected) {/*...*/}
Expand Down

0 comments on commit ddc2016

Please sign in to comment.