@Override
public State execute(State state, List<String> parameters, Writer outputWriter) throws IOException {
+ if (parameters.isEmpty()) {
+ return state;
+ }
Integer index = Ints.tryParse(parameters.get(0));
if ((index != null) && (index < state.getLastResults().size())) {
core.fetch(state.getLastResults().get(index).bot(), state.getLastResults().get(index).pack());
--- /dev/null
+package net.pterodactylus.xdcc.ui.stdin
+
+import net.pterodactylus.xdcc.core.Core
+import org.hamcrest.MatcherAssert.assertThat
+import org.hamcrest.Matchers.equalTo
+import org.mockito.Matchers.any
+import org.mockito.Mockito
+import org.mockito.Mockito.never
+import org.mockito.Mockito.verify
+import java.io.StringWriter
+import kotlin.test.Test
+
+class DownloadCommandTest {
+
+ private val core = Mockito.mock(Core::class.java)
+ private val command = DownloadCommand(core)
+ private val state = State()
+
+ @Test
+ fun `executing command without parameters will not fetch anything`() {
+ command.execute(state, emptyList(), StringWriter())
+ verify(core, never()).fetch(any(), any())
+ }
+
+ @Test
+ fun `executing command without parameters will return old state`() {
+ val newState = command.execute(state, emptyList(), StringWriter())
+ assertThat(newState, equalTo(state))
+ }
+
+}