I am learning Mockito , i have trouble understanding few things. Suppose i want to test a Doa method which gets List of objects and saves it in DB by iterating ove the list . How do test it using Mockito. Below is the code example.
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
@Repository
public class AuditDaoImpl  {
    @PersistenceContext(unitName = "somepersistance")
    EntityManager entityManager;
    public <T> boolean saveAuditData(List<T> dataList) {
        Iterator<Data> itr = (Iterator<Data>) dataList.iterator();
        while (itr.hasNext()) {
            Data Data = (Data) itr.next();
            Audit audit = new Audit();
            audit.setUserName(Data.getUserName());
            entityManager.persist(audit);
        }
        return true;
    }
}
 
     
     
    