@Override
  public String getCommandName() {
    return COMMAND_NAME;
  }
@Test
  public void alluxioCmdExecuted()
          throws IOException, AlluxioException, NoSuchFieldException, IllegalAccessException {
    CollectAlluxioInfoCommand cmd = new CollectAlluxioInfoCommand(FileSystemContext.create());

    // Write to temp dir
    File targetDir = InfoCollectorTestUtils.createTemporaryDirectory();
    CommandLine mockCommandLine = mock(CommandLine.class);
    String[] mockArgs = new String[]{cmd.getCommandName(), targetDir.getAbsolutePath()};
    when(mockCommandLine.getArgs())
        .thenReturn(mockArgs);
    when(mockCommandLine.getOptionValue(ArgumentMatchers.eq("output-dir"), ArgumentMatchers.eq("")))
        .thenReturn(targetDir.getAbsolutePath());

    // Replace commands to execute
    Field f = cmd.getClass().getSuperclass().getDeclaredField("mCommands");
    f.setAccessible(true);

    CollectAlluxioInfoCommand.AlluxioCommand mockCommand =
            mock(CollectAlluxioInfoCommand.AlluxioCommand.class);
    when(mockCommand.runWithOutput())
            .thenReturn(new CommandReturn(0, "nothing happens"));
    Map<String, ShellCommand> mockCommandMap = new HashMap<>();
    mockCommandMap.put("mockCommand", mockCommand);
    f.set(cmd, mockCommandMap);

    int ret = cmd.run(mockCommandLine);
    assertEquals(0, ret);

    // Verify the command has been run
    verify(mockCommand).runWithOutput();

    // Files will be copied to sub-dir of target dir
    File subDir = new File(Paths.get(targetDir.getAbsolutePath(),
            cmd.getCommandName()).toString());
    assertEquals(new String[]{"collectAlluxioInfo.txt"}, subDir.list());

    // Verify the command output is found
    String fileContent = new String(Files.readAllBytes(subDir.listFiles()[0].toPath()));
    assertTrue(fileContent.contains("nothing happens"));
  }