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

How to start browser instances concurrently in JFrame based on user's input?
Android - Snackbar Cover my View
Loading resources into classpath from dynamically loaded jar [duplicate]
Clearing shared preferences in case of oAuth twitter integration in android (eclipse)
LDAP: Get list of users in a specific group
Dynamic binding can show protected methods?
How to obtain particular value from Map in a “String” format
I want ro get all article content from all links inside from an website
Why doesn't my quicksort implemented in Java work? [closed]
Data output on Console instead of GUI
Using Interface in java
Save specific value in first list and last list to SQLite
Mybatis how to dynamic create table sql in xml
why is the constant FLAG_FULLSCREEN repeated in place of int mask in the following method?
Java: Printing only the First and Last when the names that the user gave are organized alphabetically
Youtube Player API results in java.lang.NoClassDefFoundError

Categories

HOME
cakephp
pdf
webpack
zeromq
gremlin
mockito
heroku
stock
fft
sqlite-net-extensions
yahoo-oauth
analysis
malloc
frameworks
fsm
disassembler
opengl-es-2.0
virtualization
gorm
reveal.js
spring-xd
quicklook
google-cloud-ml
windows-azure-storage
phaser
conemu
css-animations
kudan
smb
kendo-datasource
c++-amp
jspresso
noraui
rotational-matrices
y86
jmonkeyengine
plsql-psp
devextreme
hockeyapp
dynamics-crm-2013
angularjs-factory
ruby-on-rails-3.1
texmaker
midl
sas-jmp
komodoedit
python-c-api
blogengine.net
datastax-startup
aurelia-validation
nativeapplication
forever
boost-preprocessor
spring-mongodb
google-cdn
root-framework
cubes
xcb
measures
bstr
make-install
pagerank
uid
javax.sound.midi
xna-4.0
qtableview
endeca-workbench
citrus-pay
ibaction
sortedlist
apache-commons-net
sorl-thumbnail
gui-test-framework
rdtsc
flask-cors
responsive-slides
funcunit
fluentautomation
kgdb
picturefill
oracle-warehouse-builder
typo3-neos
jsctypes
file-locking
referrer
simba
bitsharp
cisco-jtapi
broken-links
word-processor
viewswitcher
objective-c-2.0
wse3.0
buildr
nsdatecomponents
subgurim-maps
genshi
joyent
horizontal-accordion
inotifycollectionchanged
datareader
w3wp.exe
subviews
jquery-ui-droppable
user-friendly
simpletest
phonon
text-coloring
project-hosting
spec#
msdev
dbisam

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