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

Hibernate session.createQuery().getResultList() returns null
put data to hashmap without overwrite
How to create RecordN for generated DAO lookup
Java 8: Map instead of simple loop
Detecting when an integer is made up of only the same digit
How to default an EditText to integer but allow decimal input?
Prime numbers no loop no recursive
JMX polling or TCP Pushing: What is better?
how can I stop the execution of the while loop with a keyboard input?
Profile neo4j database hits using java
Big O notation and not understading from class lecture
(javafx) I'm currently making an app which requires people to create an account, how can i make sure the texts fields aren't null?
Where file created in NetBeans
Can I force liquibase 3.5.1 to ignore legacy changeset checksum differences?
NoSuchBeanDefinitionException: No qualifying bean of type [duplicate]
how to add authorization in cxf

Categories

HOME
arduino-uno
vim
pdf
zeromq
gremlin
plot
iterator
read-eval-print-loop
q
google-oauth
enterprise-library-5
bs4
synchronization
maude-system
carthage
vaadin7
progressive-web-apps
transformation
emulator
opencover
csrf-protection
kvc
claims-based-identity
lcd
pepper
greendao
minitab
jaxb2
vision
kendo-datasource
flink-streaming
galsim
oracle-fusion-middleware
uiswipegesturerecognizer
geopositioning
wallpaper
force-layout
disassembling
bitbucket-pipelines
automake
abstract-class
sharefile
twitch
android-fingerprint-api
squib
mesos-chronos
texmaker
logfiles
zip4j
multipeer-connectivity
blogengine.net
datastax-startup
sage-one
integrity
jxcore
pillow
epson
mako
flow-control
synchronous
visual-c++-2008
gridpane
etsy
hover-over
natvis
jfugue
unity-networking
maven-tomcat-plugin
icu4j
quicklisp
ionic
oberon
dundas
p2
java.util.concurrent
codeigniter-routing
dealloc
concurrent-collections
dataadapter
errai
objective-c-2.0
punbb
cinema-4d
sudzc
gin
zend-tool
avatar
zend-decorators
thread-local-storage
spec#
scripting-languages

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