Skip to content
Snippets Groups Projects
Commit e3d927c9 authored by Clement Decottignies's avatar Clement Decottignies
Browse files

tp rest bdd

parent c42d2483
No related branches found
No related tags found
No related merge requests found
Pipeline #8328 failed
...@@ -24,5 +24,9 @@ public interface TacheDAO { ...@@ -24,5 +24,9 @@ public interface TacheDAO {
@SqlQuery("select * from taches") @SqlQuery("select * from taches")
@RegisterBeanMapper(Tache.class) @RegisterBeanMapper(Tache.class)
List<Tache> getAll(); List<Tache> getAll();
@SqlQuery("select * from taches where id=?")
@RegisterBeanMapper(Tache.class)
Tache getById(String id);
} }
...@@ -64,4 +64,20 @@ public class TodoRessource { ...@@ -64,4 +64,20 @@ public class TodoRessource {
} }
return builder.build(); return builder.build();
} }
@Path("{id}")
@GET
public Tache tacheGetId(@PathParam("id") UUID id){
LOGGER.info("tacheGetId()");
Tache tache = todoService.getTache(id);
return tache;
}
@Path("{id}")
@GET
public Tache tacheGetDescription(@PathParam("id") UUID id){
LOGGER.info("tacheGetDescription()");
Tache tache = todoService.getTache(id);
return tache;
}
} }
...@@ -15,7 +15,7 @@ public class TodoService { ...@@ -15,7 +15,7 @@ public class TodoService {
} }
public Tache getTache(UUID id) { public Tache getTache(UUID id) {
return null; return taches.getById(id.toString());
} }
public List<Tache> getAll() { public List<Tache> getAll() {
......
...@@ -88,7 +88,6 @@ public class TodoRessourceTest extends JerseyTest { ...@@ -88,7 +88,6 @@ public class TodoRessourceTest extends JerseyTest {
tache.setNom("test"); tache.setNom("test");
tache.setDescription("description"); tache.setDescription("description");
dao.insert(tache); dao.insert(tache);
Tache returned = target("taches").path(tache.getId().toString()).request().get(Tache.class); Tache returned = target("taches").path(tache.getId().toString()).request().get(Tache.class);
assertEquals(tache, returned); assertEquals(tache, returned);
...@@ -96,10 +95,24 @@ public class TodoRessourceTest extends JerseyTest { ...@@ -96,10 +95,24 @@ public class TodoRessourceTest extends JerseyTest {
@Test @Test
public void get_with_wrong_id_should_return_404() { public void get_with_wrong_id_should_return_404() {
Tache tache = new Tache();
tache.setNom("test");
tache.setDescription("description");
dao.insert(tache);
Tache returned = target("taches").path(tache.getId().toString()).request().get(Tache.class);
assertEquals(tache, returned);
} }
@Test @Test
public void get_for_description_should_work_with_existing_task() { public void get_for_description_should_work_with_existing_task() {
Tache tache = new Tache();
tache.setNom("test");
tache.setDescription("description");
dao.insert(tache);
Tache returned = target("taches").path(tache.getDescription().toString()).request().get(Tache.class);
assertEquals(tache, returned);
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment