How to redirect programatically using a route with parameters?
As pointed out by @4k4, the problem is that the module did not ask for the route parameters, so I patched it.

Then you can call the redirect like this: 

  if (!($account-&gt;hasRole('admin'))) {
    $routename = $test-&gt;getRouteName();
    $routeparameters= $test-&gt;getRouteParameters();
  }