Guest User

Untitled

a guest
Jan 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public PersonService(PersonDao personDao) {
  2. m_PersonDao = personDao;
  3. }
  4. public List<Person> getAll() {
  5. return m_PersonDao.getAll();
  6. }
  7. public void save(Person p) {
  8. if (!m_PersonDao.isExistingPerson(p)) {
  9. m_PersonDao.save(p);
  10. }
  11. }
  12. public Person getByName(String name) {
  13. return m_PersonDao.getByName(name);
  14. }
  15. public Person getByBirthYear(Integer year) {
  16. return m_PersonDao.getByBirthYear(year);
  17. }
  18.  
  19.  
  20.  
  21. @Before
  22. public void setUp() throws Exception {
  23.  
  24. }
  25.  
  26. @After
  27. public void tearDown() throws Exception {
  28. }
  29.  
  30. @Test
  31. public void testPersonService() {
  32. fail("Not yet implemented");
  33. }
  34.  
  35. @Test
  36. public void testGetAll() {
  37. fail("Not yet implemented");
  38. }
  39.  
  40. @Test
  41. public void testSave() {
  42. fail("Not yet implemented");//
  43. }
  44.  
  45. @Test
  46. public void testGetByName() {
  47. PersonDao personDao = Mockito.mock(PersonDao.class);
  48.  
  49. Mockito.when(personDao.getByName("john")).thenReturn(new Person("John Thomspon", 1856);
  50.  
  51. Person p = personDao.getByName("john");
  52.  
  53. assert (p.getName().equals("John Thomspon"));
  54.  
  55. @Test
  56. public void testGetByBirthYear() {
  57. enter code here
  58. }
Add Comment
Please, Sign In to add comment