Ao tentar executar o seguinte teste falha:
package br.com.ykz.controledeestoque.dao;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import br.com.ykz.controledeestoque.configurator.JPAConfigurator;
import br.com.ykz.controledeestoque.models.Cliente;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {JPAConfigurator.class, ClienteDao.class})
public class ClienteDaoTest {
@Autowired
ClienteDao clienteDao;
@Test
@Transactional
@Rollback(true)
public void deveSalvarCliente() {
Cliente cliente = new Cliente();
cliente.setNome("Havaianas");
clienteDao.persist(cliente);
Cliente clienteDoBanco = clienteDao.getListaClientes().get(0);
assertEquals(cliente, clienteDoBanco);
assertEquals(cliente.getNome(), clienteDoBanco.getNome());
}
}