Skip to content

Commit

Permalink
Merge pull request #15017 from evanchooly/bytecodeTests
Browse files Browse the repository at this point in the history
Update kotlin generated bytecode to include proper nullability checks and annotations
  • Loading branch information
evanchooly authored Feb 12, 2021
2 parents d3c5f11 + 7e4d1a0 commit d392404
Show file tree
Hide file tree
Showing 9 changed files with 823 additions and 141 deletions.
39 changes: 38 additions & 1 deletion extensions/panache/mongodb-panache-kotlin/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,45 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
<source>src/main/kotlin</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/java</source>
<source>src/test/kotlin</source>
</sourceDirs>
</configuration>
</execution>
</executions>
<configuration>
<javaParameters>true</javaParameters>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
</plugins>
</build>


</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
package io.quarkus.mongodb.panache.kotlin.deployment

import com.mongodb.client.MongoCollection
import com.mongodb.client.MongoDatabase
import io.quarkus.mongodb.panache.PanacheUpdate
import io.quarkus.mongodb.panache.kotlin.PanacheMongoCompanion
import io.quarkus.mongodb.panache.kotlin.PanacheMongoEntity
import io.quarkus.mongodb.panache.kotlin.PanacheQuery
import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations.Companion.INSTANCE
import io.quarkus.panache.common.Parameters
import io.quarkus.panache.common.Sort
import org.bson.Document
import org.bson.types.ObjectId
import java.util.stream.Stream

