private void printResultAdd(DaemonOperationResult operationResult) { switch (operationResult.getResultCode()) { case OK: out.println("Folder(s) successfully added to daemon config."); out.println("Run 'sy daemon reload' to apply the changes."); out.println(); break; case OK_PARTIAL: out.println("Not all folder(s) were added successfully. Please check the following"); out.println("list to see which folders could not be added:"); out.println(); printResultList(operationResult); break; case NOK: out.println("Folder(s) were NOT added, because they might already exists in the daemon configuration."); out.println(); break; default: throw new RuntimeException("Invalid result code for this action: " + operationResult.getResultCode()); } }
private void printResultRemove(DaemonOperationResult operationResult) { switch (operationResult.getResultCode()) { case OK: out.println("Folder(s) successfully removed from the daemon config."); out.println("Run 'sy daemon reload' to apply the changes."); out.println(); break; case NOK_PARTIAL: out.println("Not all folder(s) were removed successfully. Please check the following"); out.println("list to see which folders could not be added:"); out.println(); printResultList(operationResult); break; case NOK: out.println("Folder(s) could not be NOT removed, because they did not exist in the daemon config."); out.println(); break; default: throw new RuntimeException("Invalid result code for this action: " + operationResult.getResultCode()); } } }
@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 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 testGetResultCode() { DaemonResultCode res = result.getResultCode(); assertNotNull(res); assertEquals(DaemonResultCode.OK, res); }
@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()); }
@Test public void testSetResultCode() { result.setResultCode(DaemonResultCode.NOK); DaemonResultCode res = result.getResultCode(); assertNotNull(res); assertEquals(DaemonResultCode.NOK, res); }