LogEntryDAOMysqlImpl extends AbstractTableCreatingDAOImpl implements LogEntryDAO { public int getComputationDurationForDate(Date date) { Preconditions.checkNotNull(date); Integer result = getComputationDurationForDate.findObject(date); return Objects.firstNonNull(result, 0); } 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 @DataSet("/dbunit/pluginContainer/plugin_log+all_ended.xml") public void getComputationDurationForDate_shouldReturnSum() { long milliseconds = logEntryDAO.getComputationDurationForDate(date("2011-02-23 00:00:01")); final long EXPECTED_VALUE = 3 * 10 * 60; assertThat(milliseconds, is(EXPECTED_VALUE)); }
@Test public void getComputationDurationForDate_shouldIngoreNonEndedEntries() { long milliseconds = logEntryDAO.getComputationDurationForDate(date("2011-02-23 00:00:01")); final long EXPECTED_VALUE = 1 * 10 * 60; assertThat(milliseconds, is(EXPECTED_VALUE)); }
@Test public void getComputationDurationForDate_shouldReturnZeroIfNoneMatched() { long milliseconds = logEntryDAO.getComputationDurationForDate(date("2011-02-24 00:00:01")); assertThat(milliseconds, is(0L)); }
@Test(expected = NullPointerException.class) public void getComputationDurationForDate_shouldThrowOnNulLDate() { logEntryDAO.getComputationDurationForDate(null); }