initial commit

This commit is contained in:
2020-04-04 18:47:24 +02:00
commit 97b5923c1e
22 changed files with 1333 additions and 0 deletions

31
test/ApplicationTest.kt Normal file
View File

@ -0,0 +1,31 @@
package com.kmalbz
import io.ktor.application.*
import io.ktor.response.*
import io.ktor.request.*
import io.ktor.routing.*
import io.ktor.http.*
import io.ktor.gson.*
import io.ktor.features.*
import io.ktor.client.*
import io.ktor.client.engine.apache.*
import com.fasterxml.jackson.databind.*
import io.ktor.jackson.*
import io.ktor.auth.*
import kotlin.reflect.*
import java.util.*
import io.ktor.swagger.experimental.*
import kotlin.test.*
import io.ktor.server.testing.*
class ApplicationTest {
@Test
fun testRoot() {
withTestApplication({ module(testing = true) }) {
handleRequest(HttpMethod.Get, "/").apply {
assertEquals(HttpStatusCode.OK, response.status())
assertEquals("HELLO WORLD!", response.content)
}
}
}
}

View File

@ -0,0 +1,98 @@
package com.kmalbz
import java.util.*
import io.ktor.config.*
import io.ktor.http.*
import io.ktor.request.*
import io.ktor.server.testing.*
import io.ktor.swagger.experimental.*
import kotlin.test.*
class SwaggerRoutesTest {
/**
* @see OutputServiceRDBServer.getallnegative
*/
@Test
fun testGetallnegative() {
withTestApplication {
// @TODO: Adjust path as required
handleRequest(HttpMethod.Get, "/output/filter/negative") {
}.apply {
// @TODO: Your test here
assertEquals(HttpStatusCode.OK, response.status())
}
}
}
/**
* @see OutputServiceRDBServer.getallpositive
*/
@Test
fun testGetallpositive() {
withTestApplication {
// @TODO: Adjust path as required
handleRequest(HttpMethod.Get, "/output/filter/positive") {
}.apply {
// @TODO: Your test here
assertEquals(HttpStatusCode.OK, response.status())
}
}
}
/**
* @see OutputServiceRDBServer.getallafter
*/
@Test
fun testGetallafter() {
withTestApplication {
// @TODO: Adjust path as required
handleRequest(HttpMethod.Get, "/output/after/{dateAfter}") {
}.apply {
// @TODO: Your test here
assertEquals(HttpStatusCode.OK, response.status())
}
}
}
/**
* @see OutputServiceRDBServer.getallbefore
*/
@Test
fun testGetallbefore() {
withTestApplication {
// @TODO: Adjust path as required
handleRequest(HttpMethod.Get, "/output/before/{dateBefore}") {
}.apply {
// @TODO: Your test here
assertEquals(HttpStatusCode.OK, response.status())
}
}
}
/**
* @see OutputServiceRDBServer.getDecision
*/
@Test
fun testGetDecision() {
withTestApplication {
// @TODO: Adjust path as required
handleRequest(HttpMethod.Get, "/output/{tagID}") {
}.apply {
// @TODO: Your test here
assertEquals(HttpStatusCode.OK, response.status())
}
}
}
fun <R> withTestApplication(test: TestApplicationEngine.() -> R): R {
return withApplication(createTestEnvironment()) {
(environment.config as MapApplicationConfig).apply {
put("jwt.secret", "TODO-change-this-supersecret-or-use-SECRET-env")
}
application.module()
test()
}
}
fun TestApplicationRequest.setBodyJson(value: Any?) = setBody(Json.stringify(value))
}