@Test public void findByUnknownId() { when(dao.findById(2)).thenReturn(null); Employment result = service.findById(2); verify(dao).findById(2); assertNull(result); }
@Test public void findById() { Employment employment = EmploymentDaoJpaTest.createEmployment(1, "Test Employment One"); when(dao.findById(1)).thenReturn(employment); Employment employmentTest = service.findById(1); verify(dao).findById(1); assertSame(employment, employmentTest); }
@Test public void findAll() { List<Employment> employments = EmploymentDaoJpaTest.createEmployments(); when(dao.findAll()).thenReturn(employments); Collection<Employment> result = service.findAll(); verify(dao).findAll(); assertEquals(3, result.size()); }
@Test public void persist() throws DaoStoreException { Employment employment = EmploymentDaoJpaTest.createEmployment(1, "test user"); when(dao.persist(employment)).thenReturn(employment); Employment actual = service.persist(employment); verify(dao).persist(employment); assertSame(employment, actual); }