@Test public void onAddTransactionWithZeroTransactionId_shouldThrowIllegalStateException() { assertThatExceptionOfType(TransactionDataStore.ZeroIndexException.class) .isThrownBy(new ThrowableAssert.ThrowingCallable() { @Override public void call() { simpleTransactionDataStore.addTransaction(getHttpTransactionWithZeroIndex()); } }) .withNoCause(); }
@Override public void addTransaction(HttpTransaction httpTransaction) { guardForZeroAndNegativeIndices(httpTransaction.getId()); addVerifiedTransaction(httpTransaction); sendDataChangeEvent(Event.ADDED, httpTransaction); }
SimpleTransactionDataStore implements TransactionDataStore { @Override public void addTransaction(HttpTransaction httpTransaction) { guardForZeroAndNegativeIndices(httpTransaction.getId()); addVerifiedTransaction(httpTransaction); sendDataChangeEvent(Event.ADDED, httpTransaction); } }
SimpleTransactionDataStore implements TransactionDataStore { @Override public void addTransaction(HttpTransaction httpTransaction) { guardForZeroAndNegativeIndices(httpTransaction.getId()); addVerifiedTransaction(httpTransaction); sendDataChangeEvent(Event.ADDED, httpTransaction); } SimpleTransactionDataStore(); }
SimpleTransactionDataStore implements TransactionDataStore { @Override public void addTransaction(HttpTransaction httpTransaction) { guardForZeroAndNegativeIndices(httpTransaction.getId()); addVerifiedTransaction(httpTransaction); sendDataChangeEvent(Event.ADDED, httpTransaction); } SimpleTransactionDataStore(); @Override void addTransaction(HttpTransaction httpTransaction); @Override boolean updateTransaction(HttpTransaction httpTransaction); @Override boolean removeTransactionWithIndex(long index); @Override int clearAllTransactions(); @Override List<HttpTransaction> getDataList(); @Override HttpTransaction getTransactionWithId(long id); @Override void addDataChangeListener(DataChangeListener dataChangeListener); @Override void removeDataChangeListener(DataChangeListener dataChangeListener); }
SimpleTransactionDataStore implements TransactionDataStore { @Override public void addTransaction(HttpTransaction httpTransaction) { guardForZeroAndNegativeIndices(httpTransaction.getId()); addVerifiedTransaction(httpTransaction); sendDataChangeEvent(Event.ADDED, httpTransaction); } SimpleTransactionDataStore(); @Override void addTransaction(HttpTransaction httpTransaction); @Override boolean updateTransaction(HttpTransaction httpTransaction); @Override boolean removeTransactionWithIndex(long index); @Override int clearAllTransactions(); @Override List<HttpTransaction> getDataList(); @Override HttpTransaction getTransactionWithId(long id); @Override void addDataChangeListener(DataChangeListener dataChangeListener); @Override void removeDataChangeListener(DataChangeListener dataChangeListener);  }