public void testRemoveArg() {
    AtomicBoolean startCalled = new AtomicBoolean(false);
    AtomicBoolean stopCalled = new AtomicBoolean(false);
    AtomicLong stopNodeId = new AtomicLong(-1);
    StringWriter out = new StringWriter();
    PrintWriter writer = new PrintWriter(out);
    ServerCommandLine commandLine =
        new ServerCommandLine("test-cli", writer) {
          @Override
          protected void start() {
            startCalled.set(true);
          }

          @Override
          protected void remove(Set<Integer> nodeIds) {
            stopCalled.set(true);
            if (nodeIds != null) {
              stopNodeId.set(nodeIds.iterator().next());
            }
          }
        };
    int returnCode = commandLine.run(new String[] {"-r"});

    Assert.assertEquals(0, returnCode);
    // Nothing should have been output on the console.
    String consoleOutput = out.toString();
    Assert.assertTrue(consoleOutput.isEmpty());
    // Only the start method should have been called.
    Assert.assertFalse(startCalled.get());
    Assert.assertTrue(stopCalled.get());
    Assert.assertEquals(-1, stopNodeId.get());
  }
In this test, the commandline is called with the remove option, but without an additional
attribute for providing the node id. The stop method should be called and "null" should be
provided as node id.
iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/ServerCommandLineTest.java