@Test
  public void deletePurchaseTest() {

    PurchaseEntity entity = data.get(0);
    purchasePersistence.delete(entity.getId());
    PurchaseEntity deleted = em.find(PurchaseEntity.class, entity.getId());

    Assert.assertNull(deleted);
  }
  @Test
  public void getPurchaseTest() {

    PurchaseEntity entity = data.get(0);
    PurchaseEntity newEntity = purchasePersistence.find(entity.getId());

    Assert.assertNotNull(newEntity);
    Assert.assertEquals(newEntity.getCardNumber(), entity.getCardNumber());
  }
  @Test
  public void createPurchaseTest() {

    PurchaseEntity newEntity = createTestObject();
    PurchaseEntity result = purchasePersistence.create(newEntity);

    Assert.assertNotNull(result);
    PurchaseEntity entity = em.find(PurchaseEntity.class, result.getId());

    Assert.assertEquals(newEntity.getCardNumber(), entity.getCardNumber());
  }
  @Test
  public void updatePurchaseTest() {

    PurchaseEntity entity = data.get(0);
    PurchaseEntity newEntity = createTestObject();
    newEntity.setId(entity.getId());
    purchasePersistence.update(newEntity);
    PurchaseEntity resp = em.find(PurchaseEntity.class, entity.getId());

    Assert.assertEquals(newEntity.getCardNumber(), resp.getCardNumber());
  }
  @Test
  public void getPurchasesTest() {

    List<PurchaseEntity> list = purchasePersistence.findAll(null, null);

    Assert.assertEquals(data.size(), list.size());
    for (PurchaseEntity newEntity : list) {
      boolean found = false;
      for (PurchaseEntity entity : data) {
        if (newEntity.getId().equals(entity.getId())) {
          found = true;
        }
      }
      Assert.assertTrue(found);
    }
  }