Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package br.com.redeinformatica.dao;
- import br.com.redeinformatica.Autor;
- import java.util.Date;
- import java.util.List;
- import org.junit.AfterClass;
- import org.junit.BeforeClass;
- import org.junit.Test;
- import static org.junit.Assert.*;
- /**
- *
- * @author Edson
- */
- public class AutorDAOTest {
- public AutorDAOTest() {
- }
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
- @Test
- public void salvar()throws Exception {
- System.out.println("salvar");
- Autor autor = new Autor(null, "edson", "edson@email.com", new Date());
- AutorDAO instance = new AutorDAO();
- instance.salvar(autor);
- // assertNotNull("autor", autor);
- assertEquals("edson", pesquisaId(1).getNome());
- }
- public Autor pesquisaId(Integer id) throws Exception{
- AutorDAO instance = new AutorDAO();
- return instance.buscarAutor(id);
- }
- @Test
- public void alterar()throws Exception {
- System.out.println("alterar");
- Autor autor = new Autor(1, "edson","eds@gmail.com", new Date());
- AutorDAO instance = new AutorDAO();
- instance.alterar(autor);
- assertEquals("eds@gmail.com", pesquisaId(1).getEmail());
- }
- @Test
- public void deletar()throws Exception {
- System.out.println("deletar");
- Autor autor;
- AutorDAO instance = new AutorDAO();
- instance.deletar(pesquisaId(1));
- assertNull(pesquisaId(1));
- }
- /* @Test
- public void listarTodos() {
- System.out.println("listarTodos");
- AutorDAO instance = new AutorDAO();
- List<Autor> expResult = null;
- List<Autor> result = instance.listarTodos();
- assertEquals(expResult, result);
- fail("The test case is a prototype.");
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement