SystemCtl { public SystemCtl withSudo() { this.useSudo = true; return this; } SystemCtl(Terminal terminal); SystemCtl withSudo(); boolean useSudo(); void daemonReload(TaskContext taskContext); SystemCtlEnable enable(String unit); SystemCtlDisable disable(String unit); SystemCtlStart start(String unit); SystemCtlStop stop(String unit); SystemCtlRestart restart(String unit); boolean serviceExists(TaskContext context, String unit); boolean isActive(TaskContext context, String unit);  }
@Test public void withSudo() { SystemCtl systemCtl = new SystemCtl(terminal).withSudo(); terminal.expectCommand("sudo systemctl restart docker 2>&1", 0, ""); assertTrue(systemCtl.restart("docker").converge(taskContext)); }