Commits

Sam Adams  committed a71914d

Added stub deposit-cif command

  • Participants
  • Parent commits 578490d

Comments (0)

Files changed (4)

File src/main/java/uk/ac/cam/ch/wwmm/quixote/client/QuixoteCLI.java

-package uk.ac.cam.ch.wwmm.quixote.client;
-
-import net.chempound.client.cli.ChempoundClientCLI;
-
-/**
- * @author Sam Adams
- */
-public class QuixoteCLI extends ChempoundClientCLI {
-
-    public static void main(String[] args) {
-        QuixoteCLI quixoteCLI = new QuixoteCLI();
-        quixoteCLI.runMain(args);
-    }
-
-}

File src/main/java/uk/ac/cam/ch/wwmm/quixote/client/QuixoteClientCLI.java

+package uk.ac.cam.ch.wwmm.quixote.client;
+
+import com.beust.jcommander.JCommander;
+import net.chempound.client.cli.ChempoundClientCLI;
+import net.chempound.client.cli.command.Command;
+import uk.ac.cam.ch.wwmm.quixote.client.cif.DepositCifCommand;
+
+/**
+ * @author Sam Adams
+ */
+public class QuixoteClientCLI extends ChempoundClientCLI {
+
+    public static void main(String[] args) {
+        QuixoteClientCLI quixoteCLI = new QuixoteClientCLI();
+        quixoteCLI.runMain(args);
+    }
+
+    @Override
+    protected void exit(final int returnStatus) {
+        super.exit(returnStatus);
+    }
+
+    @Override
+    protected void invokeCommand(final Command command) {
+        super.invokeCommand(command);
+    }
+
+    @Override
+    protected void installCommands(final JCommander jCommander) {
+        super.installCommands(jCommander);
+
+        addCommand(jCommander, "deposit-cif", new DepositCifCommand());
+    }
+}

File src/main/java/uk/ac/cam/ch/wwmm/quixote/client/cif/DepositCifCommand.java

 package uk.ac.cam.ch.wwmm.quixote.client.cif;
 
+import net.chempound.client.cli.command.Command;
 import net.chempound.client.cli.command.DepositCommand;
 import net.chempound.client.cli.options.GlobalOptions;
 
  */
 public class DepositCifCommand extends DepositCommand {
 
-    private DepositCifOptions depositOptions;
+    private final DepositCifOptions options;
 
-    public DepositCifCommand(final GlobalOptions globalOptions, final DepositCifOptions depositOptions) {
-        super(globalOptions, depositOptions);
-        this.depositOptions = depositOptions;
+    public DepositCifCommand() {
+        super(new DepositCifOptions());
+        this.options = (DepositCifOptions) super.depositOptions;
     }
 
-
+    @Override
+    public void invoke(final GlobalOptions globalOptions) {
+        throw new UnsupportedOperationException();
+    }
 
 }

File src/test/java/uk/ac/cam/ch/wwmm/quixote/client/QuixoteClientCLITest.java

+package uk.ac.cam.ch.wwmm.quixote.client;
+
+import net.chempound.client.cli.command.Command;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import uk.ac.cam.ch.wwmm.quixote.client.cif.DepositCifCommand;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.*;
+
+/**
+ * @author Sam Adams
+ */
+public class QuixoteClientCLITest {
+
+    private QuixoteClientCLI quixoteClient;
+
+    private Command<?> command;
+
+    @Before
+    public void setUp() throws Exception {
+        quixoteClient = spy(new QuixoteClientCLI());
+
+        doNothing().when(quixoteClient).exit(anyInt());
+
+        doAnswer(new Answer() {
+            @Override
+            public Object answer(final InvocationOnMock invocation) throws Throwable {
+                command = (Command) invocation.getArguments()[0];
+                return null;
+            }
+        }).when(quixoteClient).invokeCommand(any(Command.class));
+    }
+
+    @Test
+    public void testDepositCif() {
+        quixoteClient.runMain("deposit-cif");
+
+        verify(quixoteClient).invokeCommand(any(DepositCifCommand.class));
+    }
+
+}