### Question:
VMDAOJpa implements VMDAO { @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) public VM getById(int id) { return entityManager.find(VM.class, id); }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) VM getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<VM> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(VM vm); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(VM vm); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(VM vm); @Override @SuppressWarnings("unchecked") List<VM> getNotDeletedVMsWithImage(Image image); @Override @SuppressWarnings("unchecked") @Transactional(readOnly=false, propagation=Propagation.REQUIRED) VM getVMWithProviderVMId(String proivderVMId, String providerId); @Override @SuppressWarnings("unchecked") @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<VM> getVMsWithOVfIdForDeploymentNotDeleted(String ovfId, int deploymentId); @Override @SuppressWarnings("unchecked") @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<VM> getVMsWithOvfIdAndActive(int deploymentId, String ovfId);  }### Answer:
@Test public void getById() { int size = vmDAO.getAll().size(); VM vm = new VM(); vm.setIp("127.0.0.1"); vm.setOvfId("ovf-id"); vm.setProviderId("provider-id"); vm.setProviderVmId("provider-vm-id"); vm.setSlaAgreement("sla-agreement"); vm.setStatus("RUNNING"); boolean saved = vmDAO.save(vm); assertTrue(saved); VM vmFromDatabase = vmDAO.getAll().get(size); int id = vmFromDatabase.getId(); vmFromDatabase = vmDAO.getById(id); assertEquals("RUNNING", vmFromDatabase.getStatus()); assertEquals("127.0.0.1", vmFromDatabase.getIp()); assertEquals("ovf-id", vmFromDatabase.getOvfId()); assertEquals("provider-id", vmFromDatabase.getProviderId()); assertEquals("provider-vm-id", vmFromDatabase.getProviderVmId()); assertEquals("sla-agreement", vmFromDatabase.getSlaAgreement()); VM nullVM = vmDAO.getById(30000); assertEquals(null, nullVM); }