@Disabled @Test public void testSourceBigger() throws Exception { Task task = decider.getTask(existingBigTestNode, existingTestNode, stateDecider, bufferedStateDecider); checkAction(task.getCurrentAction(), ActionType.NOT_DECIDABLE_ERROR, Location.NONE, BufferUpdate.NONE); }
@Override public Task getTask(final File src, final File dst, final StateDecider sd, final BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: if (!bsd.getState(dst).equals(State.ORPHAN_SOURCE)) { actions.add(addDestination); } else { actions.add(overwriteDestination); } break; case ORPHAN_DESTINATION: actions.add(ignoreDestinationOrphan); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: case FILE_SOURCE_DIR_DESTINATION: State buff = bsd.getState(dst); if (buff.equals(State.ORPHAN_DESTINATION)) { actions.add(new Action(ActionType.ADD, DESTINATION, BufferUpdate.DESTINATION, "There was a node in buff, but its orphan, so add")); } else if (buff.equals(state)) { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { actions.add(new Action(ActionType.NOTHING, NONE, BufferUpdate.DESTINATION, "dirherefilethere, but there is a dir instead of file, so its in sync")); } else { actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); } } else { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, SOURCE, BufferUpdate.NONE, explanation)); } else { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, explanation)); } } break; case FILE_CHANGE_SOURCE: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(updateDestination); } break; case FILE_CHANGE_DESTINATION: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(overwriteDestination); } break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); break; } actions.add(ignore); Action[] as = new Action[actions.size()]; actions.toArray(as); return new Task(src, dst, state, as); }
BackupActionDecider implements ActionDecider { @Override public Task getTask(final File src, final File dst, final StateDecider sd, final BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: if (!bsd.getState(dst).equals(State.ORPHAN_SOURCE)) { actions.add(addDestination); } else { actions.add(overwriteDestination); } break; case ORPHAN_DESTINATION: actions.add(ignoreDestinationOrphan); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: case FILE_SOURCE_DIR_DESTINATION: State buff = bsd.getState(dst); if (buff.equals(State.ORPHAN_DESTINATION)) { actions.add(new Action(ActionType.ADD, DESTINATION, BufferUpdate.DESTINATION, "There was a node in buff, but its orphan, so add")); } else if (buff.equals(state)) { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { actions.add(new Action(ActionType.NOTHING, NONE, BufferUpdate.DESTINATION, "dirherefilethere, but there is a dir instead of file, so its in sync")); } else { actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); } } else { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, SOURCE, BufferUpdate.NONE, explanation)); } else { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, explanation)); } } break; case FILE_CHANGE_SOURCE: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(updateDestination); } break; case FILE_CHANGE_DESTINATION: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(overwriteDestination); } break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); break; } actions.add(ignore); Action[] as = new Action[actions.size()]; actions.toArray(as); return new Task(src, dst, state, as); } }
BackupActionDecider implements ActionDecider { @Override public Task getTask(final File src, final File dst, final StateDecider sd, final BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: if (!bsd.getState(dst).equals(State.ORPHAN_SOURCE)) { actions.add(addDestination); } else { actions.add(overwriteDestination); } break; case ORPHAN_DESTINATION: actions.add(ignoreDestinationOrphan); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: case FILE_SOURCE_DIR_DESTINATION: State buff = bsd.getState(dst); if (buff.equals(State.ORPHAN_DESTINATION)) { actions.add(new Action(ActionType.ADD, DESTINATION, BufferUpdate.DESTINATION, "There was a node in buff, but its orphan, so add")); } else if (buff.equals(state)) { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { actions.add(new Action(ActionType.NOTHING, NONE, BufferUpdate.DESTINATION, "dirherefilethere, but there is a dir instead of file, so its in sync")); } else { actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); } } else { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, SOURCE, BufferUpdate.NONE, explanation)); } else { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, explanation)); } } break; case FILE_CHANGE_SOURCE: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(updateDestination); } break; case FILE_CHANGE_DESTINATION: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(overwriteDestination); } break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); break; } actions.add(ignore); Action[] as = new Action[actions.size()]; actions.toArray(as); return new Task(src, dst, state, as); }  }
BackupActionDecider implements ActionDecider { @Override public Task getTask(final File src, final File dst, final StateDecider sd, final BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: if (!bsd.getState(dst).equals(State.ORPHAN_SOURCE)) { actions.add(addDestination); } else { actions.add(overwriteDestination); } break; case ORPHAN_DESTINATION: actions.add(ignoreDestinationOrphan); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: case FILE_SOURCE_DIR_DESTINATION: State buff = bsd.getState(dst); if (buff.equals(State.ORPHAN_DESTINATION)) { actions.add(new Action(ActionType.ADD, DESTINATION, BufferUpdate.DESTINATION, "There was a node in buff, but its orphan, so add")); } else if (buff.equals(state)) { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { actions.add(new Action(ActionType.NOTHING, NONE, BufferUpdate.DESTINATION, "dirherefilethere, but there is a dir instead of file, so its in sync")); } else { actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); } } else { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, SOURCE, BufferUpdate.NONE, explanation)); } else { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, explanation)); } } break; case FILE_CHANGE_SOURCE: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(updateDestination); } break; case FILE_CHANGE_DESTINATION: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(overwriteDestination); } break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); 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, final StateDecider sd, final BufferStateDecider bsd); }
BackupActionDecider implements ActionDecider { @Override public Task getTask(final File src, final File dst, final StateDecider sd, final BufferStateDecider bsd) throws DataParseException, IOException { List<Action> actions = new ArrayList<>(3); State state = sd.getState(src, dst); switch (state) { case ORPHAN_SOURCE: if (!bsd.getState(dst).equals(State.ORPHAN_SOURCE)) { actions.add(addDestination); } else { actions.add(overwriteDestination); } break; case ORPHAN_DESTINATION: actions.add(ignoreDestinationOrphan); actions.add(deleteDestinationOrphan); break; case DIR_SOURCE_FILE_DESTINATION: case FILE_SOURCE_DIR_DESTINATION: State buff = bsd.getState(dst); if (buff.equals(State.ORPHAN_DESTINATION)) { actions.add(new Action(ActionType.ADD, DESTINATION, BufferUpdate.DESTINATION, "There was a node in buff, but its orphan, so add")); } else if (buff.equals(state)) { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { actions.add(new Action(ActionType.NOTHING, NONE, BufferUpdate.DESTINATION, "dirherefilethere, but there is a dir instead of file, so its in sync")); } else { actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, "file changed from/to dir, can't overwrite")); } } else { if (state.equals(State.DIR_SOURCE_FILE_DESTINATION)) { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, SOURCE, BufferUpdate.NONE, explanation)); } else { String explanation = "cant update, dir here file there error occured"; actions.add(new Action(ActionType.DIR_HERE_FILE_THERE_ERROR, DESTINATION, BufferUpdate.NONE, explanation)); } } break; case FILE_CHANGE_SOURCE: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(updateDestination); } break; case FILE_CHANGE_DESTINATION: if (bsd.getState(dst).equals(State.IN_SYNC)) { actions.add(overwriteDestination); } break; case IN_SYNC: actions.add(inSync); actions.add(overwriteDestination); 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, final StateDecider sd, final BufferStateDecider bsd);  }