/**
* This class is used by TestEnhancers to validate the bytecode generation. Each method on PanacheMongoCompanion is
* manually implemented to give us a compiler generated metric against which to validate the quarkus generated bytecode.
* TestEnhancers further validates that all @GenerateBridge annotated methods are represented by a 'target_' method
* here.
*/
@Suppress("UNCHECKED_CAST", "unused")
class Book : PanacheMongoEntity() {
companion object : PanacheMongoCompanion<Book> {
fun target_count(): Long
= INSTANCE.count(Book::class.java)

fun target_count(query: Document): Long
= INSTANCE.count(Book::class.java, query)

fun target_count(query: String, params: Map<String, Any?>): Long
= INSTANCE.count(Book::class.java, query, params)

fun target_count(query: String, params: Parameters): Long
= INSTANCE.count(Book::class.java, query, params)

fun target_count(query: String, vararg params: Any?): Long
= INSTANCE.count(Book::class.java, query, *params)

fun target_delete(query: Document): Long
= INSTANCE.delete(Book::class.java, query)

fun target_delete(query: String, params: Map<String, Any?>): Long
= INSTANCE.delete(Book::class.java, query, params)

fun target_delete(query: String, params: Parameters): Long
= INSTANCE.delete(Book::class.java, query, params)

fun target_delete(query: String, vararg params: Any?): Long
= INSTANCE.delete(Book::class.java, query, *params)

fun target_deleteAll(): Long
= INSTANCE.deleteAll(Book::class.java)

fun target_deleteById(id: ObjectId): Boolean
= INSTANCE.deleteById(Book::class.java, id)

fun target_find(query: Document): PanacheQuery<Book>
= INSTANCE.find(Book::class.java, query) as PanacheQuery<Book>

fun target_find(query: Document, sort: Document): PanacheQuery<Book>
= INSTANCE.find(Book::class.java, query, sort) as PanacheQuery<Book>

fun target_find(query: String, params: Map<String, Any?>): PanacheQuery<Book>
= INSTANCE.find(Book::class.java, query, params) as PanacheQuery<Book>

fun target_find(query: String, params: Parameters): PanacheQuery<Book>
= INSTANCE.find(Book::class.java, query, params) as PanacheQuery<Book>

fun target_find(query: String, sort: Sort, params: Map<String, Any?>): PanacheQuery<Book>
= INSTANCE.find(Book::class.java, query, sort, params) as PanacheQuery<Book>

fun target_find(query: String, sort: Sort, params: Parameters): PanacheQuery<Book>
= INSTANCE.find(Book::class.java, query, sort, params) as PanacheQuery<Book>

fun target_find(query: String, sort: Sort, vararg params: Any?): PanacheQuery<Book>
= INSTANCE.find(Book::class.java, query, sort, *params) as PanacheQuery<Book>

fun target_find(query: String, vararg params: Any?): PanacheQuery<Book>
= INSTANCE.find(Book::class.java, query, *params) as PanacheQuery<Book>

fun target_findAll(): PanacheQuery<Book>
= INSTANCE.findAll(Book::class.java) as PanacheQuery<Book>

fun target_findAll(sort: Sort): PanacheQuery<Book>
= INSTANCE.findAll(Book::class.java, sort) as PanacheQuery<Book>

fun target_findById(id: ObjectId): Book?
= INSTANCE.findById(Book::class.java, id) as Book?

fun target_list(query: Document): List<Book>
= INSTANCE.list(Book::class.java, query) as List<Book>

fun target_list(query: Document, sort: Document): List<Book>
= INSTANCE.list(Book::class.java, query, sort) as List<Book>

fun target_list(query: String, params: Map<String, Any?>): List<Book>
= INSTANCE.list(Book::class.java, query, params) as List<Book>

fun target_list(query: String, params: Parameters): List<Book>
= INSTANCE.list(Book::class.java, query, params) as List<Book>

fun target_list(query: String, sort: Sort, params: Map<String, Any?>): List<Book>
= INSTANCE.list(Book::class.java, query, sort, params) as List<Book>

fun target_list(query: String, sort: Sort, params: Parameters): List<Book>
= INSTANCE.list(Book::class.java, query, sort, params) as List<Book>

fun target_list(query: String, sort: Sort, vararg params: Any?): List<Book>
= INSTANCE.list(Book::class.java, query, sort, *params) as List<Book>

fun target_list(query: String, vararg params: Any?): List<Book>
= INSTANCE.list(Book::class.java, query, *params) as List<Book>

fun target_listAll(): List<Book>
= INSTANCE.listAll(Book::class.java) as List<Book>

fun target_listAll(sort: Sort): List<Book>
= INSTANCE.listAll(Book::class.java, sort) as List<Book>

fun target_mongoCollection(): MongoCollection<Book>
= INSTANCE.mongoCollection(Book::class.java) as MongoCollection<Book>

fun target_mongoDatabase(): MongoDatabase
= INSTANCE.mongoDatabase(Book::class.java)

fun target_stream(query: Document): Stream<Book>
= INSTANCE.stream(Book::class.java, query) as Stream<Book>

fun target_stream(query: Document, sort: Document): Stream<Book>
= INSTANCE.stream(Book::class.java, query, sort) as Stream<Book>

fun target_stream(query: String, params: Map<String, Any?>): Stream<Book>
= INSTANCE.stream(Book::class.java, query, params) as Stream<Book>

fun target_stream(query: String, params: Parameters): Stream<Book>
= INSTANCE.stream(Book::class.java, query, params) as Stream<Book>

fun target_stream(query: String, sort: Sort, params: Map<String, Any?>): Stream<Book>
= INSTANCE.stream(Book::class.java, query, sort, params) as Stream<Book>

fun target_stream(query: String, sort: Sort, params: Parameters): Stream<Book>
= INSTANCE.stream(Book::class.java, query, sort, params) as Stream<Book>

fun target_stream(query: String, sort: Sort, vararg params: Any?): Stream<Book>
= INSTANCE.stream(Book::class.java, query, sort, *params) as Stream<Book>

fun target_stream(query: String, vararg params: Any?): Stream<Book>
= INSTANCE.stream(Book::class.java, query, *params) as Stream<Book>

fun target_streamAll(): Stream<Book>
= INSTANCE.streamAll(Book::class.java) as Stream<Book>

fun target_streamAll(sort: Sort): Stream<Book>
= INSTANCE.streamAll(Book::class.java, sort) as Stream<Book>

fun target_update(update: String, params: Map<String, Any?>): PanacheUpdate
= INSTANCE.update(Book::class.java, update, params)

fun target_update(update: String, params: Parameters): PanacheUpdate
= INSTANCE.update(Book::class.java, update, params)

fun target_update(update: String, vararg params: Any?): PanacheUpdate
= INSTANCE.update(Book::class.java, update, *params)

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
package io.quarkus.mongodb.panache.kotlin.deployment

import com.mongodb.client.MongoCollection
import com.mongodb.client.MongoDatabase
import io.quarkus.mongodb.panache.PanacheUpdate
import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepositoryBase
import io.quarkus.mongodb.panache.kotlin.PanacheQuery
import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations
import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations.Companion.INSTANCE
import io.quarkus.panache.common.Parameters
import io.quarkus.panache.common.Sort
import org.bson.Document
import java.util.stream.Stream

/**
* This class is used by TestEnhancers to validate the bytecode generation. Each method on PanacheMongoRepositoryBase
* is manually implemented to give us a compiler generated metric against which to validate the quarkus generated
* bytecode. TestEnhancers further validates that all @GenerateBridge annotated methods are represented by a 'target_'
* method here.
*/
@Suppress("unused", "UNCHECKED_CAST")
class StudentRepository : PanacheMongoRepositoryBase<Student, Long> {
fun target_count(): Long = INSTANCE.count(Student::class.java)

fun target_count(query: String, vararg params: Any?): Long =
INSTANCE.count(Student::class.java, query, *params)

fun target_count(query: String, params: Map<String, Any?>): Long =
INSTANCE.count(Student::class.java, query, params)

fun target_count(query: String, params: Parameters): Long =
INSTANCE.count(Student::class.java, query, params)

fun target_count(query: Document): Long = INSTANCE.count(Student::class.java, query)

fun target_deleteAll(): Long = INSTANCE.deleteAll(Student::class.java)

fun target_deleteById(id: Long): Boolean = INSTANCE.deleteById(Student::class.java, id)

fun target_delete(query: String, vararg params: Any?): Long =
INSTANCE.delete(Student::class.java, query, *params)

fun target_delete(query: String, params: Map<String, Any?>): Long =
INSTANCE.delete(Student::class.java, query, params)

fun target_delete(query: String, params: Parameters): Long =
INSTANCE.delete(Student::class.java, query, params)

fun target_delete(query: Document): Long = INSTANCE.delete(Student::class.java, query)

fun target_findById(id: Long): Student? =
INSTANCE.findById(Student::class.java, id) as Student?

fun target_find(query: String, vararg params: Any?): PanacheQuery<Student> =
INSTANCE.find(Student::class.java, query, *params) as PanacheQuery<Student>

fun target_find(query: String, sort: Sort, vararg params: Any?): PanacheQuery<Student> =
INSTANCE.find(Student::class.java, query, sort, *params) as PanacheQuery<Student>

fun target_find(query: String, params: Map<String, Any?>): PanacheQuery<Student> =
INSTANCE.find(Student::class.java, query, params) as PanacheQuery<Student>

fun target_find(query: String, sort: Sort, params: Map<String, Any?>): PanacheQuery<Student> =
INSTANCE.find(Student::class.java, query, sort, params) as PanacheQuery<Student>

fun target_find(query: String, params: Parameters): PanacheQuery<Student> =
INSTANCE.find(Student::class.java, query, params) as PanacheQuery<Student>

fun target_find(query: String, sort: Sort, params: Parameters): PanacheQuery<Student> =
INSTANCE.find(Student::class.java, query, sort, params) as PanacheQuery<Student>

fun target_find(query: Document): PanacheQuery<Student> =
INSTANCE.find(Student::class.java, query) as PanacheQuery<Student>

fun target_find(query: Document, sort: Document): PanacheQuery<Student> =
INSTANCE.find(Student::class.java, query, sort) as PanacheQuery<Student>

fun target_findAll(): PanacheQuery<Student> =
INSTANCE.findAll(Student::class.java) as PanacheQuery<Student>

fun target_findAll(sort: Sort): PanacheQuery<Student> =
INSTANCE.findAll(Student::class.java, sort) as PanacheQuery<Student>

fun target_list(query: String, vararg params: Any?): List<Student> =
INSTANCE.list(Student::class.java, query, *params) as List<Student>

fun target_list(query: String, sort: Sort, vararg params: Any?): List<Student> =
INSTANCE.list(Student::class.java, query, sort, *params) as List<Student>

fun target_list(query: String, params: Map<String, Any?>): List<Student> =
INSTANCE.list(Student::class.java, query, params) as List<Student>

fun target_list(query: String, sort: Sort, params: Map<String, Any?>): List<Student> =
INSTANCE.list(Student::class.java, query, sort, params) as List<Student>

fun target_list(query: String, params: Parameters): List<Student> =
INSTANCE.list(Student::class.java, query, params) as List<Student>

fun target_list(query: String, sort: Sort, params: Parameters): List<Student> =
INSTANCE.list(Student::class.java, query, sort, params) as List<Student>

fun target_list(query: Document): List<Student> =
INSTANCE.list(Student::class.java, query) as List<Student>

fun target_list(query: Document, sort: Document): List<Student> =
INSTANCE.list(Student::class.java, query, sort) as List<Student>

fun target_listAll(): List<Student> = INSTANCE.listAll(Student::class.java) as List<Student>

fun target_listAll(sort: Sort): List<Student> =
INSTANCE.listAll(Student::class.java, sort) as List<Student>

fun target_mongoCollection(): MongoCollection<Student> =
INSTANCE.mongoCollection(Student::class.java) as MongoCollection<Student>

fun target_mongoDatabase(): MongoDatabase = INSTANCE.mongoDatabase(Student::class.java)

fun target_stream(query: String, vararg params: Any?): Stream<Student> =
INSTANCE.stream(Student::class.java, query, *params) as Stream<Student>

fun target_stream(query: String, sort: Sort, vararg params: Any?): Stream<Student> =
INSTANCE.stream(Student::class.java, query, sort, *params) as Stream<Student>

fun target_stream(query: String, params: Map<String, Any?>): Stream<Student> =
INSTANCE.stream(Student::class.java, query, params) as Stream<Student>

fun target_stream(query: String, sort: Sort, params: Map<String, Any?>): Stream<Student> =
INSTANCE.stream(Student::class.java, query, sort, params) as Stream<Student>

fun target_stream(query: String, params: Parameters): Stream<Student> =
INSTANCE.stream(Student::class.java, query, params) as Stream<Student>

fun target_stream(query: String, sort: Sort, params: Parameters): Stream<Student> =
INSTANCE.stream(Student::class.java, query, sort, params) as Stream<Student>

fun target_stream(query: Document): Stream<Student> =
INSTANCE.stream(Student::class.java, query) as Stream<Student>

fun target_stream(query: Document, sort: Document): Stream<Student> =
INSTANCE.stream(Student::class.java, query, sort) as Stream<Student>

fun target_streamAll(sort: Sort): Stream<Student> =
INSTANCE.streamAll(Student::class.java, sort) as Stream<Student>

fun target_streamAll(): Stream<Student> =
INSTANCE.streamAll(Student::class.java) as Stream<Student>

fun target_update(update: String, vararg params: Any?): PanacheUpdate =
INSTANCE.update(Student::class.java, update, *params)

fun target_update(update: String, params: Map<String, Any?>): PanacheUpdate =
INSTANCE.update(Student::class.java, update, params)

fun target_update(update: String, params: Parameters): PanacheUpdate =
INSTANCE.update(Student::class.java, update, params)
}
class Student
Loading

0 comments on commit d392404

Please sign in to comment.