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

How to get one “a href” out of many in one html class with jSoup
How to get Zebra USB printer status from JAVA
Attempt to invoke virtual method 'void android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' on a null object reference
How to implement a nested java interface in scala
How to send Java objects that are not defined structures in Thrift
SQL Statement and Prepared Statement error
remove dynamically added panels
How to find out where exact young/old gen is located in memory?
cancel() vs remove() on executors
Change ID in File
How can performed method setUp only once in tests
Spring - user log-in through custom controller
Spring or Tomcat: change an HTTP request to HTTPS request
Image to ByteArray to BLOB and BLOB to ByteArray to Image Conversion Issues in Java
Lazy loading children, that have eager collections inside
Use HTTP proxy to connect to a web socket

Categories

HOME
vbscript
tinymce
fft
office365api
read-eval-print-loop
electronics
twitter-bootstrap-4
google-project-tango
disassembler
blueprintjs
mouse
podio
windows-10-universal
metatrader4
node-pdfkit
postgres-xl
django-simple-history
windows-7-x64
crystal-reports-2008
scichart
immutable.js
pass-by-reference
bootstrap-tour
jndi
pingfederate
minitab
strncpy
objectanimator
google-cloud-nl
react-chartjs
uisplitview
qwerty
greenrobot-eventbus
android-tabhost
galen
g-code
reportingservices-2005
botbuilder
nomethoderror
import-from-excel
slick-3.0
executenonquery
scorm
chain-builder
filepicker
jedis
rails-routing
dotnetzip
libusb-win32
ifs
pillow
pdfclown
flutterwave
hittest
lync-client-sdk
dynamics-sl
account-kit
quartz-composer
word-vba-mac
elements
dstu2-fhir
file-writing
mikroc
qgraphicsview
thredds
citrus-pay
angular-leaflet-directive
arcanist
iiviewdeckcontroller
system.reflection
clicktag
winddk
file-copying
phalanger
codeigniter-routing
terminfo
android-radiobutton
sgen
rtmfp
farseer
eclipse-memory-analyzer
buster.js
back-stack
padarn
comaddin
mhtml
javaspaces
dbproviderfactories
netbeans-6.9
subgurim-maps
yetanotherforum
oncheckedchanged
gamequery
.nettiers
sproutcore-2
jquery-ui-droppable
asp.net-profiles
sef
mtj
zend-decorators

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile