ClusterStatusServlet extends HttpServlet { public static List<LoadingFileSetRow> getLoadingFileSetTable( ZooKeeperManager zkManager, List<FileSetWithErrorRow> fileSetsWithError) throws Exception { List<LoadingFileSetRow> rows = new ArrayList<LoadingFileSetRow>(); List<String> loadingFileSets = zkManager.getLockedFileSets(); for (String fileSet : loadingFileSets) { FileSetInfo fileSetInfo = zkManager.getLockedFileSetInfo(fileSet); if (fileSetInfo.servingInfo == null) { fileSetsWithError.add(new FileSetWithErrorRow(fileSet, FileSetError.NO_SERVING_INFO)); continue; } rows.add(new LoadingFileSetRow(fileSet, fileSetInfo.servingInfo.hdfsPath)); } return rows; }  static long parseTimestampFromHdfsPath(String hdfsPath); static List<FileSetStatusRow> getFileSetStatusTable(
      ZooKeeperManager zkManager, List<FileSetWithErrorRow> fileSetsWithError); static List<LoadingFileSetRow> getLoadingFileSetTable(
      ZooKeeperManager zkManager, List<FileSetWithErrorRow> fileSetsWithError); static List<String> getAllNodeNames(DFSClient hdfsClient); @Override void doGet(HttpServletRequest request, HttpServletResponse response); static final String BASE_URI; }
@Test public void testGetLoadingFileSetTable() { try{ when(mockZKManager.getLockedFileSets()).thenReturn(ImmutableList.of( "fileset1", "fileset2", "fileset3" )); when(mockZKManager.getLockedFileSetInfo(eq("fileset1"))).thenReturn(mockFileSetInfo1); when(mockZKManager.getLockedFileSetInfo(eq("fileset2"))).thenReturn(mockFileSetInfo2); when(mockZKManager.getLockedFileSetInfo(eq("fileset3"))).thenReturn(mockFileSetInfo3); List<ClusterStatusServlet.FileSetWithErrorRow> fileSetsWithError = new ArrayList<ClusterStatusServlet.FileSetWithErrorRow>(); List<ClusterStatusServlet.LoadingFileSetRow> loadingFileSets = ClusterStatusServlet.getLoadingFileSetTable(mockZKManager, fileSetsWithError); assertEquals(2, loadingFileSets.size()); assertEquals( new ClusterStatusServlet.LoadingFileSetRow("fileset1", "/fileset1/1234423233333"), loadingFileSets.get(0) ); assertEquals( new ClusterStatusServlet.LoadingFileSetRow("fileset2", "/fileset2/1344423233333"), loadingFileSets.get(1) ); assertEquals(1, fileSetsWithError.size()); assertEquals( new ClusterStatusServlet.FileSetWithErrorRow("fileset3", ClusterStatusServlet.FileSetError.NO_SERVING_INFO), fileSetsWithError.get(0) ); } catch (Exception e) { fail(e.getMessage()); } }