public void testRemoveWithNodeIdArg() {
    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", "42"});

    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(42L, stopNodeId.get());
  }
In this test, the commandline is called with the remove option, with an additional attribute
for providing the node id. The stop method should be called and the id should be passed to the
remove callback.
iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/ServerCommandLineTest.java