Skip to content
Snippets Groups Projects
Commit 47bd22b1 authored by Thomas OBRY's avatar Thomas OBRY
Browse files

aucune idee

parent c42d2483
Branches master
No related tags found
No related merge requests found
Pipeline #8289 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);
} }
...@@ -16,6 +16,7 @@ import jakarta.ws.rs.PUT; ...@@ -16,6 +16,7 @@ import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path; import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam; import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.EntityTag; import jakarta.ws.rs.core.EntityTag;
...@@ -46,6 +47,14 @@ public class TodoRessource { ...@@ -46,6 +47,14 @@ public class TodoRessource {
return todoService.getAll(); return todoService.getAll();
} }
@GET
@Path("{id}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Tache getById(@PathParam("id") String id) {
LOGGER.info("getById()");
return todoService.getTache(id);
}
@POST @POST
public Response createTache(CreationTacheDTO tacheDto) { public Response createTache(CreationTacheDTO tacheDto) {
LOGGER.info("createTache()"); LOGGER.info("createTache()");
......
...@@ -14,8 +14,9 @@ public class TodoService { ...@@ -14,8 +14,9 @@ public class TodoService {
taches.createTable(); taches.createTable();
} }
public Tache getTache(UUID id) { public Tache getTache(String id) {
return null; System.out.println(id);
return taches.getById(id.toString());
} }
public List<Tache> getAll() { public List<Tache> getAll() {
......
...@@ -36,13 +36,13 @@ public class TodoRessourceTest extends JerseyTest { ...@@ -36,13 +36,13 @@ public class TodoRessourceTest extends JerseyTest {
BDDFactory.setJdbiForTests(); BDDFactory.setJdbiForTests();
ResourceConfig rc = new ResourceConfig(TodoRessource.class); ResourceConfig rc = new ResourceConfig(TodoRessource.class);
// Dé-commenter pour avoir la trace des requêtes et réponses // Dé-commenter pour avoir la trace des requêtes et réponses
// rc.register(new rc.register(new
// LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME),
// Level.INFO, Level.INFO,
// LoggingFeature.Verbosity.PAYLOAD_ANY, 10000)); LoggingFeature.Verbosity.PAYLOAD_ANY, 10000));
// Dé-commenter pour avoir une trace des erreurs internes serveur (les tests sur // Dé-commenter pour avoir une trace des erreurs internes serveur (les tests sur
// le code de retour vont échouer) // le code de retour vont échouer)
// rc.register(DebugMapper.class); rc.register(DebugMapper.class);
return rc; return rc;
} }
...@@ -96,6 +96,13 @@ public class TodoRessourceTest extends JerseyTest { ...@@ -96,6 +96,13 @@ 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");
//
// Tache returned = target("taches").path(tache.getId().toString()).request().get(Tache.class);
Response response = target("taches").path("sfhkl").request().get();
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment