@Test
  public void evictedTransactionsAreSentToServer() throws Exception {
    api_cache.setReportExpirationInterval(5L);
    api_cache.report(createTransactionData());
    Thread.sleep(800L);

    verify(sender).sendPostToServer(SERVER_URL, RESPONSE_DATA);
  }
 @Test
 public void multipleTransactionsWithSameTimestampAreReportedCorrectly() throws Exception {
   api_cache.setReportExpirationInterval(50L);
   api_cache.report(createTransactionData());
   api_cache.report(createTransactionData());
   Thread.sleep(800L);
   verify(sender).sendPostToServer(SERVER_URL, RESPONSE_MULTIPLE_TRANSACTION);
 }
  @Test
  public void multipleReportsTransactionsAreSentToServerAsOneMessage() throws Exception {
    api_cache.setReportExpirationInterval(5L);
    api_cache.report(createTransactionData());
    api_cache.report(createSecondSetOfTransactionData());
    Thread.sleep(800L);

    verify(sender).sendPostToServer(SERVER_URL, MULTIPLE_RESPONSE_DATA);
  }
  @Test
  public void transactionAreExpiredAtCorrectTime() throws Exception {
    api_cache.setReportExpirationInterval(5L);
    api_cache.report(createTransactionData());
    Thread.sleep(1000L);

    ApiTransaction[] t1 = api_cache.getTransactionFor("bce4c8f4", "2009-01-01 14:23:08");
    assertNull("Transaction 1 was still in cache", t1);

    ApiTransaction[] t2 = api_cache.getTransactionFor("bad7e480", "2009-01-01 18:11:59");
    assertNull("Transaction 2 was was still in cache", t2);
  }
  @Test
  public void cacheEvictionTimeIsBeingSetCorrectly() throws Exception {
    api_cache.setReportExpirationInterval(200L);
    long currentTime = api_cache.getCurrentResponseExpirationTime();
    Thread.sleep(550L);
    long newTime = api_cache.getCurrentResponseExpirationTime();

    SimpleDateFormat df = new SimpleDateFormat("yyyy MM dd hh mm ss S");

    log.info("Current time: " + df.format(currentTime));
    log.info("    New time: " + df.format(newTime));
    assertTrue("ExpirationTime was not incremented correctly", newTime == (currentTime + 200L));
  }