### Question:
DeploymentDAOJpa implements DeploymentDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public boolean delete(Deployment deployment) { try { deployment = entityManager.getReference(Deployment.class, deployment.getId()); entityManager.remove(deployment); 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) Deployment getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Deployment> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Deployment deployment); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Deployment deployment); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Deployment deployment); @Override List<Deployment> getDeploymentsForApplicationWithStatus(Application application, String status); @Override Deployment getDeployment(String deploymentName); @Override List<Deployment> getDeploymentsWithStatus(String status);  }### Answer:
@Test public void delete() { int size = deploymentDAO.getAll().size(); Deployment deployment = new Deployment(); deployment.setStatus("RUNNIG"); deployment.setPrice("expensive"); boolean saved = deploymentDAO.save(deployment); assertTrue(saved); Deployment deploymentFromDatabase = deploymentDAO.getAll().get(size); int id = deploymentFromDatabase.getId(); boolean deleted = deploymentDAO.delete(deploymentFromDatabase); assertTrue(deleted); deleted = deploymentDAO.delete(deploymentFromDatabase); assertTrue(!deleted); deploymentFromDatabase = deploymentDAO.getById(id); assertEquals(null, deploymentFromDatabase); }