BAEL-614 java/kotlin interop

This commit is contained in:
Tomasz Lelek 2017-01-25 19:30:06 +01:00
parent a269eba427
commit 31c65f649a
3 changed files with 29 additions and 1 deletions

View File

@ -24,13 +24,17 @@ class ItemManager(val categoryId: String, val dbConnection: String) {
fun makeAnalyisOfCategory(catId: String): Unit {
val result = if (catId == "100") "Yes" else "No"
println(result)
`object`()
}
fun sum(a: Int, b: Int): Int {
return a + b
}
fun `object`(): String {
return "this is object"
}
}
fun main(args: Array<String>) {

View File

@ -0,0 +1,7 @@
package com.baeldung.kotlin
class MathematicsOperations {
fun addTwoNumbers(a: Int, b: Int): Int {
return a + b
}
}

View File

@ -0,0 +1,17 @@
package com.baeldung.kotlin;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class JavaCallToKotlinTest {
@Test
public void givenKotlinClass_whenCallFromJava_shouldProduceResults() {
//when
int res = new MathematicsOperations().addTwoNumbers(2, 4);
//then
assertEquals(6, res);
}
}