@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testRun() throws Exception { final String buildCommand = "build step"; final ScriptExecutionBuilder builder = mock(ScriptExecutionBuilder.class); when(builder.build()).thenReturn(Collections.singleton(buildCommand)); final JSchSshTerminal sshTerminal = mock(JSchSshTerminal.class); whenNew(JSchSshTerminal.class).withNoArguments().thenReturn(sshTerminal); final CclCommandTerminal cclTerminal = mock(CclCommandTerminal.class); final ScriptExecutionCommand command = new ScriptExecutionCommand(builder, false); command.run(cclTerminal); final ArgumentCaptor<List> commandCaptor = ArgumentCaptor.forClass(List.class); verify(cclTerminal).executeCommands(eq(sshTerminal), commandCaptor.capture(), eq(false)); assertThat(commandCaptor.getValue()).containsOnly(buildCommand); }
@Override public void run(final CclCommandTerminal terminal) { final EtmPoint point = PointFactory.getPoint(getClass(), "run"); try { final Collection<String> declarations = getRecordStructureDeclarations(); final Collection<String> setters = getRecordStructureSetterCommands(); final Collection<String> executionCommands = builder.build(); final Collection<RecordDataExtractor> extractors = getDataExtractors(); final List<String> commandQueue = new ArrayList<String>(executionCommands.size() + 3 * extractors.size()); commandQueue.addAll(declarations); commandQueue.addAll(setters); commandQueue.addAll(executionCommands); for (final RecordDataExtractor extractor : extractors) commandQueue.addAll(extractor.getExtractionCommands()); try { terminal.executeCommands(new JSchSshTerminal(), commandQueue, authenticate); } catch (final SshException e) { throw new CclCommandException("Execution of script " + builder.getScriptName() + " failed.", e); } for (final RecordDataExtractor extractor : extractors) try { extractor.extractRecordData(); } catch (final IOException e) { throw new CclCommandException(String.format("Failed to extract record data for record %s.", extractor.getRecord().getName()), e); } } finally { point.collect(); } }
ScriptExecutionCommand extends AbstractCclCommand { @Override public void run(final CclCommandTerminal terminal) { final EtmPoint point = PointFactory.getPoint(getClass(), "run"); try { final Collection<String> declarations = getRecordStructureDeclarations(); final Collection<String> setters = getRecordStructureSetterCommands(); final Collection<String> executionCommands = builder.build(); final Collection<RecordDataExtractor> extractors = getDataExtractors(); final List<String> commandQueue = new ArrayList<String>(executionCommands.size() + 3 * extractors.size()); commandQueue.addAll(declarations); commandQueue.addAll(setters); commandQueue.addAll(executionCommands); for (final RecordDataExtractor extractor : extractors) commandQueue.addAll(extractor.getExtractionCommands()); try { terminal.executeCommands(new JSchSshTerminal(), commandQueue, authenticate); } catch (final SshException e) { throw new CclCommandException("Execution of script " + builder.getScriptName() + " failed.", e); } for (final RecordDataExtractor extractor : extractors) try { extractor.extractRecordData(); } catch (final IOException e) { throw new CclCommandException(String.format("Failed to extract record data for record %s.", extractor.getRecord().getName()), e); } } finally { point.collect(); } } }
ScriptExecutionCommand extends AbstractCclCommand { @Override public void run(final CclCommandTerminal terminal) { final EtmPoint point = PointFactory.getPoint(getClass(), "run"); try { final Collection<String> declarations = getRecordStructureDeclarations(); final Collection<String> setters = getRecordStructureSetterCommands(); final Collection<String> executionCommands = builder.build(); final Collection<RecordDataExtractor> extractors = getDataExtractors(); final List<String> commandQueue = new ArrayList<String>(executionCommands.size() + 3 * extractors.size()); commandQueue.addAll(declarations); commandQueue.addAll(setters); commandQueue.addAll(executionCommands); for (final RecordDataExtractor extractor : extractors) commandQueue.addAll(extractor.getExtractionCommands()); try { terminal.executeCommands(new JSchSshTerminal(), commandQueue, authenticate); } catch (final SshException e) { throw new CclCommandException("Execution of script " + builder.getScriptName() + " failed.", e); } for (final RecordDataExtractor extractor : extractors) try { extractor.extractRecordData(); } catch (final IOException e) { throw new CclCommandException(String.format("Failed to extract record data for record %s.", extractor.getRecord().getName()), e); } } finally { point.collect(); } } ScriptExecutionCommand(final String scriptName, final List<Argument> arguments, final boolean authenticate);  ScriptExecutionCommand(final ScriptExecutionBuilder executionBuilder, final boolean authenticate); }
ScriptExecutionCommand extends AbstractCclCommand { @Override public void run(final CclCommandTerminal terminal) { final EtmPoint point = PointFactory.getPoint(getClass(), "run"); try { final Collection<String> declarations = getRecordStructureDeclarations(); final Collection<String> setters = getRecordStructureSetterCommands(); final Collection<String> executionCommands = builder.build(); final Collection<RecordDataExtractor> extractors = getDataExtractors(); final List<String> commandQueue = new ArrayList<String>(executionCommands.size() + 3 * extractors.size()); commandQueue.addAll(declarations); commandQueue.addAll(setters); commandQueue.addAll(executionCommands); for (final RecordDataExtractor extractor : extractors) commandQueue.addAll(extractor.getExtractionCommands()); try { terminal.executeCommands(new JSchSshTerminal(), commandQueue, authenticate); } catch (final SshException e) { throw new CclCommandException("Execution of script " + builder.getScriptName() + " failed.", e); } for (final RecordDataExtractor extractor : extractors) try { extractor.extractRecordData(); } catch (final IOException e) { throw new CclCommandException(String.format("Failed to extract record data for record %s.", extractor.getRecord().getName()), e); } } finally { point.collect(); } } ScriptExecutionCommand(final String scriptName, final List<Argument> arguments, final boolean authenticate);  ScriptExecutionCommand(final ScriptExecutionBuilder executionBuilder, final boolean authenticate); void addWithReplace(final String recordName, final Record record); @Override void run(final CclCommandTerminal terminal); }
ScriptExecutionCommand extends AbstractCclCommand { @Override public void run(final CclCommandTerminal terminal) { final EtmPoint point = PointFactory.getPoint(getClass(), "run"); try { final Collection<String> declarations = getRecordStructureDeclarations(); final Collection<String> setters = getRecordStructureSetterCommands(); final Collection<String> executionCommands = builder.build(); final Collection<RecordDataExtractor> extractors = getDataExtractors(); final List<String> commandQueue = new ArrayList<String>(executionCommands.size() + 3 * extractors.size()); commandQueue.addAll(declarations); commandQueue.addAll(setters); commandQueue.addAll(executionCommands); for (final RecordDataExtractor extractor : extractors) commandQueue.addAll(extractor.getExtractionCommands()); try { terminal.executeCommands(new JSchSshTerminal(), commandQueue, authenticate); } catch (final SshException e) { throw new CclCommandException("Execution of script " + builder.getScriptName() + " failed.", e); } for (final RecordDataExtractor extractor : extractors) try { extractor.extractRecordData(); } catch (final IOException e) { throw new CclCommandException(String.format("Failed to extract record data for record %s.", extractor.getRecord().getName()), e); } } finally { point.collect(); } } ScriptExecutionCommand(final String scriptName, final List<Argument> arguments, final boolean authenticate);  ScriptExecutionCommand(final ScriptExecutionBuilder executionBuilder, final boolean authenticate); void addWithReplace(final String recordName, final Record record); @Override void run(final CclCommandTerminal terminal);  }