LogEntryDAOMysqlImpl extends AbstractTableCreatingDAOImpl implements LogEntryDAO { public void startEntry(LogEntry entry) { Preconditions.checkNotNull(entry); Preconditions.checkNotNull(entry.getPluginId()); Preconditions.checkNotNull(entry.getPluginId().getUri()); Preconditions.checkNotNull(entry.getPluginId().getVersion()); Preconditions.checkNotNull(entry.getStartDate()); Preconditions.checkNotNull(entry.getConfiguration()); String serializedConfiguration = entry.getConfiguration().marshal(); startEntry.update(entry.getTenantId(), entry.getPluginId().getUri().toASCIIString(), entry.getPluginId().getVersion().toString(), entry.getStartDate(), entry.getAssocTypeId(), serializedConfiguration); } protected  LogEntryDAOMysqlImpl(DataSource dataSource, SqlScriptService sqlScriptService,
                                   PluginRegistry pluginRegistry); @Override String getDefaultTableName(); @Override String getTableCreatingSQLScriptName(); void startEntry(LogEntry entry); void endEntry(LogEntry entry); void endAllEntries(Date endDate); void endAllEntries(); void deleteEntry(LogEntry entry); List<Integer> getRunningTenants(); List<LogEntry> getLogEntries(int offset, int limit); List<LogEntry> getLogEntriesForTenant(int tenantId, int offset, int limit); List<LogEntry> getLogEntries(int assocTypeId, int offset, int limit); List<LogEntry> getLogEntriesForTenant(int tenantId, int assocTypeId, int offset, int limit); int getNumberOfLogEntries(); int getNumberOfLogEntriesForTenant(int tenantId); void deleteLogEntries(); int getComputationDurationForDate(Date date); int getComputationDurationForDate();  }
@Test @ExpectedDataSet("/dbunit/pluginContainer/plugin_log+1new_started.xml") public void startEntry_shouldStartNewEntry() { LogEntry newEntry = new LogEntry(2, waitingGenerator.getId().getUri(), waitingGenerator.getId().getVersion(), date("2011-02-23 16:00:00"), 1, waitingGenerator.newConfiguration()); logEntryDAO.startEntry(newEntry); }
@Test(expected = DuplicateKeyException.class) public void startEntry_shouldThrowOnNonUnique() { LogEntry newEntry = new LogEntry(1, waitingGenerator.getId().getUri(), waitingGenerator.getId().getVersion(), date("2011-02-23 15:00:00"), 1, waitingGenerator.newConfiguration()); logEntryDAO.startEntry(newEntry); }
@Test(expected = NullPointerException.class) public void startEntry_shouldThrowOnNullArgument() { logEntryDAO.startEntry(null); }
@Test(expected = NullPointerException.class) public void startEntry_shouldThrowOnNullPluginId() { LogEntry newEntry = new LogEntry(1, null, waitingGenerator.getId().getVersion(), date("2011-02-23 15:00:00"), 1, waitingGenerator.newConfiguration()); logEntryDAO.startEntry(newEntry); }
@Test(expected = NullPointerException.class) public void startEntry_shouldThrowOnNullPluginVersion() { LogEntry newEntry = new LogEntry(1, waitingGenerator.getId().getUri(), null, date("2011-02-23 15:00:00"), 1, waitingGenerator.newConfiguration()); logEntryDAO.startEntry(newEntry); }
@Test(expected = NullPointerException.class) public void startEntry_shouldThrowOnNullStartDate() { LogEntry newEntry = new LogEntry(1, waitingGenerator.getId().getUri(), waitingGenerator.getId().getVersion(), null, 1, waitingGenerator.newConfiguration()); logEntryDAO.startEntry(newEntry); }
@Test(expected = NullPointerException.class) public void startEntry_shouldThrowOnNullConfiguration() { LogEntry newEntry = new LogEntry(1, waitingGenerator.getId().getUri(), waitingGenerator.getId().getVersion(), date("2011-02-23 15:00:00"), 1, null); logEntryDAO.startEntry(newEntry); }