Skip to content

Commit

Permalink
#17 Modify project to migrate to kotlin 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Sabzevari committed Oct 6, 2018
1 parent 576aecc commit 2e6c01e
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 96 deletions.
9 changes: 0 additions & 9 deletions .idea/kotlin-http4k-realworld-example-app.iml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

27 changes: 0 additions & 27 deletions .idea/modules/conduit_main.iml

This file was deleted.

27 changes: 0 additions & 27 deletions .idea/modules/conduit_test.iml

This file was deleted.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
buildscript {
ext.kotlin_version = "1.2.51"
ext.kotlin_version = "1.3.0-rc-146"
ext.http4k_version = "3.33.1"
ext.log4j_version = "2.10.0"
ext.jackson_version = "2.9.6"

repositories {
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
mavenCentral()
}

Expand All @@ -19,6 +20,7 @@ repositories {
mavenCentral()
jcenter()
maven { url "http://dl.bintray.com/kotlin/exposed" }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
}

dependencies {
Expand All @@ -34,15 +36,22 @@ dependencies {
implementation "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$jackson_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

testImplementation "org.junit.jupiter:junit-jupiter-api:5.1.0"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation "io.mockk:mockk:1.8.7"
testImplementation "io.mockk:mockk:1.8.9.kotlin13"
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions {
freeCompilerArgs = ["-XXLanguage:+InlineClasses"]
}
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions {
freeCompilerArgs = ["-XXLanguage:+InlineClasses"]
}
}
51 changes: 29 additions & 22 deletions src/main/kotlin/conduit/model/models.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,36 @@ import com.fasterxml.jackson.annotation.JsonValue
import conduit.util.TokenAuth
import com.fasterxml.jackson.annotation.JsonCreator.Mode.DELEGATING as m

data class Email @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
override fun toString(): String = this.value
}
inline class Email(val value: String)
inline class Password(val value: String)
inline class Token(val value: String)
inline class Username(val value: String)
inline class Bio(val value: String)
inline class Image(val value: String)

data class Password @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
override fun toString(): String = this.value
}

data class Token @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
override fun toString(): String = this.value
}

data class Username @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
override fun toString(): String = this.value
}

data class Bio @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
override fun toString(): String = this.value
}

data class Image @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
override fun toString(): String = this.value
}
//data class Email @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
// override fun toString(): String = this.value
//}
//
//data class Password @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
// override fun toString(): String = this.value
//}
//
//data class Token @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
// override fun toString(): String = this.value
//}
//
//data class Username @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
// override fun toString(): String = this.value
//}
//
//data class Bio @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
// override fun toString(): String = this.value
//}
//
//data class Image @JsonCreator(mode = m) constructor(@JsonValue val value: String) {
// override fun toString(): String = this.value
//}

data class User(
val id: Int,
Expand Down
26 changes: 26 additions & 0 deletions src/test/kotlin/conduit/MockkFailingTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package conduit

import io.mockk.every
import io.mockk.mockk
import org.junit.jupiter.api.Test

class MockkFailingTest {
@Test // fails
fun `mockk test using any()`() {
val mocked = mockk<TestMock>(relaxed = true)
every { mocked.test(any()) } returns 1
}

@Test // passes
fun `mockk test using hardcoded value`() {
val mocked = mockk<TestMock>(relaxed = true)
every { mocked.test(MyInlineType("123")) } returns 1
}

}

inline class MyInlineType(val value: String)

interface TestMock {
fun test(value: MyInlineType): Int
}
3 changes: 2 additions & 1 deletion src/test/kotlin/conduit/handler/LoginHandlerImplTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ class LoginHandlerImplTest {
unit(loginInfo)
}
}
}


}

0 comments on commit 2e6c01e

Please sign in to comment.