I'm trying to write a functional test to directly exercise the save method of a JPA entity without going through a Controller. Is this possible? When I run "play test", I get error, "No EntityManager bound to this thread. Try to annotate your action method with @play.db.jpa.Transactional".
My functional test method is defined as follows:
@Test
@play.db.jpa.Transactional
public void persistNewScenario() {
Scenario testscenario = new Scenario();
testscenario.name = "test scenario";
testscenario.save();
}
My JPA entity class is defined as follows:
@Entity
@SequenceGenerator(name = "scenario_seq", sequenceName = "scenario_seq")
public class Scenario {
public Long id;
public String name;
public void save() {
this.id = id;
JPA.em().persist(this);
}
Thanks for any help.
--Ian