Skip to content
Snippets Groups Projects
Commit ed6ef19d authored by Hugo Dutoit's avatar Hugo Dutoit
Browse files

put

parent 55e849a0
Branches
No related tags found
No related merge requests found
Pipeline #9164 passed
......@@ -31,5 +31,8 @@ public interface TacheDAO {
@SqlUpdate("delete from taches where id=?")
int deleteTacheById(String id);
@SqlUpdate("UPDATE taches SET id=:id,nom=:nom,description=:description WHERE id=:id")
int update(@BindBean Tache tache);
}
......@@ -8,6 +8,7 @@ import java.util.logging.Logger;
import fr.ulille.iut.todo.dto.CreationTacheDTO;
import fr.ulille.iut.todo.service.Tache;
import fr.ulille.iut.todo.service.TodoService;
import jakarta.json.Json;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
......@@ -122,4 +123,15 @@ public class TodoRessource {
return Response.status(Response.Status.ACCEPTED).build();
}
@PUT
@Consumes({MediaType.APPLICATION_JSON})
public Response putIngredient(Tache t) {
if ( todoService.getTache(t.getId()) == null ) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
todoService.updateTache(t);
return Response.status(Response.Status.OK).build();
}
}
......@@ -31,6 +31,7 @@ public class TodoService {
}
public void updateTache(Tache tache) {
return;
taches.update(tache);
}
}
......@@ -137,6 +137,15 @@ public class TodoRessourceTest extends JerseyTest {
@Test
public void put_should_replace_existing_task_values_return_200_and_task() {
Tache tache = new Tache();
tache.setNom("test");
tache.setDescription("descriptionTest");
dao.insert(tache);
tache.setNom("Test Patch");
Response res = target("/taches").request().put(Entity.json(tache));
assertEquals(Response.Status.OK.getStatusCode(), res.getStatus());
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment