citrus framework - Extract and unmarshal JSON payload from response -


i'm trying write citrus tests restful endpoint producing , consuming application/json content, , i'm not sure how responses unmarshalled java pojo (using jackson or whatever (un)marshaller citrus supports).

e.g. in rest-assured, can write

uploadresponse response = when().post("/file").as(uploadresponse.class); 

is there equivalent in citrus?

i can find examples using validate() or extractfrompayload(), don't cover use case, since don't want operate on scalar members embed entire response object in request object subsequent test step.

you can this:

http().server(testserver)       .post("/file")       .validationcallback(new jsonmappingvalidationcallback<uploadresponse>(uploadresponse.class) {             @override             public void validate(uploadresponse payload, map<string, object> headers, testcontext context) {                 // payload object             }       }); 

the jsonmappingvalidationcallback automatically searches json objectmapper in spring bean application context. can provide objectmapper instance constructor arg jsonmappingvalidationcallback.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -