I want to test my rest api, but I'm little confused how to it. Is not about which lib to use, but what should I test.
My application is basically about cruds and reports. Some specific cruds populate another tables based in the state of the entity submited.
If I want to test those behaviours, should I test the service/repository layers directly or make requests to my endpoints?
P.S: My application will be consumed by a SPA. So probably I need to test the requests of that application too, right?
With regards of what to test. You decide what is good to test, there is no direct answer. Both options you have specified are valid. You can go with integration test only , or you can go with a combination of Unit test on service/repository level + integration test on REST protocol level. It very much depends on what are you developing, but it also depends on the developers preference. In the recent years there is a tendency more and more unit test to be replaced by integration test. I personaly prefer to have a combination of both, even to the expense of some redundancy.
With regards of technology and technics:
One would be RestAsure or Spring Mvc. This will build spring boot type Of integration tests layer or as I call them integration test - light.
Pros: You can turn on and off easily different components do a fine grained testing. It can go as fine grained almost as unit test. Cons: Prone to too much technical details.
Another would be to build external suit targeting your container - tomcat / jetty.
Pros: Your testing is independent of your component/deployment. It is prettey agnostic to the component implementation.
Cons: You have two deployments effectivly , one for test one for the component to test.
Third interesting aproach would be to use Restdoc and in one shot document your api and build a full blown contract / integration test.
Pros: You get integration test + documentation in one shot.
Cons: It comes to the price of more work.