Removed SQLite. Removed adding DAOs to Jersey register.
This commit is contained in:
parent
3dc5ebb774
commit
6a45056363
@ -1,9 +1,9 @@
|
|||||||
database:
|
database:
|
||||||
# the name of your JDBC driver
|
# the name of your JDBC driver
|
||||||
driverClass: org.sqlite.JDBC
|
driverClass: org.h2.Driver
|
||||||
|
|
||||||
# the JDBC URL
|
# the JDBC URL
|
||||||
url: jdbc:sqlite:sampledatabase.db
|
url: jdbc:h2:./sampledatabase.db
|
||||||
|
|
||||||
# any properties specific to your JDBC driver:
|
# any properties specific to your JDBC driver:
|
||||||
properties:
|
properties:
|
||||||
|
@ -62,11 +62,6 @@
|
|||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>1.4.197</version>
|
<version>1.4.197</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.xerial</groupId>
|
|
||||||
<artifactId>sqlite-jdbc</artifactId>
|
|
||||||
<version>3.23.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -48,9 +48,6 @@ public class ObservationsApplication extends Application<ObservationsConfigurati
|
|||||||
TutorDao tutorDao = new TutorDao(hibernate.getSessionFactory());
|
TutorDao tutorDao = new TutorDao(hibernate.getSessionFactory());
|
||||||
SiteDao siteDao = new SiteDao(hibernate.getSessionFactory());
|
SiteDao siteDao = new SiteDao(hibernate.getSessionFactory());
|
||||||
ObservationDao observationDao = new ObservationDao(hibernate.getSessionFactory());
|
ObservationDao observationDao = new ObservationDao(hibernate.getSessionFactory());
|
||||||
jersey.register(tutorDao);
|
|
||||||
jersey.register(siteDao);
|
|
||||||
jersey.register(observationDao);
|
|
||||||
final TutorResource tutorResource = new TutorResource(tutorDao);
|
final TutorResource tutorResource = new TutorResource(tutorDao);
|
||||||
jersey.register(tutorResource);
|
jersey.register(tutorResource);
|
||||||
final ObservationResource observationResource = new ObservationResource(observationDao, tutorDao, siteDao);
|
final ObservationResource observationResource = new ObservationResource(observationDao, tutorDao, siteDao);
|
||||||
|
@ -8,6 +8,7 @@ import uk.co.neviyn.Observations.dao.SiteDao;
|
|||||||
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,7 +32,7 @@ public class SiteResource {
|
|||||||
@Path("/{id}/tutors")
|
@Path("/{id}/tutors")
|
||||||
@GET
|
@GET
|
||||||
@UnitOfWork
|
@UnitOfWork
|
||||||
public Set<Tutor> getSiteTutors(long id){
|
public Set<Tutor> getSiteTutors(@PathParam("id") long id){
|
||||||
return dao.get(id).getTutors();
|
return dao.get(id).getTutors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,14 @@ public class ObservationDaoTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() {
|
||||||
dao = new ObservationDao(testRule.getSessionFactory());
|
dao = new ObservationDao(testRule.getSessionFactory());
|
||||||
siteDao = new SiteDao(testRule.getSessionFactory());
|
siteDao = new SiteDao(testRule.getSessionFactory());
|
||||||
testRule.inTransaction(() -> siteDao.persist(site));
|
testRule.inTransaction(() -> siteDao.persist(site));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void persistAndGet(){
|
public void persistAndGet() {
|
||||||
Observation insert = testRule.inTransaction(() -> dao.persist(observation));
|
Observation insert = testRule.inTransaction(() -> dao.persist(observation));
|
||||||
assertNotNull(insert);
|
assertNotNull(insert);
|
||||||
assertTrue(insert.getId() > 0);
|
assertTrue(insert.getId() > 0);
|
||||||
@ -47,7 +47,7 @@ public class ObservationDaoTest {
|
|||||||
public void listAll() {
|
public void listAll() {
|
||||||
int numberOfObservations = 5;
|
int numberOfObservations = 5;
|
||||||
testRule.inTransaction(() -> {
|
testRule.inTransaction(() -> {
|
||||||
for(int i = 0; i < numberOfObservations; i++){
|
for (int i = 0; i < numberOfObservations; i++) {
|
||||||
// Make actual copies, otherwise they will merely overwrite.
|
// Make actual copies, otherwise they will merely overwrite.
|
||||||
dao.persist(SerializationUtils.clone(observation));
|
dao.persist(SerializationUtils.clone(observation));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user