I have a Play Application that has multiple projects(service, service-impl, entities etc), each project is managed by maven pom. It also has a service-gateway project but managed by sbt, this manages request and response. The structure of the project looks like this
entities/
src/
pom.xml
service/
src/
pom.xml
service-impl/
src/
pom.xml
controller/
src/
pom.xml
service-gateway/
app/
build.sbt
I would like to setup Integration tests to test my services and controllers. The issue is I can't inject an EntityManager to allow repository access and also my custom services are not injected. Here is my test code
public class DefaultDriverServiceTest {
@Inject
DriverService driverService;
@Inject
JPAApi jPAApi;
@Test
public void find() throws Exception {
JpaDriver jpaDriver = new JpaDriver();
jpaDriver.setDateCreated(new Date());
jpaDriver.setDriverId(UUID.randomUUID().toString());
jpaDriver.setUsername("username");
jpaDriver.setPassword("password");
jpaDriver.setOnlineStatus("online");
jPAApi.em().persist(jpaDriver);
JpaDriver driver = driverService.find(jpaDriver.getDriverId());
assertEquals(jpaDriver.getDriverId(), "4");
}
}
I have read a lot on Play's website on setting up tests and actually tried a lot of stuff I found online but still no luck with testing my services and controllers. Any help would be much appreciated
Aucun commentaire:
Enregistrer un commentaire