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

AndEndine - PhysicsBox2D - gravity and collision with different sprite/bodytype
Drawing Graphics From multiple classes?
How can I make the input change which string is being set?
The “execution” in Spring AOP
Oracle WebLogic EAR Extensions facet not being added to my web service
Dialog preference with radio buttons
Comparing “objects allocated” in a JVisualVM snapshot to number of instances in a Java heap dump
Why do we pass objects as arguments in java?
Currently running stored procedures
Restart service in Linux when a process reaches certain memory size
What does it mean “Data-normalized”?
Sending an email via Google Groups
Large writes cause instability in Cassandra ring
searching from database and showing the output
Formatting output in java assistance
How to get text from span class in selenium

Categories

HOME
yii2
asp.net-core
deployment
kde
relative-path
vmware
routes
google-docs
cross-browser
django-imagekit
podio
swagger-ui
awesome-wm
gnupg
spring-kafka
zend-framework3
phaser
uitypeeditor
ab-testing
interop
google-pagespeed
kryo
visjs
csrf-protection
dcevm
firebase-crash-reporting
crosstab
xpages-ssjs
javacv
semantic-analysis
django-storage
facebook-access-token
gsoap
google-rich-snippets
yadcf
column-family
disassembling
x11-forwarding
sharefile
reportbuilder
sqlite2
unobtrusive-validation
hue
sfdc
texmaker
firebase-admin
vao
dropbox-php
lowpass-filter
darcs
jxcore
knpmenubundle
gnome-shell-extensions
removechild
intrusion-detection
mikroc
login-control
blackberry-10
sdf
uid
hsv
separator
google-places
angular-leaflet-directive
sortedlist
streambase
modalpopup
nsbutton
project-planning
jquery-layout
java.nio.file
dotnetnuke-5
django-nonrel
kyotocabinet
e4x
typoscript2
jspinclude
libc++
hamachi
cinema-4d
sudzc
firefox-5

Resources

Encrypt Message