@Test public void testDestinationMissing() throws Exception { Task task = decider.getTask(existingTestNode, missingTestNode, stateDecider, bufferedStateDecider); checkAction(task.getCurrentAction(), ActionType.ADD, Location.DESTINATION, BufferUpdate.DESTINATION); }
@Override public Task getTask(final File src, final File dst, StateDecider sd, BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: actions.add(addToDestination); actions.add(deleteSourceOrphan); break; case ORPHAN_DESTINATION: actions.add(addToSource); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_SOURCE_DIR_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.SOURCE, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_CHANGE_SOURCE: actions.add(updateDestination); actions.add(overwriteSource); break; case FILE_CHANGE_DESTINATION: actions.add(updateSource); actions.add(overwriteDestination); break; case FILE_CHANGE_UNKNOWN: break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); actions.add(overwriteSource); break; } actions.add(ignore); Action[] as = new Action[actions.size()]; actions.toArray(as); return new Task(src, dst, state, as); }
TwoWaySyncActionDecider implements ActionDecider { @Override public Task getTask(final File src, final File dst, StateDecider sd, BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: actions.add(addToDestination); actions.add(deleteSourceOrphan); break; case ORPHAN_DESTINATION: actions.add(addToSource); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_SOURCE_DIR_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.SOURCE, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_CHANGE_SOURCE: actions.add(updateDestination); actions.add(overwriteSource); break; case FILE_CHANGE_DESTINATION: actions.add(updateSource); actions.add(overwriteDestination); break; case FILE_CHANGE_UNKNOWN: break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); actions.add(overwriteSource); break; } actions.add(ignore); Action[] as = new Action[actions.size()]; actions.toArray(as); return new Task(src, dst, state, as); } }
TwoWaySyncActionDecider implements ActionDecider { @Override public Task getTask(final File src, final File dst, StateDecider sd, BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: actions.add(addToDestination); actions.add(deleteSourceOrphan); break; case ORPHAN_DESTINATION: actions.add(addToSource); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_SOURCE_DIR_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.SOURCE, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_CHANGE_SOURCE: actions.add(updateDestination); actions.add(overwriteSource); break; case FILE_CHANGE_DESTINATION: actions.add(updateSource); actions.add(overwriteDestination); break; case FILE_CHANGE_UNKNOWN: break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); actions.add(overwriteSource); break; } actions.add(ignore); Action[] as = new Action[actions.size()]; actions.toArray(as); return new Task(src, dst, state, as); }  }
TwoWaySyncActionDecider implements ActionDecider { @Override public Task getTask(final File src, final File dst, StateDecider sd, BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: actions.add(addToDestination); actions.add(deleteSourceOrphan); break; case ORPHAN_DESTINATION: actions.add(addToSource); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_SOURCE_DIR_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.SOURCE, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_CHANGE_SOURCE: actions.add(updateDestination); actions.add(overwriteSource); break; case FILE_CHANGE_DESTINATION: actions.add(updateSource); actions.add(overwriteDestination); break; case FILE_CHANGE_UNKNOWN: break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); actions.add(overwriteSource); break; } actions.add(ignore); Action[] as = new Action[actions.size()]; actions.toArray(as); return new Task(src, dst, state, as); }  @Override Task getTask(final File src, final File dst, StateDecider sd, BufferStateDecider bsd); }
TwoWaySyncActionDecider implements ActionDecider { @Override public Task getTask(final File src, final File dst, StateDecider sd, BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: actions.add(addToDestination); actions.add(deleteSourceOrphan); break; case ORPHAN_DESTINATION: actions.add(addToSource); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_SOURCE_DIR_DESTINATION: actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, Location.SOURCE, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); break; case FILE_CHANGE_SOURCE: actions.add(updateDestination); actions.add(overwriteSource); break; case FILE_CHANGE_DESTINATION: actions.add(updateSource); actions.add(overwriteDestination); break; case FILE_CHANGE_UNKNOWN: break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); actions.add(overwriteSource); break; } actions.add(ignore); Action[] as = new Action[actions.size()]; actions.toArray(as); return new Task(src, dst, state, as); }  @Override Task getTask(final File src, final File dst, StateDecider sd, BufferStateDecider bsd);  }