@Test public void whenATransactionWithZeroIndex_isInserted_transactionIndexShouldAlwaysIncrementByOneFromMaxIndexOfAllTransactions() { assertThat(transactionDao.insertTransaction(getHttpTransactionWithZeroIndex())).isEqualTo(1); int transactionIndex = 22; assertThat(transactionDao.insertTransaction(getHttpTransactionWithIndex(transactionIndex))).isEqualTo(22); transactionIndex = 2; assertThat(transactionDao.insertTransaction(getHttpTransactionWithIndex(transactionIndex))).isEqualTo(2); assertThat(transactionDao.insertTransaction(getHttpTransactionWithZeroIndex())).isEqualTo(23); transactionIndex = 200; assertThat(transactionDao.insertTransaction(getHttpTransactionWithIndex(transactionIndex))).isEqualTo(200); assertThat(transactionDao.insertTransaction(getHttpTransactionWithZeroIndex())).isEqualTo(201); verifyOnlyTransactionsAddedAreWithIndices(1, 22, 2, 23, 200, 201); }
@Override public long insertTransaction(HttpTransaction httpTransaction) { long newTransactionIndex; if (httpTransaction.getId() == 0) { newTransactionIndex = currentIndex; } else { newTransactionIndex = httpTransaction.getId(); } return addTransactionWithIndex(httpTransaction, newTransactionIndex); }
IMDBTransactionDao implements TransactionDao { @Override public long insertTransaction(HttpTransaction httpTransaction) { long newTransactionIndex; if (httpTransaction.getId() == 0) { newTransactionIndex = currentIndex; } else { newTransactionIndex = httpTransaction.getId(); } return addTransactionWithIndex(httpTransaction, newTransactionIndex); } }
IMDBTransactionDao implements TransactionDao { @Override public long insertTransaction(HttpTransaction httpTransaction) { long newTransactionIndex; if (httpTransaction.getId() == 0) { newTransactionIndex = currentIndex; } else { newTransactionIndex = httpTransaction.getId(); } return addTransactionWithIndex(httpTransaction, newTransactionIndex); } IMDBTransactionDao(TransactionDataStore transactionDataStore, TransactionArchComponentProvider transactionArchComponentProvider, TransactionPredicateProvider transactionPredicateProvider); }
IMDBTransactionDao implements TransactionDao { @Override public long insertTransaction(HttpTransaction httpTransaction) { long newTransactionIndex; if (httpTransaction.getId() == 0) { newTransactionIndex = currentIndex; } else { newTransactionIndex = httpTransaction.getId(); } return addTransactionWithIndex(httpTransaction, newTransactionIndex); } IMDBTransactionDao(TransactionDataStore transactionDataStore, TransactionArchComponentProvider transactionArchComponentProvider, TransactionPredicateProvider transactionPredicateProvider); @Override long insertTransaction(HttpTransaction httpTransaction); @Override int updateTransaction(HttpTransaction httpTransaction); @Override int deleteTransactions(HttpTransaction... httpTransactions); @Override int deleteTransactionsBefore(Date beforeDate); @Override int clearAll(); @Override DataSource.Factory<Integer, HttpTransaction> getAllTransactions(); @Override LiveData<HttpTransaction> getTransactionsWithId(long id); @Override DataSource.Factory<Integer, HttpTransaction> getAllTransactionsWith(String key, SearchType searchType); }
IMDBTransactionDao implements TransactionDao { @Override public long insertTransaction(HttpTransaction httpTransaction) { long newTransactionIndex; if (httpTransaction.getId() == 0) { newTransactionIndex = currentIndex; } else { newTransactionIndex = httpTransaction.getId(); } return addTransactionWithIndex(httpTransaction, newTransactionIndex); } IMDBTransactionDao(TransactionDataStore transactionDataStore, TransactionArchComponentProvider transactionArchComponentProvider, TransactionPredicateProvider transactionPredicateProvider); @Override long insertTransaction(HttpTransaction httpTransaction); @Override int updateTransaction(HttpTransaction httpTransaction); @Override int deleteTransactions(HttpTransaction... httpTransactions); @Override int deleteTransactionsBefore(Date beforeDate); @Override int clearAll(); @Override DataSource.Factory<Integer, HttpTransaction> getAllTransactions(); @Override LiveData<HttpTransaction> getTransactionsWithId(long id); @Override DataSource.Factory<Integer, HttpTransaction> getAllTransactionsWith(String key, SearchType searchType);  }