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

Android Studio E/dalvikvm: Could not find class… referenced from method
Spring JDBC - .queryForObject() returns too many results?
how to mask out “USE INDEX” in MySQL query running on h2
Ignore a column when using kmeans with mahout
Libgdx error loading atlas file
Convert $16500.00 String to 16500 Integer
Remote EJB call vs Local EJB call performance in same JVM
How to use a different class from an application's activity?
Neo4j Java API: GC overhead limit exceeded after running multiple queries
Java: OpenCL calls don't work inside Parallels Window VM
Persist always generates an insert query
How to refactor two complex classes with a lot of similar methods?
Compare two strings that contain a date to check if one is before or after the other
ERROR: Error during Sonar runner execution [closed]
NullPointerException for some reason [duplicate]
SharedPreferences helper class

Categories

HOME
sendgrid
vim
pdf
jdo
blogger
rdf
win32gui
fsm
windows-server
ios-charts
amazon-cloudformation
node-pdfkit
etl
postgres-xl
decimal
jsdoc
contextmenu
jtextfield
custom-wordpress-pages
object-detection
graphicsmagick
excel-2007
mustache.php
chromium-embedded
format-specifiers
p-value
maxmind
neo4j-spatial
webkitspeechrecognition
gsmcomm
phonegap
catel
repo
android-nestedscrollview
google-api-nodejs-client
mapdb
revolution-slider
espeak
streamsets
service-discovery
sharefile
az-application-insights
webix-treetable
hue
sas-visual-analytics
dotcover
dandelion
svmlight
tactic
windows-mobile-6.5
flutterwave
jspdf-autotable
django-scheduler
account-kit
spring-android
login-control
connect-by
holder.js
actionbardrawertoggle
superstack
associative-array
pyke
cloudbees
kendonumerictextbox
tcpserver
spim
r-tree
wso2cloud
coveralls
microbenchmark
dereference
pick
knuth
cdt
file-copying
markers
document-classification
mesa
starcluster
mysql-error-1062
braille
rtmfp
picturefill
bundles
java.nio.file
mbr
seed
limejs
anonymous-methods
browser-detection
funscript
gdata-api
windows-phone-7.1.1
hgsubversion
gnustep
pydot
vdsp
subgurim-maps
lang
web-application-design
sef
gacutil
mediarss
post-build





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