BAEL-2580 JVM Platform Annotations in Kotlin - added Unit Test
This commit is contained in:
parent
15cbaa9bdb
commit
21b43b0f11
|
@ -5,6 +5,8 @@ import java.util.*
|
|||
interface Document {
|
||||
|
||||
@JvmDefault
|
||||
fun getTypeDefault() = "document"
|
||||
|
||||
fun getType() = "document"
|
||||
}
|
||||
|
||||
|
@ -23,9 +25,3 @@ class TextDocument : Document {
|
|||
}
|
||||
|
||||
class XmlDocument(d : Document) : Document by d
|
||||
|
||||
fun main() {
|
||||
val myDocument = TextDocument()
|
||||
val myTextDocument = XmlDocument(myDocument)
|
||||
println("${myDocument.getType()} ${myTextDocument.getType()}")
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.baeldung.range
|
||||
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class DocumentTest {
|
||||
|
||||
@Test
|
||||
fun testDefaultMethod() {
|
||||
|
||||
val myDocument = TextDocument()
|
||||
val myTextDocument = XmlDocument(myDocument)
|
||||
|
||||
assertEquals("text", myDocument.getType())
|
||||
assertEquals("text", myTextDocument.getType())
|
||||
assertEquals("document", myTextDocument.getTypeDefault())
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue