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

Heapsort StackOverflow error
Spring Android not working with Gradle
Arabic value does not work in jsp servlet
JPA Sequence Generator causing ORA-01438: value larger than specified precision allowed for this column for Id column
What does Mockito.anyLong() do?
displaying the output from a serial port in JTextField
String pattern matching with regular expression in java [duplicate]
Android : GPS tracking system for find each other in a close area
is it necessary to return a different object from the getter method than the object passed by Hibernate to the setter?
Convert 2D binary matrix to black/white image in java
Unable to check for valid Login from SQLite
Android AlaramManager of android not triggering at defined time
Updating a BeanTableModel with new Data - Java
Upload to Artifactory using Java client
Preventing repetitive items from being printed [duplicate]
How to dermine if a value of type int is a match in an array?

Categories

HOME
compiler-construction
twitter
ionic-framework
pdf
date
webpack
zeromq
plot
sd-card
cvs
google-oauth
youtube-api-v3
blueprintjs
esper
maude-system
moonmail
hex-editors
decimal
solaris-10
oracle-coherence
flux
jprofiler
errorlevel
crystal-reports-2010
emgucv
smb
opennlp
status
selectedindexchanged
intel-pin
user-interaction
brunch
filezilla
maquette
jspm
jaxb2
google-cloud-nl
srcset
tinymce-4
iframe-resizer
xquery-3.0
airconsole
webtest
vsts-build-task
xmlreader
atl
host
wixsharp
suricata
vxworks
simplexml
gesture
abstract-class
sharefile
c11
ssjs
cookiecutter-django
parentheses
youcompleteme
pnotify
gabor-filter
svmlight
colorama
flow-control
setuptools
bonobo
google-web-starter-kit
essence
sdf
dlna
fadeout
yaws
ford-fulkerson
natvis
maven-tomcat-plugin
lemon
php-ci
pretty-print
inmobi
javax.mail
qcodo
zend-route
responsive-slides
uitouch
mbr
ccss
jmapviewer
apc
jelly
referrer
hamiltonian-cycle
dice
datawindow
newtonscript
osql
recent-documents
locate
android-sdk-2.1
imac
xfbml
yslow
nsviewanimation
ext3
perfect-hash
ncqrs
thunderbird-lightning
ti-dsp
yagni
caching-application-block

Resources

Encrypt Message