How to write tests for Quarkus - ResponseExceptionMapper and ExceptionMapper

966 Views Asked by At

I am using two exception mapper, responseexceptionmapper and exceptionmapper. Now I need to have code coverage from these mappers.

Any examples ?

1

There are 1 best solutions below

2
Javier Toja On

Thouse are just normal classes,

I can provide an example, but for unit testing you just need to instantiate the mapper as a normal class and invoke the ´toResponse´ method providing an exception to obtain a response a check if satisfy your requirements.

For an integration test, you just will invoke with RestAssured your service and verify if the response contains the status and body that was provided by the ExceptionMapper

what kind of logic are developing inside the mappers ?