Skip to content

Commit f748215

Browse files
committed
Fix CategoryToTag producing @tag(arg.class) instead of the correct @tag("arg"). Fixes #11
1 parent c064e04 commit f748215

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

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

100644100755
Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,6 @@ class JunitMockitoUpgradeIntegrationTest : RefactorVisitorTestForParser<J.Compil
239239
"""
240240
)
241241

242-
val unitTestCategory = """
243-
package org.openrewrite.java.testing.statik;
244-
245-
public interface UnitTest{}
246-
""".trimIndent()
247-
248242
val exampleJunitBefore = """
249243
package org.openrewrite.java.testing.junit5;
250244
@@ -255,21 +249,18 @@ class JunitMockitoUpgradeIntegrationTest : RefactorVisitorTestForParser<J.Compil
255249
import org.junit.Rule;
256250
import org.junit.Test;
257251
import org.junit.Test;
258-
import org.junit.experimental.categories.Category;
259252
import org.junit.rules.ExpectedException;
260253
import org.junit.rules.TemporaryFolder;
261254
import org.junit.rules.Timeout;
262255
import org.mockito.Mock;
263256
import org.mockito.MockitoAnnotations;
264-
import org.openrewrite.java.testing.statik.UnitTest;
265257
266258
import java.io.File;
267259
import java.io.IOException;
268260
import java.util.List;
269261
270262
import static org.mockito.Mockito.*;
271263
272-
@Category(UnitTest.class)
273264
public class ExampleJunitTestClass {
274265
275266
// @Rule
@@ -345,11 +336,8 @@ class JunitMockitoUpgradeIntegrationTest : RefactorVisitorTestForParser<J.Compil
345336
346337
@Test
347338
public void aTest() {
348-
List<Integer> foo = mock(List.class);
349-
350-
when(foo.get(any())).then(invocation -> invocation.getArgumentAt(0, Integer.class));
351-
int one = foo.get(1);
352-
Assert.assertEquals(1, one);
339+
String foo = mock(String.class);
340+
when(foo.concat(any())).then(invocation -> invocation.getArgumentAt(0, String.class));
353341
}
354342
}
355343
""".trimIndent()
@@ -368,7 +356,6 @@ class JunitMockitoUpgradeIntegrationTest : RefactorVisitorTestForParser<J.Compil
368356
import static org.junit.jupiter.api.Assertions.assertThrows;
369357
import static org.mockito.Mockito.*;
370358
371-
@Tag("UnitTest")
372359
public class ExampleJunitTestClass {
373360
374361
// @Rule
@@ -447,11 +434,8 @@ class JunitMockitoUpgradeIntegrationTest : RefactorVisitorTestForParser<J.Compil
447434
448435
@Test
449436
public void aTest() {
450-
List<Integer> foo = mock(List.class);
451-
452-
when(foo.get(any())).then(invocation -> invocation.getArgument(0, Integer.class));
453-
int one = foo.get(1);
454-
Assertions.assertEquals(1, one);
437+
String foo = mock(String.class);
438+
when(foo.concat(any())).then(invocation -> invocation.getArgument(0, String.class));
455439
}
456440
457441
private static File newFile(File root, String fileName) throws IOException {
@@ -473,7 +457,7 @@ class JunitMockitoUpgradeIntegrationTest : RefactorVisitorTestForParser<J.Compil
473457
@Test
474458
fun theBigOne() {
475459
val sources: List<SourceFile> =
476-
parser.parse(unitTestCategory, exampleJunitBefore) +
460+
parser.parse(exampleJunitBefore) +
477461
MavenParser.builder().build().parse("""
478462
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
479463
<modelVersion>4.0.0</modelVersion>

0 commit comments

Comments
 (0)