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

Java code explanation needed (recursive maze solver)
When I run my program nothing shows up [closed]
How to fill an array of strings [duplicate]
Spring Data JPA with ManyToOne save operation is throwing org.hibernate.PersistentObjectException
Spring Data Mongo : BSON field name can not be null
Trouble getting an access token with Azure Media Services
Android, Butterknife, BindView, Final
Parallel using ArrayList
Jackson - deserializing Map implementation as HashMap
Java Calendar/Date Minvalue Supported on DB/Rest
#Controller doesn't work when #RestController exist
SonarLint Eclipse - Analyze all? [duplicate]
list.clone is prefered over new ArrayList(originalList)
How to get functionality like placing a scene with in a scene in JavaFx 3d
How to set camera to the canter in preview mode? Andengine Live Wallpaper
unable to deploy EAR using jython in WAS 8.0 commadline

Categories

HOME
testing
deployment
reflection
deezer
mockito
heroku
mfc
smarty
office365api
platform-builder
jira
graphql
pivotal-cloud-foundry
onelogin
convolution
mouse
session-variables
dacpac
maude-system
php-7.1
messages
hex-editors
dynamics-crm-online
caml
lombok
aurigma
crystal-reports-2008
amazonsellercentral
object-detection
riot.js
abi
excel-2007
underflow
semantic-analysis
url-scheme
virtualdub
delicious-api
karaf
noraui
perlin-noise
normal-distribution
ssjs
reportbuilder
bootstrapper
awt
optix
g-code
sencha-touch-2.3
convertapi
btrace
qsslsocket
pebble-watch
mu
recursive-datastructures
chord-diagram
wdf
android-fonts
removechild
django-debug-toolbar
simplewebrtc
livequery
revolution-r
jfugue
r-tree
reactive-banana
lib.web.mvc
marching-cubes
tarjans-algorithm
createprocessasuser
vstest.console.exe
device-orientation
c++03
offloading
oxwall
android-imagebutton
file-copying
code-access-security
rdl
contenttype
navigationservice
valuechangelistener
transcoding
centos5
uv-mapping
xsockets.net
flash-builder4.5
back-stack
interface-orientation
limejs
selected
angularjs-controller
gil
dsn
automount
multipage
online-compilation
transactionscope
gnu-prolog
blackberry-playbook
telerik-scheduler
zend-translate
gallio
forums
sector
genealogy
lzh

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