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

a prime number program that allows the user to test numbers till the user enters zero. However, after testing 6 numbers, it prints incorrect message
Runtime exception with Drools(org.drools.util.CompositeClassLoader.clone()Lorg/drools/util/CompositeClassLoader)
Cannot see Graphics added to JPanel
Java Jpanel only updating after completed code
JSOUP: set form data
Drag and Drop in selenium java
Apache httpClient modify SSLContext
How to run PHP that have WHERE ID base on other PHP at Json Android Studio
I have Tortoise SVN Repository on one PC how to connect this from another PC?
ANDROID - Remove extra space of listview header image
How to search for a Enum file type in intellij
Compilation error while overriding abstract enum method with generic return type
The restful api is always in pending state, and tomcat occurs excpetion
How to get an array list and copy elements to a new list? [duplicate]
Split a string based on the length of individual fields
Cannot read file FileNotFoundException - Access is denied

Categories

HOME
maven
pdf
client
keycloak
image-processing
view
stock
kalman-filter
jsp-tags
getelementsbytagname
maven-3
amazon-ecs
frameworks
ckeditor
mvvmcross
ios-charts
virtualization
php-7.1
spring-tool-suite
event-handling
fallback
graphlab
highlight.js
jsdoc
jtextfield
tokenize
errorlevel
tar
ehcache
jndi
claims-based-identity
status
poltergeist
bootstrap-duallistbox
subdomains
bpel
react-chartjs
catch-all
force-layout
fusionpbx
overriding
revolution-slider
plsql-psp
automake
espeak
theano.scan
jna
lumberjack
reportingservices-2005
android-mediaprojection
keydown
vao
outlook-api
businessworks
youcompleteme
upstart
jquery-nestable
theming
return-value
brightcove
np-complete
boost-preprocessor
zendesk-app
cudafy.net
jspdf-autotable
medium.com
bonobo
google-web-starter-kit
nsviewcontroller
sdf
bluegiga
qtableview
lemon
mutation-observers
content-length
pundit
wyam
rgeo
angular-leaflet-directive
vstest.console.exe
unity5.2.3
clipperlib
proj4js
skos
nstableviewcell
nsbutton
id3v2
java-metro-framework
onactivityresult
xceed-datagrid
transcoding
oam
xsockets.net
spring-io
hungarian-algorithm
free-variable
mt
nsnetservice
automount
wse3.0
qtkit
mercurial-server
zpt
external-accessory
invite
locationlistener
rfc1123
recent-documents
disclosure
mysql-error-1005
site.master
modelstate
castle-monorail
firefox-5
user-friendly
audio-capture
kdbg
javap
data-driven

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