Skip to content

Make the assertion lambdas Kotlin friendly #2821

@OndraZizka

Description

@OndraZizka

Feature summary

Some assertions accept a functor:

public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(ThrowingCallable shouldRaiseThrowable,
                                                                             Class<THROWABLE> type) {
    return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseThrowable, type);
  }

Kotlin has a syntax for lambdas, so it could call:

catchThrowableOfType(NotFoundException::class.java) { 
    connectionService.findBy(hubId = "hub2", connId = "conn1") 
}

But as it is, it needs to stick with the less readable:

catchThrowableOfType( { 
    connectionService.findBy(hubId = "hub2", connId = "conn1") 
}, NotFoundException::class.java)

Could you please add some overrides, moving the functors to the last place? Like,

public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(
         Class<THROWABLE> type, ThrowingCallable shouldRaiseThrowable) {
    return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseThrowable, type);
  }

Thanks for considering.

AssertJ 3.23.1

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions