I want to test a specific method in a class named AdRestService that has some @GET, @POST, etc. I want to test it from another testing class named AdRestServiceTest. I want to know how can I call a method in AdRestService from AdRestServiceTest and how can I test if the return is ok or not.
public class AdRestService {
@GET
@Path("{id}")
@Produces("application/json")
public Ad get(@PathParam("id") Long adId) {
return adService.get(adId); // This points to the DB
}
}
Now the rest-assured testing :
public class AdRestServiceTest {
@InjectMocks
private AdRestService adRestService;
@Test
public void getAdTest() {
given().
when().
get("website.com/ad").
then().
assertThat().
statusCode(200).
and().
contentType(ContentType.JSON).
and().
// ???
// How can I call the method get(@PathParam("id") Long adId) from AdRestService and test if the return is correct ?
}
}