TerrapinAdmin { @VisibleForTesting protected static boolean confirmFileSetDeletion(String fileSet, InputStream inputStream) { System.out.print(String.format("are you sure to delete %s? [y/n]: ", fileSet)); Scanner scanner = new Scanner(inputStream); if (scanner.hasNextLine()) { String input = scanner.nextLine(); if (input.length() > 0 && input.equalsIgnoreCase("y")) { return true; } } return false; } TerrapinAdmin(PropertiesConfiguration configuration); void setNamenode(String[] args); void setDfsReplication(String[] args); void checkClusterHealth(String[] args); void rollbackFileSet(String[] args); void deleteFileSet(String[] args); static FileSetInfo lockFileSet(ZooKeeperManager zkManager,
                                        String fileSet,
                                        CreateMode mode); static FileSetInfo lockFileSet(ZooKeeperManager zkManager, String fileSet); static void unlockFileSet(ZooKeeperManager zkManager, String fileSet); static void rollbackFileSet(ZooKeeperManager zkManager, String fileSet,
                                     FileSetInfo fileSetInfo, int versionIndex); static void deleteFileSet(ZooKeeperManager zkManager, String fileSet); static void main(String[] args);  }
@Test public void testConfirmFileSetDeletion() { ByteArrayInputStream inputStream = new ByteArrayInputStream("y\n".getBytes()); assertTrue(TerrapinAdmin.confirmFileSetDeletion("test_fileset", inputStream)); inputStream = new ByteArrayInputStream(new byte[0]); assertFalse(TerrapinAdmin.confirmFileSetDeletion("test_fileset", inputStream)); inputStream = new ByteArrayInputStream("other input".getBytes()); assertFalse(TerrapinAdmin.confirmFileSetDeletion("test_fileset", inputStream)); }