ResultHandler.print() undefined - spring

How come ResultHandler.print() is undefined? My Spring version is 3.2.5.RELEASE.
I am using it as
this.mockMvc.perform()...andDo(print());

print() is defined on MockMvcResultHandlers not on ResultHandler
From the documentation:
* static imports: MockMvcRequestBuilders.*, MockMvcResultHandlers.*
*
* mockMvc.perform(get("/form")).andDo(print());

Related

testReport destinationDir is deprecated in gradle 7.4.2 so how to set it?

task<TestReport>("testReport") {
destinationDir = file("$buildDir/reports/allTests")
}
This is apparently deprecated, but the deprecation message doesn't make sense to me in this context. How am I actually supposed to set this value now?
/**
* Sets the directory to write the HTML report to.
*
* <strong>This method will be {#code #Deprecated} soon, please use {#link #getTestResults()} instead to access the new collection property.</strong>
*/
public void setDestinationDir(File destinationDir) {
DeprecationLogger.deprecateProperty(TestReport.class, "destinationDir").replaceWith("destinationDirectory")
.willBeRemovedInGradle8()
.withDslReference()
.nagUser();
getDestinationDirectory().set(destinationDir);
}
Please try like this.
Older version:
destinationDir = file("$buildDir/reports/tests/test")
With latest version:
getDestinationDirectory().set(file("$buildDir/reports/tests/test"))
It worked for me. Hope it'll work for you. Thanks

Unable to write unit test for Spring #Scheduler

I have implemented a scheduler with shedlock in my current spring project as follows:
#Scheduled(cron = "0 0/1 * * * *")
#SchedulerLock(name = "syncData",
lockAtMostFor = "${shedlock.myScheduler.lockAtMostFor}",
lockAtLeastFor = "${shedlock.myScheduler.lockAtLeastFor}")
public void syncSAData() {
//To assert that the lock is held
LockAssert.assertLocked();
...
}
Now I would like to write unit test for this function. Here the problem I am facing is: I am unable to mock first statement: LockAssert.assertLocked().
This should do the trick LockAssert.TestHelper.makeAllAssertsPass(true);
Just add it at the beginning of the test method.
Docs: https://github.com/lukas-krecan/ShedLock#lock-assert

_route parameter from Request is null with a custom operation

In my Event plugged on KernelEvents::RESPONSE => EventPriorities::PRE_READ when I check the _route attribute in a custom operation I received null as _route
I'm running a SF 4.2.7 and api-platform/core 2.3.4 and api-platform/api-pack 1.1.0
There is my entity annotation for this operation
subresourceOperations={
* "validate_user"={
* "path"="/legal_documents/{id}/validate",
* "method"="PUT",
* "controller"=LegalDocumentValidate::class
* }
* }
And there's the Controller annotation
#Route(
* name="api_legal_documents_validate_user",
* path="/legal_documents/{id}/validate",
* methods={"PUT"},
* defaults={
* "_api_resource_class"=LegalDocument::class,
* "_api_item_operation_name"="validate_user"
* }
* )
In my EventSubscriber when I dump the _route parameter I have null and a second dump with the good value, it's only with the custom operations, if I try on a operation handle by api-platform I have only 1 dump which shows the good value
It was caused by an exception triggered before the event who was dumping the _route attribute
When you're in a Exception Event the route appears to be null

VSCode - Reference a type of a module from JS

Using Visual Studio Code for JS programming I can access some features from typescript; since the editor will parse all .d.ts files around, it'll help me with variable types. For example it does recognize the following:
any.js
/**
* #param {string} s
* #return {Promise<Person>}
*/
function foo(s){ ... }
foo('Jhon').then((p) => p.name )
index.d.ts
interface Person {
name: string
surname: string
}
Now, I want to access types (interfaces, classes... whatever) declared in node.d.ts declaration file; for example it declares the module stream which declares the Readable interface.
I'm looking for something like this:
const stream = require('stream')
/**
* #param {stream.Readable} stream
*/
function goo(stream) { ... }
But that does not work.I've tried with:
{internal.Readable}
{stream.Readable}
{Node.stream.Readable}
{Node.Readable}
{Node.internal.Readable}
As of VS Code 1.18, this is a limitation when using require with JSDoc types. I've opened this issue to track this specifically
Some possible workarounds:
Use import:
import * as stream from 'stream'
/**
* #param {stream.Readable} stream
*/
function goo(stream) { ... }
or import Readable explicitly:
const stream = require('stream')
const {Readable} = require('stream')
/**
* #param {Readable} stream
*/
function goo(stream) { ... }
https://github.com/Microsoft/TypeScript/issues/14377 also tracks allowing you to specify module imports in jsdocs directly.

Error with undefined method CI_Loader::plugin()

I received the following error:
Call to undefined method CI_Loader::plugin() in C:\wamp\www\Code\application\libraries\DX_Auth.php on line 1233
on this code:
function captcha()
{
$this->ci->load->helper('url');
$this->ci->load->plugin('dx_captcha');
$captcha_dir = trim($this->ci->config->item('DX_captcha_path'), './');
Make sure you have moved any array values in application/config/autoload.php from $autoload[‘plugins’] to $autoload[‘helpers’] or you will notice stuff break.
This is the reference
Which version of CI are you using? Plugins has been removed since the 2.x and replaced with helper.
Try to use reCaptcha instead, it has a good library.
You're trying to load a plugin and plugins are not supported, if I remember it right since CI version 2. If that's the case (which seems to be) you need to convert your plugins into helpers.
I think you are trying to use an old version of DX_Auth on new version of CodeIgniter. Current version of DX_Auth is compatible with CI 2.x and is available on github.
A simple way to solve this problem is that you just put this code in your loader.php. The plugin its works. Go to System->Core->Loader.php.
/**
* Load Plugin
*
* This function loads the specified plugin.
*
* #access public
* #param array
* #return void
*/
function plugin($plugins = array())
{
if ( ! is_array($plugins))
{
$plugins = array($plugins);
}
foreach ($plugins as $plugin)
{
$plugin = strtolower(str_replace(EXT, '', str_replace('_pi', '', $plugin)).'_pi');
if (isset($this->_ci_plugins[$plugin]))
{
continue;
}
if (file_exists(APPPATH.'plugins/'.$plugin.EXT))
{
include_once(APPPATH.'plugins/'.$plugin.EXT);
}
else
{
if (file_exists(BASEPATH.'plugins/'.$plugin.EXT))
{
include_once(BASEPATH.'plugins/'.$plugin.EXT);
}
else
{
show_error('Unable to load the requested file: plugins/'.$plugin.EXT);
}
}
$this->_ci_plugins[$plugin] = TRUE;
log_message('debug', 'Plugin loaded: '.$plugin);
}
}
// --------------------------------------------------------------------
/**
* Load Plugins
*
* This is simply an alias to the above function in case the
* user has written the plural form of this function.
*
* #access public
* #param array
* #return void
*/
function plugins($plugins = array())
{
$this->plugin($plugins);
}

Resources