@Override
 protected void tearDown() throws Exception {
   dataManager.close();
   super.tearDown();
   getContext().deleteDatabase(DataConstants.DATABASE_NAME);
 }
  /**
   * Tests that the create() works, the persisted data can be obtained, the delete works and the
   * retrieval respects the deletion.
   */
  public void testDeleteMoreThanOne() {

    ExchangeRate input;
    List<ExchangeRate> deleteList;

    long expectedId;
    List<ExchangeRate> resultList;
    List<ExchangeRate> exchangeRateResult;

    /* ============ create ============ */

    input = REC_01;
    expectedId = ID_1;
    initialRetrievalResults.put(expectedId, dataManager.persistExchangeRate(input));

    input = REC_02;
    expectedId = ID_2;
    initialRetrievalResults.put(expectedId, dataManager.persistExchangeRate(input));

    input = REC_03;
    expectedId = ID_3;
    initialRetrievalResults.put(expectedId, dataManager.persistExchangeRate(input));

    input = REC_04;
    expectedId = ID_4;
    initialRetrievalResults.put(expectedId, dataManager.persistExchangeRate(input));

    /* ============ delete ============ */

    /* Record 1, 3 & 4 */
    deleteList = new ArrayList<ExchangeRate>();

    input = new ExchangeRate();
    input.setId(ID_1);
    deleteList.add(input);
    input = new ExchangeRate();
    input.setId(ID_3);
    deleteList.add(input);
    input = new ExchangeRate();
    input.setId(ID_4);
    deleteList.add(input);

    dataManager.deleteExchangeRates(deleteList);

    /* ---------> find post delete */
    exchangeRateResult = dataManager.findSuitableRates(EUR, USD);
    resultList = exchangeRateResult;
    Assert.assertEquals(0, resultList.size());

    exchangeRateResult = dataManager.findSuitableRates(USD, EUR);
    resultList = exchangeRateResult;
    Assert.assertEquals(0, resultList.size());

    exchangeRateResult = dataManager.findSuitableRates(EUR, TRY);
    resultList = exchangeRateResult;
    Assert.assertEquals(1, resultList.size());

    exchangeRateResult = dataManager.findSuitableRates(TRY, EUR);
    resultList = exchangeRateResult;
    Assert.assertEquals(1, resultList.size());

    exchangeRateResult = dataManager.findSuitableRates(TRY, GBP);
    resultList = exchangeRateResult;
    Assert.assertEquals(0, resultList.size());

    exchangeRateResult = dataManager.findSuitableRates(GBP, TRY);
    resultList = exchangeRateResult;
    Assert.assertEquals(0, resultList.size());

    resultList = dataManager.getAllExchangeRatesWithoutInversion();
    Assert.assertEquals(1, resultList.size());

    occuranceFlags.clear();
    for (int i = 0; i < resultList.size(); i++) {
      occuranceFlags.set((int) resultList.get(i).getId());
    }
    Assert.assertTrue(
        "Record 1 should not be part of the resultset as it has been deleted.",
        !occuranceFlags.get((int) ID_1));

    Assert.assertTrue(
        "Record 2 was not part of the resultset as it has not yet been deleted.",
        occuranceFlags.get((int) ID_2));
    Assert.assertTrue(
        "Record 3 should not be part of the resultset as it has been deleted.",
        !occuranceFlags.get((int) ID_3));
    Assert.assertTrue(
        "Record 4 should not be part of the resultset as it has been deleted.",
        !occuranceFlags.get((int) ID_4));

    dataManager.removeAll();
  }
 @Override
 protected void setUp() {
   getContext().deleteDatabase(DataConstants.DATABASE_NAME);
   dataManager = new DataManagerImpl(getContext());
   dataManager.removeAll();
 }