### Question:
DropScriptCommand extends AbstractCclCommand { @Override public void run(final CclCommandTerminal terminal) { final EtmPoint point = PointFactory.getPoint(getClass(), "run"); try { try { terminal.executeCommands(new JSchSshTerminal(), Collections.singletonList("drop program " + scriptName + " go"), false); } catch (final SshException e) { throw new CclCommandException("Dropping script " + scriptName + " failed.", e); } } finally { point.collect(); } } DropScriptCommand(final String scriptName); @Override void run(final CclCommandTerminal terminal);  }### Answer:
@Test public void testRun() throws Exception { final EtmPoint point = mock(EtmPoint.class); mockStatic(PointFactory.class); when(PointFactory.getPoint(DropScriptCommand.class, "run")).thenReturn(point); final JSchSshTerminal sshTerminal = mock(JSchSshTerminal.class); whenNew(JSchSshTerminal.class).withNoArguments().thenReturn(sshTerminal); final CclCommandTerminal cclTerminal = mock(CclCommandTerminal.class); command.run(cclTerminal); verify(cclTerminal).executeCommands(sshTerminal, Collections.singletonList("drop program " + scriptName + " go"), false); verify(point).collect(); }
@Test public void testRunSshException() throws Exception { final CclCommandTerminal cclTerminal = mock(CclCommandTerminal.class); final JSchSshTerminal sshTerminal = mock(JSchSshTerminal.class); whenNew(JSchSshTerminal.class).withAnyArguments().thenReturn(sshTerminal); doThrow(new SshException("uh-oh!")).when(cclTerminal).executeCommands(ArgumentMatchers.<JSchSshTerminal> any(), ArgumentMatchers.<List<String>> any(), anyBoolean()); CclCommandException e = assertThrows(CclCommandException.class, () -> { command.run(cclTerminal); }); assertThat(e.getMessage()).isEqualTo("Dropping script " + scriptName + " failed."); }