BAEL-614 java/kotlin interop
This commit is contained in:
parent
a269eba427
commit
31c65f649a
|
@ -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>) {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package com.baeldung.kotlin
|
||||
|
||||
class MathematicsOperations {
|
||||
fun addTwoNumbers(a: Int, b: Int): Int {
|
||||
return a + b
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue