java


Testing async controllers using MockMvc


I have a controller that returns a DeferredResult, it is a POST.
Controller:
#RequestMapping(value = "/{customerId}/cards", method = RequestMethod.POST)
#ResponseBody
public DeferredResult<CardSummaryQuery> createCard(
#PathVariable String customerId,
#RequestBody CustomerDto payload) {
DeferredResult<CardSummaryQuery> deferred = new DeferredResult<>();
Observable<CardSummaryQuery> observable =
cardService.registerCardObservable(customerId, payload);
observable.subscribe(deferred::setResult, deferred::setErrorResult);
return deferred;
}
I am trying to test it but receiving the following error: "java.lang.AssertionError: Content type not set"
MvcResult result = mockMvc
.perform(post("/customers/55e5d-4df4r-v4fgt/cards").content(payload)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(request().asyncStarted())
.andExpect(request().asyncResult("Deferred result")).andReturn();
mockMvc.perform(asyncDispatch(result)).andExpect(jsonPath("$.success").value(true));
What can I do to solve?

Related Links

z-index of some sorts and keeping things painted in Applet
Solved: Discovered #Override but still get [I#232204a1 print output
Check if device supports Unicode?
Read alphabetically sorted textfile more efficiently
HashMap Iteration infinite loop
android : how to load haarcascade inside the raw folder in javacv?
Selenium Webdriver : Reusable xml parsing class method is not working due to return type unknown
How to implement Favorite Button to my BaseAdapter ListView?
How to parse unconventional XML files
Weird Issue reading to a TreeSet
Compare two dates in Java, without compareTo
XSSFSheet (Apache POI) sorting and filtering
OpenShift - behaviour of gears
List View Adapter with url image
How to communicate return value and validation errors to the caller of a method?
Extract JSON Value

Categories

HOME
multithreading
gitlab
hive
openmp
netsuite
cookies
nullpointerexception
mean-stack
at-command
spring-cloud-stream
spring-jdbc
sqlite3
v8
jpeg
convolution
rascal
quicklook
spring-tool-suite
quickfix
circuit
reactcsstransitiongroup
microsoft-sync-framework
social-media
.net-4.0
http-get
typed.js
catch-all
language-concepts
fusionpbx
jmonkeyengine
occlusion
twitch
theano.scan
xenforo
webdriver-manager
cookiecutter-django
particles.js
eclipse-gef
apple-news
user-accounts
dds
namecoin
specrun
yt-project
word-vba-mac
instant
url-masking
pcf
merge-conflict-resolution
superstack
ios4
revolution-r
independentsoft
historian
javax.sound.midi
vhd
teamcity-8.0
eclipse-clp
t4mvc
sankey-diagram
graph-api-explorer
dereference
umbraco6
onactivityresult
php-5.4
project-planning
uitouch
wp-query
stxxl
viadeo
gnu-smalltalk
oam
spring-io
ruby-datamapper
ftps
buster.js
chuck
dice
manchester-syntax
labwindows
transactionscope
blackberry-playbook
yetanotherforum
netbeans-7.1
locate
asp.net-mvc-areas
webkit.net
data-driven
ugc
ajax-forms
document-conversion

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App