Object result = template.requestBody("direct:noWriteConcern", "{\"scientist\":\"newton\"}");
assertTrue("Result is not of type WriteResult", result instanceof WriteResult);
WriteResult wr = (WriteResult) result;
WriteConcern wc = wr.getLastConcern();
// check the WriteConcern's behaviour
if (wc.callGetLastError()) {
assertNotNull(wr.getCachedLastError());
} else {
assertNull(wr.getCachedLastError());
}
CommandResult cr = wr.getLastError();