Я хочу протестировать определенный метод в классе с именем AdRestService, который имеет некоторые @GET, @POST и т. Д. Я хочу протестировать его из другого класса тестирования с именем AdRestServiceTest. Я хочу знать, как я могу вызвать метод в AdRestService из AdRestServiceTest и как я могу проверить, в порядке ли возврат.
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
}
}
Теперь уверенное тестирование:
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 ?
}
}