diff --git a/build-parent/pom.xml b/build-parent/pom.xml index 2d17a11a05480..a0540aa7f5d53 100644 --- a/build-parent/pom.xml +++ b/build-parent/pom.xml @@ -329,7 +329,7 @@ d3js ${webjar.d3js.version} - + org.webjars chartjs ${webjar.chartjs.version} @@ -775,6 +775,49 @@ + + format-kotlin + + true + + !no-format + + + src/main/kotlin + + + + + + com.diffplug.spotless + spotless-maven-plugin + 2.25.0 + + + format-kotlin + process-sources + + apply + + + + + + + + + + + + + + + + release diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/websockets-codestart/kotlin/src/main/kotlin/org/acme/StartWebSocket.kt b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/websockets-codestart/kotlin/src/main/kotlin/org/acme/StartWebSocket.kt index 660b2b780c9b2..eadc327cb78ce 100644 --- a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/websockets-codestart/kotlin/src/main/kotlin/org/acme/StartWebSocket.kt +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/websockets-codestart/kotlin/src/main/kotlin/org/acme/StartWebSocket.kt @@ -1,13 +1,12 @@ package org.acme -import java.io.IOException import javax.enterprise.context.ApplicationScoped import javax.websocket.* import javax.websocket.server.PathParam import javax.websocket.server.ServerEndpoint -@ServerEndpoint("/start-websocket/{name}") @ApplicationScoped +@ServerEndpoint("/start-websocket/{name}") class StartWebSocket { @OnOpen diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheCompanion.kt b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheCompanion.kt index dcaaeea6514e7..e5a497036fe4b 100644 --- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheCompanion.kt +++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheCompanion.kt @@ -14,14 +14,14 @@ import javax.persistence.LockModeType * * @param Entity the entity type */ -interface PanacheCompanion: PanacheCompanionBase +interface PanacheCompanion : PanacheCompanionBase /** * Defines methods to be used via the companion objects of entities. * * @param Entity the entity type */ -interface PanacheCompanionBase { +interface PanacheCompanionBase { /** * Returns the [EntityManager] for the [Entity] for extra operations (eg. CriteriaQueries) @@ -528,7 +528,6 @@ interface PanacheCompanionBase { @GenerateBridge fun update(query: String, params: Parameters): Int = throw implementationInjectionMissing() - /** * Flushes all pending changes to the database. */ diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheEntity.kt b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheEntity.kt index 62e85dec6761c..2912a34b6d58a 100644 --- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheEntity.kt +++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheEntity.kt @@ -1,6 +1,5 @@ package io.quarkus.hibernate.orm.panache.kotlin - import javax.persistence.GeneratedValue import javax.persistence.Id import javax.persistence.MappedSuperclass @@ -18,7 +17,7 @@ import javax.persistence.MappedSuperclass * @see [PanacheEntityBase] */ @MappedSuperclass -open class PanacheEntity: PanacheEntityBase { +open class PanacheEntity : PanacheEntityBase { /** * The auto-generated ID field. This field is set by Hibernate ORM when this entity * is persisted. diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheEntityBase.kt b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheEntityBase.kt index 54a0a1af3a0fc..923c89783634c 100644 --- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheEntityBase.kt +++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheEntityBase.kt @@ -1,10 +1,8 @@ package io.quarkus.hibernate.orm.panache.kotlin import com.fasterxml.jackson.annotation.JsonIgnore -import io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations import io.quarkus.hibernate.orm.panache.kotlin.runtime.KotlinJpaOperations.Companion.INSTANCE import javax.json.bind.annotation.JsonbTransient -import javax.persistence.EntityManager /** * Represents an entity. If your Hibernate entities extend this class they gain auto-generated accessors @@ -31,9 +29,9 @@ interface PanacheEntityBase { /** * Persist this entity in the database, if not already persisted. This will set your ID field if it is not already set. * - * @see [PanacheEntityBase.isPersistent] - * @see [PanacheEntityBase.flush] - * @see [PanacheEntityBase.persistAndFlush] + * @see [PanacheEntityBase.isPersistent] + * @see [PanacheEntityBase.flush] + * @see [PanacheEntityBase.persistAndFlush] */ fun persist() { INSTANCE.persist(this) diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheQuery.kt b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheQuery.kt index 77e61defab198..0939f4339048b 100644 --- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheQuery.kt +++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheQuery.kt @@ -18,14 +18,14 @@ import javax.persistence.NonUniqueResultException * * @param Entity The entity type being queried */ -interface PanacheQuery { +interface PanacheQuery { /** * Defines a projection class: the getters, and the public fields, will be used to restrict which fields should be * retrieved from the database. * * @return a new query with the same state as the previous one (params, page, range, lockMode, hints, ...). */ - fun project(type: Class): PanacheQuery + fun project(type: Class): PanacheQuery /** * Sets the current page. diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheRepository.kt b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheRepository.kt index 63387c66abddc..b9b224d4d4234 100644 --- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheRepository.kt +++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheRepository.kt @@ -7,4 +7,4 @@ package io.quarkus.hibernate.orm.panache.kotlin * * @param Entity The type of entity to operate on */ -interface PanacheRepository: PanacheRepositoryBase \ No newline at end of file +interface PanacheRepository : PanacheRepositoryBase diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheRepositoryBase.kt b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheRepositoryBase.kt index 994cdca12132f..d65543283c26c 100644 --- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheRepositoryBase.kt +++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/PanacheRepositoryBase.kt @@ -17,7 +17,7 @@ import kotlin.reflect.KClass * @param Entity The type of entity to operate on * @param Id The ID type of the entity */ -interface PanacheRepositoryBase { +interface PanacheRepositoryBase { /** * Returns the [EntityManager] for the [Entity] for extra operations (eg. CriteriaQueries) @@ -33,8 +33,10 @@ interface PanacheRepositoryBase { * @return the [EntityManager] tied to the given class */ @GenerateBridge - @Deprecated(message="use Panache.getEntityManager() instead to access an entity manager for any entity class", - replaceWith = ReplaceWith("Panache.getEntityManager()")) + @Deprecated( + message = "use Panache.getEntityManager() instead to access an entity manager for any entity class", + replaceWith = ReplaceWith("Panache.getEntityManager()") + ) fun getEntityManager(clazz: KClass): EntityManager = throw implementationInjectionMissing() /** diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/runtime/PanacheQueryImpl.kt b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/runtime/PanacheQueryImpl.kt index f3b0c6c5a5377..778467b361e8e 100644 --- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/runtime/PanacheQueryImpl.kt +++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/main/kotlin/io/quarkus/hibernate/orm/panache/kotlin/runtime/PanacheQueryImpl.kt @@ -8,7 +8,7 @@ import java.util.stream.Stream import javax.persistence.EntityManager import javax.persistence.LockModeType -class PanacheQueryImpl : PanacheQuery { +class PanacheQueryImpl : PanacheQuery { private var delegate: CommonPanacheQueryImpl internal constructor(em: EntityManager?, query: String?, orderBy: String?, paramsArrayOrMap: Any?) { @@ -20,7 +20,7 @@ class PanacheQueryImpl : PanacheQuery { } // Builder - override fun project(type: Class): PanacheQuery { + override fun project(type: Class): PanacheQuery { return PanacheQueryImpl(delegate.project(type)) } diff --git a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/test/kotlin/io/quarkus/hibernate/orm/panache/kotlin/runtime/TestAnalogs.kt b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/test/kotlin/io/quarkus/hibernate/orm/panache/kotlin/runtime/TestAnalogs.kt index d0076144f59e4..0d4de6b8d1679 100644 --- a/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/test/kotlin/io/quarkus/hibernate/orm/panache/kotlin/runtime/TestAnalogs.kt +++ b/extensions/panache/hibernate-orm-panache-kotlin/runtime/src/test/kotlin/io/quarkus/hibernate/orm/panache/kotlin/runtime/TestAnalogs.kt @@ -1,6 +1,5 @@ package io.quarkus.hibernate.orm.panache.kotlin.runtime - import io.quarkus.gizmo.Gizmo import io.quarkus.hibernate.orm.panache.kotlin.PanacheCompanionBase import io.quarkus.hibernate.orm.panache.kotlin.PanacheEntityBase @@ -41,24 +40,26 @@ class TestAnalogs { fun testPanacheEntityBase() { val javaMethods = map(JavaPanacheEntityBase::class).methods val kotlinMethods = map(PanacheEntityBase::class).methods - val companionMethods = map(PanacheCompanionBase::class, - ByteCodeType(PanacheEntityBase::class.java)).methods + val companionMethods = map( + PanacheCompanionBase::class, + ByteCodeType(PanacheEntityBase::class.java) + ).methods val implemented = mutableListOf() javaMethods - .forEach { - if (!it.isStatic()) { - if (it in kotlinMethods) { - kotlinMethods -= it - implemented += it - } - } else { - if (it in companionMethods) { - companionMethods -= it - implemented += it - } + .forEach { + if (!it.isStatic()) { + if (it in kotlinMethods) { + kotlinMethods -= it + implemented += it + } + } else { + if (it in companionMethods) { + companionMethods -= it + implemented += it } } + } javaMethods.removeIf { it.name.endsWith("Optional") || it in implemented } @@ -78,9 +79,8 @@ class TestAnalogs { } } - private fun KClass<*>.bytes() = - java.classLoader.getResourceAsStream(qualifiedName.toString().replace(".", "/") + ".class") + java.classLoader.getResourceAsStream(qualifiedName.toString().replace(".", "/") + ".class") private fun compare(javaClass: AnalogVisitor, kotlinClass: AnalogVisitor, allowList: List = listOf()) { val javaMethods = javaClass.methods @@ -88,12 +88,12 @@ class TestAnalogs { val implemented = mutableListOf() javaMethods - .forEach { - if (it in kotlinMethods) { - kotlinMethods -= it - implemented += it - } + .forEach { + if (it in kotlinMethods) { + kotlinMethods -= it + implemented += it } + } javaMethods.removeIf { it.name.endsWith("Optional") || @@ -112,29 +112,34 @@ class TestAnalogs { private fun methods(label: String, methods: List) { println("$label: ") methods.toSortedSet(compareBy { it.toString() }) - .forEach { - println(it) - } + .forEach { + println(it) + } } } private fun List.byLine(): String { val map = map { it.toString() } return map - .joinToString("\n" ) + .joinToString("\n") } class AnalogVisitor(val erasedType: ByteCodeType? = null) : ClassVisitor(Gizmo.ASM_API_VERSION) { val methods = mutableListOf() - override fun visitMethod(access: Int, name: String, descriptor: String, signature: String?, - exceptions: Array?): MethodVisitor? { + override fun visitMethod( + access: Int, + name: String, + descriptor: String, + signature: String?, + exceptions: Array? + ): MethodVisitor? { if (name != "") { val type = descriptor.substringAfterLast(")").trim() var parameters = descriptor.substring( descriptor.indexOf("("), descriptor.lastIndexOf(")") + 1 ) - erasedType?.let { type-> + erasedType?.let { type -> parameters = parameters.replace(type.descriptor(), OBJECT.descriptor()) } @@ -149,7 +154,7 @@ class Method(val access: Int, val name: String, val type: String, val parameters override fun toString(): String { return (if (isStatic()) "static " else "") + "fun ${name}$parameters" + - (if (type.isNotBlank()) ": $type" else "") //+ + (if (type.isNotBlank()) ": $type" else "") // + } override fun equals(other: Any?): Boolean { @@ -168,7 +173,6 @@ class Method(val access: Int, val name: String, val type: String, val parameters result = 31 * result + parameters.hashCode() return result } - } fun Int.matches(mask: Int) = (this and mask) == mask diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt index 39f4fab589413..13ef0c144a981 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt @@ -15,7 +15,7 @@ import java.util.stream.Stream * * @param Entity the entity type */ -interface PanacheMongoCompanion: PanacheMongoCompanionBase +interface PanacheMongoCompanion : PanacheMongoCompanionBase /** * Define persistence and query methods for an Entity with a type of Id @@ -23,7 +23,7 @@ interface PanacheMongoCompanion: PanacheMongoCo * @param Entity the entity type * @param Id the ID type */ -interface PanacheMongoCompanionBase { +interface PanacheMongoCompanionBase { /** * Find an entity of this type by ID. * @@ -45,7 +45,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun find(query: String, vararg params: Any?): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query and the given sort options with optional indexed parameters. @@ -60,7 +60,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun find(query: String, sort: Sort, vararg params: Any?): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query, with named parameters. @@ -74,7 +74,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun find(query: String, params: Map): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query and the given sort options, with named parameters. @@ -89,7 +89,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun find(query: String, sort: Sort, params: Map): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query, with named parameters. @@ -103,7 +103,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun find(query: String, params: Parameters): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query and the given sort options with named parameters. @@ -118,7 +118,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun find(query: String, sort: Sort, params: Parameters): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query. @@ -196,7 +196,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun list(query: String, sort: Sort, vararg params: Any?): List = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -226,7 +226,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun list(query: String, sort: Sort, params: Map): List = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -256,7 +256,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun list(query: String, sort: Sort, params: Parameters): List = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query. @@ -338,7 +338,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun stream(query: String, sort: Sort, vararg params: Any?): Stream = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -353,7 +353,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun stream(query: String, params: Map): Stream = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query and the given sort options, with named parameters. @@ -369,7 +369,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun stream(query: String, sort: Sort, params: Map): Stream = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -399,7 +399,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun stream(query: String, sort: Sort, params: Parameters): Stream = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query. @@ -668,7 +668,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun update(update: String, params: Map): io.quarkus.mongodb.panache.common.PanacheUpdate = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Update all entities of this type by the given update document, with named parameters. @@ -694,7 +694,7 @@ interface PanacheMongoCompanionBase { */ @GenerateBridge fun update(update: Document): io.quarkus.mongodb.panache.common.PanacheUpdate = throw INSTANCE.implementationInjectionMissing() - + /** * Allow to access the underlying Mongo Collection. * diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoEntity.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoEntity.kt index 493d67bc67794..fb303c0f95306 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoEntity.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoEntity.kt @@ -11,7 +11,7 @@ import org.bson.types.ObjectId * instead, and write your own ID field. You will still get auto-generated accessors and * all the useful methods. * - * @see [PanacheMongoEntityBase] + * @see [PanacheMongoEntityBase] */ abstract class PanacheMongoEntity : PanacheMongoEntityBase() { /** @@ -28,4 +28,4 @@ abstract class PanacheMongoEntity : PanacheMongoEntityBase() { * @return the class type and ID type */ override fun toString(): String = "${this.javaClass.simpleName}<$id>" -} \ No newline at end of file +} diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoEntityBase.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoEntityBase.kt index 5642a7ffdf8bd..0ea741aba9abd 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoEntityBase.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoEntityBase.kt @@ -7,7 +7,7 @@ import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations.Companion * to all their public fields, as well as a lot of useful methods. Unless you have a custom ID strategy, you * should not extend this class directly but extend [PanacheMongoEntity] instead. * - * @see [PanacheMongoEntity] + * @see [PanacheMongoEntity] */ @Suppress("unused") abstract class PanacheMongoEntityBase { @@ -40,4 +40,4 @@ abstract class PanacheMongoEntityBase { fun delete() { INSTANCE.delete(this) } -} \ No newline at end of file +} diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepository.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepository.kt index 8dd5ebfeb5399..13593dd46e1be 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepository.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepository.kt @@ -10,4 +10,4 @@ import org.bson.types.ObjectId * * @param Entity The type of entity to operate on */ -interface PanacheMongoRepository : PanacheMongoRepositoryBase \ No newline at end of file +interface PanacheMongoRepository : PanacheMongoRepositoryBase diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepositoryBase.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepositoryBase.kt index ba29e22d8a65f..09592a6360315 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepositoryBase.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepositoryBase.kt @@ -4,12 +4,12 @@ package io.quarkus.mongodb.panache.kotlin import com.mongodb.client.MongoCollection import com.mongodb.client.MongoDatabase +import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations.Companion.INSTANCE import io.quarkus.panache.common.Parameters import io.quarkus.panache.common.Sort import io.quarkus.panache.common.impl.GenerateBridge import org.bson.Document import java.util.stream.Stream -import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations.Companion.INSTANCE /** * Represents a Repository for a specific type of entity [Entity], with an ID type @@ -21,7 +21,7 @@ import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations.Companion * @param Id The ID type of the entity * @see [PanacheMongoRepository] */ -interface PanacheMongoRepositoryBase { +interface PanacheMongoRepositoryBase { /** * Persist the given entity in the database. * This will set its ID field if not already set. @@ -72,7 +72,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, vararg params: Any?): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query and the given sort options, with optional indexed parameters. @@ -86,7 +86,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, sort: Sort, vararg params: Any?): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query, with named parameters. @@ -99,7 +99,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, params: Map): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query and the given sort options, with named parameters. @@ -113,7 +113,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, sort: Sort, params: Map): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query, with named parameters. @@ -126,7 +126,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, params: Parameters): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query and the given sort options, with named parameters. @@ -140,7 +140,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, sort: Sort, params: Parameters): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query. @@ -212,7 +212,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun list(query: String, sort: Sort, vararg params: Any?): List = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -240,7 +240,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun list(query: String, sort: Sort, params: Map): List = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -268,7 +268,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun list(query: String, sort: Sort, params: Parameters): List = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query. @@ -344,7 +344,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun stream(query: String, sort: Sort, vararg params: Any?): Stream = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -358,7 +358,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun stream(query: String, params: Map): Stream = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query and the given sort options, with named parameters. @@ -373,7 +373,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun stream(query: String, sort: Sort, params: Map): Stream = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -401,7 +401,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun stream(query: String, sort: Sort, params: Parameters): Stream = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query. @@ -619,7 +619,7 @@ interface PanacheMongoRepositoryBase { * @param entities the entities to update */ fun persistOrUpdate(firstEntity: Entity, vararg entities: Entity) = - INSTANCE.persistOrUpdate(firstEntity, *entities) + INSTANCE.persistOrUpdate(firstEntity, *entities) /** * Update all entities of this type by the given update document, with optional indexed parameters. @@ -644,7 +644,7 @@ interface PanacheMongoRepositoryBase { */ @GenerateBridge fun update(update: String, params: Map): io.quarkus.mongodb.panache.common.PanacheUpdate = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Update all entities of this type by the given update document, with named parameters. diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheQuery.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheQuery.kt index 1885a61567435..4f6251b0db3f8 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheQuery.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheQuery.kt @@ -15,14 +15,14 @@ import java.util.stream.Stream * * @param Entity The entity type being queried */ -interface PanacheQuery { +interface PanacheQuery { /** * Defines a projection class: the getters, and the public fields, will be used to restrict which fields should be * retrieved from the database. * * @return a new query with the same state as the previous one (params, page, range, ...). */ - fun project(type: Class): PanacheQuery + fun project(type: Class): PanacheQuery /** * Sets the current page. @@ -46,7 +46,7 @@ interface PanacheQuery { * * @return this query, modified * @throws UnsupportedOperationException if a page hasn't been set or if a range is already set - * @see [previousPage] + * @see [previousPage] */ fun nextPage(): PanacheQuery @@ -55,7 +55,7 @@ interface PanacheQuery { * * @return this query, modified * @throws UnsupportedOperationException if a page hasn't been set or if a range is already set - * @see [nextPage] + * @see [nextPage] */ fun previousPage(): PanacheQuery @@ -64,7 +64,7 @@ interface PanacheQuery { * * @return this query, modified * @throws UnsupportedOperationException if a page hasn't been set or if a range is already set - * @see [lastPage] + * @see [lastPage] */ fun firstPage(): PanacheQuery @@ -73,8 +73,8 @@ interface PanacheQuery { * * @return this query, modified * @throws UnsupportedOperationException if a page hasn't been set or if a range is already set - * @see [firstPage] - * @see [count] + * @see [firstPage] + * @see [count] */ fun lastPage(): PanacheQuery @@ -84,8 +84,8 @@ interface PanacheQuery { * * @return true if there is another page to read * @throws UnsupportedOperationException if a page hasn't been set or if a range is already set - * @see [hasPreviousPage] - * @see [count] + * @see [hasPreviousPage] + * @see [count] */ fun hasNextPage(): Boolean @@ -94,7 +94,7 @@ interface PanacheQuery { * * @return true if there is a previous page to read * @throws UnsupportedOperationException if a page hasn't been set or if a range is already set - * @see [hasNextPage] + * @see [hasNextPage] */ fun hasPreviousPage(): Boolean @@ -155,8 +155,8 @@ interface PanacheQuery { * Returns the current page of results as a [List]. * * @return the current page of results as a [List]. - * @see [stream] - * @see [page] + * @see [stream] + * @see [page] */ fun list(): List @@ -164,8 +164,8 @@ interface PanacheQuery { * Returns the current page of results as a [Stream]. * * @return the current page of results as a [Stream]. - * @see [list] - * @see [page] + * @see [list] + * @see [page] */ fun stream(): Stream @@ -174,7 +174,7 @@ interface PanacheQuery { * a single result. * * @return the first result of the current page index, or null if there are no results. - * @see [singleResult] + * @see [singleResult] */ fun firstResult(): Entity? @@ -183,7 +183,7 @@ interface PanacheQuery { * * @return the single result * @throws PanacheQueryException if there is not exactly one result. - * @see [firstResult] + * @see [firstResult] */ fun singleResult(): Entity? -} \ No newline at end of file +} diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoCompanion.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoCompanion.kt index 1940f2c8a0ce0..b42ee4c2123d2 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoCompanion.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoCompanion.kt @@ -17,8 +17,8 @@ import java.util.stream.Stream * * @param Entity the entity type */ -interface ReactivePanacheMongoCompanion - : ReactivePanacheMongoCompanionBase +interface ReactivePanacheMongoCompanion : + ReactivePanacheMongoCompanionBase /** * Define persistence and query methods for an Entity with a type of Id @@ -26,7 +26,7 @@ interface ReactivePanacheMongoCompanion * @param Entity the entity type * @param Id the ID type */ -interface ReactivePanacheMongoCompanionBase { +interface ReactivePanacheMongoCompanionBase { /** * Find an entity of this type by ID. * @@ -713,7 +713,7 @@ interface ReactivePanacheMongoCompanionBase = - INSTANCE.persistOrUpdate(firstEntity, *entities) + INSTANCE.persistOrUpdate(firstEntity, *entities) /** * Update all entities of this type by the given update document, with optional indexed parameters. @@ -766,7 +766,7 @@ interface ReactivePanacheMongoCompanionBase : ReactivePanacheMongoRepositoryBase \ No newline at end of file +interface ReactivePanacheMongoRepository : ReactivePanacheMongoRepositoryBase diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoRepositoryBase.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoRepositoryBase.kt index dc001eb1de3ad..0fd68262b47b8 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoRepositoryBase.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoRepositoryBase.kt @@ -23,7 +23,7 @@ import java.util.stream.Stream * @param Id The ID type of the entity * @see [ReactivePanacheMongoRepository] */ -interface ReactivePanacheMongoRepositoryBase { +interface ReactivePanacheMongoRepositoryBase { /** * Persist the given entity in the database. * This will set its ID field if not already set. @@ -74,7 +74,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, vararg params: Any?): ReactivePanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query and the given sort options, with optional indexed parameters. @@ -88,7 +88,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, sort: Sort, vararg params: Any?): ReactivePanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query, with named parameters. @@ -101,7 +101,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, params: Map): ReactivePanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query and the given sort options, with named parameters. @@ -115,7 +115,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, sort: Sort, params: Map): ReactivePanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query, with named parameters. @@ -128,7 +128,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, params: Parameters): ReactivePanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a query and the given sort options, with named parameters. @@ -142,7 +142,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: String, sort: Sort, params: Parameters): ReactivePanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query. @@ -166,7 +166,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun find(query: Document, sort: Document): ReactivePanacheQuery = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find all entities of this type. @@ -215,7 +215,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun list(query: String, sort: Sort, vararg params: Any?): Uni> = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -229,7 +229,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun list(query: String, params: Map): Uni> = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query and the given sort options, with named parameters. @@ -244,7 +244,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun list(query: String, sort: Sort, params: Map): Uni> = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -347,7 +347,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun stream(query: String, sort: Sort, vararg params: Any?): Multi = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -361,7 +361,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun stream(query: String, params: Map): Multi = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query and the given sort options, with named parameters. @@ -376,7 +376,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun stream(query: String, sort: Sort, params: Map): Multi = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities matching a query, with named parameters. @@ -404,7 +404,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun stream(query: String, sort: Sort, params: Parameters): Multi = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query. @@ -580,7 +580,7 @@ interface ReactivePanacheMongoRepositoryBase { * @param entities the entities to insert */ fun persist(firstEntity: Entity, vararg entities: Entity): Uni = - INSTANCE.persist(firstEntity, *entities) + INSTANCE.persist(firstEntity, *entities) /** * Update all given entities. @@ -602,7 +602,7 @@ interface ReactivePanacheMongoRepositoryBase { * @param entities the entities to update */ fun update(firstEntity: Entity, vararg entities: Entity): Uni = - INSTANCE.update(firstEntity, *entities) + INSTANCE.update(firstEntity, *entities) /** * Persist all given entities or update them if they already exist. @@ -610,7 +610,7 @@ interface ReactivePanacheMongoRepositoryBase { * @param entities the entities to update */ fun persistOrUpdate(entities: Iterable): Uni = - INSTANCE.persistOrUpdate(entities) + INSTANCE.persistOrUpdate(entities) /** * Persist all given entities or update them if they already exist. @@ -618,7 +618,7 @@ interface ReactivePanacheMongoRepositoryBase { * @param entities the entities to update */ fun persistOrUpdate(entities: Stream): Uni = - INSTANCE.persistOrUpdate(entities) + INSTANCE.persistOrUpdate(entities) /** * Persist all given entities or update them if they already exist. @@ -626,7 +626,7 @@ interface ReactivePanacheMongoRepositoryBase { * @param entities the entities to update */ fun persistOrUpdate(firstEntity: Entity, vararg entities: Entity): Uni = - INSTANCE.persistOrUpdate(firstEntity, *entities) + INSTANCE.persistOrUpdate(firstEntity, *entities) /** * Update all entities of this type by the given update document, with optional indexed parameters. @@ -639,7 +639,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun update(update: String, vararg params: Any?): io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Update all entities of this type by the given update document, with named parameters. @@ -652,7 +652,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun update(update: String, params: Map): io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Update all entities of this type by the given update document, with named parameters. @@ -665,7 +665,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun update(update: String, params: Parameters): io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Update all entities of this type by the given BSON update document. @@ -677,7 +677,7 @@ interface ReactivePanacheMongoRepositoryBase { */ @GenerateBridge fun update(update: Document): io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate = - throw INSTANCE.implementationInjectionMissing() + throw INSTANCE.implementationInjectionMissing() /** * Allow to access the underlying Mongo Collection diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheQuery.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheQuery.kt index e3cc176e507de..be939bf4cfbc0 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheQuery.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheQuery.kt @@ -187,4 +187,4 @@ interface ReactivePanacheQuery { * @see [firstResult] */ fun singleResult(): Uni -} \ No newline at end of file +} diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/KotlinReactiveMongoOperations.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/KotlinReactiveMongoOperations.kt index ff70db439f23a..923633458dcf9 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/KotlinReactiveMongoOperations.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/KotlinReactiveMongoOperations.kt @@ -1,9 +1,9 @@ package io.quarkus.mongodb.panache.kotlin.reactive.runtime import io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate -import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheQuery import io.quarkus.mongodb.panache.common.reactive.runtime.ReactiveMongoOperations import io.quarkus.mongodb.panache.common.reactive.runtime.ReactivePanacheUpdateImpl +import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheQuery import io.quarkus.mongodb.reactive.ReactiveMongoCollection import io.smallrye.mutiny.Multi import io.smallrye.mutiny.Uni @@ -32,7 +32,7 @@ class KotlinReactiveMongoOperations : ReactiveMongoOperations, query: Document?, sortDoc: Document?) = - ReactivePanacheQueryImpl(collection, query, sortDoc) + ReactivePanacheQueryImpl(collection, query, sortDoc) /** * Creates the update implementation @@ -44,7 +44,7 @@ class KotlinReactiveMongoOperations : ReactiveMongoOperations, entityClass: Class<*>, docUpdate: Document) = - ReactivePanacheUpdateImpl(this, entityClass, docUpdate, collection) + ReactivePanacheUpdateImpl(this, entityClass, docUpdate, collection) /** * Extracts the query results in to a List. diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/ReactivePanacheQueryImpl.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/ReactivePanacheQueryImpl.kt index 78ace939995ba..1b16783a54dd2 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/ReactivePanacheQueryImpl.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/ReactivePanacheQueryImpl.kt @@ -1,14 +1,14 @@ package io.quarkus.mongodb.panache.kotlin.reactive.runtime -import io.quarkus.mongodb.panache.common.reactive.runtime.CommonReactivePanacheQueryImpl -import io.quarkus.mongodb.reactive.ReactiveMongoCollection -import org.bson.conversions.Bson -import io.smallrye.mutiny.Uni import com.mongodb.ReadPreference import com.mongodb.client.model.Collation +import io.quarkus.mongodb.panache.common.reactive.runtime.CommonReactivePanacheQueryImpl import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheQuery +import io.quarkus.mongodb.reactive.ReactiveMongoCollection import io.quarkus.panache.common.Page import io.smallrye.mutiny.Multi +import io.smallrye.mutiny.Uni +import org.bson.conversions.Bson class ReactivePanacheQueryImpl : ReactivePanacheQuery { private val delegate: CommonReactivePanacheQueryImpl diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/KotlinMongoOperations.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/KotlinMongoOperations.kt index f3058a83416b0..2fc96350f6dc5 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/KotlinMongoOperations.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/KotlinMongoOperations.kt @@ -3,9 +3,9 @@ package io.quarkus.mongodb.panache.kotlin.runtime import com.mongodb.client.ClientSession import com.mongodb.client.MongoCollection import io.quarkus.mongodb.panache.common.PanacheUpdate -import io.quarkus.mongodb.panache.kotlin.PanacheQuery import io.quarkus.mongodb.panache.common.runtime.MongoOperations import io.quarkus.mongodb.panache.common.runtime.PanacheUpdateImpl +import io.quarkus.mongodb.panache.kotlin.PanacheQuery import org.bson.Document import java.util.stream.Stream @@ -24,15 +24,13 @@ class KotlinMongoOperations : MongoOperations, PanacheUpdate>() /** * Creates the query implementation - * - * @param collection the collection to query + * * @param collection the collection to query * @param query the query to base the new query off of * @param sortDoc the sort document to use - * - * @return the new query implementation + * * @return the new query implementation */ override fun createQuery(collection: MongoCollection<*>, session: ClientSession?, query: Document?, sortDoc: Document?) = - PanacheQueryImpl(collection, session, query, sortDoc) + PanacheQueryImpl(collection, session, query, sortDoc) /** * Creates the update implementation @@ -44,14 +42,12 @@ class KotlinMongoOperations : MongoOperations, PanacheUpdate>() * @return the new query implementation */ override fun createUpdate(collection: MongoCollection<*>, entityClass: Class<*>, docUpdate: Document) = - PanacheUpdateImpl(this, entityClass, docUpdate, collection) + PanacheUpdateImpl(this, entityClass, docUpdate, collection) /** * Extracts the query results in to a List. - * - * @param query the query to list - * - * @return a [List] of the results + * * @param query the query to list + * * @return a [List] of the results */ override fun list(query: PanacheQuery<*>): List<*> = query.list() diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/PanacheQueryImpl.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/PanacheQueryImpl.kt index 2b8a0400401ba..b0971593bb598 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/PanacheQueryImpl.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/PanacheQueryImpl.kt @@ -4,13 +4,13 @@ import com.mongodb.ReadPreference import com.mongodb.client.ClientSession import com.mongodb.client.MongoCollection import com.mongodb.client.model.Collation -import io.quarkus.mongodb.panache.kotlin.PanacheQuery import io.quarkus.mongodb.panache.common.runtime.CommonPanacheQueryImpl +import io.quarkus.mongodb.panache.kotlin.PanacheQuery import io.quarkus.panache.common.Page import org.bson.conversions.Bson import java.util.stream.Stream -class PanacheQueryImpl : PanacheQuery { +class PanacheQueryImpl : PanacheQuery { private val delegate: CommonPanacheQueryImpl internal constructor(collection: MongoCollection?, session: ClientSession?, mongoQuery: Bson?, sort: Bson?) { @@ -21,7 +21,7 @@ class PanacheQueryImpl : PanacheQuery { this.delegate = delegate } - override fun project(type: Class): PanacheQuery { + override fun project(type: Class): PanacheQuery { return PanacheQueryImpl(delegate.project(type)) } diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/TestAnalogs.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/TestAnalogs.kt index cf16838d3056b..cdd3305c8b00f 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/TestAnalogs.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/TestAnalogs.kt @@ -27,7 +27,6 @@ import io.quarkus.mongodb.panache.PanacheMongoEntityBase as JavaPanacheMongoEnti import io.quarkus.mongodb.panache.PanacheMongoRepository as JavaPanacheMongoRepository import io.quarkus.mongodb.panache.PanacheMongoRepositoryBase as JavaPanacheMongoRepositoryBase import io.quarkus.mongodb.panache.PanacheQuery as JavaPanacheQuery - import io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoEntity as ReactiveJavaPanacheMongoEntity import io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoEntityBase as ReactiveJavaPanacheMongoEntityBase import io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoRepository as ReactiveJavaPanacheMongoRepository @@ -66,46 +65,48 @@ class TestAnalogs { compare(ReactiveJavaPanacheMongoEntityBase::class, ReactivePanacheMongoEntityBase::class, ReactivePanacheMongoCompanionBase::class) } - private fun compare(javaEntity: KClass<*>, - kotlinEntity: KClass<*>, - companion: KClass<*>) { + private fun compare( + javaEntity: KClass<*>, + kotlinEntity: KClass<*>, + companion: KClass<*> + ) { val javaMethods = map(javaEntity).methods val kotlinMethods = map(kotlinEntity).methods - .filterNot { - it.name.contains("getId") - || it.name.contains("setId") - || it.name.contains("getOperations") - } - .toMutableList() + .filterNot { + it.name.contains("getId") || + it.name.contains("setId") || + it.name.contains("getOperations") + } + .toMutableList() val companionMethods = map(companion).methods val implemented = mutableListOf() javaMethods - .forEach { - if (!it.isStatic()) { - if (it in kotlinMethods) { - kotlinMethods -= it - implemented += it - } - } else { - if (it in companionMethods) { - companionMethods -= it - implemented += it - } + .forEach { + if (!it.isStatic()) { + if (it in kotlinMethods) { + kotlinMethods -= it + implemented += it + } + } else { + if (it in companionMethods) { + companionMethods -= it + implemented += it } } + } javaMethods.removeIf { it.name == "findByIdOptional" || - it in implemented + it in implemented } methods("javaMethods", javaMethods) methods("kotlinMethods", kotlinMethods) methods("companionMethods", companionMethods) - assertTrue(javaMethods.isEmpty(), "New methods not implemented: ${javaMethods}") - assertTrue(kotlinMethods.isEmpty(), "Old methods not removed: ${kotlinMethods}") - assertTrue(companionMethods.isEmpty(), "Old methods not removed: ${companionMethods}") + assertTrue(javaMethods.isEmpty(), "New methods not implemented: $javaMethods") + assertTrue(kotlinMethods.isEmpty(), "Old methods not removed: $kotlinMethods") + assertTrue(companionMethods.isEmpty(), "Old methods not removed: $companionMethods") } private fun map(type: KClass<*>): AnalogVisitor { @@ -114,9 +115,8 @@ class TestAnalogs { } } - private fun KClass<*>.bytes() = - java.classLoader.getResourceAsStream(qualifiedName.toString().replace(".", "/") + ".class") + java.classLoader.getResourceAsStream(qualifiedName.toString().replace(".", "/") + ".class") private fun compare(javaClass: AnalogVisitor, kotlinClass: AnalogVisitor, allowList: List = listOf()) { val javaMethods = javaClass.methods @@ -124,20 +124,20 @@ class TestAnalogs { val implemented = mutableListOf() javaMethods - .forEach { - if (it in kotlinMethods) { - kotlinMethods -= it - implemented += it - } + .forEach { + if (it in kotlinMethods) { + kotlinMethods -= it + implemented += it } + } javaMethods.removeIf { it.name in allowList || - it in implemented + it in implemented } - assertTrue(javaMethods.isEmpty(), "New methods not implemented: ${javaMethods}") - assertTrue(kotlinMethods.isEmpty(), "Old methods not removed: ${kotlinMethods}") + assertTrue(javaMethods.isEmpty(), "New methods not implemented: $javaMethods") + assertTrue(kotlinMethods.isEmpty(), "Old methods not removed: $kotlinMethods") } @Suppress("unused") @@ -145,9 +145,9 @@ class TestAnalogs { if (methods.isNotEmpty()) { println("$label: ") methods - .forEach { - println(it) - } + .forEach { + println(it) + } println() } } @@ -155,13 +155,18 @@ class TestAnalogs { class AnalogVisitor : ClassVisitor(Gizmo.ASM_API_VERSION) { val erasures = mapOf( - getType(PanacheMongoEntityBase::class.java).descriptor to getType(Object::class.java).descriptor, - getType(ReactivePanacheMongoEntityBase::class.java).descriptor to getType(Object::class.java).descriptor + getType(PanacheMongoEntityBase::class.java).descriptor to getType(Object::class.java).descriptor, + getType(ReactivePanacheMongoEntityBase::class.java).descriptor to getType(Object::class.java).descriptor ) val methods = mutableListOf() - override fun visitMethod(access: Int, name: String, descriptor: String, signature: String?, - exceptions: Array?): MethodVisitor? { + override fun visitMethod( + access: Int, + name: String, + descriptor: String, + signature: String?, + exceptions: Array? + ): MethodVisitor? { if (name != "" && name != "" && !descriptor.endsWith(ByteCodeType(Optional::class.java).descriptor())) { val method = Method(access, name, erase(getReturnType(descriptor)), erase(getArgumentTypes(descriptor))) methods += method @@ -171,9 +176,11 @@ class AnalogVisitor : ClassVisitor(Gizmo.ASM_API_VERSION) { private fun erase(type: Type): String { var value = type.descriptor - erasures.entries.forEach(Consumer { - value = value.replace(it.key, it.value) - }) + erasures.entries.forEach( + Consumer { + value = value.replace(it.key, it.value) + } + ) return value } @@ -184,8 +191,8 @@ class Method(val access: Int, val name: String, val type: String, val parameters fun isStatic() = access.matches(Opcodes.ACC_STATIC) override fun toString(): String { - return (if (isStatic()) "static " else "") + "fun ${name}(${parameters.joinToString(", ")})" + - (if (type != Unit::class.qualifiedName) ": $type" else "") + return (if (isStatic()) "static " else "") + "fun $name(${parameters.joinToString(", ")})" + + (if (type != Unit::class.qualifiedName) ": $type" else "") } override fun equals(other: Any?): Boolean { @@ -204,7 +211,6 @@ class Method(val access: Int, val name: String, val type: String, val parameters result = 31 * result + parameters.hashCode() return result } - } fun Int.matches(mask: Int) = (this and mask) == mask @@ -227,4 +233,4 @@ fun Int.accDecode(): List { } } return decode -} \ No newline at end of file +} diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializerRecorder.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializerRecorder.kt index 26038b0002f4c..1ef4e89d25acb 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializerRecorder.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization-common/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializerRecorder.kt @@ -3,7 +3,6 @@ package io.quarkus.kotlin.serialization import io.quarkus.runtime.annotations.Recorder import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json -import kotlinx.serialization.modules.EmptySerializersModule import java.util.function.Supplier @Recorder diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt index b5a99f7892b61..1631aaf5b4822 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyReader.kt @@ -11,7 +11,6 @@ import org.jboss.resteasy.reactive.server.spi.ServerMessageBodyReader import org.jboss.resteasy.reactive.server.spi.ServerRequestContext import java.io.InputStream import java.lang.reflect.Type -import javax.inject.Inject import javax.ws.rs.core.MediaType import javax.ws.rs.core.MultivaluedMap @@ -39,7 +38,8 @@ class KotlinSerializationMessageBodyReader(private val json: Json) : AbstractJso @ExperimentalSerializationApi private fun doReadFrom(type: Class, entityStream: InputStream): Any? { - return if (StreamUtil.isEmpty(entityStream)) null else + return if (StreamUtil.isEmpty(entityStream)) null else { json.decodeFromStream(serializer(type), entityStream) + } } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt index 670449695565d..134e5592e7ad6 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/kotlin/serialization/KotlinSerializationMessageBodyWriter.kt @@ -10,7 +10,6 @@ import org.jboss.resteasy.reactive.server.spi.ServerRequestContext import java.io.OutputStream import java.lang.reflect.Type import java.nio.charset.StandardCharsets -import javax.inject.Inject import javax.ws.rs.Produces import javax.ws.rs.core.MediaType import javax.ws.rs.core.MultivaluedMap @@ -19,14 +18,19 @@ import javax.ws.rs.core.MultivaluedMap @OptIn(ExperimentalSerializationApi::class) class KotlinSerializationMessageBodyWriter(private val json: Json) : AllWriteableMessageBodyWriter() { override fun writeTo( - o: Any, type: Class<*>, genericType: Type, annotations: Array, mediaType: MediaType, - httpHeaders: MultivaluedMap, entityStream: OutputStream + o: Any, + type: Class<*>, + genericType: Type, + annotations: Array, + mediaType: MediaType, + httpHeaders: MultivaluedMap, + entityStream: OutputStream ) { JsonMessageBodyWriterUtil.setContentTypeIfNecessary(httpHeaders) if (o is String) { // YUK: done in order to avoid adding extra quotes... entityStream.write(o.toByteArray(StandardCharsets.UTF_8)) } else { - json.encodeToStream(serializer(o.javaClass) , o, entityStream) + json.encodeToStream(serializer(o.javaClass), o, entityStream) } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/AbstractSuspendedRequestFilter.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/AbstractSuspendedRequestFilter.kt index 4327ceea24f8f..72c92a22cdcee 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/AbstractSuspendedRequestFilter.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/AbstractSuspendedRequestFilter.kt @@ -18,11 +18,10 @@ abstract class AbstractSuspendedRequestFilter : ResteasyReactiveContainerRequest abstract fun handleResult(containerRequestContext: ResteasyReactiveContainerRequestContext, uniResult: Uni<*>) - private val originalTCCL: ClassLoader = Thread.currentThread().contextClassLoader override fun filter(containerRequestContext: ResteasyReactiveContainerRequestContext) { - val (dispatcher,coroutineScope) = prepareExecution(containerRequestContext.serverRequestContext as ResteasyReactiveRequestContext) + val (dispatcher, coroutineScope) = prepareExecution(containerRequestContext.serverRequestContext as ResteasyReactiveRequestContext) val uni = coroutineScope.async(context = dispatcher) { // ensure the proper CL is not lost in dev-mode diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/AbstractSuspendedResponseFilter.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/AbstractSuspendedResponseFilter.kt index d2a09e733b033..46cb5206a638c 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/AbstractSuspendedResponseFilter.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/AbstractSuspendedResponseFilter.kt @@ -18,8 +18,7 @@ abstract class AbstractSuspendedResponseFilter : ResteasyReactiveContainerRespon private val originalTCCL: ClassLoader = Thread.currentThread().contextClassLoader override fun filter(requestContext: ResteasyReactiveContainerRequestContext, responseContext: ContainerResponseContext) { - val (dispatcher,coroutineScope) = prepareExecution(requestContext.serverRequestContext as ResteasyReactiveRequestContext) - + val (dispatcher, coroutineScope) = prepareExecution(requestContext.serverRequestContext as ResteasyReactiveRequestContext) requestContext.suspend() coroutineScope.launch(context = dispatcher) { diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/ApplicationCoroutineScope.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/ApplicationCoroutineScope.kt index 036947f3b4308..8f8f76acd7b08 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/ApplicationCoroutineScope.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/ApplicationCoroutineScope.kt @@ -1,7 +1,11 @@ package org.jboss.resteasy.reactive.server.runtime.kotlin import io.vertx.core.Context -import kotlinx.coroutines.* +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Runnable +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel import org.jboss.resteasy.reactive.server.core.CurrentRequestManager import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext import org.jboss.resteasy.reactive.spi.ThreadSetupAction @@ -29,16 +33,16 @@ class ApplicationCoroutineScope : CoroutineScope, AutoCloseable { /** * Dispatches the coroutine in Vertx IO thread. */ -class VertxDispatcher(private val vertxContext: Context, private val requestScope : ThreadSetupAction.ThreadState, private val rrContext: ResteasyReactiveRequestContext) : CoroutineDispatcher() { +class VertxDispatcher(private val vertxContext: Context, private val requestScope: ThreadSetupAction.ThreadState, private val rrContext: ResteasyReactiveRequestContext) : CoroutineDispatcher() { override fun dispatch(context: CoroutineContext, block: Runnable) { // context propagation for suspending functions is not enabled yet, will be handled later vertxContext.runOnContext { requestScope.activate() - CurrentRequestManager.set(rrContext); + CurrentRequestManager.set(rrContext) try { block.run() } finally { - CurrentRequestManager.set(null); + CurrentRequestManager.set(null) requestScope.deactivate() } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineEndpointInvoker.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineEndpointInvoker.kt index 8581cda97f77d..d364b0f4524ac 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineEndpointInvoker.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineEndpointInvoker.kt @@ -7,7 +7,7 @@ import org.jboss.resteasy.reactive.server.spi.EndpointInvoker * * @see [KotlinCoroutineIntegrationProcessor] the build-time part of coroutine support */ -interface CoroutineEndpointInvoker: EndpointInvoker { +interface CoroutineEndpointInvoker : EndpointInvoker { /** * Delegates control over the bean that defines the endpoint * diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandler.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandler.kt index e4194d8d15939..3cecbe975b524 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandler.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandler.kt @@ -11,12 +11,13 @@ import org.slf4j.LoggerFactory private val logger = LoggerFactory.getLogger(CoroutineInvocationHandler::class.java) -class CoroutineInvocationHandler(private val invoker: EndpointInvoker, - private val coroutineScope: CoroutineScope) : ServerRestHandler { +class CoroutineInvocationHandler( + private val invoker: EndpointInvoker, + private val coroutineScope: CoroutineScope +) : ServerRestHandler { private val originalTCCL: ClassLoader = Thread.currentThread().contextClassLoader - override fun handle(requestContext: ResteasyReactiveRequestContext) { if (requestContext.result != null) { return @@ -27,8 +28,8 @@ class CoroutineInvocationHandler(private val invoker: EndpointInvoker, } val requestScope = requestContext.captureCDIRequestScope() - val dispatcher: CoroutineDispatcher = Vertx.currentContext()?.let {VertxDispatcher(it,requestScope, requestContext)} - ?: throw IllegalStateException("No Vertx context found") + val dispatcher: CoroutineDispatcher = Vertx.currentContext()?.let { VertxDispatcher(it, requestScope, requestContext) } + ?: throw IllegalStateException("No Vertx context found") logger.trace("Handling request with dispatcher {}", dispatcher) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandlerFactory.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandlerFactory.kt index aa827863c2dcc..1446af6ccd552 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandlerFactory.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineInvocationHandlerFactory.kt @@ -3,8 +3,6 @@ package org.jboss.resteasy.reactive.server.runtime.kotlin import io.quarkus.arc.Unremovable import org.jboss.resteasy.reactive.server.spi.EndpointInvoker import org.jboss.resteasy.reactive.server.spi.ServerRestHandler -import javax.enterprise.context.ApplicationScoped -import javax.inject.Inject import javax.inject.Singleton /** diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineMethodProcessor.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineMethodProcessor.kt index c8585a0789fcf..01ab7ac4d6be5 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineMethodProcessor.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/CoroutineMethodProcessor.kt @@ -10,9 +10,11 @@ import javax.enterprise.inject.spi.CDI /** * Intercepts method invocations to force an EndpointInvoker. */ -open class CoroutineMethodProcessor @Deprecated("Used only in synthetic code") constructor() : HandlerChainCustomizer { +open class CoroutineMethodProcessor +@Deprecated("Used only in synthetic code") +constructor() : HandlerChainCustomizer { - constructor(alternativeInvoker: Supplier): this() { + constructor(alternativeInvoker: Supplier) : this() { this.alternativeInvoker = alternativeInvoker } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/FlowToPublisherHandler.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/FlowToPublisherHandler.kt index 0dee691bac36d..824202de6e0e6 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/FlowToPublisherHandler.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/FlowToPublisherHandler.kt @@ -17,10 +17,9 @@ class FlowToPublisherHandler : ServerRestHandler { override fun handle(requestContext: ResteasyReactiveRequestContext?) { val result = requestContext!!.result if (result is Flow<*>) { - val requestScope = requestContext.captureCDIRequestScope() - val dispatcher: CoroutineDispatcher = Vertx.currentContext()?.let {VertxDispatcher(it,requestScope, requestContext)} - ?: throw IllegalStateException("No Vertx context found") + val dispatcher: CoroutineDispatcher = Vertx.currentContext()?.let { VertxDispatcher(it, requestScope, requestContext) } + ?: throw IllegalStateException("No Vertx context found") val coroutineScope = CDI.current().select(ApplicationCoroutineScope::class.java) requestContext.suspend() @@ -28,8 +27,8 @@ class FlowToPublisherHandler : ServerRestHandler { // ensure the proper CL is not lost in dev-mode Thread.currentThread().contextClassLoader = originalTCCL requestContext.result = result.asMulti() - //run in a direct invocation executor to run the rest of the invocation in the co-route scope - //feels a bit fragile, but let's see how it goes + // run in a direct invocation executor to run the rest of the invocation in the co-route scope + // feels a bit fragile, but let's see how it goes requestContext.resume(Executor { it.run() }) } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/FilterUtils.kt b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/PrepareExecution.kt similarity index 84% rename from extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/FilterUtils.kt rename to extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/PrepareExecution.kt index 07d8fe72e1de2..03d711dd2adfc 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/FilterUtils.kt +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-kotlin/runtime/src/main/kotlin/org/jboss/resteasy/reactive/server/runtime/kotlin/PrepareExecution.kt @@ -7,8 +7,8 @@ import javax.enterprise.inject.spi.CDI fun prepareExecution(requestContext: ResteasyReactiveRequestContext): Pair { val requestScope = requestContext.captureCDIRequestScope() - val dispatcher: CoroutineDispatcher = Vertx.currentContext()?.let {VertxDispatcher(it,requestScope, requestContext)} - ?: throw IllegalStateException("No Vertx context found") + val dispatcher: CoroutineDispatcher = Vertx.currentContext()?.let { VertxDispatcher(it, requestScope, requestContext) } + ?: throw IllegalStateException("No Vertx context found") val coroutineScope = CDI.current().select(ApplicationCoroutineScope::class.java) requestContext.suspend() diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt index a63bd5cc7f7f0..e30c20afa85b5 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyReader.kt @@ -7,7 +7,6 @@ import kotlinx.serialization.serializer import org.jboss.resteasy.reactive.common.util.StreamUtil import java.io.InputStream import java.lang.reflect.Type -import javax.inject.Inject import javax.ws.rs.core.MediaType import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.ext.MessageBodyReader @@ -17,10 +16,15 @@ class ClientKotlinMessageBodyReader(private val json: Json) : MessageBodyReader< override fun isReadable(type: Class<*>?, generic: Type?, annotations: Array?, mediaType: MediaType?) = true override fun readFrom( - type: Class, generic: Type, annotations: Array?, mediaType: MediaType?, - httpHeaders: MultivaluedMap?, entityStream: InputStream + type: Class, + generic: Type, + annotations: Array?, + mediaType: MediaType?, + httpHeaders: MultivaluedMap?, + entityStream: InputStream ): Any? { - return if (StreamUtil.isEmpty(entityStream)) null else + return if (StreamUtil.isEmpty(entityStream)) null else { json.decodeFromStream(serializer(generic), entityStream) + } } } diff --git a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt index 9b2ee6178e290..8d2a4c9398b42 100644 --- a/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt +++ b/extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/rest/client/reactive/kotlin/runtime/serializers/ClientKotlinMessageBodyWriter.kt @@ -6,7 +6,6 @@ import kotlinx.serialization.json.encodeToStream import kotlinx.serialization.serializer import java.io.OutputStream import java.lang.reflect.Type -import javax.inject.Inject import javax.ws.rs.core.MediaType import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.ext.MessageBodyWriter @@ -16,8 +15,13 @@ class ClientKotlinMessageBodyWriter(private val json: Json) : MessageBodyWriter< override fun isWriteable(type: Class<*>, genericType: Type, annotations: Array?, mediaType: MediaType?) = true override fun writeTo( - t: Any, type: Class<*>, genericType: Type, annotations: Array?, mediaType: MediaType, - httpHeaders: MultivaluedMap, entityStream: OutputStream + t: Any, + type: Class<*>, + genericType: Type, + annotations: Array?, + mediaType: MediaType, + httpHeaders: MultivaluedMap, + entityStream: OutputStream ) { json.encodeToStream(serializer(genericType), t, entityStream) } diff --git a/extensions/scheduler/kotlin/src/main/kotlin/io/quarkus/scheduler/kotlin/runtime/AbstractCoroutineInvoker.kt b/extensions/scheduler/kotlin/src/main/kotlin/io/quarkus/scheduler/kotlin/runtime/AbstractCoroutineInvoker.kt index 1ed8030e51c66..2fe5470e38919 100644 --- a/extensions/scheduler/kotlin/src/main/kotlin/io/quarkus/scheduler/kotlin/runtime/AbstractCoroutineInvoker.kt +++ b/extensions/scheduler/kotlin/src/main/kotlin/io/quarkus/scheduler/kotlin/runtime/AbstractCoroutineInvoker.kt @@ -9,12 +9,12 @@ import kotlinx.coroutines.async import kotlinx.coroutines.future.asCompletableFuture import java.util.concurrent.CompletionStage -abstract class AbstractCoroutineInvoker: ScheduledInvoker { +abstract class AbstractCoroutineInvoker : ScheduledInvoker { override fun invoke(execution: ScheduledExecution): CompletionStage { val coroutineScope = Arc.container().instance(ApplicationCoroutineScope::class.java).get() val dispatcher: CoroutineDispatcher = Vertx.currentContext()?.let(::VertxDispatcher) - ?: throw IllegalStateException("No Vertx context found") + ?: throw IllegalStateException("No Vertx context found") return coroutineScope.async(context = dispatcher) { invokeBean(execution) diff --git a/extensions/scheduler/kotlin/src/main/kotlin/io/quarkus/scheduler/kotlin/runtime/ApplicationCoroutineScope.kt b/extensions/scheduler/kotlin/src/main/kotlin/io/quarkus/scheduler/kotlin/runtime/ApplicationCoroutineScope.kt index dc38c5c736994..96dfed1db77a8 100644 --- a/extensions/scheduler/kotlin/src/main/kotlin/io/quarkus/scheduler/kotlin/runtime/ApplicationCoroutineScope.kt +++ b/extensions/scheduler/kotlin/src/main/kotlin/io/quarkus/scheduler/kotlin/runtime/ApplicationCoroutineScope.kt @@ -1,6 +1,5 @@ package io.quarkus.scheduler.kotlin.runtime -import io.quarkus.arc.Unremovable import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel diff --git a/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/EmitterExtensions.kt b/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/EmitterExtensions.kt deleted file mode 100644 index dc23199ea9597..0000000000000 --- a/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/EmitterExtensions.kt +++ /dev/null @@ -1,6 +0,0 @@ -package io.quarkus.smallrye.reactivemessaging - -import kotlinx.coroutines.future.await -import org.eclipse.microprofile.reactive.messaging.Emitter - -suspend fun Emitter.sendSuspending(t: T) = send(t).await() \ No newline at end of file diff --git a/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/MessageExtensions.kt b/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/Extensions.kt similarity index 69% rename from extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/MessageExtensions.kt rename to extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/Extensions.kt index ac0d6eb60bf06..3d9b524f24fe3 100644 --- a/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/MessageExtensions.kt +++ b/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/Extensions.kt @@ -1,8 +1,10 @@ package io.quarkus.smallrye.reactivemessaging import kotlinx.coroutines.future.await +import org.eclipse.microprofile.reactive.messaging.Emitter import org.eclipse.microprofile.reactive.messaging.Message suspend fun Message.ackSuspending() = ack().await() suspend fun Message.nackSuspending(t: Throwable) = nack(t).await() +suspend fun Emitter.sendSuspending(t: T) = send(t).await() diff --git a/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/runtime/kotlin/AbstractSubscribingCoroutineInvoker.kt b/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/runtime/kotlin/AbstractSubscribingCoroutineInvoker.kt index 27df4ef209158..c2ba9f6274a4e 100644 --- a/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/runtime/kotlin/AbstractSubscribingCoroutineInvoker.kt +++ b/extensions/smallrye-reactive-messaging/kotlin/src/main/kotlin/io/quarkus/smallrye/reactivemessaging/runtime/kotlin/AbstractSubscribingCoroutineInvoker.kt @@ -8,12 +8,12 @@ import kotlinx.coroutines.async import kotlinx.coroutines.future.asCompletableFuture import java.util.concurrent.CompletableFuture -abstract class AbstractSubscribingCoroutineInvoker(private val beanInstance: Any): Invoker { +abstract class AbstractSubscribingCoroutineInvoker(private val beanInstance: Any) : Invoker { override fun invoke(vararg args: Any?): CompletableFuture { val coroutineScope = Arc.container().instance(ApplicationCoroutineScope::class.java).get() val dispatcher: CoroutineDispatcher = Vertx.currentContext()?.let(::VertxDispatcher) - ?: throw IllegalStateException("No Vertx context found. Consider using @NonBlocking on the caller method, or make sure the upstream emits items on the Vert.x context") + ?: throw IllegalStateException("No Vertx context found. Consider using @NonBlocking on the caller method, or make sure the upstream emits items on the Vert.x context") return coroutineScope.async(context = dispatcher) { invokeBean(beanInstance, args) diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_main_resources_application.properties b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_main_resources_application.properties index a41954b201a08..d8f24b7593bd7 100644 --- a/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_main_resources_application.properties +++ b/integration-tests/devtools/src/test/resources/__snapshots__/ReactiveMessagingCodestartIT/testKafkaContent/src_main_resources_application.properties @@ -1,3 +1,3 @@ mp.messaging.incoming.words-in.topic=words mp.messaging.outgoing.words-out.topic=words -mp.messaging.incoming.words-in.auto.offset.reset=earliest \ No newline at end of file +mp.messaging.incoming.words-in.auto.offset.reset=earliest diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/WebSocketsCodestartTest/testContent/src_main_kotlin_ilove_quark_us_StartWebSocket.kt b/integration-tests/devtools/src/test/resources/__snapshots__/WebSocketsCodestartTest/testContent/src_main_kotlin_ilove_quark_us_StartWebSocket.kt index cddb502b90d3a..a738cb3e8a5eb 100644 --- a/integration-tests/devtools/src/test/resources/__snapshots__/WebSocketsCodestartTest/testContent/src_main_kotlin_ilove_quark_us_StartWebSocket.kt +++ b/integration-tests/devtools/src/test/resources/__snapshots__/WebSocketsCodestartTest/testContent/src_main_kotlin_ilove_quark_us_StartWebSocket.kt @@ -1,13 +1,12 @@ package ilove.quark.us -import java.io.IOException import javax.enterprise.context.ApplicationScoped import javax.websocket.* import javax.websocket.server.PathParam import javax.websocket.server.ServerEndpoint -@ServerEndpoint("/start-websocket/{name}") @ApplicationScoped +@ServerEndpoint("/start-websocket/{name}") class StartWebSocket { @OnOpen diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AbstractRepository.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AbstractRepository.kt index 361a70ea61936..9d0486a708740 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AbstractRepository.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AbstractRepository.kt @@ -2,4 +2,4 @@ package io.quarkus.it.panache.kotlin import io.quarkus.hibernate.orm.panache.kotlin.PanacheRepositoryBase -abstract class AbstractRepository : PanacheRepositoryBase \ No newline at end of file +abstract class AbstractRepository : PanacheRepositoryBase diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AccessorEntity.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AccessorEntity.kt index 2d72bfcab9b3b..b7b122564d0d3 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AccessorEntity.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/AccessorEntity.kt @@ -28,22 +28,26 @@ open class AccessorEntity : GenericEntity() { } var f = 0f var d = 0.0 + @Transient var trans: Any? = null + @Transient var trans2: Any? = null // FIXME: those appear to be mapped by hibernate @Transient var getBCalls = 0 + @Transient var setICalls = 0 + @Transient var getTransCalls = 0 + @Transient var setTransCalls = 0 - fun method() { // touch some fields val b2 = b i = 2 diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Address.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Address.kt index 67b93ce533f62..15f7b66eca9c7 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Address.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Address.kt @@ -30,4 +30,4 @@ open class Address : PanacheEntityBase { } override fun toString() = "${javaClass.simpleName}<$id>" -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5274EntityRepository.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5274EntityRepository.kt index 6ba02b890f023..9d0ea8e8a5a38 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5274EntityRepository.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5274EntityRepository.kt @@ -3,4 +3,4 @@ package io.quarkus.it.panache.kotlin import javax.enterprise.context.ApplicationScoped @ApplicationScoped -open class Bug5274EntityRepository : AbstractRepository() \ No newline at end of file +open class Bug5274EntityRepository : AbstractRepository() diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5885AbstractRepository.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5885AbstractRepository.kt index d55097f661b9f..12ff3f0a505f2 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5885AbstractRepository.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5885AbstractRepository.kt @@ -2,4 +2,4 @@ package io.quarkus.it.panache.kotlin import io.quarkus.hibernate.orm.panache.kotlin.PanacheRepository -abstract class Bug5885AbstractRepository : PanacheRepository \ No newline at end of file +abstract class Bug5885AbstractRepository : PanacheRepository diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5885EntityRepository.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5885EntityRepository.kt index 5c7707de1350c..84dfb0cae5a35 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5885EntityRepository.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Bug5885EntityRepository.kt @@ -3,4 +3,4 @@ package io.quarkus.it.panache.kotlin import javax.enterprise.context.ApplicationScoped @ApplicationScoped -open class Bug5885EntityRepository : Bug5885AbstractRepository() \ No newline at end of file +open class Bug5885EntityRepository : Bug5885AbstractRepository() diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Dog.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Dog.kt index 1e78426b9ac5f..6f2f6a5770eb2 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Dog.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Dog.kt @@ -12,7 +12,7 @@ import javax.persistence.ManyToOne open class Dog() : PanacheEntityBase { companion object : PanacheCompanion - constructor(name: String, race: String): this() { + constructor(name: String, race: String) : this() { this.name = name this.race = race } @@ -21,6 +21,7 @@ open class Dog() : PanacheEntityBase { var owner: Person? = null var name: String? = null var race: String? = null + /** * The auto-generated ID field. This field is set by Hibernate ORM when this entity * is persisted. @@ -37,4 +38,4 @@ open class Dog() : PanacheEntityBase { * @return the class type and ID type */ override fun toString() = "${javaClass.simpleName}<$id>" -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DogDao.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DogDao.kt index 48a8a99ae0099..670e5153bfce0 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DogDao.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DogDao.kt @@ -4,4 +4,4 @@ import io.quarkus.hibernate.orm.panache.kotlin.PanacheRepositoryBase import javax.enterprise.context.ApplicationScoped @ApplicationScoped -open class DogDao : PanacheRepositoryBase \ No newline at end of file +open class DogDao : PanacheRepositoryBase diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DummyService.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DummyService.kt index 85c330413fdb7..40b0146b30502 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DummyService.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/DummyService.kt @@ -4,5 +4,4 @@ import javax.enterprise.context.ApplicationScoped // used only to validate that we can inject CDI beans into Panache repositories written in Kotlin @ApplicationScoped -class DummyService { -} +class DummyService diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/GenericEntity.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/GenericEntity.kt index 155c5d92a2d65..54cc789609506 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/GenericEntity.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/GenericEntity.kt @@ -7,4 +7,4 @@ import javax.persistence.MappedSuperclass abstract class GenericEntity : PanacheEntity() { var t: T? = null var t2: T? = null -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/JAXBEntity.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/JAXBEntity.kt index 7c25df85885ff..a606084a010ea 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/JAXBEntity.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/JAXBEntity.kt @@ -26,4 +26,4 @@ open class JAXBEntity : PanacheEntity() { @XmlElements(XmlElement(name = "array1"), XmlElement(name = "array2")) var arrayAnnotatedProp: String? = null var unAnnotatedProp: String? = null -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Person.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Person.kt index 84bb899cf95ff..5b65534854af8 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Person.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Person.kt @@ -2,22 +2,22 @@ package io.quarkus.it.panache.kotlin import io.quarkus.hibernate.orm.panache.kotlin.PanacheCompanion import io.quarkus.hibernate.orm.panache.kotlin.PanacheEntity +import org.hibernate.annotations.Filter +import org.hibernate.annotations.FilterDef +import org.hibernate.annotations.FilterDefs +import org.hibernate.annotations.Filters +import org.hibernate.annotations.ParamDef import javax.persistence.CascadeType import javax.persistence.Column import javax.persistence.Entity +import javax.persistence.EnumType +import javax.persistence.Enumerated import javax.persistence.FetchType import javax.persistence.ManyToOne import javax.persistence.OneToMany import javax.persistence.Transient import javax.xml.bind.annotation.XmlRootElement import javax.xml.bind.annotation.XmlTransient -import javax.persistence.Enumerated -import org.hibernate.annotations.Filter -import org.hibernate.annotations.FilterDef -import org.hibernate.annotations.ParamDef -import org.hibernate.annotations.FilterDefs -import org.hibernate.annotations.Filters -import javax.persistence.EnumType @XmlRootElement @Entity(name = "Person2") @@ -25,23 +25,24 @@ import javax.persistence.EnumType FilterDef(name = "Person.hasName", defaultCondition = "name = :name", parameters = [ParamDef(name = "name", type = "string")]), FilterDef(name = "Person.isAlive", defaultCondition = "status = 'LIVING'") ) -@Filters( - Filter(name = "Person.isAlive"), - Filter(name = "Person.hasName") -) +@Filters(Filter(name = "Person.isAlive"), Filter(name = "Person.hasName")) open class Person : PanacheEntity() { companion object : PanacheCompanion { - fun findOrdered(): List
= AddressDao.shouldBeOverridden() + fun findOrdered(): List
= AddressDao.shouldBeOverridden() } var name: String? = null + @Column(unique = true) var uniqueName: String? = null + @ManyToOne(cascade = [CascadeType.ALL], fetch = FetchType.LAZY) var address: Address? = null + // FIXME: this isn't working @Enumerated(EnumType.STRING) var status: Status? = null + @OneToMany(mappedBy = "owner", cascade = [CascadeType.ALL], fetch = FetchType.LAZY) var dogs = mutableListOf() @@ -58,6 +59,4 @@ open class Person : PanacheEntity() { override fun toString(): String { return "Person(id=$id, name=$name, status=$status)" } - - -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Status.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Status.kt index d3e5f89e47e55..a7e8e5225cd36 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Status.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/Status.kt @@ -2,4 +2,4 @@ package io.quarkus.it.panache.kotlin enum class Status { LIVING, DECEASED -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/TestEndpoint.kt b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/TestEndpoint.kt index af2be995459ee..e97f685a1624f 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/TestEndpoint.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/main/kotlin/io/quarkus/it/panache/kotlin/TestEndpoint.kt @@ -39,7 +39,7 @@ class TestEndpoint { @Transactional fun testModel(): String { Person.flush() - Assertions.assertNotNull(Person.getEntityManager()); + Assertions.assertNotNull(Person.getEntityManager()) Assertions.assertDoesNotThrow { Person.findById(Long.MIN_VALUE) @@ -221,7 +221,7 @@ class TestEndpoint { person2.persistAndFlush() Assertions.fail() } catch (pe: PersistenceException) { - //this is expected + // this is expected } return "OK" } @@ -233,8 +233,10 @@ class TestEndpoint { var updateByIndexParameter: Int = Person.update("update from Person2 p set p.name = 'stefNEW' where p.name = ?1", "stefp1") Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - var updateByNamedParameter: Int = Person.update("update from Person2 p set p.name = 'stefNEW' where p.name = :pName", - Parameters.with("pName", "stefp2").map()) + var updateByNamedParameter: Int = Person.update( + "update from Person2 p set p.name = 'stefNEW' where p.name = :pName", + Parameters.with("pName", "stefp2").map() + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, Person.deleteAll()) @@ -245,8 +247,10 @@ class TestEndpoint { updateByIndexParameter = Person.update("from Person2 p set p.name = 'stefNEW' where p.name = ?1", "stefp1") Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - updateByNamedParameter = Person.update("from Person2 p set p.name = 'stefNEW' where p.name = :pName", - Parameters.with("pName", "stefp2").map()) + updateByNamedParameter = Person.update( + "from Person2 p set p.name = 'stefNEW' where p.name = :pName", + Parameters.with("pName", "stefp2").map() + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, Person.deleteAll()) @@ -257,8 +261,10 @@ class TestEndpoint { updateByIndexParameter = Person.update("set name = 'stefNEW' where name = ?1", "stefp1") Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - updateByNamedParameter = Person.update("set name = 'stefNEW' where name = :pName", - Parameters.with("pName", "stefp2").map()) + updateByNamedParameter = Person.update( + "set name = 'stefNEW' where name = :pName", + Parameters.with("pName", "stefp2").map() + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, Person.deleteAll()) @@ -269,8 +275,10 @@ class TestEndpoint { updateByIndexParameter = Person.update("name = 'stefNEW' where name = ?1", "stefp1") Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - updateByNamedParameter = Person.update("name = 'stefNEW' where name = :pName", - Parameters.with("pName", "stefp2").map()) + updateByNamedParameter = Person.update( + "name = 'stefNEW' where name = :pName", + Parameters.with("pName", "stefp2").map() + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, Person.deleteAll()) @@ -281,8 +289,10 @@ class TestEndpoint { updateByIndexParameter = Person.update("name = 'stefNEW' where name = ?1", "stefp1") Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - updateByNamedParameter = Person.update("name = 'stefNEW' where name = :pName", - Parameters.with("pName", "stefp2")) + updateByNamedParameter = Person.update( + "name = 'stefNEW' where name = :pName", + Parameters.with("pName", "stefp2") + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, Person.deleteAll()) @@ -290,20 +300,27 @@ class TestEndpoint { // Assertions.assertThrows(PanacheQueryException::class.java, { Person.update(null) }, // "PanacheQueryException should have thrown") - Assertions.assertThrows(PanacheQueryException::class.java, { Person.update(" ") }, - "PanacheQueryException should have thrown") + Assertions.assertThrows( + PanacheQueryException::class.java, + { Person.update(" ") }, + "PanacheQueryException should have thrown" + ) } private fun testUpdateDAO() { makeSavedPerson("p1") makeSavedPerson("p2") - var updateByIndexParameter: Int = personRepository.update("update from Person2 p set p.name = 'stefNEW' where p.name = ?1", - "stefp1") + var updateByIndexParameter: Int = personRepository.update( + "update from Person2 p set p.name = 'stefNEW' where p.name = ?1", + "stefp1" + ) Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - var updateByNamedParameter: Int = personRepository.update("update from Person2 p set p.name = 'stefNEW' where p.name = :pName", - Parameters.with("pName", "stefp2").map()) + var updateByNamedParameter: Int = personRepository.update( + "update from Person2 p set p.name = 'stefNEW' where p.name = :pName", + Parameters.with("pName", "stefp2").map() + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, personRepository.deleteAll()) @@ -314,8 +331,10 @@ class TestEndpoint { updateByIndexParameter = personRepository.update("from Person2 p set p.name = 'stefNEW' where p.name = ?1", "stefp1") Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - updateByNamedParameter = personRepository.update("from Person2 p set p.name = 'stefNEW' where p.name = :pName", - Parameters.with("pName", "stefp2").map()) + updateByNamedParameter = personRepository.update( + "from Person2 p set p.name = 'stefNEW' where p.name = :pName", + Parameters.with("pName", "stefp2").map() + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, personRepository.deleteAll()) @@ -326,8 +345,10 @@ class TestEndpoint { updateByIndexParameter = personRepository.update("set name = 'stefNEW' where name = ?1", "stefp1") Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - updateByNamedParameter = personRepository.update("set name = 'stefNEW' where name = :pName", - Parameters.with("pName", "stefp2").map()) + updateByNamedParameter = personRepository.update( + "set name = 'stefNEW' where name = :pName", + Parameters.with("pName", "stefp2").map() + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, personRepository.deleteAll()) @@ -338,8 +359,10 @@ class TestEndpoint { updateByIndexParameter = personRepository.update("name = 'stefNEW' where name = ?1", "stefp1") Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - updateByNamedParameter = personRepository.update("name = 'stefNEW' where name = :pName", - Parameters.with("pName", "stefp2").map()) + updateByNamedParameter = personRepository.update( + "name = 'stefNEW' where name = :pName", + Parameters.with("pName", "stefp2").map() + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, personRepository.deleteAll()) @@ -350,8 +373,10 @@ class TestEndpoint { updateByIndexParameter = personRepository.update("name = 'stefNEW' where name = ?1", "stefp1") Assertions.assertEquals(1, updateByIndexParameter, "More than one Person updated") - updateByNamedParameter = personRepository.update("name = 'stefNEW' where name = :pName", - Parameters.with("pName", "stefp2")) + updateByNamedParameter = personRepository.update( + "name = 'stefNEW' where name = :pName", + Parameters.with("pName", "stefp2") + ) Assertions.assertEquals(1, updateByNamedParameter, "More than one Person updated") Assertions.assertEquals(2, personRepository.deleteAll()) @@ -359,8 +384,11 @@ class TestEndpoint { // Assertions.assertThrows(PanacheQueryException::class.java, { personDao.update(null) }, // "PanacheQueryException should have thrown") - Assertions.assertThrows(PanacheQueryException::class.java, { personRepository.update(" ") }, - "PanacheQueryException should have thrown") + Assertions.assertThrows( + PanacheQueryException::class.java, + { personRepository.update(" ") }, + "PanacheQueryException should have thrown" + ) } private fun testSorting() { @@ -410,7 +438,7 @@ class TestEndpoint { Assertions.assertEquals(order2, list) list = Person.stream("name = :name", sort2, Parameters.with("name", "stef").map()) - .collect(Collectors.toList()) + .collect(Collectors.toList()) Assertions.assertEquals(order2, list) list = Person.find("name = :name", sort2, Parameters.with("name", "stef")).list() @@ -477,7 +505,7 @@ class TestEndpoint { @Transactional fun testModelDao(): String { personRepository.flush() - Assertions.assertNotNull(personRepository.getEntityManager()); + Assertions.assertNotNull(personRepository.getEntityManager()) var persons = personRepository.findAll().list() Assertions.assertEquals(0, persons.size) @@ -625,7 +653,7 @@ class TestEndpoint { testUpdateDAO() - //flush + // flush val person1 = Person() person1.name = "testFlush1" person1.uniqueName = "unique" @@ -637,7 +665,7 @@ class TestEndpoint { personRepository.persistAndFlush(person2) Assertions.fail() } catch (pe: PersistenceException) { - //this is expected + // this is expected } return "OK" @@ -660,7 +688,7 @@ class TestEndpoint { personRepository.persist(person3) val sort1 = Sort.by("name", "status") - val order1: List = listOf(person3, person2, person1 ) + val order1: List = listOf(person3, person2, person1) var list = personRepository.findAll(sort1).list() Assertions.assertEquals(order1, list) @@ -906,7 +934,7 @@ class TestEndpoint { val person = Person.findAll().firstResult() Assertions.assertEquals("1", person?.name) - if(person != null) { + if (person != null) { person.name = "2" } return "OK" @@ -1022,7 +1050,6 @@ class TestEndpoint { Assertions.assertNotNull(f.getAnnotation(XmlTransient::class.java)) } - @GET @Path("9036") @Transactional @@ -1047,8 +1074,8 @@ class TestEndpoint { // should be filtered val query = Person.findAll(Sort.by("id")) - .filter("Person.isAlive") - .filter("Person.hasName", Parameters.with("name", "Stef")) + .filter("Person.isAlive") + .filter("Person.hasName", Parameters.with("name", "Stef")) Assertions.assertEquals(1, query.count()) Assertions.assertEquals(1, query.list().size) Assertions.assertEquals(livePerson, query.list()[0]) diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityInGraalITCase.kt b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityInGraalITCase.kt index 49a4e7de09ea3..03187e865cdd3 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityInGraalITCase.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityInGraalITCase.kt @@ -1,7 +1,6 @@ package io.quarkus.it.panache import io.quarkus.test.junit.QuarkusIntegrationTest -import org.junit.jupiter.api.Disabled /** * Test various Panache operations running in native mode diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityTest.kt b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityTest.kt index 6974610f1dd5c..0ae2f5b770f23 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityTest.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityTest.kt @@ -32,9 +32,12 @@ open class KotlinPanacheFunctionalityTest { @Test fun testPanacheSerialisation() { RestAssured.given().accept(ContentType.XML) - .`when`()["/test/ignored-properties"] - .then().body(Matchers.`is`( - "666Eddie1DECEASED")) + .`when`()["/test/ignored-properties"] + .then().body( + Matchers.`is`( + "666Eddie1DECEASED" + ) + ) } /** @@ -52,8 +55,9 @@ open class KotlinPanacheFunctionalityTest { // check // hence no 'persistence'-attribute Assertions.assertEquals( - "{\"id\":null,\"name\":\"max\",\"uniqueName\":null,\"address\":null,\"status\":null,\"dogs\":[],\"serialisationTrick\":1}", - personAsString) + "{\"id\":null,\"name\":\"max\",\"uniqueName\":null,\"address\":null,\"status\":null,\"dogs\":[],\"serialisationTrick\":1}", + personAsString + ) } @Test @@ -66,4 +70,4 @@ open class KotlinPanacheFunctionalityTest { fun entityManagerIsInjected() { assertNotNull(Dog.getEntityManager()) } -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityWithInjectTest.kt b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityWithInjectTest.kt index 5a2106082c23d..bc3585da41c43 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityWithInjectTest.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/KotlinPanacheFunctionalityWithInjectTest.kt @@ -22,4 +22,4 @@ open class KotlinPanacheFunctionalityWithInjectTest { Assertions.assertTrue(personDao.findAll().list().isEmpty()) Assertions.assertTrue(Person.findAll().list().isEmpty()) } -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/MockPersonRepository.kt b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/MockPersonRepository.kt index 58ad09a9dc8b7..8c5cdc87db08e 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/MockPersonRepository.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/MockPersonRepository.kt @@ -12,4 +12,4 @@ import javax.enterprise.inject.Alternative @Alternative @Priority(1) @ApplicationScoped -open class MockPersonRepository : PersonRepository() \ No newline at end of file +open class MockPersonRepository : PersonRepository() diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestEndpointRunner.kt b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestEndpointRunner.kt index 19548cf4d25e7..99268af2ed28b 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestEndpointRunner.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestEndpointRunner.kt @@ -81,4 +81,4 @@ class TestEndpointRunner { fail("This method should have been replaced", ignored) } } -} \ No newline at end of file +} diff --git a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestResources.kt b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestResources.kt index 3109f5a10bd40..6960cb481c6c7 100644 --- a/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestResources.kt +++ b/integration-tests/hibernate-orm-panache-kotlin/src/test/kotlin/io/quarkus/it/panache/TestResources.kt @@ -4,4 +4,4 @@ import io.quarkus.test.common.QuarkusTestResource import io.quarkus.test.h2.H2DatabaseTestResource @QuarkusTestResource(H2DatabaseTestResource::class) -class TestResources \ No newline at end of file +class TestResources diff --git a/integration-tests/kotlin-serialization/src/main/kotlin/io/quarkus/it/kotser/GreetingResource.kt b/integration-tests/kotlin-serialization/src/main/kotlin/io/quarkus/it/kotser/GreetingResource.kt index c3eddcab2088d..b1b6aa4a8b2f7 100644 --- a/integration-tests/kotlin-serialization/src/main/kotlin/io/quarkus/it/kotser/GreetingResource.kt +++ b/integration-tests/kotlin-serialization/src/main/kotlin/io/quarkus/it/kotser/GreetingResource.kt @@ -59,4 +59,3 @@ class GreetingResource { fun reflect() = "hello, world" } - diff --git a/integration-tests/kotlin-serialization/src/test/kotlin/io/quarkus/it/kotser/ResourceIT.kt b/integration-tests/kotlin-serialization/src/test/kotlin/io/quarkus/it/kotser/ResourceIT.kt index 5db6ab0d29922..b83b6e9a38893 100644 --- a/integration-tests/kotlin-serialization/src/test/kotlin/io/quarkus/it/kotser/ResourceIT.kt +++ b/integration-tests/kotlin-serialization/src/test/kotlin/io/quarkus/it/kotser/ResourceIT.kt @@ -3,5 +3,4 @@ package io.quarkus.it.kotser import io.quarkus.test.junit.QuarkusIntegrationTest @QuarkusIntegrationTest -class ResourceIT : ResourceTest() { -} +class ResourceIT : ResourceTest() diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/Book.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/Book.kt index a391c3627c777..515bf19d89eef 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/Book.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/Book.kt @@ -1,12 +1,12 @@ package io.quarkus.it.mongodb.panache.book +import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonFormat.Shape import io.quarkus.mongodb.panache.common.MongoEntity import org.bson.codecs.pojo.annotations.BsonIgnore import org.bson.codecs.pojo.annotations.BsonProperty import org.bson.types.ObjectId import java.time.LocalDate -import com.fasterxml.jackson.annotation.JsonFormat -import com.fasterxml.jackson.annotation.JsonFormat.Shape @MongoEntity(collection = "TheBook", clientName = "cl2") class Book { @@ -55,5 +55,4 @@ class Book { this.transientDescription = transientDescription return this } - -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookDetail.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookDetail.kt index 5b4d2e2a9a737..4effea5358497 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookDetail.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookDetail.kt @@ -15,4 +15,4 @@ class BookDetail { this.rating = rating return this } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntity.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntity.kt index 99a43e9b71155..2ea85aaf953ab 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntity.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntity.kt @@ -1,5 +1,7 @@ package io.quarkus.it.mongodb.panache.book +import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonFormat.Shape import io.quarkus.mongodb.panache.common.MongoEntity import io.quarkus.mongodb.panache.kotlin.PanacheMongoCompanion import io.quarkus.mongodb.panache.kotlin.PanacheMongoEntity @@ -8,8 +10,6 @@ import org.bson.codecs.pojo.annotations.BsonIgnore import org.bson.codecs.pojo.annotations.BsonProperty import org.bson.types.ObjectId import java.time.LocalDate -import com.fasterxml.jackson.annotation.JsonFormat -import com.fasterxml.jackson.annotation.JsonFormat.Shape @MongoEntity(collection = "TheBookEntity", clientName = "cl2") class BookEntity : PanacheMongoEntity() { @@ -57,5 +57,4 @@ class BookEntity : PanacheMongoEntity() { this.details = details return this } - -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntityResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntityResource.kt index a497760f76c97..38cd2da07f6e2 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntityResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntityResource.kt @@ -7,7 +7,6 @@ import org.jboss.logging.Logger import java.net.URI import java.time.LocalDate import javax.annotation.PostConstruct -import javax.ws.rs.Consumes import javax.ws.rs.DELETE import javax.ws.rs.GET import javax.ws.rs.NotFoundException @@ -16,9 +15,7 @@ import javax.ws.rs.POST import javax.ws.rs.PUT import javax.ws.rs.Path import javax.ws.rs.PathParam -import javax.ws.rs.Produces import javax.ws.rs.QueryParam -import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response @Path("/books/entity") @@ -73,29 +70,44 @@ class BookEntityResource { @GET @Path("/search/{author}") fun getBooksByAuthor(@PathParam("author") author: String): List = - BookEntity.find("author", author).project(BookShortView::class.java).list() + BookEntity.find("author", author).project(BookShortView::class.java).list() @GET @Path("/search") - fun search(@QueryParam("author") author: String?, @QueryParam("title") title: String?, - @QueryParam("dateFrom") dateFrom: String?, @QueryParam("dateTo") dateTo: String?): BookEntity? { + fun search( + @QueryParam("author") author: String?, + @QueryParam("title") title: String?, + @QueryParam("dateFrom") dateFrom: String?, + @QueryParam("dateTo") dateTo: String? + ): BookEntity? { return if (author != null) { BookEntity.find("{'author': ?1,'bookTitle': ?2}", author, title!!).firstResult() } else BookEntity - .find("{'creationDate': {\$gte: ?1}, 'creationDate': {\$lte: ?2}}", LocalDate.parse(dateFrom), - LocalDate.parse(dateTo)) - .firstResult() + .find( + "{'creationDate': {\$gte: ?1}, 'creationDate': {\$lte: ?2}}", + LocalDate.parse(dateFrom), + LocalDate.parse(dateTo) + ) + .firstResult() } @GET @Path("/search2") - fun search2(@QueryParam("author") author: String?, @QueryParam("title") title: String?, - @QueryParam("dateFrom") dateFrom: String?, @QueryParam("dateTo") dateTo: String?): BookEntity? { + fun search2( + @QueryParam("author") author: String?, + @QueryParam("title") title: String?, + @QueryParam("dateFrom") dateFrom: String?, + @QueryParam("dateTo") dateTo: String? + ): BookEntity? { return if (author != null) { - BookEntity.find("{'author': :author,'bookTitle': :title}", - Parameters.with("author", author).and("title", title)).firstResult() - } else BookEntity.find("{'creationDate': {\$gte: :dateFrom}, 'creationDate': {\$lte: :dateTo}}", - Parameters.with("dateFrom", LocalDate.parse(dateFrom)).and("dateTo", LocalDate.parse(dateTo))).firstResult() + BookEntity.find( + "{'author': :author,'bookTitle': :title}", + Parameters.with("author", author).and("title", title) + ).firstResult() + } else BookEntity.find( + "{'creationDate': {\$gte: :dateFrom}, 'creationDate': {\$lte: :dateTo}}", + Parameters.with("dateFrom", LocalDate.parse(dateFrom)).and("dateTo", LocalDate.parse(dateTo)) + ).firstResult() } @DELETE @@ -106,4 +118,4 @@ class BookEntityResource { companion object { private val LOGGER: Logger = Logger.getLogger(BookEntityResource::class.java) } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookRepositoryResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookRepositoryResource.kt index c2e21277abe52..50c5400eb5d2e 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookRepositoryResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookRepositoryResource.kt @@ -8,7 +8,6 @@ import java.net.URI import java.time.LocalDate import javax.annotation.PostConstruct import javax.inject.Inject -import javax.ws.rs.Consumes import javax.ws.rs.DELETE import javax.ws.rs.GET import javax.ws.rs.NotFoundException @@ -17,9 +16,7 @@ import javax.ws.rs.POST import javax.ws.rs.PUT import javax.ws.rs.Path import javax.ws.rs.PathParam -import javax.ws.rs.Produces import javax.ws.rs.QueryParam -import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response @Path("/books/repository") @@ -76,29 +73,44 @@ class BookRepositoryResource { @GET @Path("/search/{author}") fun getBooksByAuthor(@PathParam("author") author: String): List = - bookRepository.find("author", author).project(BookShortView::class.java).list() + bookRepository.find("author", author).project(BookShortView::class.java).list() @GET @Path("/search") - fun search(@QueryParam("author") author: String?, @QueryParam("title") title: String?, - @QueryParam("dateFrom") dateFrom: String?, @QueryParam("dateTo") dateTo: String?): Book? { + fun search( + @QueryParam("author") author: String?, + @QueryParam("title") title: String?, + @QueryParam("dateFrom") dateFrom: String?, + @QueryParam("dateTo") dateTo: String? + ): Book? { return if (author != null) { bookRepository.find("{'author': ?1,'bookTitle': ?2}", author, title!!).firstResult() } else bookRepository - .find("{'creationDate': {\$gte: ?1}, 'creationDate': {\$lte: ?2}}", LocalDate.parse(dateFrom), - LocalDate.parse(dateTo)) - .firstResult() ?: throw NotFoundException() + .find( + "{'creationDate': {\$gte: ?1}, 'creationDate': {\$lte: ?2}}", + LocalDate.parse(dateFrom), + LocalDate.parse(dateTo) + ) + .firstResult() ?: throw NotFoundException() } @GET @Path("/search2") - fun search2(@QueryParam("author") author: String?, @QueryParam("title") title: String?, - @QueryParam("dateFrom") dateFrom: String?, @QueryParam("dateTo") dateTo: String?): Book? { + fun search2( + @QueryParam("author") author: String?, + @QueryParam("title") title: String?, + @QueryParam("dateFrom") dateFrom: String?, + @QueryParam("dateTo") dateTo: String? + ): Book? { return if (author != null) { - bookRepository.find("{'author': :author,'bookTitle': :title}", - Parameters.with("author", author).and("title", title)).firstResult() - } else bookRepository.find("{'creationDate': {\$gte: :dateFrom}, 'creationDate': {\$lte: :dateTo}}", - Parameters.with("dateFrom", LocalDate.parse(dateFrom)).and("dateTo", LocalDate.parse(dateTo))).firstResult() + bookRepository.find( + "{'author': :author,'bookTitle': :title}", + Parameters.with("author", author).and("title", title) + ).firstResult() + } else bookRepository.find( + "{'creationDate': {\$gte: :dateFrom}, 'creationDate': {\$lte: :dateTo}}", + Parameters.with("dateFrom", LocalDate.parse(dateFrom)).and("dateTo", LocalDate.parse(dateTo)) + ).firstResult() } @DELETE @@ -109,4 +121,4 @@ class BookRepositoryResource { companion object { private val LOGGER: Logger = Logger.getLogger(BookRepositoryResource::class.java) } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookShortView.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookShortView.kt index 0c6d88fac5e4b..8e2054396c0e3 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookShortView.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookShortView.kt @@ -1,9 +1,9 @@ package io.quarkus.it.mongodb.panache.book -import io.quarkus.mongodb.panache.common.ProjectionFor -import java.time.LocalDate import com.fasterxml.jackson.annotation.JsonFormat import com.fasterxml.jackson.annotation.JsonFormat.Shape +import io.quarkus.mongodb.panache.common.ProjectionFor +import java.time.LocalDate @ProjectionFor(Book::class) class BookShortView { @@ -13,4 +13,4 @@ class BookShortView { @JsonFormat(shape = Shape.STRING, pattern = "yyyy-MM-dd") var creationDate: LocalDate? = null -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/DummyService.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/DummyService.kt index eed33d52a1ba8..7ce0f6fb34e81 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/DummyService.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/DummyService.kt @@ -4,5 +4,4 @@ import javax.enterprise.context.ApplicationScoped // used only to validate that we can inject CDI beans into Panache repositories written in Kotlin @ApplicationScoped -class DummyService { -} +class DummyService diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/AbstractRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/AbstractRepository.kt index aa5732ad6656d..f43e24b547a35 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/AbstractRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/AbstractRepository.kt @@ -2,4 +2,4 @@ package io.quarkus.it.mongodb.panache.bugs import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepositoryBase -abstract class AbstractRepository : PanacheMongoRepositoryBase \ No newline at end of file +abstract class AbstractRepository : PanacheMongoRepositoryBase diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5274EntityRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5274EntityRepository.kt index 7abdd45fa5479..7989d22d23cc7 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5274EntityRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5274EntityRepository.kt @@ -4,4 +4,4 @@ import io.quarkus.it.mongodb.panache.book.Book import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class Bug5274EntityRepository : AbstractRepository() \ No newline at end of file +class Bug5274EntityRepository : AbstractRepository() diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5885AbstractRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5885AbstractRepository.kt index ec8109aa86bb5..bccc14d59e289 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5885AbstractRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5885AbstractRepository.kt @@ -2,4 +2,4 @@ package io.quarkus.it.mongodb.panache.bugs import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepositoryBase -abstract class Bug5885AbstractRepository : PanacheMongoRepositoryBase \ No newline at end of file +abstract class Bug5885AbstractRepository : PanacheMongoRepositoryBase diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5885EntityRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5885EntityRepository.kt index fdd2538e763f2..ee3bcc51ef5d7 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5885EntityRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug5885EntityRepository.kt @@ -4,4 +4,4 @@ import io.quarkus.it.mongodb.panache.person.PersonEntity import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class Bug5885EntityRepository : Bug5885AbstractRepository() \ No newline at end of file +class Bug5885EntityRepository : Bug5885AbstractRepository() diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324AbstractRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324AbstractRepository.kt index 0ad66742a6eee..ce1dde053bb29 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324AbstractRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324AbstractRepository.kt @@ -2,4 +2,4 @@ package io.quarkus.it.mongodb.panache.bugs import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepository -abstract class Bug6324AbstractRepository : PanacheMongoRepository \ No newline at end of file +abstract class Bug6324AbstractRepository : PanacheMongoRepository diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324ConcreteRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324ConcreteRepository.kt index 4b98163786cb5..b0c83f159006d 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324ConcreteRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324ConcreteRepository.kt @@ -3,4 +3,4 @@ package io.quarkus.it.mongodb.panache.bugs import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class Bug6324ConcreteRepository : Bug6324AbstractRepository() \ No newline at end of file +class Bug6324ConcreteRepository : Bug6324AbstractRepository() diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324Repository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324Repository.kt index 78ed184bd4736..db4075f439a59 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324Repository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/Bug6324Repository.kt @@ -4,4 +4,4 @@ import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepository import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class Bug6324Repository : PanacheMongoRepository \ No newline at end of file +class Bug6324Repository : PanacheMongoRepository diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/BugResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/BugResource.kt index 06b7af4bb4463..47b85117dfc03 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/BugResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/BugResource.kt @@ -69,10 +69,15 @@ class BugResource { val localDateTimeTomorrow: LocalDateTime = LocalDateTime.now().plus(1, ChronoUnit.DAYS) val instantTomorrow: Instant = Instant.now().plus(1, ChronoUnit.DAYS) val result: DateEntity = DateEntity - .find("dateDate < ?1 and localDate < ?2 and localDateTime < ?3 and instant < ?4", - dateTomorrow, localDateTomorrow, localDateTimeTomorrow, instantTomorrow) - .firstResult() - ?: return Response.status(404).build() + .find( + "dateDate < ?1 and localDate < ?2 and localDateTime < ?3 and instant < ?4", + dateTomorrow, + localDateTomorrow, + localDateTimeTomorrow, + instantTomorrow + ) + .firstResult() + ?: return Response.status(404).build() return Response.ok().build() } @@ -91,4 +96,4 @@ class BugResource { LinkedEntity.find("myForeignId", link.id!!).firstResult() ?: throw NotFoundException() return Response.ok().build() } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/DateEntity.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/DateEntity.kt index b9390d4ab5f6d..1649709bf9ded 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/DateEntity.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/DateEntity.kt @@ -11,9 +11,11 @@ import java.util.Date * An entity that have all the supported date format. * Asserting #6566 and possibility other date issues. */ -class DateEntity(var dateDate: Date = Date(), var localDate: LocalDate = LocalDate.now(), - var localDateTime: LocalDateTime = LocalDateTime.now(), - var instant: Instant = Instant.now()) : PanacheMongoEntity() { - companion object: PanacheMongoCompanion - -} \ No newline at end of file +class DateEntity( + var dateDate: Date = Date(), + var localDate: LocalDate = LocalDate.now(), + var localDateTime: LocalDateTime = LocalDateTime.now(), + var instant: Instant = Instant.now() +) : PanacheMongoEntity() { + companion object : PanacheMongoCompanion +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/LinkedEntity.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/LinkedEntity.kt index 72fecd3e9a8d4..20abe2b556423 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/LinkedEntity.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/LinkedEntity.kt @@ -5,8 +5,8 @@ import io.quarkus.mongodb.panache.kotlin.PanacheMongoEntity import org.bson.types.ObjectId class LinkedEntity : PanacheMongoEntity() { - companion object: PanacheMongoCompanion + companion object : PanacheMongoCompanion var name: String? = null var myForeignId: ObjectId? = null -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/NeedReflection.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/NeedReflection.kt index 5af253182e2c2..e58252d9fb646 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/NeedReflection.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/bugs/NeedReflection.kt @@ -2,4 +2,4 @@ package io.quarkus.it.mongodb.panache.bugs class NeedReflection { var comment: String? = null -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/MockablePersonRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/MockablePersonRepository.kt index 25debd8c5a899..fdcd85abd841e 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/MockablePersonRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/MockablePersonRepository.kt @@ -11,4 +11,4 @@ open class MockablePersonRepository : PanacheMongoRepositoryBase { return findAll(Sort.by("lastname", "firstname")).list() } - } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/PersonName.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/PersonName.kt index 5808cd7e3df1b..c1a553b7de691 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/PersonName.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/PersonName.kt @@ -14,5 +14,4 @@ class PersonName { override fun hashCode(): Int { return lastname?.hashCode() ?: 0 } - } diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/PersonRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/PersonRepository.kt index d38f6b57708ab..49d4c0ed6d3a9 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/PersonRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/PersonRepository.kt @@ -4,5 +4,4 @@ import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepositoryBase import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class PersonRepository : PanacheMongoRepositoryBase { -} \ No newline at end of file +class PersonRepository : PanacheMongoRepositoryBase diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/Status.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/Status.kt index c23cf9418ee47..b68ff5d6c79c4 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/Status.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/Status.kt @@ -6,5 +6,4 @@ enum class Status(val value: String) { override fun toString(): String { return value } - -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/resources/PersonEntityResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/resources/PersonEntityResource.kt index a228c866131c3..4e46fba760b13 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/resources/PersonEntityResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/resources/PersonEntityResource.kt @@ -20,17 +20,17 @@ import javax.ws.rs.core.Response class PersonEntityResource { @GET fun getPersons(@QueryParam("sort") sort: String?): List = - sort?.let { PersonEntity.listAll(Sort.ascending(sort)) } - ?: PersonEntity.listAll() + sort?.let { PersonEntity.listAll(Sort.ascending(sort)) } + ?: PersonEntity.listAll() @GET @Path("/search/{name}") fun searchPersons(@PathParam("name") name: String): Set { return PersonEntity.find("lastname = ?1 and status = ?2", name, Status.ALIVE) - .project(PersonName::class.java) - .withReadPreference(ReadPreference.primaryPreferred()) - .list() - .toSet() + .project(PersonName::class.java) + .withReadPreference(ReadPreference.primaryPreferred()) + .list() + .toSet() } @POST @@ -81,7 +81,7 @@ class PersonEntityResource { @Path("/rename") fun rename(@QueryParam("previousName") previousName: String, @QueryParam("newName") newName: String): Response { PersonEntity.update("lastname", newName) - .where("lastname", previousName) + .where("lastname", previousName) return Response.ok().build() } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/resources/PersonRepositoryResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/resources/PersonRepositoryResource.kt index 78909274bbdcc..8349cb4df6ca7 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/resources/PersonRepositoryResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/person/resources/PersonRepositoryResource.kt @@ -39,10 +39,10 @@ class PersonRepositoryResource { @Path("/search/{name}") fun searchPersons(@PathParam("name") name: String): Set { return personRepository.find("lastname = ?1 and status = ?2", name, Status.ALIVE) - .project(PersonName::class.java) - .withReadPreference(ReadPreference.primaryPreferred()) - .list() - .toSet() + .project(PersonName::class.java) + .withReadPreference(ReadPreference.primaryPreferred()) + .list() + .toSet() } @POST @@ -77,7 +77,6 @@ class PersonRepositoryResource { personRepository.delete(person!!) } - @GET @Path("/{id}") fun getPerson(@PathParam("id") id: String) = personRepository.findById(id.toLong()) @@ -97,4 +96,4 @@ class PersonRepositoryResource { personRepository.update("lastname", newName).where("lastname", previousName) return Response.ok().build() } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.kt index 742fa04204ea7..7ed1c17287348 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.kt @@ -1,5 +1,7 @@ package io.quarkus.it.mongodb.panache.reactive.book +import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonFormat.Shape import io.quarkus.it.mongodb.panache.book.BookDetail import io.quarkus.mongodb.panache.common.MongoEntity import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoCompanion @@ -8,12 +10,10 @@ import org.bson.codecs.pojo.annotations.BsonIgnore import org.bson.codecs.pojo.annotations.BsonProperty import java.time.LocalDate import java.util.ArrayList -import com.fasterxml.jackson.annotation.JsonFormat -import com.fasterxml.jackson.annotation.JsonFormat.Shape @MongoEntity(collection = "TheBookEntity", clientName = "cl2") class ReactiveBookEntity : ReactivePanacheMongoEntity() { - companion object: ReactivePanacheMongoCompanion + companion object : ReactivePanacheMongoCompanion @BsonProperty("bookTitle") var title: String? = null @@ -50,5 +50,4 @@ class ReactiveBookEntity : ReactivePanacheMongoEntity() { this.details = details return this } - -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.kt index afd0da69e52f2..751fd16f33766 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntityResource.kt @@ -52,7 +52,7 @@ class ReactiveBookEntityResource { @POST fun addBook(book: ReactiveBookEntity): Uni { return book.persist().map { - //the ID is populated before sending it to the database + // the ID is populated before sending it to the database Response.created(URI.create("/books/entity${book.id}")).build() } } @@ -63,18 +63,18 @@ class ReactiveBookEntityResource { // PATCH is not correct here but it allows to test persistOrUpdate without a specific subpath @PATCH fun upsertBook(book: ReactiveBookEntity): Uni = - book.persistOrUpdate().map { Response.accepted().build() } + book.persistOrUpdate().map { Response.accepted().build() } @DELETE @Path("/{id}") fun deleteBook(@PathParam("id") id: String?): Uni { return ReactiveBookEntity.deleteById(ObjectId(id)) - .map { d -> - if (d) { - return@map null - } - throw NotFoundException() + .map { d -> + if (d) { + return@map null } + throw NotFoundException() + } } @GET @@ -84,34 +84,47 @@ class ReactiveBookEntityResource { @GET @Path("/search/{author}") fun getBooksByAuthor(@PathParam("author") author: String): Uni> = - ReactiveBookEntity.list("author", author) + ReactiveBookEntity.list("author", author) @GET @Path("/search") - fun search(@QueryParam("author") author: String?, @QueryParam("title") title: String?, - @QueryParam("dateFrom") dateFrom: String?, @QueryParam("dateTo") dateTo: String?): Uni { + fun search( + @QueryParam("author") author: String?, + @QueryParam("title") title: String?, + @QueryParam("dateFrom") dateFrom: String?, + @QueryParam("dateTo") dateTo: String? + ): Uni { return if (author != null) { ReactiveBookEntity.find("{'author': ?1,'bookTitle': ?2}", author, title!!).firstResult() } else ReactiveBookEntity - .find("{'creationDate': {\$gte: ?1}, 'creationDate': {\$lte: ?2}}", parse(dateFrom), - parse(dateTo)) - .firstResult() + .find( + "{'creationDate': {\$gte: ?1}, 'creationDate': {\$lte: ?2}}", + parse(dateFrom), + parse(dateTo) + ) + .firstResult() } @GET @Path("/search2") - fun search2(@QueryParam("author") author: String?, @QueryParam("title") title: String?, - @QueryParam("dateFrom") dateFrom: String?, @QueryParam("dateTo") dateTo: String?) - : Uni = - - if (author != null) { - ReactiveBookEntity.find("{'author': :author,'bookTitle': :title}", - with("author", author).and("title", title)).firstResult() - } else { - ReactiveBookEntity.find("{'creationDate': {\$gte: :dateFrom}, 'creationDate': {\$lte: :dateTo}}", - with("dateFrom", parse(dateFrom)).and("dateTo", parse(dateTo))) - .firstResult() - } + fun search2( + @QueryParam("author") author: String?, + @QueryParam("title") title: String?, + @QueryParam("dateFrom") dateFrom: String?, + @QueryParam("dateTo") dateTo: String? + ): Uni = + if (author != null) { + ReactiveBookEntity.find( + "{'author': :author,'bookTitle': :title}", + with("author", author).and("title", title) + ).firstResult() + } else { + ReactiveBookEntity.find( + "{'creationDate': {\$gte: :dateFrom}, 'creationDate': {\$lte: :dateTo}}", + with("dateFrom", parse(dateFrom)).and("dateTo", parse(dateTo)) + ) + .firstResult() + } @DELETE fun deleteAll(): Uni = ReactiveBookEntity.deleteAll().map { l -> null } @@ -119,4 +132,4 @@ class ReactiveBookEntityResource { companion object { private val LOGGER: Logger = Logger.getLogger(ReactiveBookEntityResource::class.java) } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepository.kt index cae81fd8d66ce..59f62d1f04888 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepository.kt @@ -5,4 +5,4 @@ import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoRepository import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class ReactiveBookRepository : ReactivePanacheMongoRepository \ No newline at end of file +class ReactiveBookRepository : ReactivePanacheMongoRepository diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.kt index 7bcc43e3a141f..6d7f95cf43df6 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookRepositoryResource.kt @@ -57,7 +57,7 @@ class ReactiveBookRepositoryResource { @POST fun addBook(book: Book): Uni { return reactiveBookRepository.persist(book).map { - //the ID is populated before sending it to the database + // the ID is populated before sending it to the database Response.created(URI.create("/books/entity${book.id}")).build() } } @@ -68,18 +68,18 @@ class ReactiveBookRepositoryResource { // PATCH is not correct here but it allows to test persistOrUpdate without a specific subpath @PATCH fun upsertBook(book: Book): Uni = - reactiveBookRepository.persistOrUpdate(book).map { Response.accepted().build() } + reactiveBookRepository.persistOrUpdate(book).map { Response.accepted().build() } @DELETE @Path("/{id}") fun deleteBook(@PathParam("id") id: String?): Uni { return reactiveBookRepository.deleteById(ObjectId(id)) - .map { d -> - if (d) { - return@map null - } - throw NotFoundException() + .map { d -> + if (d) { + return@map null } + throw NotFoundException() + } } @GET @@ -89,31 +89,46 @@ class ReactiveBookRepositoryResource { @GET @Path("/search/{author}") fun getBooksByAuthor(@PathParam("author") author: String): Uni> = - reactiveBookRepository.list("author", author) + reactiveBookRepository.list("author", author) @GET @Path("/search") - fun search(@QueryParam("author") author: String?, @QueryParam("title") title: String?, - @QueryParam("dateFrom") dateFrom: String?, @QueryParam("dateTo") dateTo: String?): Uni { + fun search( + @QueryParam("author") author: String?, + @QueryParam("title") title: String?, + @QueryParam("dateFrom") dateFrom: String?, + @QueryParam("dateTo") dateTo: String? + ): Uni { return if (author != null) { reactiveBookRepository.find("{'author': ?1,'bookTitle': ?2}", author, title!!).firstResult() } else { reactiveBookRepository - .find("{'creationDate': {\$gte: ?1}, 'creationDate': {\$lte: ?2}}", LocalDate.parse(dateFrom), - LocalDate.parse(dateTo)) - .firstResult() + .find( + "{'creationDate': {\$gte: ?1}, 'creationDate': {\$lte: ?2}}", + LocalDate.parse(dateFrom), + LocalDate.parse(dateTo) + ) + .firstResult() } } @GET @Path("/search2") - fun search2(@QueryParam("author") author: String?, @QueryParam("title") title: String?, - @QueryParam("dateFrom") dateFrom: String?, @QueryParam("dateTo") dateTo: String?): Uni { + fun search2( + @QueryParam("author") author: String?, + @QueryParam("title") title: String?, + @QueryParam("dateFrom") dateFrom: String?, + @QueryParam("dateTo") dateTo: String? + ): Uni { return if (author != null) { - reactiveBookRepository.find("{'author': :author,'bookTitle': :title}", - Parameters.with("author", author).and("title", title)).firstResult() - } else reactiveBookRepository.find("{'creationDate': {\$gte: :dateFrom}, 'creationDate': {\$lte: :dateTo}}", - Parameters.with("dateFrom", LocalDate.parse(dateFrom)).and("dateTo", LocalDate.parse(dateTo))).firstResult() + reactiveBookRepository.find( + "{'author': :author,'bookTitle': :title}", + Parameters.with("author", author).and("title", title) + ).firstResult() + } else reactiveBookRepository.find( + "{'creationDate': {\$gte: :dateFrom}, 'creationDate': {\$lte: :dateTo}}", + Parameters.with("dateFrom", LocalDate.parse(dateFrom)).and("dateTo", LocalDate.parse(dateTo)) + ).firstResult() } @DELETE @@ -122,4 +137,4 @@ class ReactiveBookRepositoryResource { companion object { private val LOGGER: Logger = Logger.getLogger(ReactiveBookRepositoryResource::class.java) } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/ReactivePersonEntity.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/ReactivePersonEntity.kt index 2e7e76a27d276..4c8ac380dc811 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/ReactivePersonEntity.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/ReactivePersonEntity.kt @@ -5,10 +5,10 @@ import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoEntityBase import org.bson.codecs.pojo.annotations.BsonId class ReactivePersonEntity : ReactivePanacheMongoEntityBase() { - companion object: ReactivePanacheMongoCompanionBase + companion object : ReactivePanacheMongoCompanionBase @BsonId var id: Long? = null var firstname: String? = null var lastname: String? = null -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/ReactivePersonRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/ReactivePersonRepository.kt index e14dd7e9e5379..8817a989b43fb 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/ReactivePersonRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/ReactivePersonRepository.kt @@ -5,4 +5,4 @@ import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoRepository import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class ReactivePersonRepository : ReactivePanacheMongoRepositoryBase \ No newline at end of file +class ReactivePersonRepository : ReactivePanacheMongoRepositoryBase diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/resources/ReactivePersonEntityResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/resources/ReactivePersonEntityResource.kt index 41d8ec324ca85..855f471d40711 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/resources/ReactivePersonEntityResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/resources/ReactivePersonEntityResource.kt @@ -1,6 +1,5 @@ package io.quarkus.it.mongodb.panache.reactive.person.resources - import com.mongodb.ReadPreference import io.quarkus.it.mongodb.panache.person.PersonName import io.quarkus.it.mongodb.panache.reactive.person.ReactivePersonEntity @@ -31,11 +30,11 @@ class ReactivePersonEntityResource { fun searchPersons(@PathParam("name") name: String): Set { val uniqueNames = mutableSetOf() val lastnames: List = ReactivePersonEntity.find("lastname", name) - .project(PersonName::class.java) - .withReadPreference(ReadPreference.primaryPreferred()) - .list() - .await() - .indefinitely() + .project(PersonName::class.java) + .withReadPreference(ReadPreference.primaryPreferred()) + .list() + .await() + .indefinitely() lastnames.forEach { p -> uniqueNames.add(p) } return uniqueNames } @@ -43,7 +42,7 @@ class ReactivePersonEntityResource { @POST fun addPerson(person: ReactivePersonEntity): Uni { return person.persist() - .map { Response.created(URI.create("/persons/entity${person.id}")).build() } + .map { Response.created(URI.create("/persons/entity${person.id}")).build() } } @POST @@ -52,22 +51,22 @@ class ReactivePersonEntityResource { @PUT fun updatePerson(person: ReactivePersonEntity): Uni = - person.update().map { Response.accepted().build() } + person.update().map { Response.accepted().build() } // PATCH is not correct here but it allows to test persistOrUpdate without a specific subpath @PATCH fun upsertPerson(person: ReactivePersonEntity): Uni = - person.persistOrUpdate().map { Response.accepted().build() } + person.persistOrUpdate().map { Response.accepted().build() } @DELETE @Path("/{id}") fun deletePerson(@PathParam("id") id: String): Uni = - ReactivePersonEntity.findById(id.toLong()).flatMap { person -> person?.delete() } + ReactivePersonEntity.findById(id.toLong()).flatMap { person -> person?.delete() } @GET @Path("/{id}") fun getPerson(@PathParam("id") id: String): Uni = - ReactivePersonEntity.findById(id.toLong()) + ReactivePersonEntity.findById(id.toLong()) @GET @Path("/count") @@ -80,7 +79,7 @@ class ReactivePersonEntityResource { @Path("/rename") fun rename(@QueryParam("previousName") previousName: String, @QueryParam("newName") newName: String): Uni { return ReactivePersonEntity.update("lastname", newName) - .where("lastname", previousName) - .map { count -> Response.ok().build() } + .where("lastname", previousName) + .map { count -> Response.ok().build() } } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/resources/ReactivePersonRepositoryResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/resources/ReactivePersonRepositoryResource.kt index 20efbc0273b9c..f1dc2af5d9209 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/resources/ReactivePersonRepositoryResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/person/resources/ReactivePersonRepositoryResource.kt @@ -1,6 +1,5 @@ package io.quarkus.it.mongodb.panache.reactive.person.resources - import com.mongodb.ReadPreference import io.quarkus.it.mongodb.panache.person.Person import io.quarkus.it.mongodb.panache.person.PersonName @@ -36,11 +35,11 @@ class ReactivePersonRepositoryResource { fun searchPersons(@PathParam("name") name: String): Set { val uniqueNames = mutableSetOf() val lastnames: List = reactivePersonRepository.find("lastname", name) - .project(PersonName::class.java) - .withReadPreference(ReadPreference.primaryPreferred()) - .list() - .await() - .indefinitely() + .project(PersonName::class.java) + .withReadPreference(ReadPreference.primaryPreferred()) + .list() + .await() + .indefinitely() lastnames.forEach { p -> uniqueNames.add(p) } // this will throw if it's not the right type return uniqueNames } @@ -48,7 +47,7 @@ class ReactivePersonRepositoryResource { @POST fun addPerson(person: Person): Uni { return reactivePersonRepository.persist(person).map { - //the ID is populated before sending it to the database + // the ID is populated before sending it to the database Response.created(URI.create("/persons/entity${person.id}")).build() } } @@ -59,18 +58,18 @@ class ReactivePersonRepositoryResource { @PUT fun updatePerson(person: Person): Uni = - reactivePersonRepository.update(person).map { Response.accepted().build() } + reactivePersonRepository.update(person).map { Response.accepted().build() } // PATCH is not correct here but it allows to test persistOrUpdate without a specific subpath @PATCH fun upsertPerson(person: Person): Uni = - reactivePersonRepository.persistOrUpdate(person).map { v -> Response.accepted().build() } + reactivePersonRepository.persistOrUpdate(person).map { v -> Response.accepted().build() } @DELETE @Path("/{id}") fun deletePerson(@PathParam("id") id: String): Uni { return reactivePersonRepository.findById(id.toLong()) - .flatMap { person -> person?.let { reactivePersonRepository.delete(it) } } + .flatMap { person -> person?.let { reactivePersonRepository.delete(it) } } } @GET @@ -88,6 +87,6 @@ class ReactivePersonRepositoryResource { @Path("/rename") fun rename(@QueryParam("previousName") previousName: String, @QueryParam("newName") newName: String): Uni { return reactivePersonRepository.update("lastname", newName).where("lastname", previousName) - .map { count -> Response.ok().build() } + .map { count -> Response.ok().build() } } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestImperativeEntity.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestImperativeEntity.kt index f300844daa8f3..46270a22364d1 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestImperativeEntity.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestImperativeEntity.kt @@ -17,4 +17,4 @@ class TestImperativeEntity : PanacheMongoEntity { this.category = category this.description = description } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestImperativeRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestImperativeRepository.kt index 19fb094764583..bb898e05c052f 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestImperativeRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestImperativeRepository.kt @@ -4,4 +4,4 @@ import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepository import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class TestImperativeRepository : PanacheMongoRepository \ No newline at end of file +class TestImperativeRepository : PanacheMongoRepository diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestReactiveEntity.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestReactiveEntity.kt index ee6ddb3a0d352..e7cbaf40c4405 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestReactiveEntity.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestReactiveEntity.kt @@ -16,4 +16,4 @@ class TestReactiveEntity : ReactivePanacheMongoEntity { this.category = category this.description = description } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestReactiveRepository.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestReactiveRepository.kt index 383a4855c3420..0ee3d496bf402 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestReactiveRepository.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestReactiveRepository.kt @@ -4,4 +4,4 @@ import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoRepository import javax.enterprise.context.ApplicationScoped @ApplicationScoped -class TestReactiveRepository : ReactivePanacheMongoRepository \ No newline at end of file +class TestReactiveRepository : ReactivePanacheMongoRepository diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestResource.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestResource.kt index 36c7391e4faac..7e751030fdf9a 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestResource.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/test/TestResource.kt @@ -64,16 +64,31 @@ class TestResource { // query Assertions.assertEquals(5, TestImperativeEntity.list("category", "category0").size) Assertions.assertEquals(5, TestImperativeEntity.list("category = ?1", "category0").size) - Assertions.assertEquals(5, TestImperativeEntity.list("category = :category", - Parameters.with("category", "category1")).size) + Assertions.assertEquals( + 5, + TestImperativeEntity.list( + "category = :category", + Parameters.with("category", "category1") + ).size + ) Assertions.assertEquals(5, TestImperativeEntity.list("{'category' : ?1}", "category0").size) - Assertions.assertEquals(5, TestImperativeEntity.list("{'category' : :category}", - Parameters.with("category", "category1")).size) + Assertions.assertEquals( + 5, + TestImperativeEntity.list( + "{'category' : :category}", + Parameters.with("category", "category1") + ).size + ) val listQuery: Document = Document().append("category", "category1") Assertions.assertEquals(5, TestImperativeEntity.list(listQuery).size) Assertions.assertEquals(0, TestImperativeEntity.list("category", null).size) - Assertions.assertEquals(0, TestImperativeEntity.list("category = :category", - Parameters.with("category", null)).size) + Assertions.assertEquals( + 0, + TestImperativeEntity.list( + "category = :category", + Parameters.with("category", null) + ).size + ) // regex val entityWithUpperCase = TestImperativeEntity("title11", "upperCaseCategory", "desc") @@ -106,7 +121,7 @@ class TestResource { Assertions.assertEquals("BBB", results[1].title) Assertions.assertEquals("aaa", results[2].title) val collation: Collation = Collation.builder().caseLevel(true).collationStrength(CollationStrength.PRIMARY).locale("fr") - .build() + .build() results = TestImperativeEntity.findAll(Sort.ascending("title")).withCollation(collation).list() Assertions.assertEquals("aaa", results[0].title) Assertions.assertEquals("AAA", results[1].title) @@ -118,11 +133,21 @@ class TestResource { // count Assertions.assertEquals(5, TestImperativeEntity.count("category", "category0")) Assertions.assertEquals(5, TestImperativeEntity.count("category = ?1", "category0")) - Assertions.assertEquals(5, TestImperativeEntity.count("category = :category", - Parameters.with("category", "category1"))) + Assertions.assertEquals( + 5, + TestImperativeEntity.count( + "category = :category", + Parameters.with("category", "category1") + ) + ) Assertions.assertEquals(5, TestImperativeEntity.count("{'category' : ?1}", "category0")) - Assertions.assertEquals(5, TestImperativeEntity.count("{'category' : :category}", - Parameters.with("category", "category1"))) + Assertions.assertEquals( + 5, + TestImperativeEntity.count( + "{'category' : :category}", + Parameters.with("category", "category1") + ) + ) val countQuery: Document = Document().append("category", "category1") Assertions.assertEquals(5, TestImperativeEntity.count(countQuery)) @@ -142,10 +167,10 @@ class TestResource { updated = TestImperativeEntity.update("{'category' : ?1}", "newCategory2").where("{'category' : ?1}", "newCategory") Assertions.assertEquals(5, updated) updated = TestImperativeEntity.update("category = :category", Parameters.with("category", "newCategory")) - .where("category = :category", Parameters.with("category", "newCategory2")) + .where("category = :category", Parameters.with("category", "newCategory2")) Assertions.assertEquals(5, updated) updated = TestImperativeEntity.update("{'category' : :category}", Parameters.with("category", "newCategory2")) - .where("{'category' : :category}", Parameters.with("category", "newCategory")) + .where("{'category' : :category}", Parameters.with("category", "newCategory")) Assertions.assertEquals(5, updated) Assertions.assertEquals(5, TestImperativeEntity.count("category = ?1", "newCategory2")) updated = TestImperativeEntity.update("newField", "newValue").all() @@ -209,16 +234,31 @@ class TestResource { // query Assertions.assertEquals(5, testImperativeRepository.list("category", "category0").size) Assertions.assertEquals(5, testImperativeRepository.list("category = ?1", "category0").size) - Assertions.assertEquals(5, testImperativeRepository.list("category = :category", - Parameters.with("category", "category1")).size) + Assertions.assertEquals( + 5, + testImperativeRepository.list( + "category = :category", + Parameters.with("category", "category1") + ).size + ) Assertions.assertEquals(5, testImperativeRepository.list("{'category' : ?1}", "category0").size) - Assertions.assertEquals(5, testImperativeRepository.list("{'category' : :category}", - Parameters.with("category", "category1")).size) + Assertions.assertEquals( + 5, + testImperativeRepository.list( + "{'category' : :category}", + Parameters.with("category", "category1") + ).size + ) val listQuery: Document = Document().append("category", "category1") Assertions.assertEquals(5, testImperativeRepository.list(listQuery).size) Assertions.assertEquals(0, testImperativeRepository.list("category", null).size) - Assertions.assertEquals(0, testImperativeRepository.list("category = :category", - Parameters.with("category", null)).size) + Assertions.assertEquals( + 0, + testImperativeRepository.list( + "category = :category", + Parameters.with("category", null) + ).size + ) // regex val entityWithUpperCase = TestImperativeEntity("title11", "upperCaseCate)gory", "desc") @@ -251,10 +291,10 @@ class TestResource { Assertions.assertEquals("BBB", results[1].title) Assertions.assertEquals("aaa", results[2].title) val collation: Collation = Collation.builder().caseLevel(true).collationStrength(CollationStrength.PRIMARY).locale("fr") - .build() + .build() results = testImperativeRepository.findAll(Sort.ascending("title")) - .withCollation(collation) - .list() + .withCollation(collation) + .list() Assertions.assertEquals("aaa", results[0].title) Assertions.assertEquals("AAA", results[1].title) Assertions.assertEquals("BBB", results[2].title) @@ -265,11 +305,21 @@ class TestResource { // count Assertions.assertEquals(5, testImperativeRepository.count("category", "category0")) Assertions.assertEquals(5, testImperativeRepository.count("category = ?1", "category0")) - Assertions.assertEquals(5, testImperativeRepository.count("category = :category", - Parameters.with("category", "category1"))) + Assertions.assertEquals( + 5, + testImperativeRepository.count( + "category = :category", + Parameters.with("category", "category1") + ) + ) Assertions.assertEquals(5, testImperativeRepository.count("{'category' : ?1}", "category0")) - Assertions.assertEquals(5, testImperativeRepository.count("{'category' : :category}", - Parameters.with("category", "category1"))) + Assertions.assertEquals( + 5, + testImperativeRepository.count( + "{'category' : :category}", + Parameters.with("category", "category1") + ) + ) val countQuery: Document = Document().append("category", "category1") Assertions.assertEquals(5, testImperativeRepository.count(countQuery)) @@ -286,14 +336,16 @@ class TestResource { Assertions.assertEquals(5, updated) updated = testImperativeRepository.update("category = ?1", "newCategory").where("category = ?1", "newCategory2") Assertions.assertEquals(5, updated) - updated = testImperativeRepository.update("{'category' : ?1}", "newCategory2").where("{'category' : ?1}", - "newCategory") + updated = testImperativeRepository.update("{'category' : ?1}", "newCategory2").where( + "{'category' : ?1}", + "newCategory" + ) Assertions.assertEquals(5, updated) updated = testImperativeRepository.update("category = :category", Parameters.with("category", "newCategory")) - .where("category = :category", Parameters.with("category", "newCategory2")) + .where("category = :category", Parameters.with("category", "newCategory2")) Assertions.assertEquals(5, updated) updated = testImperativeRepository.update("{'category' : :category}", Parameters.with("category", "newCategory2")) - .where("{'category' : :category}", Parameters.with("category", "newCategory")) + .where("{'category' : :category}", Parameters.with("category", "newCategory")) Assertions.assertEquals(5, updated) Assertions.assertEquals(5, testImperativeRepository.count("category = ?1", "newCategory2")) updated = testImperativeRepository.update("newField", "newValue").all() @@ -415,29 +467,56 @@ class TestResource { testReactiveRange(TestReactiveEntity.findAll()) // query - Assertions.assertEquals(5, - TestReactiveEntity.list("category", "category0").await().indefinitely().size) - Assertions.assertEquals(5, - TestReactiveEntity.list("category = ?1", "category0").await().indefinitely().size) - Assertions.assertEquals(5, TestReactiveEntity.list("category = :category", - Parameters.with("category", "category1")).await().indefinitely().size) - Assertions.assertEquals(5, - TestReactiveEntity.list("{'category' : ?1}", "category0").await().indefinitely().size) - Assertions.assertEquals(5, TestReactiveEntity.list("{'category' : :category}", - Parameters.with("category", "category1")).await().indefinitely().size) + Assertions.assertEquals( + 5, + TestReactiveEntity.list("category", "category0").await().indefinitely().size + ) + Assertions.assertEquals( + 5, + TestReactiveEntity.list("category = ?1", "category0").await().indefinitely().size + ) + Assertions.assertEquals( + 5, + TestReactiveEntity.list( + "category = :category", + Parameters.with("category", "category1") + ).await().indefinitely().size + ) + Assertions.assertEquals( + 5, + TestReactiveEntity.list("{'category' : ?1}", "category0").await().indefinitely().size + ) + Assertions.assertEquals( + 5, + TestReactiveEntity.list( + "{'category' : :category}", + Parameters.with("category", "category1") + ).await().indefinitely().size + ) val listQuery: Document = Document().append("category", "category1") Assertions.assertEquals(5, TestReactiveEntity.list(listQuery).await().indefinitely().size) Assertions.assertEquals(0, TestReactiveEntity.list("category", null).await().indefinitely().size) - Assertions.assertEquals(0, TestReactiveEntity.list("category = :category", - Parameters.with("category", null)).await().indefinitely().size) + Assertions.assertEquals( + 0, + TestReactiveEntity.list( + "category = :category", + Parameters.with("category", null) + ).await().indefinitely().size + ) // regex val entityWithUpperCase = TestReactiveEntity("title11", "upperCaseCategory", "desc") entityWithUpperCase.persist().await().indefinitely() - Assertions.assertEquals(1, TestReactiveEntity.list("category like ?1", "upperCase.*") - .await().indefinitely().size) - Assertions.assertEquals(1, TestReactiveEntity.list("category like ?1", "/uppercase.*/i") - .await().indefinitely().size) + Assertions.assertEquals( + 1, + TestReactiveEntity.list("category like ?1", "upperCase.*") + .await().indefinitely().size + ) + Assertions.assertEquals( + 1, + TestReactiveEntity.list("category like ?1", "/uppercase.*/i") + .await().indefinitely().size + ) entityWithUpperCase.delete().await().indefinitely() // sort @@ -446,7 +525,7 @@ class TestResource { val entityZ = TestReactiveEntity("zzz", "zzz", "zzz") entityZ.persistOrUpdate().await().indefinitely() var result: TestReactiveEntity = TestReactiveEntity.listAll(Sort.ascending("title")).await() - .indefinitely()[0] + .indefinitely()[0] Assertions.assertEquals("aaa", result.title) result = TestReactiveEntity.listAll(Sort.descending("title")).await().indefinitely()[0] Assertions.assertEquals("zzz", result.title) @@ -461,14 +540,14 @@ class TestResource { val entityB = TestReactiveEntity("BBB", "BBB", "BBB") entityB.persistOrUpdate().await().indefinitely() var results: List = TestReactiveEntity.listAll(Sort.ascending("title")).await() - .indefinitely() + .indefinitely() Assertions.assertEquals("AAA", results[0].title) Assertions.assertEquals("BBB", results[1].title) Assertions.assertEquals("aaa", results[2].title) val collation: Collation = Collation.builder().caseLevel(true).collationStrength(CollationStrength.PRIMARY).locale("fr") - .build() - results = TestReactiveEntity.findAll( Sort.ascending("title")).withCollation(collation).list() - .await().indefinitely() + .build() + results = TestReactiveEntity.findAll(Sort.ascending("title")).withCollation(collation).list() + .await().indefinitely() Assertions.assertEquals("aaa", results[0].title) Assertions.assertEquals("AAA", results[1].title) Assertions.assertEquals("BBB", results[2].title) @@ -479,17 +558,27 @@ class TestResource { // count Assertions.assertEquals(5, TestReactiveEntity.count("category", "category0").await().indefinitely()) Assertions.assertEquals(5, TestReactiveEntity.count("category = ?1", "category0").await().indefinitely()) - Assertions.assertEquals(5, TestReactiveEntity.count("category = :category", - Parameters.with("category", "category1")).await().indefinitely()) + Assertions.assertEquals( + 5, + TestReactiveEntity.count( + "category = :category", + Parameters.with("category", "category1") + ).await().indefinitely() + ) Assertions.assertEquals(5, TestReactiveEntity.count("{'category' : ?1}", "category0").await().indefinitely()) - Assertions.assertEquals(5, TestReactiveEntity.count("{'category' : :category}", - Parameters.with("category", "category1")).await().indefinitely()) + Assertions.assertEquals( + 5, + TestReactiveEntity.count( + "{'category' : :category}", + Parameters.with("category", "category1") + ).await().indefinitely() + ) val countQuery: Document = Document().append("category", "category1") Assertions.assertEquals(5, TestReactiveEntity.count(countQuery).await().indefinitely()) // update val list: List = TestReactiveEntity.list("category = ?1", "category0").await() - .indefinitely() + .indefinitely() Assertions.assertEquals(5, list.size) for (entity in list) { entity.category = "newCategory" @@ -498,19 +587,19 @@ class TestResource { TestReactiveEntity.update(list.stream()).await().indefinitely() TestReactiveEntity.persistOrUpdate(list).await().indefinitely() var updated: Long = TestReactiveEntity.update("category", "newCategory2").where("category", "newCategory").await() - .indefinitely() + .indefinitely() Assertions.assertEquals(5, updated) updated = TestReactiveEntity.update("category = ?1", "newCategory").where("category = ?1", "newCategory2").await() - .indefinitely() + .indefinitely() Assertions.assertEquals(5, updated) updated = TestReactiveEntity.update("{'category' : ?1}", "newCategory2").where("{'category' : ?1}", "newCategory") - .await().indefinitely() + .await().indefinitely() Assertions.assertEquals(5, updated) updated = TestReactiveEntity.update("category = :category", Parameters.with("category", "newCategory")) - .where("category = :category", Parameters.with("category", "newCategory2")).await().indefinitely() + .where("category = :category", Parameters.with("category", "newCategory2")).await().indefinitely() Assertions.assertEquals(5, updated) updated = TestReactiveEntity.update("{'category' : :category}", Parameters.with("category", "newCategory2")) - .where("{'category' : :category}", Parameters.with("category", "newCategory")).await().indefinitely() + .where("{'category' : :category}", Parameters.with("category", "newCategory")).await().indefinitely() Assertions.assertEquals(5, updated) Assertions.assertEquals(5, TestReactiveEntity.count("category = ?1", "newCategory2").await().indefinitely()) updated = TestReactiveEntity.update("newField", "newValue").all().await().indefinitely() @@ -572,29 +661,56 @@ class TestResource { testReactiveRange(testReactiveRepository.findAll()) // query - Assertions.assertEquals(5, - testReactiveRepository.list("category", "category0").await().indefinitely().size) - Assertions.assertEquals(5, - testReactiveRepository.list("category = ?1", "category0").await().indefinitely().size) - Assertions.assertEquals(5, testReactiveRepository.list("category = :category", - Parameters.with("category", "category1")).await().indefinitely().size) - Assertions.assertEquals(5, - testReactiveRepository.list("{'category' : ?1}", "category0").await().indefinitely().size) - Assertions.assertEquals(5, testReactiveRepository.list("{'category' : :category}", - Parameters.with("category", "category1")).await().indefinitely().size) + Assertions.assertEquals( + 5, + testReactiveRepository.list("category", "category0").await().indefinitely().size + ) + Assertions.assertEquals( + 5, + testReactiveRepository.list("category = ?1", "category0").await().indefinitely().size + ) + Assertions.assertEquals( + 5, + testReactiveRepository.list( + "category = :category", + Parameters.with("category", "category1") + ).await().indefinitely().size + ) + Assertions.assertEquals( + 5, + testReactiveRepository.list("{'category' : ?1}", "category0").await().indefinitely().size + ) + Assertions.assertEquals( + 5, + testReactiveRepository.list( + "{'category' : :category}", + Parameters.with("category", "category1") + ).await().indefinitely().size + ) val listQuery: Document = Document().append("category", "category1") Assertions.assertEquals(5, testReactiveRepository.list(listQuery).await().indefinitely().size) Assertions.assertEquals(0, testReactiveRepository.list("category", null).await().indefinitely().size) - Assertions.assertEquals(0, testReactiveRepository.list("category = :category", - Parameters.with("category", null)).await().indefinitely().size) + Assertions.assertEquals( + 0, + testReactiveRepository.list( + "category = :category", + Parameters.with("category", null) + ).await().indefinitely().size + ) // regex val entityWithUpperCase = TestReactiveEntity("title11", "upperCaseCategory", "desc") testReactiveRepository.persist(entityWithUpperCase).await().indefinitely() - Assertions.assertEquals(1, testReactiveRepository.list("category like ?1", "upperCase.*") - .await().indefinitely().size) - Assertions.assertEquals(1, testReactiveRepository.list("category like ?1", "/uppercase.*/i") - .await().indefinitely().size) + Assertions.assertEquals( + 1, + testReactiveRepository.list("category like ?1", "upperCase.*") + .await().indefinitely().size + ) + Assertions.assertEquals( + 1, + testReactiveRepository.list("category like ?1", "/uppercase.*/i") + .await().indefinitely().size + ) testReactiveRepository.delete(entityWithUpperCase).await().indefinitely() // sort @@ -621,9 +737,9 @@ class TestResource { Assertions.assertEquals("BBB", results[1].title) Assertions.assertEquals("aaa", results[2].title) val collation: Collation = Collation.builder().caseLevel(true).collationStrength(CollationStrength.PRIMARY).locale("fr") - .build() + .build() results = testReactiveRepository.findAll(Sort.ascending("title")).withCollation(collation).list().await() - .indefinitely() + .indefinitely() Assertions.assertEquals("aaa", results[0].title) Assertions.assertEquals("AAA", results[1].title) Assertions.assertEquals("BBB", results[2].title) @@ -632,16 +748,32 @@ class TestResource { testReactiveRepository.delete(entityB).await().indefinitely() // count - Assertions.assertEquals(5, - testReactiveRepository.count("category", "category0").await().indefinitely()) - Assertions.assertEquals(5, - testReactiveRepository.count("category = ?1", "category0").await().indefinitely()) - Assertions.assertEquals(5, testReactiveRepository.count("category = :category", - Parameters.with("category", "category1")).await().indefinitely()) - Assertions.assertEquals(5, - testReactiveRepository.count("{'category' : ?1}", "category0").await().indefinitely()) - Assertions.assertEquals(5, testReactiveRepository.count("{'category' : :category}", - Parameters.with("category", "category1")).await().indefinitely()) + Assertions.assertEquals( + 5, + testReactiveRepository.count("category", "category0").await().indefinitely() + ) + Assertions.assertEquals( + 5, + testReactiveRepository.count("category = ?1", "category0").await().indefinitely() + ) + Assertions.assertEquals( + 5, + testReactiveRepository.count( + "category = :category", + Parameters.with("category", "category1") + ).await().indefinitely() + ) + Assertions.assertEquals( + 5, + testReactiveRepository.count("{'category' : ?1}", "category0").await().indefinitely() + ) + Assertions.assertEquals( + 5, + testReactiveRepository.count( + "{'category' : :category}", + Parameters.with("category", "category1") + ).await().indefinitely() + ) val countQuery: Document = Document().append("category", "category1") Assertions.assertEquals(5, testReactiveRepository.count(countQuery).await().indefinitely()) @@ -655,19 +787,19 @@ class TestResource { testReactiveRepository.update(list.stream()).await().indefinitely() testReactiveRepository.persistOrUpdate(list).await().indefinitely() var updated: Long = testReactiveRepository.update("category", "newCategory2").where("category", "newCategory").await() - .indefinitely() + .indefinitely() Assertions.assertEquals(5, updated) updated = testReactiveRepository.update("category = ?1", "newCategory").where("category = ?1", "newCategory2").await() - .indefinitely() + .indefinitely() Assertions.assertEquals(5, updated) updated = testReactiveRepository.update("{'category' : ?1}", "newCategory2").where("{'category' : ?1}", "newCategory") - .await().indefinitely() + .await().indefinitely() Assertions.assertEquals(5, updated) updated = testReactiveRepository.update("category = :category", Parameters.with("category", "newCategory")) - .where("category = :category", Parameters.with("category", "newCategory2")).await().indefinitely() + .where("category = :category", Parameters.with("category", "newCategory2")).await().indefinitely() Assertions.assertEquals(5, updated) updated = testReactiveRepository.update("{'category' : :category}", Parameters.with("category", "newCategory2")) - .where("{'category' : :category}", Parameters.with("category", "newCategory")).await().indefinitely() + .where("{'category' : :category}", Parameters.with("category", "newCategory")).await().indefinitely() Assertions.assertEquals(5, updated) Assertions.assertEquals(5, testReactiveRepository.count("category = ?1", "newCategory2").await().indefinitely()) updated = testReactiveRepository.update("newField", "newValue").all().await().indefinitely() @@ -685,7 +817,7 @@ class TestResource { testReactiveRepository.persist(entities.stream()).await().indefinitely() testReactiveRepository.delete("category = :category", Parameters.with("category", "category0")).await().indefinitely() testReactiveRepository.delete("{'category' : :category}", Parameters.with("category", "category1")).await() - .indefinitely() + .indefinitely() Assertions.assertEquals(0, testReactiveRepository.count().await().indefinitely()) testReactiveRepository.persistOrUpdate(entities.stream()).await().indefinitely() testReactiveRepository.delete("category", "category0").await().indefinitely() @@ -697,9 +829,11 @@ class TestResource { private val testReactiveEntities: List get() { return (0..9).map { - TestReactiveEntity("title$it", - "category" + it % 2, - "description$it") + TestReactiveEntity( + "title$it", + "category" + it % 2, + "description$it" + ) } } @@ -762,4 +896,4 @@ class TestResource { range = query.range(0, 2).page(0, 3).list().await().indefinitely() Assertions.assertEquals(3, range.size) } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/BookDTO.kt b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/BookDTO.kt index 37149010476f5..7451ad09a90a8 100644 --- a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/BookDTO.kt +++ b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/BookDTO.kt @@ -61,13 +61,13 @@ class BookDTO { @Override override fun toString(): String { return "BookDTO{" + - "title='" + title + '\'' + - ", author='" + author + '\'' + - ", id='" + id + '\'' + - ", transientDescription='" + transientDescription + '\'' + - ", creationDate='" + creationDate + '\'' + - ", categories=" + categories + - ", details=" + details + - '}' + "title='" + title + '\'' + + ", author='" + author + '\'' + + ", id='" + id + '\'' + + ", transientDescription='" + transientDescription + '\'' + + ", creationDate='" + creationDate + '\'' + + ", categories=" + categories + + ", details=" + details + + '}' } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/MongodbPanacheMockingTest.kt b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/MongodbPanacheMockingTest.kt index 09e35c6c7017d..617e03d38024c 100644 --- a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/MongodbPanacheMockingTest.kt +++ b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/MongodbPanacheMockingTest.kt @@ -5,10 +5,8 @@ import io.quarkus.it.mongodb.panache.person.Person import io.quarkus.it.mongodb.panache.person.PersonEntity import io.quarkus.it.mongodb.panache.person.PersonRepository import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepositoryBase -import io.quarkus.test.common.QuarkusTestResource import io.quarkus.test.junit.QuarkusTest import io.quarkus.test.junit.mockito.InjectMock -import io.quarkus.test.mongodb.MongoTestResource import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.junit.jupiter.api.condition.DisabledOnOs @@ -107,4 +105,4 @@ class MongodbPanacheMockingTest { // bridge call Assertions.assertEquals(false, (realPersonRepository as PanacheMongoRepositoryBase).deleteById(0L)) } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/MongodbPanacheResourceTest.kt b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/MongodbPanacheResourceTest.kt index a20e75f88f06f..523527e2bc6b1 100644 --- a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/MongodbPanacheResourceTest.kt +++ b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/MongodbPanacheResourceTest.kt @@ -52,66 +52,70 @@ open class MongodbPanacheResourceTest { private fun callBookEndpoint(endpoint: String) { RestAssured.defaultParser = Parser.JSON RestAssured.config - .objectMapperConfig(ObjectMapperConfig().jackson2ObjectMapperFactory { _, _ -> + .objectMapperConfig( + ObjectMapperConfig().jackson2ObjectMapperFactory { _, _ -> ObjectMapper() - .registerModule(Jdk8Module()) - .registerModule(JavaTimeModule()) - .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - }) + .registerModule(Jdk8Module()) + .registerModule(JavaTimeModule()) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + } + ) var list: List = get(endpoint).`as`(LIST_OF_BOOK_TYPE_REF) Assertions.assertEquals(0, list.size) val book1: BookDTO = BookDTO().setAuthor("Victor Hugo").setTitle("Les Misérables") - .setCreationDate(yearToDate(1886)) - .setCategories(listOf("long", "very long")) - .setDetails(BookDetail().setRating(3).setSummary("A very long book")) + .setCreationDate(yearToDate(1886)) + .setCategories(listOf("long", "very long")) + .setDetails(BookDetail().setRating(3).setSummary("A very long book")) var response: Response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book1) - .post(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book1) + .post(endpoint) + .andReturn() Assertions.assertEquals(201, response.statusCode()) - Assertions.assertTrue(response.header("Location").length > 20) //Assert that id has been populated + Assertions.assertTrue(response.header("Location").length > 20) // Assert that id has been populated val book2: BookDTO = BookDTO().setAuthor("Victor Hugo").setTitle("Notre-Dame de Paris") - .setCreationDate(yearToDate(1831)) - .setCategories(listOf("long", "quasimodo")) - .setDetails(BookDetail().setRating(4).setSummary("quasimodo and esmeralda")) + .setCreationDate(yearToDate(1831)) + .setCategories(listOf("long", "quasimodo")) + .setDetails(BookDetail().setRating(4).setSummary("quasimodo and esmeralda")) response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book2) - .post(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book2) + .post(endpoint) + .andReturn() Assertions.assertEquals(201, response.statusCode()) list = get(endpoint).`as`(LIST_OF_BOOK_TYPE_REF) Assertions.assertEquals(2, list.size) val book3: BookDTO = BookDTO().setAuthor("Charles Baudelaire").setTitle("Les fleurs du mal") - .setCreationDate(yearToDate(1857)) - .setCategories(Collections.singletonList("poem")) - .setDetails(BookDetail().setRating(2).setSummary("Les Fleurs du mal is a volume of poetry.")) + .setCreationDate(yearToDate(1857)) + .setCategories(Collections.singletonList("poem")) + .setDetails(BookDetail().setRating(2).setSummary("Les Fleurs du mal is a volume of poetry.")) response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book3) - .post(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book3) + .post(endpoint) + .andReturn() Assertions.assertEquals(201, response.statusCode()) val book4: BookDTO = BookDTO().setAuthor("Charles Baudelaire").setTitle("Le Spleen de Paris") - .setCreationDate(yearToDate(1869)) - .setCategories(Collections.singletonList("poem")) - .setDetails(BookDetail().setRating(2) - .setSummary("Le Spleen de Paris is a collection of 50 short prose poems.")) + .setCreationDate(yearToDate(1869)) + .setCategories(Collections.singletonList("poem")) + .setDetails( + BookDetail().setRating(2) + .setSummary("Le Spleen de Paris is a collection of 50 short prose poems.") + ) response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book4) - .patch(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book4) + .patch(endpoint) + .andReturn() Assertions.assertEquals(202, response.statusCode()) list = get(endpoint).`as`(LIST_OF_BOOK_TYPE_REF) Assertions.assertEquals(4, list.size) - //with sort + // with sort list = get("$endpoint?sort=author").`as`(LIST_OF_BOOK_TYPE_REF) Assertions.assertEquals(4, list.size) @@ -138,52 +142,54 @@ open class MongodbPanacheResourceTest { Assertions.assertNotNull(book.id) Assertions.assertNotNull(book.details) - //update a book + // update a book book.setTitle("Notre-Dame de Paris 2").setTransientDescription("should not be persisted") response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book) - .put(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book) + .put(endpoint) + .andReturn() Assertions.assertEquals(202, response.statusCode()) - //check that the title has been updated and the transient description ignored + // check that the title has been updated and the transient description ignored book = get(endpoint + "/" + book.id.toString()).`as`(BookDTO::class.java) Assertions.assertNotNull(book) Assertions.assertEquals("Notre-Dame de Paris 2", book.title) Assertions.assertNull(book.transientDescription) - //delete a book + // delete a book response = RestAssured - .given() - .delete(endpoint + "/" + book.id.toString()) - .andReturn() + .given() + .delete(endpoint + "/" + book.id.toString()) + .andReturn() Assertions.assertEquals(204, response.statusCode()) list = get(endpoint).`as`(LIST_OF_BOOK_TYPE_REF) Assertions.assertEquals(3, list.size) - //test some special characters + // test some special characters list = get("$endpoint/search/Victor'\\ Hugo").`as`(LIST_OF_BOOK_TYPE_REF) Assertions.assertEquals(0, list.size) - //delete all + // delete all response = RestAssured - .given() - .delete(endpoint) - .andReturn() + .given() + .delete(endpoint) + .andReturn() Assertions.assertEquals(204, response.statusCode()) } private fun callPersonEndpoint(endpoint: String) { RestAssured.defaultParser = Parser.JSON RestAssured.config - .objectMapperConfig(ObjectMapperConfig().jackson2ObjectMapperFactory { _, _ -> + .objectMapperConfig( + ObjectMapperConfig().jackson2ObjectMapperFactory { _, _ -> ObjectMapper() - .registerModule(Jdk8Module()) - .registerModule(JavaTimeModule()) - .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - }) + .registerModule(Jdk8Module()) + .registerModule(JavaTimeModule()) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + } + ) var list: List = get(endpoint).`as`(LIST_OF_PERSON_TYPE_REF) Assertions.assertEquals(0, list.size) val person1 = Person() @@ -191,11 +197,11 @@ open class MongodbPanacheResourceTest { person1.firstname = "John" person1.lastname = "Doe" var response: Response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(person1) - .post(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(person1) + .post(endpoint) + .andReturn() Assertions.assertEquals(201, response.statusCode()) val person2 = Person() person2.id = 2L @@ -209,80 +215,80 @@ open class MongodbPanacheResourceTest { persons.add(person2) persons.add(person3) response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(persons) - .post("$endpoint/multiple") - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(persons) + .post("$endpoint/multiple") + .andReturn() Assertions.assertEquals(204, response.statusCode()) val person4 = Person() person4.id = 4L person4.firstname = "Charles" person4.lastname = "Baudelaire" response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(person4) - .patch(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(person4) + .patch(endpoint) + .andReturn() Assertions.assertEquals(202, response.statusCode()) list = get(endpoint).`as`(LIST_OF_PERSON_TYPE_REF) Assertions.assertEquals(4, list.size) - //with sort + // with sort list = get("$endpoint?sort=firstname").`as`(LIST_OF_PERSON_TYPE_REF) Assertions.assertEquals(4, list.size) - //with project + // with project list = get("$endpoint/search/Doe").`as`(LIST_OF_PERSON_TYPE_REF) Assertions.assertEquals(1, list.size) Assertions.assertNotNull(list[0].lastname) - //expected the firstname field to be null as we project on lastname only + // expected the firstname field to be null as we project on lastname only Assertions.assertNull(list[0].firstname) - //rename the Doe + // rename the Doe RestAssured - .given() - .queryParam("previousName", "Doe").queryParam("newName", "Dupont") - .header("Content-Type", "application/json") - .`when`().post("$endpoint/rename") - .then().statusCode(200) + .given() + .queryParam("previousName", "Doe").queryParam("newName", "Dupont") + .header("Content-Type", "application/json") + .`when`().post("$endpoint/rename") + .then().statusCode(200) list = get("$endpoint/search/Dupont").`as`(LIST_OF_PERSON_TYPE_REF) Assertions.assertEquals(1, list.size) - //count + // count var count: Long = get("$endpoint/count").`as`(Long::class.java) Assertions.assertEquals(4, count) - //update a person + // update a person person3.lastname = "Webster" response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(person3) - .put(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(person3) + .put(endpoint) + .andReturn() Assertions.assertEquals(202, response.statusCode()) - //check that the title has been updated + // check that the title has been updated person3 = get("$endpoint/${person3.id}").`as`(Person::class.java) Assertions.assertEquals(3L, person3.id ?: -1) Assertions.assertEquals("Webster", person3.lastname) - //delete a person + // delete a person response = RestAssured - .given() - .delete("$endpoint/${person3.id}") - .andReturn() + .given() + .delete("$endpoint/${person3.id}") + .andReturn() Assertions.assertEquals(204, response.statusCode()) count = get("$endpoint/count").`as`(Long::class.java) Assertions.assertEquals(3, count) - //delete all + // delete all response = RestAssured - .given() - .delete(endpoint) - .andReturn() + .given() + .delete(endpoint) + .andReturn() Assertions.assertEquals(204, response.statusCode()) count = get("$endpoint/count").`as`(Long::class.java) Assertions.assertEquals(0, count) @@ -334,4 +340,4 @@ open class MongodbPanacheResourceTest { private val LIST_OF_BOOK_TYPE_REF: TypeRef> = object : TypeRef>() {} private val LIST_OF_PERSON_TYPE_REF: TypeRef> = object : TypeRef>() {} } -} \ No newline at end of file +} diff --git a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.kt b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.kt index d16f81005d8b1..922e074748eae 100644 --- a/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.kt +++ b/integration-tests/mongodb-panache-kotlin/src/test/kotlin/io/quarkus/it/mongodb/panache/reactive/ReactiveMongodbPanacheResourceTest.kt @@ -25,7 +25,10 @@ import org.junit.jupiter.api.condition.DisabledOnOs import org.junit.jupiter.api.condition.OS import java.io.IOException import java.time.Duration -import java.util.* +import java.util.Calendar +import java.util.Collections +import java.util.Date +import java.util.GregorianCalendar import javax.ws.rs.client.Client import javax.ws.rs.client.ClientBuilder import javax.ws.rs.client.WebTarget @@ -66,72 +69,74 @@ internal open class ReactiveMongodbPanacheResourceTest { private fun callReactiveBookEndpoint(endpoint: String) { RestAssured.defaultParser = Parser.JSON val objectMapper: ObjectMapper = ObjectMapper() - .registerModule(Jdk8Module()) - .registerModule(JavaTimeModule()) - .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .registerModule(Jdk8Module()) + .registerModule(JavaTimeModule()) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) RestAssured.config - .objectMapperConfig(ObjectMapperConfig().jackson2ObjectMapperFactory { _, _ -> objectMapper }) + .objectMapperConfig(ObjectMapperConfig().jackson2ObjectMapperFactory { _, _ -> objectMapper }) var list: List = get(endpoint).`as`(LIST_OF_BOOK_TYPE_REF) assertEquals(0, list.size) val book1: BookDTO = BookDTO().setAuthor("Victor Hugo").setTitle("Les Misérables") - .setCreationDate(yearToDate(1886)) - .setCategories(listOf("long", "very long")) - .setDetails(BookDetail().setRating(3).setSummary("A very long book")) + .setCreationDate(yearToDate(1886)) + .setCategories(listOf("long", "very long")) + .setDetails(BookDetail().setRating(3).setSummary("A very long book")) var response: Response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book1) - .post(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book1) + .post(endpoint) + .andReturn() assertEquals(201, response.statusCode()) - Assertions.assertTrue(response.header("Location").length > 20) //Assert that id has been populated + Assertions.assertTrue(response.header("Location").length > 20) // Assert that id has been populated val book2: BookDTO = BookDTO().setAuthor("Victor Hugo").setTitle("Notre-Dame de Paris") - .setCreationDate(yearToDate(1831)) - .setCategories(listOf("long", "quasimodo")) - .setDetails(BookDetail().setRating(4).setSummary("quasimodo and esmeralda")) + .setCreationDate(yearToDate(1831)) + .setCategories(listOf("long", "quasimodo")) + .setDetails(BookDetail().setRating(4).setSummary("quasimodo and esmeralda")) response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book2) - .post(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book2) + .post(endpoint) + .andReturn() assertEquals(201, response.statusCode()) list = get(endpoint).`as`(LIST_OF_BOOK_TYPE_REF) assertEquals(2, list.size) val book3: BookDTO = BookDTO().setAuthor("Charles Baudelaire").setTitle("Les fleurs du mal") - .setCreationDate(yearToDate(1857)) - .setCategories(Collections.singletonList("poem")) - .setDetails(BookDetail().setRating(2).setSummary("Les Fleurs du mal is a volume of poetry.")) + .setCreationDate(yearToDate(1857)) + .setCategories(Collections.singletonList("poem")) + .setDetails(BookDetail().setRating(2).setSummary("Les Fleurs du mal is a volume of poetry.")) response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book3) - .post(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book3) + .post(endpoint) + .andReturn() assertEquals(201, response.statusCode()) val book4: BookDTO = BookDTO().setAuthor("Charles Baudelaire").setTitle("Le Spleen de Paris") - .setCreationDate(yearToDate(1869)) - .setCategories(Collections.singletonList("poem")) - .setDetails(BookDetail().setRating(2) - .setSummary("Le Spleen de Paris is a collection of 50 short prose poems.")) + .setCreationDate(yearToDate(1869)) + .setCategories(Collections.singletonList("poem")) + .setDetails( + BookDetail().setRating(2) + .setSummary("Le Spleen de Paris is a collection of 50 short prose poems.") + ) response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book4) - .patch(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book4) + .patch(endpoint) + .andReturn() assertEquals(202, response.statusCode()) list = get(endpoint).`as`(LIST_OF_BOOK_TYPE_REF) assertEquals(4, list.size) - //with sort + // with sort list = get("$endpoint?sort=author").`as`(LIST_OF_BOOK_TYPE_REF) assertEquals(4, list.size) @@ -156,36 +161,36 @@ internal open class ReactiveMongodbPanacheResourceTest { assertNotNull(book.id) assertNotNull(book.details) - //update a book + // update a book book.setTitle("Notre-Dame de Paris 2").setTransientDescription("should not be persisted") response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(book) - .put(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(book) + .put(endpoint) + .andReturn() assertEquals(202, response.statusCode()) - //check that the title has been updated and the transient description ignored + // check that the title has been updated and the transient description ignored book = get(endpoint + "/" + book.id.toString()).`as`(BookDTO::class.java) assertEquals("Notre-Dame de Paris 2", book.title) Assertions.assertNull(book.transientDescription) - //delete a book + // delete a book response = RestAssured - .given() - .delete(endpoint + "/" + book.id.toString()) - .andReturn() + .given() + .delete(endpoint + "/" + book.id.toString()) + .andReturn() assertEquals(204, response.statusCode()) list = get(endpoint).`as`(LIST_OF_BOOK_TYPE_REF) assertEquals(3, list.size) - //test some special characters + // test some special characters list = get("$endpoint/search/Victor'\\ Hugo").`as`(LIST_OF_BOOK_TYPE_REF) assertEquals(0, list.size) - //test SSE : there is no JSON serialization for SSE so the test is not very elegant ... + // test SSE : there is no JSON serialization for SSE so the test is not very elegant ... val client: Client = ClientBuilder.newClient() val target: WebTarget = client.target("http://localhost:8081$endpoint/stream") SseEventSource.target(target).build().use { source -> @@ -203,23 +208,25 @@ internal open class ReactiveMongodbPanacheResourceTest { await().atMost(Duration.ofSeconds(10)).until({ nbEvent.count() == 3 }) } - //delete all + // delete all response = RestAssured - .given() - .delete(endpoint) - .andReturn() + .given() + .delete(endpoint) + .andReturn() assertEquals(204, response.statusCode()) } private fun callReactivePersonEndpoint(endpoint: String) { RestAssured.defaultParser = Parser.JSON RestAssured.config - .objectMapperConfig(ObjectMapperConfig().jackson2ObjectMapperFactory({ type, s -> + .objectMapperConfig( + ObjectMapperConfig().jackson2ObjectMapperFactory({ type, s -> ObjectMapper() - .registerModule(Jdk8Module()) - .registerModule(JavaTimeModule()) - .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - })) + .registerModule(Jdk8Module()) + .registerModule(JavaTimeModule()) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + }) + ) var list: List = get(endpoint).`as`(LIST_OF_PERSON_TYPE_REF) assertEquals(0, list.size) val person1 = Person() @@ -227,11 +234,11 @@ internal open class ReactiveMongodbPanacheResourceTest { person1.firstname = "John" person1.lastname = "Doe" var response: Response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(person1) - .post(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(person1) + .post(endpoint) + .andReturn() assertEquals(201, response.statusCode()) val person2 = Person() person2.id = 2L @@ -245,80 +252,80 @@ internal open class ReactiveMongodbPanacheResourceTest { persons.add(person2) persons.add(person3) response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(persons) - .post("$endpoint/multiple") - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(persons) + .post("$endpoint/multiple") + .andReturn() assertEquals(204, response.statusCode()) val person4 = Person() person4.id = 4L person4.firstname = "Charles" person4.lastname = "Baudelaire" response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(person4) - .patch(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(person4) + .patch(endpoint) + .andReturn() assertEquals(202, response.statusCode()) list = get(endpoint).`as`(LIST_OF_PERSON_TYPE_REF) assertEquals(4, list.size) - //with sort + // with sort list = get("$endpoint?sort=firstname").`as`(LIST_OF_PERSON_TYPE_REF) assertEquals(4, list.size) - //with project + // with project list = get("$endpoint/search/Doe").`as`(LIST_OF_PERSON_TYPE_REF) assertEquals(1, list.size) assertNotNull(list[0].lastname) - //expected the firstname field to be null as we project on lastname only + // expected the firstname field to be null as we project on lastname only Assertions.assertNull(list[0].firstname) - //rename the Doe + // rename the Doe RestAssured - .given() - .queryParam("previousName", "Doe").queryParam("newName", "Dupont") - .header("Content-Type", "application/json") - .`when`().post("$endpoint/rename") - .then().statusCode(200) + .given() + .queryParam("previousName", "Doe").queryParam("newName", "Dupont") + .header("Content-Type", "application/json") + .`when`().post("$endpoint/rename") + .then().statusCode(200) list = get("$endpoint/search/Dupont").`as`(LIST_OF_PERSON_TYPE_REF) assertEquals(1, list.size) - //count + // count var count: Long = get("$endpoint/count").`as`(Long::class.java) assertEquals(4, count) - //update a person + // update a person person3.lastname = "Webster" response = RestAssured - .given() - .header("Content-Type", "application/json") - .body(person3) - .put(endpoint) - .andReturn() + .given() + .header("Content-Type", "application/json") + .body(person3) + .put(endpoint) + .andReturn() assertEquals(202, response.statusCode()) - //check that the title has been updated + // check that the title has been updated person3 = get("$endpoint/${person3.id}").`as`(Person::class.java) assertEquals(3L, person3.id ?: -1L) assertEquals("Webster", person3.lastname) - //delete a person + // delete a person response = RestAssured - .given() - .delete(endpoint + "/" + person3.id) - .andReturn() + .given() + .delete(endpoint + "/" + person3.id) + .andReturn() assertEquals(204, response.statusCode()) count = get("$endpoint/count").`as`(Long::class.java) assertEquals(3, count) - //delete all + // delete all response = RestAssured - .given() - .delete(endpoint) - .andReturn() + .given() + .delete(endpoint) + .andReturn() assertEquals(204, response.statusCode()) count = get("$endpoint/count").`as`(Long::class.java) assertEquals(0, count) @@ -348,4 +355,4 @@ internal open class ReactiveMongodbPanacheResourceTest { fun testMoreRepositoryFunctionalities() { get("/test/reactive/repository").then().statusCode(200) } -} \ No newline at end of file +} diff --git a/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesClient.kt b/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesClient.kt index 6b7e337d8ac55..89602e9d73ba9 100644 --- a/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesClient.kt +++ b/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesClient.kt @@ -2,7 +2,11 @@ package io.quarkus.it.rest import io.quarkus.rest.client.reactive.ClientExceptionMapper import org.jboss.resteasy.reactive.ClientWebApplicationException -import javax.ws.rs.* +import javax.ws.rs.Consumes +import javax.ws.rs.GET +import javax.ws.rs.POST +import javax.ws.rs.Path +import javax.ws.rs.Produces import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response diff --git a/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesNotFoundException.kt b/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesNotFoundException.kt index 96f06d3ed98dd..eea284972ef5b 100644 --- a/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesNotFoundException.kt +++ b/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesNotFoundException.kt @@ -1,4 +1,3 @@ package io.quarkus.it.rest -class CountriesNotFoundException : RuntimeException() { -} +class CountriesNotFoundException : RuntimeException() diff --git a/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesResource.kt b/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesResource.kt index 2321cbf889705..a87de1f5713a8 100644 --- a/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesResource.kt +++ b/integration-tests/rest-client-reactive-kotlin-serialization/src/main/kotlin/io/quarkus/it/rest/CountriesResource.kt @@ -25,7 +25,9 @@ class CountriesResource(private val json: Json) { .build(CountriesClient::class.java) val result = client.country( Country( - "Sweden", "SE", "Stockholm", + "Sweden", + "SE", + "Stockholm", listOf(Currency("SEK", "Swedish Crowns", "kr")) ) ) @@ -71,7 +73,9 @@ class CountriesResource(private val json: Json) { router.route("/countries").blockingHandler { rc: RoutingContext -> val body = listOf( Country( - "Sweden", "SE", "Stockholm", + "Sweden", + "SE", + "Stockholm", listOf(Currency("SEK", "Swedish Crowns", "kr")) ) ) diff --git a/integration-tests/rest-client-reactive-kotlin-serialization/src/test/kotlin/io/quarkus/it/rest/client/BasicTest.kt b/integration-tests/rest-client-reactive-kotlin-serialization/src/test/kotlin/io/quarkus/it/rest/client/BasicTest.kt index e1b61569a1c1d..2fcd6bfef495b 100644 --- a/integration-tests/rest-client-reactive-kotlin-serialization/src/test/kotlin/io/quarkus/it/rest/client/BasicTest.kt +++ b/integration-tests/rest-client-reactive-kotlin-serialization/src/test/kotlin/io/quarkus/it/rest/client/BasicTest.kt @@ -35,5 +35,4 @@ open class BasicTest { .post("/call-not-found-countries") Assertions.assertThat(response.statusCode).isEqualTo(204) } - } diff --git a/integration-tests/rest-client-reactive-kotlin-serialization/src/test/kotlin/io/quarkus/it/rest/client/BasicTestIT.kt b/integration-tests/rest-client-reactive-kotlin-serialization/src/test/kotlin/io/quarkus/it/rest/client/BasicTestIT.kt index 1eebc7144c796..10f6e29e44fce 100644 --- a/integration-tests/rest-client-reactive-kotlin-serialization/src/test/kotlin/io/quarkus/it/rest/client/BasicTestIT.kt +++ b/integration-tests/rest-client-reactive-kotlin-serialization/src/test/kotlin/io/quarkus/it/rest/client/BasicTestIT.kt @@ -3,4 +3,4 @@ package io.quarkus.it.rest.client import io.quarkus.test.junit.QuarkusIntegrationTest @QuarkusIntegrationTest -class BasicTestIT : BasicTest() \ No newline at end of file +class BasicTestIT : BasicTest() diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountriesEndpoint.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountriesEndpoint.kt index f77894ed7a286..4e434b3599a32 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountriesEndpoint.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountriesEndpoint.kt @@ -10,9 +10,11 @@ import javax.ws.rs.POST import javax.ws.rs.Path @Path("country") -class CountriesEndpoint(@RestClient private val countriesGateway: CountriesGateway, - private val countryNameConsumer: CountryNameConsumer, - @Channel("countries-emitter") private val countryEmitter: Emitter) { +class CountriesEndpoint( + @RestClient private val countriesGateway: CountriesGateway, + private val countryNameConsumer: CountryNameConsumer, + @Channel("countries-emitter") private val countryEmitter: Emitter +) { @GET @Path("/name/{name}") diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/Country.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/Country.kt index fd06d720b4be3..d65f86a2d0354 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/Country.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/Country.kt @@ -1,4 +1,3 @@ package io.quarkus.it.resteasy.reactive.kotlin -data class Country(val name: String, val capital: String) { -} +data class Country(val name: String, val capital: String) diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameConsumer.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameConsumer.kt index 690721b09432f..91161261bb08d 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameConsumer.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameConsumer.kt @@ -5,7 +5,6 @@ import org.eclipse.microprofile.rest.client.inject.RestClient import java.util.concurrent.ConcurrentHashMap import javax.enterprise.context.ApplicationScoped - @ApplicationScoped class CountryNameConsumer(@RestClient private val countryGateway: CountriesGateway) { @@ -16,5 +15,4 @@ class CountryNameConsumer(@RestClient private val countryGateway: CountriesGatew resolvedCounties.addAll(countryGateway.byName("fake$countryName")) resolvedCounties.addAll(countryGateway.byName(countryName)) } - -} \ No newline at end of file +} diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameMessageTransformer.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameMessageTransformer.kt index 289dffd6a7295..350f51c12c2b3 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameMessageTransformer.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameMessageTransformer.kt @@ -17,4 +17,4 @@ class CountryNameMessageTransformer { return input.withPayload(input.payload.toLowerCase()) // return input.toLowerCase() } -} \ No newline at end of file +} diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNamePayloadTransformer.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNamePayloadTransformer.kt index bd0e29478fbf6..4de37aa47f689 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNamePayloadTransformer.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNamePayloadTransformer.kt @@ -14,4 +14,4 @@ class CountryNamePayloadTransformer { delay(100) return countryName.toUpperCase() } -} \ No newline at end of file +} diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameProducer.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameProducer.kt index c699e10b05c52..3981b29c2402d 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameProducer.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/CountryNameProducer.kt @@ -9,4 +9,4 @@ class CountryNameProducer { @Outgoing("countries-out") fun generate(): Multi = Multi.createFrom().items("Greece", "USA", "France") -} \ No newline at end of file +} diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/EnumEndpoint.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/EnumEndpoint.kt index 01836dfb03ec9..390cc56c8fae7 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/EnumEndpoint.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/EnumEndpoint.kt @@ -12,5 +12,4 @@ class EnumEndpoint { @GET @Produces(MediaType.TEXT_PLAIN) fun test(@QueryParam(value = "state") states: List) = "States: $states" - } diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/Filters.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/Filters.kt index dfefb296a7097..9c49f774f9a4f 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/Filters.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/Filters.kt @@ -12,14 +12,14 @@ import javax.ws.rs.core.UriInfo class Filters { @ServerRequestFilter - suspend fun addHeader(uriInfo: UriInfo, context: ContainerRequestContext){ + suspend fun addHeader(uriInfo: UriInfo, context: ContainerRequestContext) { delay(100) context.headers.add("firstName", "foo") delay(100) } @ServerRequestFilter - suspend fun addHeaderOrAbort(context: ContainerRequestContext): Response?{ + suspend fun addHeaderOrAbort(context: ContainerRequestContext): Response? { delay(100) if (context.headers.containsKey("abort")) { return Response.noContent().build() diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/GreetingResource.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/GreetingResource.kt index 24ff5fa8f063b..8d1c096fcbaef 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/GreetingResource.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/GreetingResource.kt @@ -17,8 +17,7 @@ class GreetingResource(val headers: HttpHeaders) { @GET @Path("noop") suspend fun noop() { - } } -data class Greeting(val message:String) +data class Greeting(val message: String) diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveGreetingResource.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveGreetingResource.kt index 7b6d1a516e897..56bc3d2e7129b 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveGreetingResource.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveGreetingResource.kt @@ -1,9 +1,6 @@ package io.quarkus.it.resteasy.reactive.kotlin import kotlinx.coroutines.delay -import java.io.BufferedReader -import java.io.InputStreamReader -import java.net.URL import javax.inject.Inject import javax.ws.rs.GET import javax.ws.rs.Path @@ -11,14 +8,14 @@ import javax.ws.rs.Produces import javax.ws.rs.core.MediaType @Path("/hello-resteasy-reactive") -class ReactiveGreetingResource @Inject constructor (val req : RequestScopedKotlinClass){ +class ReactiveGreetingResource @Inject constructor(val req: RequestScopedKotlinClass) { @GET @Produces(MediaType.TEXT_PLAIN) suspend fun hello(): String { req.message = "msg" delay(50) if (req.message != "msg") { - throw Throwable("Request scoped data was lost"); + throw Throwable("Request scoped data was lost") } return "Hello RestEASY Reactive" } @@ -35,6 +32,6 @@ class ReactiveGreetingResource @Inject constructor (val req : RequestScopedKotli @Path("/{name}") suspend fun hello(name: String): String { delay(50) - return "Hello ${name}" + return "Hello $name" } } diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/RequestScopedKotlinClass.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/RequestScopedKotlinClass.kt index 8349754e3d726..e2945172f0a62 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/RequestScopedKotlinClass.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/RequestScopedKotlinClass.kt @@ -5,6 +5,5 @@ import javax.enterprise.context.RequestScoped @RequestScoped class RequestScopedKotlinClass { - var message : String = "initial"; - -} \ No newline at end of file + var message: String = "initial" +} diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ft/ClientResource.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ft/ClientResource.kt index fd163796406e9..46c616f45cfdd 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ft/ClientResource.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/main/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ft/ClientResource.kt @@ -1,10 +1,8 @@ package io.quarkus.it.resteasy.reactive.kotlin.ft import org.eclipse.microprofile.rest.client.inject.RestClient -import java.util.concurrent.atomic.AtomicBoolean import javax.inject.Inject import javax.ws.rs.GET -import javax.ws.rs.POST import javax.ws.rs.Path @Path("/ft/client") diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/EnumTest.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/EnumTest.kt index a370591322c95..d03b6d84ed1ec 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/EnumTest.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/EnumTest.kt @@ -1,7 +1,6 @@ package io.quarkus.it.resteasy.reactive.kotlin import io.quarkus.test.junit.QuarkusTest -import io.restassured.RestAssured.given import io.restassured.module.kotlin.extensions.Then import io.restassured.module.kotlin.extensions.When import org.hamcrest.Matchers.equalTo diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/FlowResourceTest.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/FlowResourceTest.kt index c8c90210a08dd..546f1b455507e 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/FlowResourceTest.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/FlowResourceTest.kt @@ -6,7 +6,7 @@ import io.restassured.module.kotlin.extensions.Then import io.restassured.module.kotlin.extensions.When import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import java.util.* +import java.util.Collections import java.util.concurrent.CompletableFuture import java.util.concurrent.TimeUnit import javax.ws.rs.client.ClientBuilder @@ -47,9 +47,10 @@ class FlowResourceTest { fun testSeeJson() { testSse("json", 10) { assertThat(it).containsExactly( - "{\"name\":\"Barbados\",\"capital\":\"Bridgetown\"}", - "{\"name\":\"Mauritius\",\"capital\":\"Port Louis\"}", - "{\"name\":\"Fiji\",\"capital\":\"Suva\"}") + "{\"name\":\"Barbados\",\"capital\":\"Bridgetown\"}", + "{\"name\":\"Mauritius\",\"capital\":\"Port Louis\"}", + "{\"name\":\"Fiji\",\"capital\":\"Suva\"}" + ) } } @@ -57,13 +58,13 @@ class FlowResourceTest { val client = ClientBuilder.newBuilder().build() val target: WebTarget = client.target("$flowPath/$path") SseEventSource.target(target).reconnectingEvery(Int.MAX_VALUE.toLong(), TimeUnit.SECONDS) - .build().use { eventSource -> - val res = CompletableFuture>() - val collect = Collections.synchronizedList(ArrayList()) - eventSource.register({ inboundSseEvent -> collect.add(inboundSseEvent.readData()) }, { throwable -> res.completeExceptionally(throwable) }) { res.complete(collect) } - eventSource.open() - val list = res.get(timeout, TimeUnit.SECONDS) - assertion(list) - } + .build().use { eventSource -> + val res = CompletableFuture>() + val collect = Collections.synchronizedList(ArrayList()) + eventSource.register({ inboundSseEvent -> collect.add(inboundSseEvent.readData()) }, { throwable -> res.completeExceptionally(throwable) }) { res.complete(collect) } + eventSource.open() + val list = res.get(timeout, TimeUnit.SECONDS) + assertion(list) + } } } diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/KafkaTestResource.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/KafkaTestResource.kt index 69e7d864ee58f..8c1315b1e5b2f 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/KafkaTestResource.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/KafkaTestResource.kt @@ -19,4 +19,4 @@ class KafkaTestResource : QuarkusTestResourceLifecycleManager { override fun stop() { kafka.close() } -} \ No newline at end of file +} diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveClientTest.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveClientTest.kt index e4ae4ae3930a1..24617ca84f398 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveClientTest.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveClientTest.kt @@ -1,7 +1,6 @@ package io.quarkus.it.resteasy.reactive.kotlin import io.quarkus.test.junit.QuarkusTest -import io.restassured.RestAssured import io.restassured.http.ContentType import io.restassured.module.kotlin.extensions.Then import io.restassured.module.kotlin.extensions.When @@ -18,8 +17,12 @@ class ReactiveClientTest { } Then { statusCode(200) contentType(ContentType.JSON) - body("$.size()", CoreMatchers.`is`(1), - "[0].capital", CoreMatchers.`is`("foo-capital")) + body( + "$.size()", + CoreMatchers.`is`(1), + "[0].capital", + CoreMatchers.`is`("foo-capital") + ) } } } diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveGreetingResourceTest.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveGreetingResourceTest.kt index 326910f09f123..9be8662897674 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveGreetingResourceTest.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveGreetingResourceTest.kt @@ -1,7 +1,6 @@ package io.quarkus.it.resteasy.reactive.kotlin import io.quarkus.test.junit.QuarkusTest -import io.restassured.RestAssured.given import io.restassured.module.kotlin.extensions.Then import io.restassured.module.kotlin.extensions.When import org.hamcrest.CoreMatchers.`is` diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveMessagingTest.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveMessagingTest.kt index 8c0ce9f48cd0f..1b80e9c90edff 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveMessagingTest.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ReactiveMessagingTest.kt @@ -3,7 +3,6 @@ package io.quarkus.it.resteasy.reactive.kotlin import io.quarkus.test.common.QuarkusTestResource import io.quarkus.test.junit.QuarkusTest import io.restassured.RestAssured.get -import io.restassured.RestAssured.given import io.restassured.common.mapper.TypeRef import io.restassured.module.kotlin.extensions.Then import io.restassured.module.kotlin.extensions.When @@ -16,7 +15,7 @@ import java.time.Duration @QuarkusTestResource(KafkaTestResource::class) class ReactiveMessagingTest { - private val TYPE_REF: TypeRef> = object: TypeRef>() {} + private val TYPE_REF: TypeRef> = object : TypeRef>() {} @Test fun test() { diff --git a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ScheduledEndpointTest.kt b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ScheduledEndpointTest.kt index 5d2a3c8ac2558..f004ca617efab 100644 --- a/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ScheduledEndpointTest.kt +++ b/integration-tests/resteasy-reactive-kotlin/standard/src/test/kotlin/io/quarkus/it/resteasy/reactive/kotlin/ScheduledEndpointTest.kt @@ -11,7 +11,7 @@ class ScheduledEndpointTest { @Test fun testScheduledMethodWithNoArg() { When { - get("/scheduled/num1") + get("/scheduled/num1") } Then { statusCode(201) }