Kotlin jvm field (#2610)

* Add project for hibernate immutable article
Add Event entity
Add hibernate configuration file
Add hibernateutil for configuration
Add test to match snippets from article

* Update master

* Jvm Field
Add sample classes
Include test for sample classes
This commit is contained in:
Walter Gómez 2017-09-12 00:18:03 -06:00 committed by maibin
parent 22015c8007
commit 4edcd08cbd
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,12 @@
package com.baeldung.kotlin
class JvmSample(text:String) {
@JvmField
val sampleText:String = text
}
class CompanionSample {
companion object {
@JvmField val MAX_LIMIT = 20
}
}

View File

@ -0,0 +1,26 @@
package com.baeldung.kotlin
import org.junit.Before
import org.junit.Test
import kotlin.test.assertTrue
class JvmSampleTest {
var sample = ""
@Before
fun setUp() {
sample = JvmSample("Hello!").sampleText
}
@Test
fun givenField_whenCheckValue_thenMatchesValue() {
assertTrue(sample == "Hello!")
}
@Test
fun givenStaticVariable_whenCheckValue_thenMatchesValue() {
// Sample when is treated as a static variable
assertTrue(CompanionSample.MAX_LIMIT == 20)
}
}