Я хочу закрепить спецификацию конечной точки отдыха в модульном тесте без каких-либо насмешек. Возможно ли это?
У меня есть очень простой сервис JAX-RS, использующий Jersey и Jackson, который просто предоставляет базовый сервисный компонент.
Код: Выделить всё
@POST
@Path("/call")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public OutputDTO call(InputDTO input) {
return service.call(input);
}
Код: Выделить всё
service.call()
I would like to have a unittest, that only checks:
- that there is an endpoint under
Код: Выделить всё
"/call"
- it consumes a json with certain fields
- it produces a json with certain fields
It seems that the standard way of doing this, is to mock the service, to put in example data and check if it is returning the mocked result.
I am thinking of something simpler that works this way:
Код: Выделить всё
e = getEndpointSpecification("/call")
ispec = e.getInputBodySpecification()
assertThat ispec defines a field named "A" that takes a isodate
ospec = e.getOutputBodySpecification()
assertThat ospec defines a json object
assertThat ospec defines a field named "B" that is a string
Источник: https://stackoverflow.com/questions/781 ... and-output