### Question:
ApplicationDAOJpa implements ApplicationDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean delete(Application application) { try { application = entityManager.getReference(Application.class, application.getId()); entityManager.remove(application); entityManager.flush(); return true; } catch(EntityNotFoundException e) { logger.debug(e); return false; } }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Application getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Application getByIdWithoutDeployments(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Application> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Application> getAllWithOutDeployments(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Application application); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Application application); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Application application); @Override Application getByName(String name); @Override Application getByNameWithoutDeployments(String name);  }### Answer:
@Test public void delete() { int size = applicationDAO.getAll().size(); Application application = new Application(); application.setName("name"); boolean saved = applicationDAO.save(application); assertTrue(saved); Application applicationFromDatabase = applicationDAO.getAll().get(size); int id = applicationFromDatabase.getId(); boolean deleted = applicationDAO.delete(applicationFromDatabase); assertTrue(deleted); deleted = applicationDAO.delete(applicationFromDatabase); assertTrue(!deleted); applicationFromDatabase = applicationDAO.getById(id); assertEquals(null, applicationFromDatabase); }