DatabaseTruncater { @Transactional public void truncateDatabase() { List<BackupEntityType> types = backupConfig.reverseOrderedValues(); for (BackupEntityType type : types) { Class<? extends DomainObject<? extends Serializable, ?>> domainObjectClass = type.getDomainObjectClass(); if (domainObjectClass != null) { LOG.debug("Truncating table " + domainObjectClass); restoreDao.delete(domainObjectClass); } } restoreDao.delete(Configuration.class); restoreDao.delete(BinaryConfiguration.class); restoreDao.delete(MailLog.class); restoreDao.clearCache(); } @Autowired  DatabaseTruncater(RestoreDao restoreDao, BackupConfig backupConfig); @Transactional void truncateDatabase(); void setRestoreDao(RestoreDao restoreDao);  }
@Test public void shouldTruncate() { BackupEntityType entity = new BackupEntityType(TimesheetEntry.class, "timesheet_entry", 0); when(backupConfig.reverseOrderedValues()).thenReturn(Lists.newArrayList(entity)); truncater.truncateDatabase(); int wantedNumberOfInvocations = 1 + 3; verify(importDao, times(wantedNumberOfInvocations)).delete(Matchers.<Class<Object>>anyObject()); }