TerrapinAdmin { public void deleteFileSet(String[] args) throws Exception { if (args.length > 1) { String fileSet = args[1]; if (confirmFileSetDeletion(fileSet, System.in)) { deleteFileSet(zkManager, fileSet); System.out.println("file set is successfully marked to be deleted. It will be " + "physically deleted after short period of time."); } } else { System.err.println("missing file set argument"); } } 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 testDeleteFileSet() throws Exception { ZooKeeperManager mockZKManager = mock(ZooKeeperManager.class); FileSetInfo fileSetInfo = new FileSetInfo(); fileSetInfo.fileSetName = "test_fileset"; when(mockZKManager.getFileSetInfo(eq(fileSetInfo.fileSetName))).thenReturn(fileSetInfo); doNothing().when(mockZKManager).lockFileSet(anyString(), any(FileSetInfo.class)); doNothing().when(mockZKManager).setFileSetInfo(anyString(), any(FileSetInfo.class)); TerrapinAdmin.deleteFileSet(mockZKManager, fileSetInfo.fileSetName); verify(mockZKManager, times(1)) .setFileSetInfo(eq(fileSetInfo.fileSetName), any(FileSetInfo.class)); assertTrue(fileSetInfo.deleted); }