Skip to content
Advertisement

How do I unit test spring security @PreAuthorize custom expression

JavaScript

I want to write the test of this endpoint, but I am getting the following error.

JavaScript

How can I make the expression resolve bean ?

Using @MockBean MessageSecurityService didn’t work.

Advertisement

Answer

Have you stub the return of the @MockBean e.g

JavaScript

also have you added the following in your test class:

JavaScript
Advertisement