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 marker setVisible(false) didn't works
I want to achieve something like multiple circularimageview's overlapping each other, just like the google plus community page [closed]
Platforms for game
Fresco isn't updating Image
How to define a unidirectional OneToMany JPA relationship without any cascade?
How does the output of the following code change if i change f from int to double?
How to call a method by the order of parameters in OOP?
JTable edting mode
Restricting access to particular directory in java
Magnify Y axis in Java Mission Control charts
Starting a class in Java, but different
Allowing clients to talk to the server in order
Using Variables - Java Eclipse
Convert PCM to MP3 in Java (Using Tritonus)
Combining #Secured and #PreAuthorize annotation on one method
Kotlin lateinit correspondent java

Categories

HOME
java
tizen
mfc
appx
syntax
routes
bookshelf.js
setup-deployment
baqend
enterprise-library-5
echarts
amazon-cloudformation
metatrader4
static-libraries
zebra-printers
openrefine
tostring
nodatime
introduction
swingx
autosys
blazemeter
user-interaction
brunch
fluentvalidation
strncpy
assistant
buck
libuv
quote
fabric8
google-qpx-express-api
kendo-ui-grid
asset-pipeline
atl
html5-fullscreen
io-redirection
gesture
vapor
ansible-playbook
email-templates
pdf-reactor
grid.mvc
google-closure
http-redirect
thin
boost-multi-index
ionicons
git-diff
tropo
lowpass-filter
forever
typed-lambda-calculus
r-forge
flow-control
eventkit
nxt
adxstudio-portals
multi-level
measures
websitepanel
holder.js
testng-dataprovider
freedesktop.org
separator
execute
endeca-workbench
angular-leaflet-directive
ios9.1
apache-commons-net
c3
qpainter
rdtsc
dml
navigationservice
xceed-datagrid
algebraic-data-types
java.nio.file
ivyde
orchardcms-1.7
kyotocabinet
itmstransporter
nsmanagedobject
subgurim-maps
pyinotify
sql-server-profiler
nhibernate.search
ctp4
noscript
spec#
ntvdm.exe

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