ConfigReleaseIbatisDao extends SqlMapClientDaoSupport implements ConfigReleaseDao { @Override public void createConfigSnapshots(List<ConfigSnapshot> configSnapshots) { int batchSize = 50; int snapshotSize = configSnapshots.size(); for (int fromIndex = 0; fromIndex < snapshotSize;) { int toIndex = fromIndex + batchSize <= snapshotSize ? fromIndex + batchSize : snapshotSize; List<ConfigSnapshot> batchList = configSnapshots.subList(fromIndex, toIndex); getSqlMapClientTemplate().insert("ConfigRelease.insertConfigSnapshots", batchList); fromIndex = toIndex; } }  @Override int createSetTask(ConfigSetTask task); @SuppressWarnings("unchecked") @Override List<ConfigSetTask> getSetTask(int projectId, int envId, String[] features, String[] keys); @Override int createConfigSnapshotSet(ConfigSnapshotSet snapshot); @Override void createConfigSnapshots(List<ConfigSnapshot> configSnapshots); @Override void createConfigInstSnapshots(List<ConfigInstanceSnapshot> configInstSnapshots); @Override ConfigSnapshotSet findSnapshotSetToRollback(int projectId, int envId, String task); @SuppressWarnings("unchecked") @Override List<ConfigSnapshot> findConfigSnapshots(int snapshotSetId); @SuppressWarnings("unchecked") @Override List<ConfigInstanceSnapshot> findConfigInstSnapshots(int snapshotSetId);  }
@Test public void testCreateConfigSnapshots() { int setId = configReleaseDao.createConfigSnapshotSet(buildConfigSnapshotSet(Project_Foo_Id, Env1_Id, Task_1)); List<ConfigSnapshot> snapshots = new ArrayList<ConfigSnapshot>(); Config config = configDao.getConfig(foo1ConfigId); ConfigSnapshot snapshot = new ConfigSnapshot(config); snapshot.setSnapshotSetId(setId); snapshot.setValueModifyTime(new Date()); snapshots.add(snapshot); config = configDao.getConfig(foo2ConfigId); snapshot = new ConfigSnapshot(config); snapshot.setSnapshotSetId(setId); snapshot.setValueModifyTime(new Date()); snapshots.add(snapshot); try { configReleaseDao.createConfigSnapshots(snapshots); } catch (Exception e) { fail("create config snapshots failed."); } List<ConfigSnapshot> snapshotsFound = configReleaseDao.findConfigSnapshots(setId); assertNotNull(snapshotsFound); assertEquals(2, snapshotsFound.size()); }