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

Hibernate - one to one relation
How to find the index of a node based on the weight of the node in a binary search tree?
save xygraph from eclipse nebula in java
NullPointerException Exception when trying to get the value of a field in an Entity in Google App Engine
Twitter pagination for home_timeline API not working
How to find the bounds of a TypeMirror & turn them into a JavaPoet TypeSpec?
Check returned value by res is null [duplicate]
Confusing specification for creating constructors, methods and storing arrays?
protoc creates broken Java files
Stop ConcurrentTaskScheduler when spring context closed
Java: How to connect to mysql and redhsift hosted in AWS?
substituting x to an equation (Java)
Unable to access test java files from src java files
conversion of natural language text into a graphical form
Where “bpm:activitiStartTask” is used in alfresco?
How to handle dates when the input dates are in the transition period from PDT to PST?

Categories

HOME
vim
hive
cookies
heroku
comparison
fft
lodash
cplex
twitter-bootstrap-4
mvvmcross
wamp
node-notifier
esper
primary-key
gorm
kibana-4
ssl-client-authentication
windows-azure-storage
visual-studio-cordova
flask-wtforms
dynamics-crm-online
clearcase-ucm
uitypeeditor
dosgi
immutable.js
cx-freeze
web-sql
css-animations
tapestry
jndi
emgucv
buildbot
brunch
uninstall
windows-server-2000
c++-amp
file-rename
ecto
http-status-code-503
twilio-api
textmate
fusionpbx
file-format
swisscomdev
occlusion
http-live-streaming
flashair
acoustics
eclipse-gef
theming
dropbox-php
lowpass-filter
composite-key
libusb-win32
sqlbulkcopy
hittest
wdf
grails-tomcat-plugin
nsfilemanager
django-debug-toolbar
merge-conflict-resolution
moveit
fadeout
bluemix-app-scan
suffix-tree
design-by-contract
goose
freedesktop.org
cannon.js
mutation-observers
fouc
citrus-pay
arcanist
dia
c3
cdt
code-access-security
rdl
document-classification
mesa
dml
funcunit
doskey
jboss-weld
java.nio.file
imdbpy
flexmojos
ruby-datamapper
file-locking
cos
sublist
word-processor
jquery-ui-layout
gnu-prolog
subgurim-maps
blackberry-playbook
xmemcached
oncheckedchanged
remember-me
database-management
exchange-server-2003
xetex
aquaticprime
signal-handling
rtml

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile