private void printResultList(DaemonOperationResult operationResult) { List<String[]> tableValues = new ArrayList<String[]>(); tableValues.add(new String[] { "#", "Enabled", "Path" }); for (int i=0; i<operationResult.getWatchList().size(); i++) { FolderTO folderTO = operationResult.getWatchList().get(i); String number = Integer.toString(i+1); String enabledStr = folderTO.isEnabled() ? "yes" : "no"; tableValues.add(new String[] { number, enabledStr, folderTO.getPath() }); } CliTableUtil.printTable(out, tableValues, "No managed folders found."); }
@Test public void testExecuteAdd() throws Exception { when(options.getAction()).thenReturn(DaemonAction.ADD); List<String> watchRoots = new ArrayList<String>(); watchRoots.add(tempWatchRootAppFolder.getParent()); when(options.getWatchRoots()).thenReturn(watchRoots); DaemonOperationResult res = deamonOp.execute(); assertNotNull(res); assertEquals(DaemonResultCode.OK, res.getResultCode()); assertNotNull(res.getWatchList()); assertEquals(1, res.getWatchList().size()); assertEquals(tempWatchRootAppFolder.getParentFile().getAbsolutePath(), res.getWatchList().get(0).getPath()); }
@Test public void testExecuteRemove() throws Exception { when(options.getAction()).thenReturn(DaemonAction.REMOVE); List<String> watchRoots = new ArrayList<String>(); watchRoots.add(tempWatchRootAppFolder.getParent()); when(options.getWatchRoots()).thenReturn(watchRoots); DaemonOperationResult res = deamonOp.execute(); assertNotNull(res); assertEquals(DaemonResultCode.OK, res.getResultCode()); assertNotNull(res.getWatchList()); assertTrue(res.getWatchList().isEmpty()); }
@Test public void testGetWatchList() { ArrayList<FolderTO> res = result.getWatchList(); assertNotNull(res); assertFalse(res.isEmpty()); assertTrue(res.contains(folder)); }
@Test public void setWatchList() { ArrayList<FolderTO> newList = new ArrayList<FolderTO>(); result.setWatchList(newList); ArrayList<FolderTO> res = result.getWatchList(); assertNotNull(res); assertTrue(res.isEmpty()); }
@Test public void testExecuteList() throws Exception { when(options.getAction()).thenReturn(DaemonAction.LIST); DaemonOperationResult res = deamonOp.execute(); assertNotNull(res); assertEquals(DaemonResultCode.OK, res.getResultCode()); assertNotNull(res.getWatchList()); }