Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions replay-tests/typed-input-kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
tmp
10 changes: 10 additions & 0 deletions replay-tests/typed-input-kotlin/app/TypedInputKotlinApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import play.server.Starter

object TypedInputKotlinApp {
@JvmStatic
fun main(args: Array<String>) {
val port = Starter.start("prod")
println("Try: http://localhost:$port/<forced|generic>/{long}")
println()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package controllers

import model.Identifier
import model.User
import play.mvc.PlayController
import play.mvc.results.BadRequest
import play.mvc.results.Result
import play.rebel.View

@Suppress("unused")
class TypedInputController : PlayController {

fun printForced(userId: Long?): Result {
if (userId == null) return BadRequest("forced userId missing")
return View(
"index.html",
mapOf(
"userId" to userId,
"innerType" to userId::class.simpleName,
"outerType" to "N/A"
)
)
}

fun printGeneric(userId: Identifier<User>?): Result {
if (userId == null) return BadRequest("generic userId missing")
return View(
"index.html",
mapOf(
"userId" to userId,
"innerType" to userId.value::class.simpleName,
"outerType" to userId.getTypeString()
)
)
}
}
15 changes: 15 additions & 0 deletions replay-tests/typed-input-kotlin/app/model/Identifier.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package model

@JvmInline
value class Identifier<T>(val value: Long) : Comparable<Identifier<T>> {

override fun toString(): String =
value.toString()

override fun compareTo(other: Identifier<T>) =
value.compareTo(other.value)

fun getTypeString(): String =
this::class.java.simpleName

}
3 changes: 3 additions & 0 deletions replay-tests/typed-input-kotlin/app/model/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package model

data class User(val id: Identifier<User>)
8 changes: 8 additions & 0 deletions replay-tests/typed-input-kotlin/app/views/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>Hello User</title>
</head>
<body>
<h1>Hello, User ${userId} with identifier type ${outerType} and value type ${innerType}!</h1>
</body>
</html>
9 changes: 9 additions & 0 deletions replay-tests/typed-input-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
alias(libs.plugins.kotlinJvm)
}
dependencies {
implementation(libs.guava) { transitive = false }
implementation(libs.kotlinStdlib)
}

apply from: '../replay-tests.gradle'
8 changes: 8 additions & 0 deletions replay-tests/typed-input-kotlin/conf/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
application.name=typed-input-kotlin

application.session.maxAge=5mn

http.port=9000
%test.http.port=0

ehcache.heapSizeInEntries=100
7 changes: 7 additions & 0 deletions replay-tests/typed-input-kotlin/conf/play.plugins
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
100:play.data.parsing.TempFilePlugin
200:play.data.validation.ValidationPlugin
600:play.libs.WS
700:play.jobs.JobsPlugin
800:play.modules.gtengineplugin.GTEnginePlugin
1002:play.db.jpa.JPAPlugin
100100:play.plugins.PlayStatusPlugin
2 changes: 2 additions & 0 deletions replay-tests/typed-input-kotlin/conf/routes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GET /forced/{<[0-9]+>userId} TypedInputController.printForced
GET /generic/{<[0-9]+>userId} TypedInputController.printGeneric
16 changes: 16 additions & 0 deletions replay-tests/typed-input-kotlin/test/ui/hello/kotlin/BaseSpec.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ui.hello.kotlin

import com.codeborne.selenide.Configuration
import org.junit.jupiter.api.BeforeEach
import play.Play
import play.server.Starter

open class BaseSpec {
@BeforeEach
fun setUp() {
val port = Starter.start("test")
Configuration.baseUrl = "http://localhost:$port"
Play.configuration.setProperty("application.baseUrl", Configuration.baseUrl)
System.setProperty("webdriver.http.factory", "jdk-http-client")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ui.hello.kotlin

import com.codeborne.selenide.Condition
import com.codeborne.selenide.Selenide
import org.junit.jupiter.api.Test

class TypedInputSpec : BaseSpec() {
@Test
fun openPageForced() {
Selenide.open("/forced/1")
Selenide.element("h1")
.shouldHave(Condition.text("Hello, User 1 with identifier type N/A and value type Long!"))
}

@Test
fun openPageGeneric() {
Selenide.open("/generic/2")
Selenide.element("h1")
.shouldHave(Condition.text("Hello, User 2 with identifier type User and value type Long!"))
}
}
43 changes: 43 additions & 0 deletions replay-tests/typed-input-kotlin/typed-input-kotlin.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/conf" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/test-result" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/build/lib" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$MODULE_DIR$/build/lib" />
</SOURCES>
<jarDirectory url="file://$MODULE_DIR$/build/lib" recursive="false" />
<jarDirectory url="file://$MODULE_DIR$/build/lib" recursive="false" type="SOURCES" />
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/build/lib-test" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$MODULE_DIR$/build/lib-test" />
</SOURCES>
<jarDirectory url="file://$MODULE_DIR$/build/lib-test" recursive="false" />
<jarDirectory url="file://$MODULE_DIR$/build/lib-test" recursive="false" type="SOURCES" />
</library>
</orderEntry>
<orderEntry type="module" module-name="replay" />
</component>
</module>
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include 'ehcache'
include 'memcached'
include ':replay-tests:helloworld'
include ':replay-tests:helloworld-kotlin'
include ':replay-tests:typed-input-kotlin'
include ':replay-tests:dependency-injection'
include ':replay-tests:liquibase-app'
include ':replay-tests:criminals'
Expand Down
Loading