diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..77acbc882ded4c0ad2334e146c3b1676a14638f5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,49 @@ +{ + "java.project.referencedLibraries": [ + "lib/**/*.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/annotations-api.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/catalina.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/catalina-ant.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/catalina-ha.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/catalina-ssi.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/catalina-storeconfig.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/catalina-tribes.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/ecj-4.27.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/el-api.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jackson-annotations-2.15.3.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jackson-core-2.15.3.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jackson-databind-2.15.3.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jackson-dataformat-xml-2.15.3.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jakartaee-migration-1.0.7-shaded.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jasper.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jasper-el.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jaspic-api.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jjwt-api-0.12.5.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jjwt-impl-0.12.5.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jjwt-jackson-0.12.5.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/jsp-api.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/postgresql-42.6.0.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/servlet-api.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/stax2-api-4.2.2.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-api.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-coyote.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-dbcp.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-i18n-cs.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-i18n-de.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-i18n-es.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-i18n-fr.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-i18n-ja.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-i18n-ko.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-i18n-pt-BR.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-i18n-ru.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-i18n-zh-CN.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-jdbc.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-jni.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-util.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-util-scan.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/tomcat-websocket.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/websocket-api.jar", + "/home/infoetu/antoine.gaienier.etu/tomcat/lib/websocket-client-api.jar" + ], + "java.project.outputPath": "WEB-INF/classes" +} \ No newline at end of file diff --git a/WEB-INF/bruno/pizzeria/1_ingredient/IngrediantPatch price.bru b/WEB-INF/bruno/pizzeria/1_Ingredient/IngrediantPatch price.bru similarity index 85% rename from WEB-INF/bruno/pizzeria/1_ingredient/IngrediantPatch price.bru rename to WEB-INF/bruno/pizzeria/1_Ingredient/IngrediantPatch price.bru index 08a16123940c5b9dc04a6d22c13143b5e4374ef1..7eb9720fb7a6deba1fd857e5ad441104d977a348 100644 --- a/WEB-INF/bruno/pizzeria/1_ingredient/IngrediantPatch price.bru +++ b/WEB-INF/bruno/pizzeria/1_Ingredient/IngrediantPatch price.bru @@ -15,3 +15,7 @@ body:json { "price":10.5 } } + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/1_ingredient/DeleteIngredient.bru b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Delete.bru similarity index 84% rename from WEB-INF/bruno/pizzeria/1_ingredient/DeleteIngredient.bru rename to WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Delete.bru index e43cc0ffa25a6e626749943776da4eac81b21d70..ad8bf7576c9d16d648f2fe1c31e498d1517df1d3 100644 --- a/WEB-INF/bruno/pizzeria/1_ingredient/DeleteIngredient.bru +++ b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Delete.bru @@ -1,7 +1,7 @@ meta { - name: DeleteIngredient + name: Ingredient Delete type: http - seq: 7 + seq: 9 } delete { diff --git a/WEB-INF/bruno/pizzeria/1_ingredient/FindIngrediantByID.bru b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient FindByID.bru similarity index 65% rename from WEB-INF/bruno/pizzeria/1_ingredient/FindIngrediantByID.bru rename to WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient FindByID.bru index f3148a3fef218291b52de532112f9e56e8d6133b..d0e602671444f600742042e0018fa56eff44f464 100644 --- a/WEB-INF/bruno/pizzeria/1_ingredient/FindIngrediantByID.bru +++ b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient FindByID.bru @@ -1,5 +1,5 @@ meta { - name: FindIngrediantByID + name: Ingredient FindByID type: http seq: 2 } @@ -9,3 +9,7 @@ get { body: none auth: none } + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/1_ingredient/findall.bru b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Findall.bru similarity index 81% rename from WEB-INF/bruno/pizzeria/1_ingredient/findall.bru rename to WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Findall.bru index a21f00c93543f295f1368a7c870fc661d9817267..0418102203e26c39f62dcc22240577645ecc6c76 100644 --- a/WEB-INF/bruno/pizzeria/1_ingredient/findall.bru +++ b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Findall.bru @@ -1,5 +1,5 @@ meta { - name: findall + name: Ingredient Findall type: http seq: 1 } diff --git a/WEB-INF/bruno/pizzeria/1_ingredient/Ingredient Patch name.bru b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Patch name.bru similarity index 85% rename from WEB-INF/bruno/pizzeria/1_ingredient/Ingredient Patch name.bru rename to WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Patch name.bru index 753735e8f7abcd22624191ed11275ec23e47abc9..267a69d09d0ef9b806cb15d6bb1af70e39fb00a8 100644 --- a/WEB-INF/bruno/pizzeria/1_ingredient/Ingredient Patch name.bru +++ b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Patch name.bru @@ -15,3 +15,7 @@ body:json { "name":"poisson" } } + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/1_ingredient/IngrediantPost.bru b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Post.bru similarity index 76% rename from WEB-INF/bruno/pizzeria/1_ingredient/IngrediantPost.bru rename to WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Post.bru index e1f2213670a3a9678818ad98ca692d87c7280ca3..996de26b27dd8be0d593cad503a06ac67039bc2d 100644 --- a/WEB-INF/bruno/pizzeria/1_ingredient/IngrediantPost.bru +++ b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Post.bru @@ -1,5 +1,5 @@ meta { - name: IngrediantPost + name: Ingredient Post type: http seq: 4 } @@ -17,3 +17,7 @@ body:json { "price":0 } } + +assert { + res.status: eq 201 +} diff --git a/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Put.bru b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Put.bru new file mode 100644 index 0000000000000000000000000000000000000000..7f98d8279f632489f531bf19f212dde1634ec650 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingredient Put.bru @@ -0,0 +1,19 @@ +meta { + name: Ingredient Put + type: http + seq: 7 +} + +put { + url: http://localhost:8080/pizzeria/ingredients + body: json + auth: none +} + +body:json { + { + "id": 0, + "name":"coke" , + "price":50 + } +} diff --git a/WEB-INF/bruno/pizzeria/1_ingredient/IngretiantName.bru b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingretiant FindByID Name.bru similarity index 65% rename from WEB-INF/bruno/pizzeria/1_ingredient/IngretiantName.bru rename to WEB-INF/bruno/pizzeria/1_Ingredient/Ingretiant FindByID Name.bru index 297ac658ec02269dc52ad3445f2f1ce4afe7f982..468e13a7ab692a002ffd29af028c6ade73422042 100644 --- a/WEB-INF/bruno/pizzeria/1_ingredient/IngretiantName.bru +++ b/WEB-INF/bruno/pizzeria/1_Ingredient/Ingretiant FindByID Name.bru @@ -1,5 +1,5 @@ meta { - name: IngretiantName + name: Ingretiant FindByID Name type: http seq: 3 } @@ -9,3 +9,7 @@ get { body: none auth: none } + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/2_ingrediantError/FailDelete.bru b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Delete Faill.bru similarity index 82% rename from WEB-INF/bruno/pizzeria/2_ingrediantError/FailDelete.bru rename to WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Delete Faill.bru index abb421b7f57ed5ee9593cf6c3817976a86c4e792..f2c384da0297d4363c901cfe121aa9ef7dbe5623 100644 --- a/WEB-INF/bruno/pizzeria/2_ingrediantError/FailDelete.bru +++ b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Delete Faill.bru @@ -1,5 +1,5 @@ meta { - name: FailDelete + name: Ingredient Delete Faill type: http seq: 5 } diff --git a/WEB-INF/bruno/pizzeria/2_ingrediantError/FindByIDFail.bru b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient FindByID Faill.bru similarity index 81% rename from WEB-INF/bruno/pizzeria/2_ingrediantError/FindByIDFail.bru rename to WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient FindByID Faill.bru index 5776f8fe833c4d84b8901489b77243febf6ff05b..bd06dfeda82f47409cdd84373df9e45e8d5dabdf 100644 --- a/WEB-INF/bruno/pizzeria/2_ingrediantError/FindByIDFail.bru +++ b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient FindByID Faill.bru @@ -1,5 +1,5 @@ meta { - name: FindByIDFail + name: Ingredient FindByID Faill type: http seq: 1 } diff --git a/WEB-INF/bruno/pizzeria/2_ingrediantError/FindByIDNameFail.bru b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient FindByID Name Faill.bru similarity index 81% rename from WEB-INF/bruno/pizzeria/2_ingrediantError/FindByIDNameFail.bru rename to WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient FindByID Name Faill.bru index ebb72f0fadaf1a6417f903d80b2567ad757fd237..6f5bddef40e6204f119437bddcf632e735225188 100644 --- a/WEB-INF/bruno/pizzeria/2_ingrediantError/FindByIDNameFail.bru +++ b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient FindByID Name Faill.bru @@ -1,5 +1,5 @@ meta { - name: FindByIDNameFail + name: Ingredient FindByID Name Faill type: http seq: 6 } diff --git a/WEB-INF/bruno/pizzeria/2_ingrediantError/Ingredient Patch name fail.bru b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Patch Faill (name colonne).bru similarity index 80% rename from WEB-INF/bruno/pizzeria/2_ingrediantError/Ingredient Patch name fail.bru rename to WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Patch Faill (name colonne).bru index 6b8c20d5903d42497c4d85c57a9530936e5146ce..726867863fab71b111d541e24d9b9021af0846a6 100644 --- a/WEB-INF/bruno/pizzeria/2_ingrediantError/Ingredient Patch name fail.bru +++ b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Patch Faill (name colonne).bru @@ -1,5 +1,5 @@ meta { - name: Ingredient Patch name fail + name: Ingredient Patch Faill (name colonne) type: http seq: 3 } diff --git a/WEB-INF/bruno/pizzeria/2_ingrediantError/Ingredient Patch fail (not foud ingredient).bru b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Patch Faill (not foud ingredient).bru similarity index 78% rename from WEB-INF/bruno/pizzeria/2_ingrediantError/Ingredient Patch fail (not foud ingredient).bru rename to WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Patch Faill (not foud ingredient).bru index 85f2abd5d558377545d367eb3efb27f58fbe6d7a..4d885844c42ca0fb3bb333d714698fc061ed0333 100644 --- a/WEB-INF/bruno/pizzeria/2_ingrediantError/Ingredient Patch fail (not foud ingredient).bru +++ b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Patch Faill (not foud ingredient).bru @@ -1,5 +1,5 @@ meta { - name: Ingredient Patch fail (not foud ingredient) + name: Ingredient Patch Faill (not foud ingredient) type: http seq: 4 } diff --git a/WEB-INF/bruno/pizzeria/2_ingrediantError/IngrediantPostFail.bru b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Post Faill.bru similarity index 88% rename from WEB-INF/bruno/pizzeria/2_ingrediantError/IngrediantPostFail.bru rename to WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Post Faill.bru index 7b4f63fdc0f6eb100d8c8db0ae11ac3b6e3d58a0..a0ad61c6da142e523bc5c24af6dcd20c7fbd13af 100644 --- a/WEB-INF/bruno/pizzeria/2_ingrediantError/IngrediantPostFail.bru +++ b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/Ingredient Post Faill.bru @@ -1,5 +1,5 @@ meta { - name: IngrediantPostFail + name: Ingredient Post Faill type: http seq: 2 } diff --git a/WEB-INF/bruno/pizzeria/2_IngrediantFaill/ingredient Put Faill.bru b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/ingredient Put Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..6c350a4999c143a767e57a763fef2a09e33ff6c0 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/2_IngrediantFaill/ingredient Put Faill.bru @@ -0,0 +1,23 @@ +meta { + name: ingredient Put Faill + type: http + seq: 7 +} + +put { + url: http://localhost:8080/pizzeria/ingredients + body: json + auth: none +} + +body:json { + { + "id": 0, + "name": "coke", + "price": 50 + } +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName (chorizo 2).bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName (chorizo 2).bru new file mode 100644 index 0000000000000000000000000000000000000000..598972d025323044b7a9526f4dbd7972ba7b1bcb --- /dev/null +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName (chorizo 2).bru @@ -0,0 +1,15 @@ +meta { + name: Pizza ByName (chorizo 2) + type: http + seq: 11 +} + +get { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: none + auth: none +} + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName (chorizo 3).bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName (chorizo 3).bru new file mode 100644 index 0000000000000000000000000000000000000000..d2c83746f89e870c1234b43898f4d15e7d92489d --- /dev/null +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName (chorizo 3).bru @@ -0,0 +1,15 @@ +meta { + name: Pizza ByName (chorizo 3) + type: http + seq: 13 +} + +get { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: none + auth: none +} + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName (chorizo).bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName (chorizo).bru new file mode 100644 index 0000000000000000000000000000000000000000..ea049f42d091774972cb8b4cb830af6779ca21e2 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName (chorizo).bru @@ -0,0 +1,15 @@ +meta { + name: Pizza ByName (chorizo) + type: http + seq: 9 +} + +get { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: none + auth: none +} + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/PizzaByName.bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName.bru similarity index 69% rename from WEB-INF/bruno/pizzeria/3_Pizza/PizzaByName.bru rename to WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName.bru index baa5588c22dae0f309520d6597e30e374ff03388..88bb1955666b80733b3bfcf589dafd453ea6f5e0 100644 --- a/WEB-INF/bruno/pizzeria/3_Pizza/PizzaByName.bru +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza ByName.bru @@ -1,5 +1,5 @@ meta { - name: PizzaByName + name: Pizza ByName type: http seq: 2 } @@ -9,3 +9,7 @@ get { body: none auth: none } + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Delete (une pizza).bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Delete (une pizza).bru index 651c68955725cc1f376130576044dd8761455eb9..d1a10c2950d18cefa656db1178c816ae91a7ed21 100644 --- a/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Delete (une pizza).bru +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Delete (une pizza).bru @@ -1,7 +1,7 @@ meta { name: Pizza Delete (une pizza) type: http - seq: 6 + seq: 14 } delete { diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/pizzaALL.bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza FindALL.bru similarity index 83% rename from WEB-INF/bruno/pizzeria/3_Pizza/pizzaALL.bru rename to WEB-INF/bruno/pizzeria/3_Pizza/Pizza FindALL.bru index ce2ec088fcd3e8385c8492605c0fb4ac83d294b7..0a544a83f21c83cfe1a7f788866fc32c66ef2c45 100644 --- a/WEB-INF/bruno/pizzeria/3_Pizza/pizzaALL.bru +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza FindALL.bru @@ -1,5 +1,5 @@ meta { - name: pizzaALL + name: Pizza FindALL type: http seq: 1 } diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/PizzaPrixtotal.bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza FindByName Prixtotal.bru similarity index 65% rename from WEB-INF/bruno/pizzeria/3_Pizza/PizzaPrixtotal.bru rename to WEB-INF/bruno/pizzeria/3_Pizza/Pizza FindByName Prixtotal.bru index 96a90a3842db8adb6f1f4ae945b8e033f5945235..c505f35870b62d7adce3b37f01105b9e72fe334a 100644 --- a/WEB-INF/bruno/pizzeria/3_Pizza/PizzaPrixtotal.bru +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza FindByName Prixtotal.bru @@ -1,5 +1,5 @@ meta { - name: PizzaPrixtotal + name: Pizza FindByName Prixtotal type: http seq: 3 } @@ -9,3 +9,7 @@ get { body: none auth: none } + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (liste ingrediant).bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (liste ingrediant).bru new file mode 100644 index 0000000000000000000000000000000000000000..2b95e43b3b7988545a6b014ca3a8516869f15942 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (liste ingrediant).bru @@ -0,0 +1,33 @@ +meta { + name: Pizza Patch (liste ingrediant) + type: http + seq: 8 +} + +patch { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: json + auth: none +} + +body:json { + { + "ingredients":[ + { + "id": 1, + "name": "pomme de terre", + "price": 1 + }, + { + "id": 3, + "name": "chorizo", + "price": 2 + }, + { + "id": 4, + "name": "lardons", + "price": 2 + } + ] + } +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (pate et prixbase).bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (pate et prixbase).bru new file mode 100644 index 0000000000000000000000000000000000000000..cb51816901ad066fb843d065be05aaafcec29fdd --- /dev/null +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (pate et prixbase).bru @@ -0,0 +1,18 @@ +meta { + name: Pizza Patch (pate et prixbase) + type: http + seq: 10 +} + +patch { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: json + auth: none +} + +body:json { + { + "pate":"super fine", + "prixBase" :5.25 + } +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (prixbase).bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (prixbase).bru new file mode 100644 index 0000000000000000000000000000000000000000..f2e8cad6c945c742c8609a789ef40b67e253985c --- /dev/null +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (prixbase).bru @@ -0,0 +1,17 @@ +meta { + name: Pizza Patch (prixbase) + type: http + seq: 7 +} + +patch { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: json + auth: none +} + +body:json { + { + "prixBase" :9.4 + } +} diff --git "a/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (p\303\242te).bru" "b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (p\303\242te).bru" new file mode 100644 index 0000000000000000000000000000000000000000..fc3d8305d959d55516328c995d0754f0b70c3a13 --- /dev/null +++ "b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Patch (p\303\242te).bru" @@ -0,0 +1,17 @@ +meta { + name: Pizza Patch (pâte) + type: http + seq: 6 +} + +patch { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: json + auth: none +} + +body:json { + { + "pate" :"fine" + } +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/PizzaPost.bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Post.bru similarity index 88% rename from WEB-INF/bruno/pizzeria/3_Pizza/PizzaPost.bru rename to WEB-INF/bruno/pizzeria/3_Pizza/Pizza Post.bru index a31e7610b2b24b757e60274291ebdfea778af0c7..d2fb1dcf69e9404f85ea7e201819e3403d660b8f 100644 --- a/WEB-INF/bruno/pizzeria/3_Pizza/PizzaPost.bru +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizza Post.bru @@ -1,5 +1,5 @@ meta { - name: PizzaPost + name: Pizza Post type: http seq: 4 } @@ -29,3 +29,7 @@ body:json { } } + +assert { + res.status: eq 201 +} diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/PizzaDeleteIngredient (un ingredient d'une pizza).bru b/WEB-INF/bruno/pizzeria/3_Pizza/PizzaDelete Ingredient (un ingredient d'une pizza).bru similarity index 67% rename from WEB-INF/bruno/pizzeria/3_Pizza/PizzaDeleteIngredient (un ingredient d'une pizza).bru rename to WEB-INF/bruno/pizzeria/3_Pizza/PizzaDelete Ingredient (un ingredient d'une pizza).bru index b55a0e44633ce64e21bdce2d14a07ff64b389564..843cc8c749439f518cd76727a733de06b0c9875f 100644 --- a/WEB-INF/bruno/pizzeria/3_Pizza/PizzaDeleteIngredient (un ingredient d'une pizza).bru +++ b/WEB-INF/bruno/pizzeria/3_Pizza/PizzaDelete Ingredient (un ingredient d'une pizza).bru @@ -1,5 +1,5 @@ meta { - name: PizzaDeleteIngredient (un ingredient d'une pizza) + name: PizzaDelete Ingredient (un ingredient d'une pizza) type: http seq: 5 } diff --git a/WEB-INF/bruno/pizzeria/3_Pizza/Pizzaa Put.bru b/WEB-INF/bruno/pizzeria/3_Pizza/Pizzaa Put.bru new file mode 100644 index 0000000000000000000000000000000000000000..a0b7113d45c67b405b011dcd4ddeaa26f805fad8 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/3_Pizza/Pizzaa Put.bru @@ -0,0 +1,30 @@ +meta { + name: Pizzaa Put + type: http + seq: 12 +} + +put { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: json + auth: none +} + +body:json { + { + "nom" : "chorizo", + "pate" :"finne", + "prixBase" : 45, + "ingredients":[ + { + "id":7 , + "name":"sauce tomate" , + "price":0.50 + }, + {"id":1 , + "name":"pomme de terre" , + "price":1 + } + ] + } +} diff --git a/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Delete (une pizza) Faill.bru b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Delete (une pizza) Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..b2da78b8e17f818fa121e8b5895fd61e0e20ea86 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Delete (une pizza) Faill.bru @@ -0,0 +1,15 @@ +meta { + name: Pizza Delete (une pizza) Faill + type: http + seq: 6 +} + +delete { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: none + auth: none +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza FindByName Faill.bru b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza FindByName Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..5e8f3eefb8f1424187a9500ddc08e68f81166fab --- /dev/null +++ b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza FindByName Faill.bru @@ -0,0 +1,15 @@ +meta { + name: Pizza FindByName Faill + type: http + seq: 1 +} + +get { + url: http://localhost:8080/pizzeria/pizzas/hawaienne + body: none + auth: none +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Patch Faill (sur une colonne).bru b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Patch Faill (sur une colonne).bru new file mode 100644 index 0000000000000000000000000000000000000000..c1f42a0c26e1b234a74adb8f5a63ba0d2537c6de --- /dev/null +++ b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Patch Faill (sur une colonne).bru @@ -0,0 +1,21 @@ +meta { + name: Pizza Patch Faill (sur une colonne) + type: http + seq: 4 +} + +patch { + url: http://localhost:8080/pizzeria/pizzas/3fromages + body: json + auth: none +} + +body:json { + { + "paate" :"fine" + } +} + +assert { + res.status: eq 500 +} diff --git a/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Patch Faill.bru b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Patch Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..8e93a8df83458746e4f17b891cfb4f6bff098ad4 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Patch Faill.bru @@ -0,0 +1,21 @@ +meta { + name: Pizza Patch Faill + type: http + seq: 5 +} + +patch { + url: http://localhost:8080/pizzeria/pizzas/chorizo + body: json + auth: none +} + +body:json { + { + "pate" :"fine" + } +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Post Faill.bru b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Post Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..2f66654d47deca743a42a36cd31be6767be513a3 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/4_PizzaFaill/Pizza Post Faill.bru @@ -0,0 +1,35 @@ +meta { + name: Pizza Post Faill + type: http + seq: 2 +} + +post { + url: http://localhost:8080/pizzeria/pizzas + body: json + auth: none +} + +body:json { + { + "nom" : "3fromages", + "pate" :"classique", + "prixBase" : 4, + "ingredients":[ + { + "id":7 , + "name":"sauce tomate" , + "price":0.50 + }, + {"id":1 , + "name":"pomme de terre" , + "price":1 + } + ] + } + +} + +assert { + res.status: eq 409 +} diff --git a/WEB-INF/bruno/pizzeria/4_PizzaFaill/PizzaDelete (un ingredient d'une pizza)Faill.bru b/WEB-INF/bruno/pizzeria/4_PizzaFaill/PizzaDelete (un ingredient d'une pizza)Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..5a5bda2db1cbb7881ab7a6e002b4a413ecfce6f0 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/4_PizzaFaill/PizzaDelete (un ingredient d'une pizza)Faill.bru @@ -0,0 +1,15 @@ +meta { + name: PizzaDelete (un ingredient d'une pizza)Faill + type: http + seq: 3 +} + +delete { + url: http://localhost:8080/pizzeria/pizzas/3fromages/1 + body: none + auth: none +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/5_Commande/Commande Delete (une pizza).bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Delete (une commande).bru similarity index 68% rename from WEB-INF/bruno/pizzeria/5_Commande/Commande Delete (une pizza).bru rename to WEB-INF/bruno/pizzeria/5_Commande/Commandes Delete (une commande).bru index b625b595c742b88630be3727f57d63a929a8f396..e1673bbe392710b379e4573c1cd53746c190866d 100644 --- a/WEB-INF/bruno/pizzeria/5_Commande/Commande Delete (une pizza).bru +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Delete (une commande).bru @@ -1,7 +1,7 @@ meta { - name: Commande Delete (une pizza) + name: Commandes Delete (une commande) type: http - seq: 4 + seq: 11 } delete { diff --git a/WEB-INF/bruno/pizzeria/5_Commande/Commande Delete (une commande).bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Delete (une pizza ).bru similarity index 71% rename from WEB-INF/bruno/pizzeria/5_Commande/Commande Delete (une commande).bru rename to WEB-INF/bruno/pizzeria/5_Commande/Commandes Delete (une pizza ).bru index 96f585faafeb92ba6a1aeeec8724f9ed2c5f563c..8f55f901bf8fad31c2231c4ddf1dfa06304f827d 100644 --- a/WEB-INF/bruno/pizzeria/5_Commande/Commande Delete (une commande).bru +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Delete (une pizza ).bru @@ -1,7 +1,7 @@ meta { - name: Commande Delete (une commande) + name: Commandes Delete (une pizza ) type: http - seq: 5 + seq: 6 } delete { diff --git a/WEB-INF/bruno/pizzeria/5_Commande/Commandes Pach (pizzas).bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Pach (pizzas).bru new file mode 100644 index 0000000000000000000000000000000000000000..85206557ba15ab3eddae8341fbafb7ce59329b16 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Pach (pizzas).bru @@ -0,0 +1,21 @@ +meta { + name: Commandes Pach (pizzas) + type: http + seq: 7 +} + +patch { + url: http://localhost:8080/pizzeria/commandes/4 + body: json + auth: none +} + +body:json { + { + "pizzas": [ + { + "nom": "3fromages" + } + ] + } +} diff --git a/WEB-INF/bruno/pizzeria/5_Commande/Commandes Patch (nom et date).bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Patch (nom et date).bru new file mode 100644 index 0000000000000000000000000000000000000000..0ba200d5d0b5fb5a9b9406d4ab320a78bd6f6fd1 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Patch (nom et date).bru @@ -0,0 +1,19 @@ +meta { + name: Commandes Patch (nom et date) + type: http + seq: 5 +} + +patch { + url: http://localhost:8080/pizzeria/commandes/4 + body: json + auth: none +} + +body:json { + { + "nom": "machin bipbip", + "date": 17118224000000 + } + +} diff --git a/WEB-INF/bruno/pizzeria/5_Commande/CommandePost.bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Post.bru similarity index 82% rename from WEB-INF/bruno/pizzeria/5_Commande/CommandePost.bru rename to WEB-INF/bruno/pizzeria/5_Commande/Commandes Post.bru index effed991995bd308b0cc1fb2870d6cba247fa0e2..7de10cff1a50289c084c515131e9508306d386dc 100644 --- a/WEB-INF/bruno/pizzeria/5_Commande/CommandePost.bru +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Post.bru @@ -1,7 +1,7 @@ meta { - name: CommandePost + name: Commandes Post type: http - seq: 3 + seq: 4 } post { @@ -25,3 +25,7 @@ body:json { ] } } + +assert { + res.status: eq 201 +} diff --git a/WEB-INF/bruno/pizzeria/5_Commande/Commandes Put.bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Put.bru new file mode 100644 index 0000000000000000000000000000000000000000..669675ff485ca13a067ca2b1e59ea821c68cee19 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes Put.bru @@ -0,0 +1,27 @@ +meta { + name: Commandes Put + type: http + seq: 9 +} + +put { + url: http://localhost:8080/pizzeria/commandes/4 + body: json + auth: none +} + +body:json { + { + "id": 4, + "nom": "machin chose", + "date": 1711922400000, + "pizzas": [ + { + "nom": "3fromages" + }, + { + "nom": "6fromages" + } + ] + } +} diff --git a/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById (commande 4 Patch).bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById (commande 4 Patch).bru new file mode 100644 index 0000000000000000000000000000000000000000..3e9e25e902893afc498e71039617c11adc159b07 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById (commande 4 Patch).bru @@ -0,0 +1,15 @@ +meta { + name: Commandes findById (commande 4 Patch) + type: http + seq: 8 +} + +get { + url: http://localhost:8080/pizzeria/commandes/4 + body: none + auth: none +} + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById (commandes 4 Put).bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById (commandes 4 Put).bru new file mode 100644 index 0000000000000000000000000000000000000000..8f1c5632f0dd4ced01bcba08245f9806ca0087bb --- /dev/null +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById (commandes 4 Put).bru @@ -0,0 +1,15 @@ +meta { + name: Commandes findById (commandes 4 Put) + type: http + seq: 10 +} + +get { + url: http://localhost:8080/pizzeria/commandes/4 + body: none + auth: none +} + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById.bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById.bru index 723c18ae3e1fba1ef6c03c7076da29f358e2408b..43cf2fe8bb19d16c4e0919831055fc144123410c 100644 --- a/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById.bru +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes findById.bru @@ -9,3 +9,7 @@ get { body: none auth: none } + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/5_Commande/Commandes totalPrice.bru b/WEB-INF/bruno/pizzeria/5_Commande/Commandes totalPrice.bru index 1efca787b2f49831022e69bb3de6f46d4b82d1fa..4d75dcf946a8c30c80d5557b737efdc48802374d 100644 --- a/WEB-INF/bruno/pizzeria/5_Commande/Commandes totalPrice.bru +++ b/WEB-INF/bruno/pizzeria/5_Commande/Commandes totalPrice.bru @@ -1,7 +1,7 @@ meta { name: Commandes totalPrice type: http - seq: 6 + seq: 3 } get { @@ -9,3 +9,7 @@ get { body: none auth: none } + +assert { + res.status: eq 302 +} diff --git a/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Delete (une commande) Faill.bru b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Delete (une commande) Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..37a2e437dd91f51a109d28114b9d8911a171f8ae --- /dev/null +++ b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Delete (une commande) Faill.bru @@ -0,0 +1,15 @@ +meta { + name: Commandes Delete (une commande) Faill + type: http + seq: 8 +} + +delete { + url: http://localhost:8080/pizzeria/commandes/4 + body: none + auth: none +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Delete (une pizza) Faill.bru b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Delete (une pizza) Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..0e66fed84b58eafd4206e4fff1736c399101ca60 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Delete (une pizza) Faill.bru @@ -0,0 +1,15 @@ +meta { + name: Commandes Delete (une pizza) Faill + type: http + seq: 7 +} + +delete { + url: http://localhost:8080/pizzeria/commandes/1/6fromages + body: none + auth: none +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Patch Faill(nom colonne).bru b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Patch Faill(nom colonne).bru new file mode 100644 index 0000000000000000000000000000000000000000..3bcd9cfa7a5fcb670e503f02411f392790ad075d --- /dev/null +++ b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Patch Faill(nom colonne).bru @@ -0,0 +1,22 @@ +meta { + name: Commandes Patch Faill(nom colonne) + type: http + seq: 2 +} + +patch { + url: http://localhost:8080/pizzeria/commandes/1 + body: json + auth: none +} + +body:json { + { + "mmmmmm": "machin bipbip" + } + +} + +assert { + res.status: eq 500 +} diff --git a/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Patch Faill.bru b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Patch Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..82787309527de686ea58de5b4eb430d50eaae5b9 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Patch Faill.bru @@ -0,0 +1,23 @@ +meta { + name: Commandes Patch Faill + type: http + seq: 3 +} + +patch { + url: http://localhost:8080/pizzeria/commandes/4 + body: json + auth: none +} + +body:json { + { + "nom": "machin bipbip", + "date": 17118224000000 + } + +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Post Faill.bru b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Post Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..7843a07ef05c5ca2ad0882bfce158a02a60407cd --- /dev/null +++ b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Post Faill.bru @@ -0,0 +1,31 @@ +meta { + name: Commandes Post Faill + type: http + seq: 6 +} + +post { + url: http://localhost:8080/pizzeria/commandes + body: json + auth: none +} + +body:json { + { + "id": 1, + "nom": "truc bidule", + "date": 1711922400000, + "pizzas": [ + { + "nom": "6fromages" + }, + { + "nom": "3fromages" + } + ] + } +} + +assert { + res.status: eq 409 +} diff --git a/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Put Faill.bru b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Put Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..1ad590d0102037d063d8120a9edcbf903872bce1 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes Put Faill.bru @@ -0,0 +1,31 @@ +meta { + name: Commandes Put Faill + type: http + seq: 5 +} + +put { + url: http://localhost:8080/pizzeria/commandes/4 + body: json + auth: none +} + +body:json { + { + "id": 4, + "nom": "machin chose", + "date": 1711922400000, + "pizzas": [ + { + "nom": "3fromages" + }, + { + "nom": "6fromages" + } + ] + } +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes findById Faill.bru b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes findById Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..65b4660029db288403abf045a2773d53ab30c790 --- /dev/null +++ b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes findById Faill.bru @@ -0,0 +1,15 @@ +meta { + name: Commandes findById Faill + type: http + seq: 1 +} + +get { + url: http://localhost:8080/pizzeria/commandes/0 + body: none + auth: none +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes totalPrice Faill.bru b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes totalPrice Faill.bru new file mode 100644 index 0000000000000000000000000000000000000000..52863bc7bc8a1b868e1833b9821f89b642ad5d6d --- /dev/null +++ b/WEB-INF/bruno/pizzeria/6_CommandeFaill/Commandes totalPrice Faill.bru @@ -0,0 +1,15 @@ +meta { + name: Commandes totalPrice Faill + type: http + seq: 4 +} + +get { + url: http://localhost:8080/pizzeria/commandes/0/prixfinal + body: none + auth: none +} + +assert { + res.status: eq 404 +} diff --git a/WEB-INF/classes/controleurs/CommandeRestAPI.class b/WEB-INF/classes/controleurs/CommandeRestAPI.class index 04276ec9131778ccc102a3960304d92762e5adc6..c98b6f66a7b70781ab826741e6f0617d08f57a87 100644 Binary files a/WEB-INF/classes/controleurs/CommandeRestAPI.class and b/WEB-INF/classes/controleurs/CommandeRestAPI.class differ diff --git a/WEB-INF/classes/controleurs/IngredientRestAPI.class b/WEB-INF/classes/controleurs/IngredientRestAPI.class index 8f19fdae6e2690d550afc107a97dc4403156e46c..988dddf397f43b80c8c0477201f253a125d97c54 100644 Binary files a/WEB-INF/classes/controleurs/IngredientRestAPI.class and b/WEB-INF/classes/controleurs/IngredientRestAPI.class differ diff --git a/WEB-INF/classes/controleurs/PizzasRestAPI.class b/WEB-INF/classes/controleurs/PizzasRestAPI.class index 4be926579fa3acd9f6aa791e484994c348ae879e..890114179c6965f2838a5e6611cb3e5e4f18b844 100644 Binary files a/WEB-INF/classes/controleurs/PizzasRestAPI.class and b/WEB-INF/classes/controleurs/PizzasRestAPI.class differ diff --git a/WEB-INF/classes/dao/CommandeDAO.class b/WEB-INF/classes/dao/CommandeDAO.class index 63a4a0686cf2de0a30e4ab095ec70bf6c675117c..a793b6d4b42dfc3387b39dcac0c8d30fd65e3523 100644 Binary files a/WEB-INF/classes/dao/CommandeDAO.class and b/WEB-INF/classes/dao/CommandeDAO.class differ diff --git a/WEB-INF/classes/dao/IngredientDAODatabase.class b/WEB-INF/classes/dao/IngredientDAODatabase.class index a2ed957200e05d1bad87951fbb6f9ad621d8cd88..2e267c7694f8dee10b5ea5251bcb79a30a556ef3 100644 Binary files a/WEB-INF/classes/dao/IngredientDAODatabase.class and b/WEB-INF/classes/dao/IngredientDAODatabase.class differ diff --git a/WEB-INF/classes/dao/PizzasDAO.class b/WEB-INF/classes/dao/PizzasDAO.class index 91b0c032c9d8b5010e1c80e45ae4696067a276c3..fd7209becc0578418f1662aafb264d0e6090c4f3 100644 Binary files a/WEB-INF/classes/dao/PizzasDAO.class and b/WEB-INF/classes/dao/PizzasDAO.class differ diff --git a/WEB-INF/classes/dto/Commande.class b/WEB-INF/classes/dto/Commande.class index cfcc9a6b601dd06e02f7629dd6209c528fb2cd9a..d49fa6b369cb286580e17608e05111a1d2c0e32b 100644 Binary files a/WEB-INF/classes/dto/Commande.class and b/WEB-INF/classes/dto/Commande.class differ diff --git a/WEB-INF/classes/dto/CommandeDetail$1.class b/WEB-INF/classes/dto/CommandeDetail$1.class new file mode 100644 index 0000000000000000000000000000000000000000..bdb9610e7f79e0926ac1dd537dd8d841c365c2a0 Binary files /dev/null and b/WEB-INF/classes/dto/CommandeDetail$1.class differ diff --git a/WEB-INF/classes/dto/CommandeDetail.class b/WEB-INF/classes/dto/CommandeDetail.class index d96f18c44e99303a239e20149f94a463faf551d3..51974b2fa4b0c2f38b7b10b75ca2f548257c5f9f 100644 Binary files a/WEB-INF/classes/dto/CommandeDetail.class and b/WEB-INF/classes/dto/CommandeDetail.class differ diff --git a/WEB-INF/classes/dto/PizzaCompo.class b/WEB-INF/classes/dto/PizzaCompo.class index 812d177e3fdbe0aba470dd63198d8ec2b5dd78a3..2562c799453f10f1ab0ee3799ce2f4e4f8793e9d 100644 Binary files a/WEB-INF/classes/dto/PizzaCompo.class and b/WEB-INF/classes/dto/PizzaCompo.class differ diff --git a/WEB-INF/pizzeria.sql b/WEB-INF/pizzeria.sql new file mode 100644 index 0000000000000000000000000000000000000000..5a7a403358bda7ac5ab1852fc424235f2f93556e --- /dev/null +++ b/WEB-INF/pizzeria.sql @@ -0,0 +1,100 @@ +Drop table if exists commande_detail cascade; +Drop table if exists commandes cascade; +Drop table if exists pizzas_ingredients cascade; + +Drop table if exists pizzas cascade; +Drop table if exists ingredients cascade; + +CREATE TABLE ingredients( + id int primary key, + name text, + price double precision + ); + + +CREATE TABLE pizzas( + nom text primary key, + pate text, + prixBase double precision + ); + +CREATE TABLE pizzas_ingredients( + nom text, + id int, + constraint fk_pizza foreign key (nom) references pizzas(nom) , + constraint fk_ingredient foreign key (id) references ingredients(id) , + primary key (nom,id) + ); + + + +CREATE TABLE commandes( + id int primary key, + nom text, + date date + ); + + + +CREATE table commande_detail( + id int, + nom text, + constraint fk_commande foreign key (id) references commandes(id) on delete cascade, + constraint fk_pizza foreign key (nom) references pizzas(nom), + primary key (id,nom) + ); + +/* Insertion des données */ + +insert into ingredients values (1,'pomme de terre',1); +insert into ingredients values (3,'chorizo',2); +insert into ingredients values (4,'lardons',2); +insert into ingredients values (5,'aubergines',1); +insert into ingredients values (6,'champignons',1); +insert into ingredients values (10,'fromage',3); +insert into ingredients values (7,'sauce tomate',0.5); +insert into ingredients values (8,'chevre',1.25); +insert into ingredients values (9,'mozzarella',0.75); +insert into ingredients values (2,'crème',2); + + +insert into pizzas values ('3fromages','classique',3.25); +insert into pizzas values ('4fromages','classique',3.75); +insert into pizzas values ('5fromages','fine',10); +insert into pizzas values ('6fromages','fine',10); + + +insert into pizzas_ingredients values ('3fromages',10); +insert into pizzas_ingredients values ('3fromages',7); +insert into pizzas_ingredients values ('3fromages',8); +insert into pizzas_ingredients values ('3fromages',9); +insert into pizzas_ingredients values ('6fromages',1); +insert into pizzas_ingredients values ('6fromages',2); +insert into pizzas_ingredients values ('6fromages',3); +insert into pizzas_ingredients values ('6fromages',8); +insert into pizzas_ingredients values ('4fromages',9); +insert into pizzas_ingredients values ('4fromages',8); +insert into pizzas_ingredients values ('4fromages',7); +insert into pizzas_ingredients values ('4fromages',10); + + +insert into commandes values (1,'jean machin','2024-04-01'); +insert into commandes values (2,'jean truc','2024-04-01'); +insert into commandes values (3,'jean bidule','2024-04-01'); + + +insert into commande_detail values (1,'3fromages'); +insert into commande_detail values (1,'4fromages'); +insert into commande_detail values (2,'3fromages'); +insert into commande_detail values (2,'4fromages'); +insert into commande_detail values (2,'6fromages'); +insert into commande_detail values (3,'3fromages'); + + + + + + + + + diff --git a/WEB-INF/src/controleurs/CommandeRestAPI.java b/WEB-INF/src/controleurs/CommandeRestAPI.java index e4878b60e8824dd9509a595d2ebd6896a79538e3..3876a071e2b4482f97558738c4a7e7a79f804fa4 100644 --- a/WEB-INF/src/controleurs/CommandeRestAPI.java +++ b/WEB-INF/src/controleurs/CommandeRestAPI.java @@ -28,26 +28,27 @@ public class CommandeRestAPI extends HttpServlet{ // si /commandes/{id}/prixtotal alors on renvoie le prix total de la commande {id} if (pathParts.length > 2 && pathParts[2].equals("prixfinal")) { int id = Integer.parseInt(pathParts[1]); - Commande commande = commandeDAO.findById(id); - if (commande == null) { + + if (commandeDAO.findById(id) == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { out.print(commandeDAO.totalPrice(id)); + response.setStatus(HttpServletResponse.SC_FOUND); } } // si /commandes/{id} alors on renvoie la commande {id} en JSON else if (pathParts.length > 1) { int id = Integer.parseInt(pathParts[1]); - Commande commande = commandeDAO.findById(id); - if (commande == null) { + if (commandeDAO.findById(id) == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { ObjectMapper mapper = new ObjectMapper(); - out.print(mapper.writeValueAsString(commande)); + out.print(mapper.writeValueAsString(commandeDAO.findById(id))); + response.setStatus(HttpServletResponse.SC_FOUND); } } } - // si /commandes alors on renvoie la liste des commandes en JSON + // si /commandes alors on renvoie toutes les commandes en JSON else { ObjectMapper mapper = new ObjectMapper(); out.println(mapper.writeValueAsString(commandeDAO.findAll())); @@ -59,28 +60,100 @@ public class CommandeRestAPI extends HttpServlet{ PrintWriter out = response.getWriter(); ObjectMapper mapper = new ObjectMapper(); CommandeDetail commande = mapper.readValue(request.getReader(), CommandeDetail.class); - commandeDAO.save(commande); - out.println(mapper.writeValueAsString(commande)); + // si la commande existe déjà, on renvoie une erreur conflict + if (commandeDAO.findById(commande.getId()) != null) { + response.sendError(HttpServletResponse.SC_CONFLICT); + + }else{ + // sinon on l'ajoute à la base de données + commandeDAO.save(commande); + out.println(mapper.writeValueAsString(commande)); + response.setStatus(HttpServletResponse.SC_CREATED); + } } public void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json; charset=UTF-8"); String pathInfo = request.getPathInfo(); PrintWriter out = response.getWriter(); - - // si /commandes/{id}/{pizza} alors on supprime la pizza {pizza} de la commande {id} + if (pathInfo != null) { String[] pathParts = pathInfo.split("/"); + // si /commandes/{id}/{pizza} alors on supprime la pizza {pizza} de la commande {id} if (pathParts.length > 2) { int id = Integer.parseInt(pathParts[1]); - String pizza = pathParts[2]; - commandeDAO.deleteCommandeDetail(id, pizza); - } - if (pathParts.length > 1) { + // si la commande {id} n'existe pas, on renvoie une erreur 404 + if (commandeDAO.findById(id) == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + }else { + String pizza = pathParts[2]; + // si la pizza {pizza} n'existe pas dans la commande {id}, on renvoie une erreur 404 + if (commandeDAO.commandeFindPizza(id, pizza)) { + commandeDAO.deleteCommandeDetail(id, pizza); + } else { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + } + } + } + // sinon on supprime la commande {id} + else if (pathParts.length > 1) { + int id = Integer.parseInt(pathParts[1]); + if (commandeDAO.findById(id) == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + } else { commandeDAO.deleteCommande(id); + } } } } + public void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("application/json; charset=UTF-8"); + PrintWriter out = response.getWriter(); + ObjectMapper mapper = new ObjectMapper(); + CommandeDetail commande = mapper.readValue(request.getReader(), CommandeDetail.class); + if (commandeDAO.findById(commande.getId()) == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + } else { + commandeDAO.update(commande); + out.println(mapper.writeValueAsString(commande)); + } + + } + + public void doPatch(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + response.setContentType("application/json; charset=UTF-8"); + PrintWriter out = response.getWriter(); + ObjectMapper mapper = new ObjectMapper(); + CommandeDetail commande = mapper.readValue(request.getReader(), CommandeDetail.class); + + String pathInfo = request.getPathInfo(); + String[] pathParts = pathInfo.split("/"); + int id = Integer.parseInt(pathParts[1]); + if (commandeDAO.findById(id) == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + } else { + commande.setId(id); + commandeDAO.commandePatch(id, commande); + out.println(mapper.writeValueAsString(commande)); + response.setStatus(HttpServletResponse.SC_OK); + } + } + @Override + public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if (request.getMethod().equals("GET")) { + doGet(request, response); + } else if (request.getMethod().equals("POST")) { + doPost(request, response); + } else if (request.getMethod().equals("DELETE")) { + doDelete(request, response); + } else if (request.getMethod().equals("PUT")) { + doPut(request, response); + } else if (request.getMethod().equals("PATCH")) { + doPatch(request, response); + } + } + } diff --git a/WEB-INF/src/controleurs/IngredientRestAPI.java b/WEB-INF/src/controleurs/IngredientRestAPI.java index b86f8ad5557492f307505cdff6e739dd8c3822d1..99c991e2decddb91dccbab63c3cad139733da9ce 100644 --- a/WEB-INF/src/controleurs/IngredientRestAPI.java +++ b/WEB-INF/src/controleurs/IngredientRestAPI.java @@ -37,6 +37,7 @@ public class IngredientRestAPI extends HttpServlet{ response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { out.print(ingredient.getName()); + response.setStatus(HttpServletResponse.SC_FOUND); } } // si /ingrédients/{id} alors on renvoie l'ingrédient {id} en JSON @@ -47,6 +48,7 @@ public class IngredientRestAPI extends HttpServlet{ response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { ObjectMapper mapper = new ObjectMapper(); + response.setStatus(HttpServletResponse.SC_FOUND); out.print(mapper.writeValueAsString(ingredient)); } @@ -92,17 +94,16 @@ public class IngredientRestAPI extends HttpServlet{ int id = Integer.parseInt(pathParts[1]); // regarde si l'ingrédient existe if (ingredientDAOList.findById(id) == null) { - //renvoie une erreur 404 response.sendError(HttpServletResponse.SC_NOT_FOUND); - out.println("L'ingrédient n'existe pas"); - + } else { //sinon on le supprime ingredientDAOList.delete(id); //et renvoi un message is le json de l'ingrédient supprimé + response.setStatus(HttpServletResponse.SC_OK); - out.println("L'ingrédient a bien été supprimé"); + out.println("{}"); } } @@ -156,6 +157,8 @@ public class IngredientRestAPI extends HttpServlet{ } } + + // faire une méthode service qui redirige vers les bonnes méthodes en fonction de la méthode de la requête public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getMethod().equals("GET")) { @@ -164,7 +167,7 @@ public class IngredientRestAPI extends HttpServlet{ doPost(request, response); } else if (request.getMethod().equals("DELETE")) { doDelete(request, response); - } else if (request.getMethod().equals("UPDATE")) { + } else if (request.getMethod().equals("PUT")) { doPut(request, response); } else if (request.getMethod().equals("PATCH")) { doPatch(request, response); diff --git a/WEB-INF/src/controleurs/PizzasRestAPI.java b/WEB-INF/src/controleurs/PizzasRestAPI.java index 96585b93eaa6b28a208d10c3526dfdab0b48ba16..cb5c37fffb91008faeeaf42f0a0510a572e8da65 100644 --- a/WEB-INF/src/controleurs/PizzasRestAPI.java +++ b/WEB-INF/src/controleurs/PizzasRestAPI.java @@ -1,5 +1,6 @@ package controleurs; +import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebServlet; import java.io.IOException; @@ -31,6 +32,7 @@ public class PizzasRestAPI extends HttpServlet{ if (pizzasDAO.findByName(nom) != null){ PizzaCompo pizza = pizzasDAO.findByName(nom); out.print(pizzasDAO.totalPrice(nom)); + response.setStatus(HttpServletResponse.SC_FOUND); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); @@ -42,6 +44,7 @@ public class PizzasRestAPI extends HttpServlet{ if (pizzasDAO.findByName(nom) != null){ Pizza pizza = pizzasDAO.findByName(nom); out.println(mapper.writeValueAsString(pizza)); + response.setStatus(HttpServletResponse.SC_FOUND); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } @@ -58,12 +61,17 @@ public class PizzasRestAPI extends HttpServlet{ PrintWriter out = response.getWriter(); ObjectMapper mapper = new ObjectMapper(); PizzaCompo pizza = mapper.readValue(request.getReader(), PizzaCompo.class); - pizzasDAO.save(pizza); - out.println(mapper.writeValueAsString(pizza)); + if (pizzasDAO.findByName(pizza.getNom()) != null){ + response.sendError(HttpServletResponse.SC_CONFLICT); + + }else { + pizzasDAO.save(pizza); + out.println(mapper.writeValueAsString(pizza)); + response.setStatus(HttpServletResponse.SC_CREATED); + } + } - - // Supprimez une pizza de la base de données public void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("application/json; charset=UTF-8"); @@ -76,8 +84,15 @@ public class PizzasRestAPI extends HttpServlet{ String nom = pathParts[1]; int id = Integer.parseInt(pathParts[2]); if (pizzasDAO.findByName(nom) != null){ + // regarde si l'ingrédient existe dans la table pizzas_ingredient + if (!pizzasDAO.findPizzaIngredient(nom, id)) { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + } + else{ pizzasDAO.deletePizzaIngredient(nom, id); out.println("La relation entre la pizza et l'ingrédient a été supprimée"); + response.setStatus(HttpServletResponse.SC_OK); + } } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } @@ -96,4 +111,55 @@ public class PizzasRestAPI extends HttpServlet{ } + + @Override + public void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("application/json; charset=UTF-8"); + PrintWriter out = response.getWriter(); + ObjectMapper mapper = new ObjectMapper(); + PizzaCompo pizza = mapper.readValue(request.getReader(), PizzaCompo.class); + if (pizzasDAO.findByName(pizza.getNom()) != null){ + pizzasDAO.update(pizza); + out.println(mapper.writeValueAsString(pizza)); + response.setStatus(HttpServletResponse.SC_OK); + } else { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + } + } + + + public void doPatch(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("application/json; charset=UTF-8"); + PrintWriter out = response.getWriter(); + ObjectMapper mapper = new ObjectMapper(); + PizzaCompo pizza = mapper.readValue(request.getReader(), PizzaCompo.class); + + String pathInfo = request.getPathInfo(); + String[] pathParts = pathInfo.split("/"); + String nom = pathParts[1]; + + if( pizzasDAO.findByName(nom) != null){ + pizzasDAO.patchPizza(nom, pizza); + out.println(mapper.writeValueAsString(pizza)); + response.setStatus(HttpServletResponse.SC_OK); + } else { + response.sendError(HttpServletResponse.SC_NOT_FOUND); + } + } + + + @Override + protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if(request.getMethod().equals("PUT")) { + doPut(request, response); + } else if (request.getMethod().equals("DELETE")) { + doDelete(request, response); + } else if (request.getMethod().equals("POST")) { + doPost(request, response); + } else if(request.getMethod().equals("GET")) { + doGet(request, response); + } else if (request.getMethod().equals("PATCH")) { + doPatch(request, response); + } + } } diff --git a/WEB-INF/src/dao/CommandeDAO.java b/WEB-INF/src/dao/CommandeDAO.java index ecdbc2efa1a880c2fc8d1a464d2c7d4b98898e28..c3caa90363c9cd669d0a7bd4f104b7d2a9ff40d9 100644 --- a/WEB-INF/src/dao/CommandeDAO.java +++ b/WEB-INF/src/dao/CommandeDAO.java @@ -19,7 +19,7 @@ public class CommandeDAO { } - public Commande findById(int id) { + public CommandeDetail findById(int id) { try { Connection con = ds.getConnection(); String query = "select * from commandes where id = " + id + ";"; @@ -30,7 +30,7 @@ public class CommandeDAO { query = "select * from commande_detail where id = " + id + ";"; rs = con.createStatement().executeQuery(query); while (rs.next()) { - String nom = rs.getString("pizza"); + String nom = rs.getString("nom"); PizzaCompo pizza = new PizzasDAO().findByName(nom); commande.addPizza(pizza); } @@ -95,7 +95,7 @@ public class CommandeDAO { ResultSet rs = con.createStatement().executeQuery(query); while (rs.next()) { - String nom = rs.getString("pizza"); + String nom = rs.getString("nom"); total += new PizzasDAO().totalPrice(nom); } con.close(); @@ -110,7 +110,7 @@ public class CommandeDAO { public void deleteCommandeDetail(int id, String pizza) { try { Connection con = ds.getConnection(); - String query = "delete from commande_detail where id = " + id + " and pizza = '" + pizza + "';"; + String query = "delete from commande_detail where id = " + id + " and nom = '" + pizza + "';"; con.createStatement().executeUpdate(query); con.close(); } catch (Exception e) { @@ -130,4 +130,75 @@ public class CommandeDAO { System.out.println(e.getMessage()); } } -} + + public void update(CommandeDetail commande) { + try { + Connection con = ds.getConnection(); + String query = "update commandes set nom = '" + commande.getNom() + "', date = '" + commande.getDate() + "' where id = " + commande.getId() + ";"; + con.createStatement().executeUpdate(query); + query = "delete from commande_detail where id = " + commande.getId() + ";"; + con.createStatement().executeUpdate(query); + for (PizzaCompo pizza : commande.getPizzas()) { + query = "insert into commande_detail values (" + commande.getId() + ", '" + pizza.getNom() + "');"; + con.createStatement().executeUpdate(query); + } + con.close(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } + + public void commandePatch(int id, CommandeDetail commande) { + try { + Connection con = ds.getConnection(); + if (commande.getNom() != null) { + String query = "update commandes set nom = '" + commande.getNom() + "' where id = " + id + ";"; + con.createStatement().executeUpdate(query); + } + if (commande.getDate() != null) { + String query = "update commandes set date = '" + commande.getDate() + "' where id = " + id + ";"; + con.createStatement().executeUpdate(query); + } + con.close(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + if (!commande.getPizzas().isEmpty()) { + try { + Connection con = ds.getConnection(); + String query = "delete from commande_detail where id = " + id + ";"; + con.createStatement().executeUpdate(query); + for (PizzaCompo pizza : commande.getPizzas()) { + query = "insert into commande_detail values (" + id + ", '" + pizza.getNom() + "');"; + con.createStatement().executeUpdate(query); + } + con.close(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + + } + } + + public boolean commandeFindPizza(int id, String nom) { + try { + Connection con = ds.getConnection(); + String query = "select * from commande_detail where id = " + id + " and nom = '" + nom + "';"; + ResultSet rs = con.createStatement().executeQuery(query); + if (rs.next()) { + con.close(); + return true; + } + con.close(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + return false; + } + + public static void main(String[] args) { + CommandeDAO commandeDAO = new CommandeDAO(); + CommandeDetail commande = commandeDAO.findById(1); + System.out.println(commande); + } + } diff --git a/WEB-INF/src/dao/IngredientDAODatabase.java b/WEB-INF/src/dao/IngredientDAODatabase.java index 053dc2bd58685f9c969ebd7facd2935c5bd02305..86ab394c7f9c31dcdb0e84b6efde96c5ceca97df 100644 --- a/WEB-INF/src/dao/IngredientDAODatabase.java +++ b/WEB-INF/src/dao/IngredientDAODatabase.java @@ -75,7 +75,7 @@ public class IngredientDAODatabase { public void update(Ingredient ingredient) { try { Connection con = ds.getConnection(); - String query = "update ingredients set name = '" + ingredient.getName() + "', price = " + ingredient.getPrice() + " where id = " + ingredient.getId() + " where id=" + ingredient.getId() + ";"; + String query = "update ingredients set name = '" + ingredient.getName() + "', price = " + ingredient.getPrice() + " where id = " + ingredient.getId() +";"; con.createStatement().executeUpdate(query); con.close(); } catch (Exception e) {System.out.println(e.getMessage());} @@ -102,6 +102,13 @@ public class IngredientDAODatabase { con.close(); } catch (Exception e) {System.out.println(e.getMessage());} } + + + public static void main(String[] args) { + IngredientDAODatabase ingredientDAOList = new IngredientDAODatabase(); + ingredientDAOList.update(new Ingredient(0, "tomate", 1.5)); + } + } diff --git a/WEB-INF/src/dao/PizzasDAO.java b/WEB-INF/src/dao/PizzasDAO.java index 27cf9d04bdf95bffab0d986ccaeddb7c75629771..b315d10689e74d689df7bb0f809c411af9aaa623 100644 --- a/WEB-INF/src/dao/PizzasDAO.java +++ b/WEB-INF/src/dao/PizzasDAO.java @@ -131,11 +131,68 @@ public class PizzasDAO { try { Connection con = ds.getConnection(); String query = "update pizzas set pate = '" + pizza.getPate() + "', prixbase = " + pizza.getPrixBase() + " where nom = '" + pizza.getNom() + "';"; + + // delete all ingredients de la pizza + query = "delete from pizzas_ingredient where nom = '" + pizza.getNom() + "';"; con.createStatement().executeUpdate(query); + + for (Ingredient ingredient : pizza.getIngredients()) { + query = "insert into pizzas_ingredient values ('" + pizza.getNom() + "', " + ingredient.getId() + ");"; + con.createStatement().executeUpdate(query); + } + con.createStatement().executeUpdate(query); + con.close(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + } + public void patchPizza(String nom ,PizzaCompo pizza){ + try{ + Connection con = ds.getConnection(); + if (pizza.getPate() != null) { + String query = "update pizzas set pate = '" + pizza.getPate() + "' where nom = '" + nom + "';"; + con.createStatement().executeUpdate(query); + } + if (pizza.getPrixBase() != null) { + + String query = "update pizzas set prixbase = " + pizza.getPrixBase() + " where nom = '" + nom + "';"; + con.createStatement().executeUpdate(query); + } + con.close(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + if (!pizza.getIngredients().isEmpty()) { + try{ + Connection con = ds.getConnection(); + String query = "delete from pizzas_ingredient where nom = '" + nom + "';"; + con.createStatement().executeUpdate(query); + for(Ingredient ingredient : pizza.getIngredients()){ + query = "insert into pizzas_ingredient values ('" + nom + "', " + ingredient.getId() + ");"; + con.createStatement().executeUpdate(query); + } + + con.close(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + + } + } + public boolean findPizzaIngredient(String nom, int id) { + try { + Connection con = ds.getConnection(); + String query = "select * from pizzas_ingredient where nom = '" + nom + "' and id = " + id + ";"; + ResultSet rs = con.createStatement().executeQuery(query); + if (rs.next()) { + con.close(); + return true; + } con.close(); } catch (Exception e) { System.out.println(e.getMessage()); } + return false; } } diff --git a/WEB-INF/src/dto/Commande.java b/WEB-INF/src/dto/Commande.java index 229f84c1ee2081c60dadf1e44884724ae590ca4b..1ec667d8b5430b13bc737b72c1cbcc1052104c14 100644 --- a/WEB-INF/src/dto/Commande.java +++ b/WEB-INF/src/dto/Commande.java @@ -27,6 +27,10 @@ public class Commande { public Date getDate() { return date; } + + public void setId(int id) { + this.id = id; + } } diff --git a/WEB-INF/src/dto/CommandeDetail.java b/WEB-INF/src/dto/CommandeDetail.java index 8361f7112273e231deef127e6bc2a8a4e6c8b739..834f2eecbf72e32606da92d9527d60e14e02acf2 100644 --- a/WEB-INF/src/dto/CommandeDetail.java +++ b/WEB-INF/src/dto/CommandeDetail.java @@ -6,7 +6,9 @@ import java.util.ArrayList; public class CommandeDetail extends Commande{ - private List<PizzaCompo> pizzas; + private List<PizzaCompo> pizzas = new ArrayList<PizzaCompo>() { + + }; public CommandeDetail() { super(); diff --git a/WEB-INF/src/dto/PizzaCompo.java b/WEB-INF/src/dto/PizzaCompo.java index d97db6734542a89c668bd8c9f961f28155021452..b3bc71c7aa05834e263a0fb962986871e8536d8f 100644 --- a/WEB-INF/src/dto/PizzaCompo.java +++ b/WEB-INF/src/dto/PizzaCompo.java @@ -20,7 +20,7 @@ public class PizzaCompo extends Pizza { public PizzaCompo(String nom, String pate, Double prixBase) { super(nom, pate, prixBase); - this.ingredients = new ArrayList<Ingredient>(); + } public Double totalPrice() { Double total = super.getPrixBase() ;