Skip to content

Commit e7f0148

Browse files
magicwerkThomas Mauch
andauthored
fix-issue-441 (#442)
Co-authored-by: Thomas Mauch <[email protected]>
1 parent e383281 commit e7f0148

File tree

4 files changed

+17
-81
lines changed

4 files changed

+17
-81
lines changed

src/main/java/org/openrewrite/java/testing/junit5/UpdateTestAnnotation.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
116116
ChangeTestAnnotation cta = new ChangeTestAnnotation();
117117
J.MethodDeclaration m = (J.MethodDeclaration) cta.visitNonNull(method, ctx, getCursor().getParentOrThrow());
118118
if (m != method) {
119-
if (Boolean.FALSE.equals(TypeUtils.isOverride(m.getMethodType()))) {
120-
m = (J.MethodDeclaration) new ChangeMethodAccessLevelVisitor<ExecutionContext>(new MethodMatcher(m), null)
121-
.visitNonNull(m, ctx, getCursor().getParentOrThrow());
122-
}
123119
if (cta.expectedException != null) {
124120
m = JavaTemplate.builder("org.junit.jupiter.api.function.Executable o = () -> #{};")
125121
.contextSensitive()

src/test/java/org/openrewrite/java/testing/junit5/JUnit5MigrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void filterShouldRemoveUnusedConfig() {
9898
public class SampleTest {
9999
@SuppressWarnings("ALL")
100100
@Test
101-
void filterShouldRemoveUnusedConfig() {
101+
public void filterShouldRemoveUnusedConfig() {
102102
assertThat(asList("1", "2", "3"),
103103
containsInAnyOrder("3", "2", "1"));
104104
}

src/test/java/org/openrewrite/java/testing/junit5/UpdateTestAnnotationTest.java

Lines changed: 15 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void test_printLine() {
6060
public class MyTest {
6161
6262
@Test
63-
void test_printLine() {
63+
public void test_printLine() {
6464
assertDoesNotThrow(() -> {
6565
int arr = new int[]{0}[0];
6666
});
@@ -95,7 +95,7 @@ public void test() {
9595
public class MyTest {
9696
9797
@Test
98-
void test() {
98+
public void test() {
9999
assertThrows(IllegalArgumentException.class, () -> {
100100
throw new IllegalArgumentException("boom");
101101
});
@@ -131,7 +131,7 @@ public void test() {
131131
public class MyTest {
132132
133133
@Test
134-
void test() {
134+
public void test() {
135135
assertThrows(IndexOutOfBoundsException.class, () -> {
136136
int arr = new int[]{}[0];
137137
});
@@ -167,7 +167,7 @@ public void test() {
167167
public class MyTest {
168168
169169
@Test
170-
void test() {
170+
public void test() {
171171
assertThrows(IllegalArgumentException.class, () -> {
172172
String foo = "foo";
173173
throw new IllegalArgumentException("boom");
@@ -200,7 +200,7 @@ public void test() {
200200
public class MyTest {
201201
202202
@Test
203-
void test() {
203+
public void test() {
204204
}
205205
}
206206
"""
@@ -253,17 +253,17 @@ public class MyTest {
253253
// some comments
254254
@Issue("some issue")
255255
@Test
256-
void test() {
256+
public void test() {
257257
}
258258
259259
// some comments
260260
@Test
261-
void test1() {
261+
public void test1() {
262262
}
263263
264-
// some comments
265264
@Test
266-
void test2() {
265+
// some comments
266+
public void test2() {
267267
}
268268
}
269269
"""
@@ -294,7 +294,7 @@ public class MyTest {
294294
295295
@Test
296296
@Timeout(500)
297-
void test() {
297+
public void test() {
298298
}
299299
}
300300
"""
@@ -338,7 +338,7 @@ public void test() {
338338
public class MyTest {
339339
340340
@Test
341-
void test() {
341+
public void test() {
342342
assertThrows(MyException.class, () -> {
343343
throw new MyException("my exception");
344344
});
@@ -375,7 +375,7 @@ public class MyTest {
375375
376376
@Test
377377
@Timeout(500)
378-
void test() {
378+
public void test() {
379379
assertThrows(IllegalArgumentException.class, () -> {
380380
throw new IllegalArgumentException("boom");
381381
});
@@ -386,66 +386,6 @@ void test() {
386386
);
387387
}
388388

389-
@Issue("https://github.com/openrewrite/rewrite/issues/150")
390-
@Test
391-
void protectedToPackageVisibility() {
392-
//language=java
393-
rewriteRun(
394-
java(
395-
"""
396-
import org.junit.Test;
397-
398-
public class MyTest {
399-
400-
@Test
401-
protected void test() {
402-
}
403-
}
404-
""",
405-
"""
406-
import org.junit.jupiter.api.Test;
407-
408-
public class MyTest {
409-
410-
@Test
411-
void test() {
412-
}
413-
}
414-
"""
415-
)
416-
);
417-
}
418-
419-
@SuppressWarnings("JUnitMalformedDeclaration")
420-
@Test
421-
void privateToPackageVisibility() {
422-
//language=java
423-
rewriteRun(
424-
java(
425-
"""
426-
import org.junit.Test;
427-
428-
public class MyTest {
429-
430-
@Test
431-
private void test() {
432-
}
433-
}
434-
""",
435-
"""
436-
import org.junit.jupiter.api.Test;
437-
438-
public class MyTest {
439-
440-
@Test
441-
void test() {
442-
}
443-
}
444-
"""
445-
)
446-
);
447-
}
448-
449389
@Test
450390
void preservesVisibilityOnTestMethodThatIsAnOverride() {
451391
//language=java
@@ -532,7 +472,7 @@ public void test() {
532472
/** @see org.junit.jupiter.api.Test */
533473
public class MyTest {
534474
@Test
535-
void test() {
475+
public void test() {
536476
}
537477
}
538478
"""
@@ -557,7 +497,7 @@ public void feature1() {
557497
558498
public class MyTest {
559499
@org.junit.jupiter.api.Test
560-
void feature1() {
500+
public void feature1() {
561501
}
562502
}
563503
"""
@@ -587,7 +527,7 @@ void feature2() {
587527
588528
public class MyTest {
589529
@org.junit.jupiter.api.Test
590-
void feature1() {
530+
public void feature1() {
591531
}
592532
593533
@Test

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void initMocks() {
108108
}
109109
110110
@Test
111-
void usingAnnotationBasedMock() {
111+
public void usingAnnotationBasedMock() {
112112
113113
mockedList.add("one");
114114
mockedList.clear();

0 commit comments

Comments
 (0)