/** Méthode de test Delete. */ @Test public void delete() { final Inclusion patient = new Inclusion(); Mockito.when(this.patientDao.get(patient.getId())).thenReturn(patient); this.patientDao.remove(patient); Mockito.verify(this.entityManager, Mockito.times(1)).remove(Matchers.any()); }
/** Méthode de test Save. */ @Test public void save() { final Inclusion patient = new Inclusion(); patient.setId(1L); Mockito.when(this.entityManager.merge(patient)).thenReturn(patient); final Inclusion patientSaved = this.patientDao.save(patient); Mockito.verify(this.entityManager, Mockito.times(1)).merge(Matchers.any()); Assert.assertNotNull(patientSaved); Assert.assertEquals(patient, patientSaved); }
/** Méthode de test Get. */ @Test public void get() { final Inclusion patient = new Inclusion(); patient.setId(1L); Mockito.when(this.entityManager.find(Inclusion.class, patient.getId())).thenReturn(patient); final Inclusion patientReturned = this.patientDao.get(patient.getId()); Assert.assertNotNull(patientReturned); Assert.assertNotNull(patientReturned.getId()); Assert.assertEquals(1L, patientReturned.getId().longValue()); }