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

Build, clean issue with android studio
Do not concatenate text displayed with setText issue + App crashing when other language than default lang is used
Extract PDF file in java and render as HTML
How to handle the JAVA WatchService Overflow event?
Traveling on A Triangle - syntaxt error
save generic type of List in SharePreference
Getting a 404 error when using java servlet/filter
SonarQube: uploading Cobertura results using Maven
How do I inject a value from Properties file to a field of an existing instance (not managed by Spring) using Spring annotations?
Extending java configuration in spring
Spring Web Flow - Handle concurrent access
Use default and custom liquibase configurations in spring boot application
creating new excel rows when the column reaches a specific number
JSch cumulatively causes Oracle JVM to grab all file handles and all memory on machine - Centos 7 - Java SE 1.8
Change cursor in JavaFx for long operations implemented for multiple background actions
Read external property files from JBoss server using Spring framework

Categories

HOME
maven
compiler-construction
ionic-framework
coq
webstorm
mean-stack
gis
amazon-ecs
baqend
echarts
reveal.js
export-to-csv
graphlab
ab-testing
nodatime
predix
intentfilter
google-search-api
fluentvalidation
windowbuilder
quote
google-cloud-nl
stormpath
iframe-resizer
oracle-fusion-middleware
http-get
kendo-ui-grid
mpmediaquery
git-merge
swift3.0.2
galen
sql-server-agent
acoustics
.net-4.6.2
businessworks
websphere-mq-fte
hendrix
colorama
kbuild
feeds
memory-alignment
orthogonal
gnome-shell-extensions
cubes
time-and-attendance
heidisql
libpng
sts-springsourcetoolsuite
impresspages
master-slave
python-stackless
dlna
php-parse-error
xpath-1.0
xna-4.0
qtableview
lemon
quicklisp
apache-commons-fileupload
typekit
qcodo
titanium-modules
rdl
heisenbug
valueconverter
rtmfp
xamlparseexception
plasma
specification-pattern
funscript
bluepill
viewswitcher
objective-c-2.0
appconkit
chrono
reddot
iphone-web-app
google-friend-connect
routedevent
ext3
firefox-5
substrings
mdac
multiple-languages
wsdl.exe
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