Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package br.com.redeinformatica.dao;
  7.  
  8. import br.com.redeinformatica.Autor;
  9. import java.util.Date;
  10. import java.util.List;
  11. import org.junit.AfterClass;
  12. import org.junit.BeforeClass;
  13. import org.junit.Test;
  14. import static org.junit.Assert.*;
  15.  
  16. /**
  17. *
  18. * @author Edson
  19. */
  20. public class AutorDAOTest {
  21.  
  22. public AutorDAOTest() {
  23. }
  24.  
  25. @BeforeClass
  26. public static void setUpClass() throws Exception {
  27. }
  28.  
  29. @AfterClass
  30. public static void tearDownClass() throws Exception {
  31. }
  32.  
  33. @Test
  34. public void salvar()throws Exception {
  35. System.out.println("salvar");
  36. Autor autor = new Autor(null, "edson", "edson@email.com", new Date());
  37. AutorDAO instance = new AutorDAO();
  38. instance.salvar(autor);
  39. // assertNotNull("autor", autor);
  40. assertEquals("edson", pesquisaId(1).getNome());
  41.  
  42. }
  43.  
  44. public Autor pesquisaId(Integer id) throws Exception{
  45. AutorDAO instance = new AutorDAO();
  46. return instance.buscarAutor(id);
  47. }
  48.  
  49. @Test
  50. public void alterar()throws Exception {
  51. System.out.println("alterar");
  52. Autor autor = new Autor(1, "edson","eds@gmail.com", new Date());
  53. AutorDAO instance = new AutorDAO();
  54. instance.alterar(autor);
  55. assertEquals("eds@gmail.com", pesquisaId(1).getEmail());
  56. }
  57.  
  58. @Test
  59. public void deletar()throws Exception {
  60. System.out.println("deletar");
  61. Autor autor;
  62. AutorDAO instance = new AutorDAO();
  63. instance.deletar(pesquisaId(1));
  64. assertNull(pesquisaId(1));
  65. }
  66.  
  67. /* @Test
  68. public void listarTodos() {
  69. System.out.println("listarTodos");
  70. AutorDAO instance = new AutorDAO();
  71. List<Autor> expResult = null;
  72. List<Autor> result = instance.listarTodos();
  73. assertEquals(expResult, result);
  74. fail("The test case is a prototype.");
  75. }*/
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement