How would you go about unit testing an EJB that uses JPA? For example, if I have an Order entity and and OrderEJB that is supposed to calculate the total of an order (as defined below) how would I go about unit testing the EJB without touching the database? Also, how would you define values for your entities, so you can assert the expected calculation? Here is some example code below...
@Entity
public class Order {
@Id
private long OrderId;
private LineItem[] items;
}
And an orderEJB
@Stateless
public class OrderEJB {
EntityManager em;
public double calculateOrderTotal(long orderId) { .. }
}
How would you go about unit testing the calculateOrderTotal method if I can't touch the database? I don't want to implement a DAO because I'm trying to move away from that approach.
Thanks for any help.