Então … eu comecei a fazer aqui mas não deu muito certo. Agora que você se propôs a dar um help vou tentar novamente…
Sorry, eu não entendi o que você disse aqui
[quote=Lucas Cavalcanti]
não lembro de ter visto esse mock, mas se quiser ajuda pra implementar dá um toque, e se quiser fazer um pull request seria muito bem vindo =)[/quote]
Legal!!
Você recomenda levar essa discussão para uma PullRequest ou deixar por aqui mesmo?
Eu pensei em fazer no meu mock:
result = new MockSerializationResult();
myController = new MyController(result);
...
myController.doStuff();
String json = result.serializedResult();
MyController#doStuff:
@Get
@Path("doStuff")
public void getData(String itemName){
...
result.use(Results.http()).addHeader("Content-Type", "application/json").body(json);
}
Porém, debugando a classe MockSerialization, percebi que o response.getContentType() não foi setado ao fazer addHeader(“Content-Type”, “application/json”). Tenho a impressão que as responses ou o tempo que elas são usadas não são o mesmo:
/**
* Retrieve the string with the serialized (JSON/XML) Object if have one as response.
*
* @return String with the object serialized
*/
public String serializedResult() throws Exception {
if("application/xml".equals(response.getContentType())){
return response.getContentAsString();
}
if("application/json".equals(response.getContentType())){
return response.getContentAsString();
}
return null;
}