### Question:
AgreementDAOJpa implements AgreementDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public Agreement getById(int id) { Agreement agreement = entityManager.find(Agreement.class, id); return agreement; }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Agreement getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Agreement> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Agreement agreement); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Agreement agreement); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Agreement agreement); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) @SuppressWarnings("unchecked") Agreement getAcceptedAgreement(Deployment deployment);  }### Answer:
@Test public void getById() { int size = agreementDAO.getAll().size(); Agreement agreement = new Agreement(); agreement.setPrice("111"); agreement.setProviderId("provider-id"); agreement.setSlaAgreement("sla-agreement"); agreement.setSlaAgreementId("sla-agreement-id"); boolean saved = agreementDAO.save(agreement); assertTrue(saved); Agreement agreementFromDatabase = agreementDAO.getAll().get(size); int id = agreementFromDatabase.getId(); agreementFromDatabase = agreementDAO.getById(id); assertEquals("111", agreementFromDatabase.getPrice()); assertEquals("provider-id", agreementFromDatabase.getProviderId()); assertEquals("sla-agreement", agreementFromDatabase.getSlaAgreement()); assertEquals("sla-agreement-id", agreementFromDatabase.getSlaAgreementId()); Agreement nullAgreement = agreementDAO.getById(30000); assertEquals(null, nullAgreement); }