@Test public void executeDelegatesToExecutableWithTimeout() throws IOException, InterruptedException { String response = "Success!"; int timeout = 1000; String terraformCommand = "terraform init "; Executable executable = Mockito.mock(Executable.class); Mockito.when(executable.execute(terraformCommand, timeout)).thenReturn(response); TerraformCommandLineDecorator terraform = new TerraformCommandLineDecorator(TerraformCommand.INIT, executable); String output = terraform.execute("", timeout); Assert.assertEquals(response, output); Mockito.verify(executable, Mockito.times(1)).execute(terraformCommand, timeout); }
@Override public String execute(String command, int timeout) throws IOException, InterruptedException { return commandLine.execute(getTerraformCommand(command), timeout); }
TerraformCommandLineDecorator implements Executable { @Override public String execute(String command, int timeout) throws IOException, InterruptedException { return commandLine.execute(getTerraformCommand(command), timeout); } }
TerraformCommandLineDecorator implements Executable { @Override public String execute(String command, int timeout) throws IOException, InterruptedException { return commandLine.execute(getTerraformCommand(command), timeout); } TerraformCommandLineDecorator(TerraformCommand cmd, Executable commandLine, Logger logger);  TerraformCommandLineDecorator(TerraformCommand cmd, Executable commandLine);  TerraformCommandLineDecorator(TerraformCommand cmd, Logger logger);  TerraformCommandLineDecorator(TerraformCommand cmd);  TerraformCommandLineDecorator(TerraformCommand cmd, String tfRootDir); }
TerraformCommandLineDecorator implements Executable { @Override public String execute(String command, int timeout) throws IOException, InterruptedException { return commandLine.execute(getTerraformCommand(command), timeout); } TerraformCommandLineDecorator(TerraformCommand cmd, Executable commandLine, Logger logger);  TerraformCommandLineDecorator(TerraformCommand cmd, Executable commandLine);  TerraformCommandLineDecorator(TerraformCommand cmd, Logger logger);  TerraformCommandLineDecorator(TerraformCommand cmd);  TerraformCommandLineDecorator(TerraformCommand cmd, String tfRootDir); @Override String execute(String command, int timeout); @Override String execute(String command); @Override void setLogger(Logger logger); Executable getCommandLine(); }
TerraformCommandLineDecorator implements Executable { @Override public String execute(String command, int timeout) throws IOException, InterruptedException { return commandLine.execute(getTerraformCommand(command), timeout); } TerraformCommandLineDecorator(TerraformCommand cmd, Executable commandLine, Logger logger);  TerraformCommandLineDecorator(TerraformCommand cmd, Executable commandLine);  TerraformCommandLineDecorator(TerraformCommand cmd, Logger logger);  TerraformCommandLineDecorator(TerraformCommand cmd);  TerraformCommandLineDecorator(TerraformCommand cmd, String tfRootDir); @Override String execute(String command, int timeout); @Override String execute(String command); @Override void setLogger(Logger logger); Executable getCommandLine();  }