Skip to content
Snippets Groups Projects
Commit aefe0542 authored by Leonard Corre's avatar Leonard Corre
Browse files

presque fini

parent c42d2483
Branches
No related tags found
No related merge requests found
Pipeline #8288 failed
......@@ -24,5 +24,9 @@ public interface TacheDAO {
@SqlQuery("select * from taches")
@RegisterBeanMapper(Tache.class)
List<Tache> getAll();
@SqlQuery("select * from taches where id = ?")
@RegisterBeanMapper(Tache.class)
Tache getById(String id);
}
......@@ -5,6 +5,7 @@ import java.util.List;
import java.util.UUID;
import java.util.logging.Logger;
import fr.ulille.iut.todo.dao.UUIDArgumentFactory;
import fr.ulille.iut.todo.dto.CreationTacheDTO;
import fr.ulille.iut.todo.service.Tache;
import fr.ulille.iut.todo.service.TodoService;
......@@ -46,6 +47,16 @@ public class TodoRessource {
return todoService.getAll();
}
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("{id}")
public Tache getById(@PathParam("id") String id) {
LOGGER.info("getById()");
return todoService.getTache(UUID.fromString(id));
}
@POST
public Response createTache(CreationTacheDTO tacheDto) {
LOGGER.info("createTache()");
......
......@@ -15,7 +15,7 @@ public class TodoService {
}
public Tache getTache(UUID id) {
return null;
return taches.getById(id.toString());
}
public List<Tache> getAll() {
......@@ -33,4 +33,5 @@ public class TodoService {
public void updateTache(Tache tache) {
return;
}
}
......@@ -5,6 +5,7 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -88,7 +89,6 @@ public class TodoRessourceTest extends JerseyTest {
tache.setNom("test");
tache.setDescription("description");
dao.insert(tache);
Tache returned = target("taches").path(tache.getId().toString()).request().get(Tache.class);
assertEquals(tache, returned);
......@@ -96,6 +96,8 @@ public class TodoRessourceTest extends JerseyTest {
@Test
public void get_with_wrong_id_should_return_404() {
Response response = target("taches").path(UUID.randomUUID().toString()).request().get();
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment