@Test public void testUpdate() { FileDiff[] fileDiffs = new FileDiff[2]; fileDiffs[0] = new FileDiff(); fileDiffs[0].setDiffId(1); fileDiffs[0].setRuleId(1); fileDiffs[0].setParameters(new HashMap<String, String>()); fileDiffs[0].setSrc("test"); fileDiffs[0].setState(FileDiffState.PENDING); fileDiffs[0].setDiffType(FileDiffType.APPEND); fileDiffs[0].setCreateTime(1); fileDiffs[1] = new FileDiff(); fileDiffs[1].setDiffId(2); fileDiffs[0].setRuleId(1); fileDiffs[1].setParameters(new HashMap<String, String>()); fileDiffs[1].setSrc("src"); fileDiffs[1].setState(FileDiffState.PENDING); fileDiffs[1].setDiffType(FileDiffType.APPEND); fileDiffs[1].setCreateTime(1); fileDiffDao.insert(fileDiffs); fileDiffDao.update(1, FileDiffState.RUNNING); fileDiffs[0].setState(FileDiffState.RUNNING); Assert.assertTrue(fileDiffDao.getById(1).equals(fileDiffs[0])); Assert.assertTrue(fileDiffDao.getPendingDiff().size() == 1); fileDiffs[0].getParameters().put("-offset", "0"); fileDiffs[0].setSrc("test1"); fileDiffs[1].setCreateTime(2); fileDiffs[1].setRuleId(2); fileDiffs[1].setDiffType(FileDiffType.RENAME); fileDiffDao.update(fileDiffs); Assert.assertTrue(fileDiffDao.getById(1).equals(fileDiffs[0])); Assert.assertTrue(fileDiffDao.getById(2).equals(fileDiffs[1])); }
public int update(long did, FileDiffState state) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "UPDATE " + TABLE_NAME + " SET state = ? WHERE did = ?"; return jdbcTemplate.update(sql, state.getValue(), did); }
FileDiffDao { public int update(long did, FileDiffState state) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "UPDATE " + TABLE_NAME + " SET state = ? WHERE did = ?"; return jdbcTemplate.update(sql, state.getValue(), did); } }
FileDiffDao { public int update(long did, FileDiffState state) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "UPDATE " + TABLE_NAME + " SET state = ? WHERE did = ?"; return jdbcTemplate.update(sql, state.getValue(), did); } FileDiffDao(DataSource dataSource); }
FileDiffDao { public int update(long did, FileDiffState state) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "UPDATE " + TABLE_NAME + " SET state = ? WHERE did = ?"; return jdbcTemplate.update(sql, state.getValue(), did); } FileDiffDao(DataSource dataSource); void setDataSource(DataSource dataSource); String getUselessFileDiffState(); List<FileDiff> getAll(); List<FileDiff> getPendingDiff(); List<FileDiff> getByState(FileDiffState fileDiffState); List<FileDiff> getByState(String prefix, FileDiffState fileDiffState); List<FileDiff> getPendingDiff(long rid); List<FileDiff> getPendingDiff(String prefix); List<FileDiff> getByIds(List<Long> dids); List<FileDiff> getByFileName(String fileName); List<String> getSyncPath(int size); FileDiff getById(long did); void delete(long did); int getUselessRecordsNum(); int deleteUselessRecords(int num); long insert(FileDiff fileDiff); void insert(FileDiff[] fileDiffs); Long[] insert(List<FileDiff> fileDiffs); int[] batchUpdate(
      final List<Long> dids, final List<FileDiffState> states,
      final List<String> parameters); int[] batchUpdate(
      final List<Long> dids, final FileDiffState state); int update(long did, FileDiffState state); int update(long did, String src); int update(long did, FileDiffState state,
       String parameters); int[] update(final FileDiff[] fileDiffs); int update(final FileDiff fileDiff); void deleteAll(); }
FileDiffDao { public int update(long did, FileDiffState state) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); String sql = "UPDATE " + TABLE_NAME + " SET state = ? WHERE did = ?"; return jdbcTemplate.update(sql, state.getValue(), did); } FileDiffDao(DataSource dataSource); void setDataSource(DataSource dataSource); String getUselessFileDiffState(); List<FileDiff> getAll(); List<FileDiff> getPendingDiff(); List<FileDiff> getByState(FileDiffState fileDiffState); List<FileDiff> getByState(String prefix, FileDiffState fileDiffState); List<FileDiff> getPendingDiff(long rid); List<FileDiff> getPendingDiff(String prefix); List<FileDiff> getByIds(List<Long> dids); List<FileDiff> getByFileName(String fileName); List<String> getSyncPath(int size); FileDiff getById(long did); void delete(long did); int getUselessRecordsNum(); int deleteUselessRecords(int num); long insert(FileDiff fileDiff); void insert(FileDiff[] fileDiffs); Long[] insert(List<FileDiff> fileDiffs); int[] batchUpdate(
      final List<Long> dids, final List<FileDiffState> states,
      final List<String> parameters); int[] batchUpdate(
      final List<Long> dids, final FileDiffState state); int update(long did, FileDiffState state); int update(long did, String src); int update(long did, FileDiffState state,
       String parameters); int[] update(final FileDiff[] fileDiffs); int update(final FileDiff fileDiff); void deleteAll(); public String uselessFileDiffStates; }