Add annotation file parse tests in AP wrapper
This commit is contained in:
@@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||||
|
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -75,6 +76,18 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
package org.jetbrains.kotlin.annotation
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import java.io.File
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
public class AnnotationListParseTest {
|
||||||
|
|
||||||
|
Test fun testClassAnnotations() = doTest("classAnnotations")
|
||||||
|
|
||||||
|
Test fun testDefaultPackage() = doTest("defaultPackage")
|
||||||
|
|
||||||
|
Test fun testFieldAnnotations() = doTest("fieldAnnotations")
|
||||||
|
|
||||||
|
Test fun testLocalClasses() = doTest("localClasses")
|
||||||
|
|
||||||
|
Test fun testMethodAnnotations() = doTest("methodAnnotations")
|
||||||
|
|
||||||
|
Test fun testNestedClasses() = doTest("nestedClasses")
|
||||||
|
|
||||||
|
Test fun testSimple() = doTest("simple")
|
||||||
|
|
||||||
|
|
||||||
|
private val resourcesRootFile = File("src/test/resources/parse")
|
||||||
|
|
||||||
|
private fun doTest(testName: String) {
|
||||||
|
val annotationsFile = File(resourcesRootFile, "$testName/annotations.txt")
|
||||||
|
val expectedFile = File(resourcesRootFile, "$testName/parsed.txt")
|
||||||
|
|
||||||
|
assertTrue(annotationsFile.getAbsolutePath() + " does not exist.", annotationsFile.exists())
|
||||||
|
assertTrue(expectedFile.getAbsolutePath() + " does not exist.", expectedFile.exists())
|
||||||
|
|
||||||
|
val expectedParseResult = expectedFile.readText()
|
||||||
|
|
||||||
|
val annotationProvider = FileKotlinAnnotationProvider(annotationsFile)
|
||||||
|
val parsedAnnotations = annotationProvider.annotatedKotlinElements
|
||||||
|
|
||||||
|
val actualAnnotations = StringBuilder()
|
||||||
|
parsedAnnotations.forEach {
|
||||||
|
for (element in it.getValue()) {
|
||||||
|
actualAnnotations.append(it.getKey()).append(' ').append(element.classFqName)
|
||||||
|
when (element) {
|
||||||
|
is AnnotatedMethodDescriptor -> actualAnnotations.append(' ').append(element.methodName)
|
||||||
|
is AnnotatedFieldDescriptor -> actualAnnotations.append(' ').append(element.fieldName)
|
||||||
|
}
|
||||||
|
actualAnnotations.append('\n')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val actualAnnotationsSorted = actualAnnotations.toString()
|
||||||
|
.lines().filter { it.isNotEmpty() }.sort().joinToString("\n")
|
||||||
|
|
||||||
|
assertEquals(expectedParseResult, actualAnnotationsSorted)
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FileKotlinAnnotationProvider(val annotationsFile: File): KotlinAnnotationProvider() {
|
||||||
|
override val serializedAnnotations: String
|
||||||
|
get() = annotationsFile.readText()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
a javax.inject.Named 0
|
||||||
|
p org.test 0
|
||||||
|
c 0 0/SomeClass
|
||||||
|
c 0 0/SomeObject
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
javax.inject.Named org.test.SomeClass
|
||||||
|
javax.inject.Named org.test.SomeObject
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
a javax.inject.Named 0
|
||||||
|
c 0 SomeClass
|
||||||
|
a javax.inject.Inject 1
|
||||||
|
f 1 SomeClass annotatedProperty
|
||||||
|
a org.jetbrains.annotations.Nullable 2
|
||||||
|
f 2 SomeClass annotatedProperty
|
||||||
|
m 2 SomeClass getAnnotatedProperty
|
||||||
|
m 1 SomeClass annotatedFunction
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
javax.inject.Inject SomeClass annotatedFunction
|
||||||
|
javax.inject.Inject SomeClass annotatedProperty
|
||||||
|
javax.inject.Named SomeClass
|
||||||
|
org.jetbrains.annotations.Nullable SomeClass annotatedProperty
|
||||||
|
org.jetbrains.annotations.Nullable SomeClass getAnnotatedProperty
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
a javax.inject.Inject 0
|
||||||
|
p org.test 0
|
||||||
|
f 0 0/SomeClass annotatedVal
|
||||||
|
a org.jetbrains.annotations.Nullable 1
|
||||||
|
f 1 0/SomeClass annotatedVal
|
||||||
|
m 1 0/SomeClass getAnnotatedVal
|
||||||
|
f 0 0/SomeClass annotatedVar
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
javax.inject.Inject org.test.SomeClass annotatedVal
|
||||||
|
javax.inject.Inject org.test.SomeClass annotatedVar
|
||||||
|
org.jetbrains.annotations.Nullable org.test.SomeClass annotatedVal
|
||||||
|
org.jetbrains.annotations.Nullable org.test.SomeClass getAnnotatedVal
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
a javax.inject.Named 0
|
||||||
|
p org.test 0
|
||||||
|
c 0 0/SomeClass$someFunction$LocalClass
|
||||||
|
a javax.inject.Inject 1
|
||||||
|
f 1 0/SomeClass$someFunction$LocalClass annotatedProperty
|
||||||
|
a org.jetbrains.annotations.Nullable 2
|
||||||
|
f 2 0/SomeClass$someFunction$LocalClass annotatedProperty
|
||||||
|
m 2 0/SomeClass$someFunction$LocalClass getAnnotatedProperty
|
||||||
|
m 1 0/SomeClass$someFunction$LocalClass annotatedFunction
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
javax.inject.Inject org.test.SomeClass$someFunction$LocalClass annotatedFunction
|
||||||
|
javax.inject.Inject org.test.SomeClass$someFunction$LocalClass annotatedProperty
|
||||||
|
javax.inject.Named org.test.SomeClass$someFunction$LocalClass
|
||||||
|
org.jetbrains.annotations.Nullable org.test.SomeClass$someFunction$LocalClass annotatedProperty
|
||||||
|
org.jetbrains.annotations.Nullable org.test.SomeClass$someFunction$LocalClass getAnnotatedProperty
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
a javax.inject.Inject 0
|
||||||
|
p org.test 0
|
||||||
|
m 0 0/SomeClass annotatedFunction
|
||||||
|
a javax.inject.Named 1
|
||||||
|
m 1 0/SomeClass$annotatedFunction$1 invoke
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
javax.inject.Inject org.test.SomeClass annotatedFunction
|
||||||
|
javax.inject.Named org.test.SomeClass$annotatedFunction$1 invoke
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
a javax.inject.Named 0
|
||||||
|
p org.test 0
|
||||||
|
c 0 0/SomeClass$Companion
|
||||||
|
a org.jetbrains.annotations.NotNull 1
|
||||||
|
m 1 0/SomeClass$Companion access$init$0
|
||||||
|
c 0 0/SomeClass$SomeInnerObject
|
||||||
|
c 0 0/SomeClass$InnerClass
|
||||||
|
c 0 0/SomeClass$NestedClass
|
||||||
|
a java.lang.Deprecated 2
|
||||||
|
f 2 0/SomeClass OBJECT$
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
java.lang.Deprecated org.test.SomeClass OBJECT$
|
||||||
|
javax.inject.Named org.test.SomeClass$Companion
|
||||||
|
javax.inject.Named org.test.SomeClass$InnerClass
|
||||||
|
javax.inject.Named org.test.SomeClass$NestedClass
|
||||||
|
javax.inject.Named org.test.SomeClass$SomeInnerObject
|
||||||
|
org.jetbrains.annotations.NotNull org.test.SomeClass$Companion access$init$0
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
a javax.inject.Inject 0
|
||||||
|
p org.test 0
|
||||||
|
m 0 0/SomeClass annotatedFunction
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
javax.inject.Inject org.test.SomeClass annotatedFunction
|
||||||
Reference in New Issue
Block a user