new to Kotlin here!
I just switched some Java testing code into Kotlin and a specific case of null codes is bugging me for the moment. I am trying to test (in a Kotlin @Test code segment) whether this java function raises the right InvalidParameterException:
void addEventListener(
@NonNull DeviceEventListener listener,
@Nullable CompletionListener completionListener);
So this function is called through Kotlin code (which worked fine before being converted from java to kotlin) like so: Before in Java :
deviceTest.addEventListener(null, testCompletionListener);
waiter.expect(InvalidParameterException.class);
The test worked well without errors.
After the transition to Kotlin, the code becomes unreachable or raises KotlinNullPointerException:
deviceTest!!.addEventListener(null!!, testCompletionListener)
waiter!!.expect(InvalidParameterException::class.java)
I am new to Kotlin and seriously at lost in how to make it work like it did precedently in Java. Any idea?
Thanks for taking the time!