diff --git a/TestPostman/Activite SpringBoot.postman_collection.json b/TestPostman/Activite SpringBoot.postman_collection.json new file mode 100644 index 00000000..e01fe7ef --- /dev/null +++ b/TestPostman/Activite SpringBoot.postman_collection.json @@ -0,0 +1,547 @@ +{ + "info": { + "_postman_id": "8490fd39-fb10-409e-8660-4c01421b6330", + "name": "Activite SpringBoot", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "listeProduits", + "event": [ + { + "listen": "test", + "script": { + "id": "fe36fe21-a4c5-42f4-ad3b-5831acef23de", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + }, + { + "name": "getProduit 2000", + "event": [ + { + "listen": "test", + "script": { + "id": "fe36fe21-a4c5-42f4-ad3b-5831acef23de", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "localhost:9090/Produits/1", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits", + "1" + ] + } + }, + "response": [] + }, + { + "name": "getProduit not existing", + "event": [ + { + "listen": "test", + "script": { + "id": "fe36fe21-a4c5-42f4-ad3b-5831acef23de", + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "localhost:9090/Produits/999", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits", + "999" + ] + } + }, + "response": [] + }, + { + "name": "SaveProduit poney", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"nom\": \"Poney en bois cracheur de feu\",\n \"prix\": 145,\n \"prixAchat\": 20\n}\n" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + }, + { + "name": "SaveProduit with id briquet", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"nom\": \"Briquet\",\n \"prix\": 200,\n \"prixAchat\":20\n}" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + }, + { + "name": "SaveProduit excalibur", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"nom\": \"excalibur\",\n \"prix\": 100000,\n \"prixAchat\": 2000\n}" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + }, + { + "name": "SaveProduit smash", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"nom\": \"smash bros\",\n \"prix\": 55\n}" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + }, + { + "name": "EditProduit 1", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"id\":1,\n \"nom\": \"EDITED\",\n \"prix\": 9999999,\n \"prixAchat\": 99999\n}" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + }, + { + "name": "getProduit 1", + "event": [ + { + "listen": "test", + "script": { + "id": "fe36fe21-a4c5-42f4-ad3b-5831acef23de", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "localhost:9090/Produits/1", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits", + "1" + ] + } + }, + "response": [] + }, + { + "name": "DeleteProduit 2000", + "request": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "localhost:9090/Produits/1", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits", + "1" + ] + } + }, + "response": [] + }, + { + "name": "getProduit 2000 error status", + "event": [ + { + "listen": "test", + "script": { + "id": "fe36fe21-a4c5-42f4-ad3b-5831acef23de", + "exec": [ + "pm.test(\"Status code is 404\", function () {", + " pm.response.to.have.status(404);", + "});", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "localhost:9090/Produits/1", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits", + "1" + ] + } + }, + "response": [] + }, + { + "name": "SaveProduit bad (toolowprice)", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"nom\": \"smash bros\",\n \"prix\": -1,\n \"prixAchat\":3\n}" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + }, + { + "name": "SaveProduit bad (gratuit)", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"nom\": \"smash bros\",\n \"prix\": 0,\n \"prixAchat\":3\n}" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + }, + { + "name": "SaveProduit bad (toobigname)", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"nom\": \"smash brosiaj ozi oij oij oi j\",\n \"prix\": 20,\n \"prixAchat\":3\n}" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + }, + { + "name": "listeProduits Copy", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "localhost:9090/Produits", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "Produits" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file diff --git a/TestPostman/Activite SpringBoot.postman_test_run.json b/TestPostman/Activite SpringBoot.postman_test_run.json new file mode 100644 index 00000000..2d6d89d3 --- /dev/null +++ b/TestPostman/Activite SpringBoot.postman_test_run.json @@ -0,0 +1,727 @@ +{ + "id": "eed20685-95ce-4bc9-a8b6-ff159ca62480", + "name": "Activite SpringBoot", + "allTests": [], + "timestamp": "2018-12-13T21:58:56.902Z", + "collection_id": "8490fd39-fb10-409e-8660-4c01421b6330", + "folder_id": 0, + "target_type": "collection", + "environment_id": "0", + "data": [], + "delay": 0, + "count": 1, + "collection": { + "id": "8490fd39-fb10-409e-8660-4c01421b6330", + "name": "Activite SpringBoot", + "description": null, + "auth": null, + "events": null, + "variables": null, + "order": [ + "dbc3b483-f151-4935-94a7-b2f555b5c918", + "59374b02-10a8-4a71-ae16-9f6765ab2321", + "09d578f3-43ff-4fab-9340-de5f19a71d24", + "df12eaf2-a837-47fb-b4ab-7dfe102b8130", + "75a1f3d9-349c-431b-8af2-9e6133058d1a", + "913ad3ea-50dd-45c0-aa58-34caac5e7d33", + "4b37ff92-133a-41e6-a0ad-3f3c745656e7", + "22439ea7-f2f2-4dd3-9912-9424cab80819", + "6df1cfd4-8c9e-4c77-b0b6-f99d70ac4f96", + "31078639-fad6-4051-bfbf-989b671ec615", + "0475cfba-8d09-4890-9d7e-0a2be5852758", + "a38b6c61-c2ad-4cbb-9181-ad3972b6bdb9", + "55357aed-2e32-43b4-86bb-1cd7c1c12cb3", + "91cf9f25-0f81-4a91-95b4-547b39079b87", + "6712c305-4f09-4368-9979-7858f0fed37f" + ], + "folders_order": [], + "owner": "4348525", + "permissions": {}, + "favorite": false, + "shared": false, + "type": "collection", + "depth": 0 + }, + "folder": null, + "environment": null, + "globals": [], + "results": [ + { + "name": "listeProduits", + "id": "dbc3b483-f151-4935-94a7-b2f555b5c918", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "tests": { + "error": null, + "name": "Status code is 200", + "status": "pass" + }, + "testPassFailCounts": { + "Status code is 200": { + "pass": 1, + "fail": 0 + } + }, + "times": [ + "160" + ], + "allTests": [ + { + "Status code is 200": true + } + ], + "time": "160", + "totalRequestTime": "160", + "iterationResults": {} + }, + { + "name": "getProduit 2000", + "id": "59374b02-10a8-4a71-ae16-9f6765ab2321", + "url": "localhost:9090/Produits/1", + "totalTime": 0, + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "tests": { + "error": null, + "name": "Status code is 200", + "status": "pass" + }, + "testPassFailCounts": { + "Status code is 200": { + "pass": 1, + "fail": 0 + } + }, + "times": [ + "24" + ], + "allTests": [ + { + "Status code is 200": true + } + ], + "time": "24", + "totalRequestTime": "24", + "iterationResults": {} + }, + { + "name": "getProduit not existing", + "id": "09d578f3-43ff-4fab-9340-de5f19a71d24", + "url": "localhost:9090/Produits/999", + "totalTime": 0, + "responseCode": { + "code": 404, + "name": "Not Found", + "detail": { + "name": "Not Found", + "detail": "The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible." + } + }, + "tests": { + "error": null, + "name": "Status code is 404", + "status": "pass" + }, + "testPassFailCounts": { + "Status code is 404": { + "pass": 1, + "fail": 0 + } + }, + "times": [ + "24" + ], + "allTests": [ + { + "Status code is 404": true + } + ], + "time": "24", + "totalRequestTime": "24", + "iterationResults": {} + }, + { + "name": "SaveProduit poney", + "id": "df12eaf2-a837-47fb-b4ab-7dfe102b8130", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 400, + "name": "Bad Request", + "detail": { + "name": "Bad Request", + "detail": "The request cannot be fulfilled due to bad syntax." + } + }, + "testPassFailCounts": {}, + "times": [ + "77" + ], + "allTests": [ + {} + ], + "time": "77", + "totalRequestTime": "77", + "iterationResults": {} + }, + { + "name": "SaveProduit with id briquet", + "id": "75a1f3d9-349c-431b-8af2-9e6133058d1a", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 201, + "name": "Created", + "detail": { + "name": "Created", + "detail": "The request has been fulfilled and resulted in a new resource being created." + } + }, + "testPassFailCounts": {}, + "times": [ + "28" + ], + "allTests": [ + {} + ], + "time": "28", + "totalRequestTime": "28", + "iterationResults": {} + }, + { + "name": "SaveProduit excalibur", + "id": "913ad3ea-50dd-45c0-aa58-34caac5e7d33", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 201, + "name": "Created", + "detail": { + "name": "Created", + "detail": "The request has been fulfilled and resulted in a new resource being created." + } + }, + "testPassFailCounts": {}, + "times": [ + "6" + ], + "allTests": [ + {} + ], + "time": "6", + "totalRequestTime": "6", + "iterationResults": {} + }, + { + "name": "SaveProduit smash", + "id": "4b37ff92-133a-41e6-a0ad-3f3c745656e7", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 201, + "name": "Created", + "detail": { + "name": "Created", + "detail": "The request has been fulfilled and resulted in a new resource being created." + } + }, + "testPassFailCounts": {}, + "times": [ + "5" + ], + "allTests": [ + {} + ], + "time": "5", + "totalRequestTime": "5", + "iterationResults": {} + }, + { + "name": "EditProduit 1", + "id": "22439ea7-f2f2-4dd3-9912-9424cab80819", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "testPassFailCounts": {}, + "times": [ + "18" + ], + "allTests": [ + {} + ], + "time": "18", + "totalRequestTime": "18", + "iterationResults": {} + }, + { + "name": "getProduit 1", + "id": "6df1cfd4-8c9e-4c77-b0b6-f99d70ac4f96", + "url": "localhost:9090/Produits/1", + "totalTime": 0, + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "tests": { + "error": null, + "name": "Status code is 200", + "status": "pass" + }, + "testPassFailCounts": { + "Status code is 200": { + "pass": 1, + "fail": 0 + } + }, + "times": [ + "5" + ], + "allTests": [ + { + "Status code is 200": true + } + ], + "time": "5", + "totalRequestTime": "5", + "iterationResults": {} + }, + { + "name": "DeleteProduit 2000", + "id": "31078639-fad6-4051-bfbf-989b671ec615", + "url": "localhost:9090/Produits/1", + "totalTime": 0, + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "testPassFailCounts": {}, + "times": [ + "18" + ], + "allTests": [ + {} + ], + "time": "18", + "totalRequestTime": "18", + "iterationResults": {} + }, + { + "name": "getProduit 2000 error status", + "id": "0475cfba-8d09-4890-9d7e-0a2be5852758", + "url": "localhost:9090/Produits/1", + "totalTime": 0, + "responseCode": { + "code": 404, + "name": "Not Found", + "detail": { + "name": "Not Found", + "detail": "The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible." + } + }, + "tests": { + "error": null, + "name": "Status code is 404", + "status": "pass" + }, + "testPassFailCounts": { + "Status code is 404": { + "pass": 1, + "fail": 0 + } + }, + "times": [ + "12" + ], + "allTests": [ + { + "Status code is 404": true + } + ], + "time": "12", + "totalRequestTime": "12", + "iterationResults": {} + }, + { + "name": "SaveProduit bad (toolowprice)", + "id": "a38b6c61-c2ad-4cbb-9181-ad3972b6bdb9", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 400, + "name": "Bad Request", + "detail": { + "name": "Bad Request", + "detail": "The request cannot be fulfilled due to bad syntax." + } + }, + "testPassFailCounts": {}, + "times": [ + "15" + ], + "allTests": [ + {} + ], + "time": "15", + "totalRequestTime": "15", + "iterationResults": {} + }, + { + "name": "SaveProduit bad (gratuit)", + "id": "55357aed-2e32-43b4-86bb-1cd7c1c12cb3", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 406, + "name": "Not Acceptable", + "detail": { + "name": "Not Acceptable", + "detail": "The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request." + } + }, + "testPassFailCounts": {}, + "times": [ + "5" + ], + "allTests": [ + {} + ], + "time": "5", + "totalRequestTime": "5", + "iterationResults": {} + }, + { + "name": "SaveProduit bad (toobigname)", + "id": "91cf9f25-0f81-4a91-95b4-547b39079b87", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 400, + "name": "Bad Request", + "detail": { + "name": "Bad Request", + "detail": "The request cannot be fulfilled due to bad syntax." + } + }, + "testPassFailCounts": {}, + "times": [ + "4" + ], + "allTests": [ + {} + ], + "time": "4", + "totalRequestTime": "4", + "iterationResults": {} + }, + { + "name": "listeProduits Copy", + "id": "6712c305-4f09-4368-9979-7858f0fed37f", + "url": "localhost:9090/Produits", + "totalTime": 0, + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "testPassFailCounts": {}, + "times": [ + "4" + ], + "allTests": [ + {} + ], + "time": "4", + "totalRequestTime": "4", + "iterationResults": {} + } + ], + "totalPass": 5, + "totalFail": 0, + "totalTime": 405, + "lifecycle": "done", + "requests": [ + { + "name": "listeProduits", + "id": "dbc3b483-f151-4935-94a7-b2f555b5c918", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "testPassFailCounts": { + "Status code is 200": { + "pass": 1, + "fail": 0 + } + } + }, + { + "name": "getProduit 2000", + "id": "59374b02-10a8-4a71-ae16-9f6765ab2321", + "url": "localhost:9090/Produits/1", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "testPassFailCounts": { + "Status code is 200": { + "pass": 1, + "fail": 0 + } + } + }, + { + "name": "getProduit not existing", + "id": "09d578f3-43ff-4fab-9340-de5f19a71d24", + "url": "localhost:9090/Produits/999", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 404, + "name": "Not Found", + "detail": { + "name": "Not Found", + "detail": "The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible." + } + }, + "testPassFailCounts": { + "Status code is 404": { + "pass": 1, + "fail": 0 + } + } + }, + { + "name": "SaveProduit poney", + "id": "df12eaf2-a837-47fb-b4ab-7dfe102b8130", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 400, + "name": "Bad Request", + "detail": { + "name": "Bad Request", + "detail": "The request cannot be fulfilled due to bad syntax." + } + }, + "testPassFailCounts": {} + }, + { + "name": "SaveProduit with id briquet", + "id": "75a1f3d9-349c-431b-8af2-9e6133058d1a", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 201, + "name": "Created", + "detail": { + "name": "Created", + "detail": "The request has been fulfilled and resulted in a new resource being created." + } + }, + "testPassFailCounts": {} + }, + { + "name": "SaveProduit excalibur", + "id": "913ad3ea-50dd-45c0-aa58-34caac5e7d33", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 201, + "name": "Created", + "detail": { + "name": "Created", + "detail": "The request has been fulfilled and resulted in a new resource being created." + } + }, + "testPassFailCounts": {} + }, + { + "name": "SaveProduit smash", + "id": "4b37ff92-133a-41e6-a0ad-3f3c745656e7", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 201, + "name": "Created", + "detail": { + "name": "Created", + "detail": "The request has been fulfilled and resulted in a new resource being created." + } + }, + "testPassFailCounts": {} + }, + { + "name": "EditProduit 1", + "id": "22439ea7-f2f2-4dd3-9912-9424cab80819", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "testPassFailCounts": {} + }, + { + "name": "getProduit 1", + "id": "6df1cfd4-8c9e-4c77-b0b6-f99d70ac4f96", + "url": "localhost:9090/Produits/1", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "testPassFailCounts": { + "Status code is 200": { + "pass": 1, + "fail": 0 + } + } + }, + { + "name": "DeleteProduit 2000", + "id": "31078639-fad6-4051-bfbf-989b671ec615", + "url": "localhost:9090/Produits/1", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "testPassFailCounts": {} + }, + { + "name": "getProduit 2000 error status", + "id": "0475cfba-8d09-4890-9d7e-0a2be5852758", + "url": "localhost:9090/Produits/1", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 404, + "name": "Not Found", + "detail": { + "name": "Not Found", + "detail": "The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible." + } + }, + "testPassFailCounts": { + "Status code is 404": { + "pass": 1, + "fail": 0 + } + } + }, + { + "name": "SaveProduit bad (toolowprice)", + "id": "a38b6c61-c2ad-4cbb-9181-ad3972b6bdb9", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 400, + "name": "Bad Request", + "detail": { + "name": "Bad Request", + "detail": "The request cannot be fulfilled due to bad syntax." + } + }, + "testPassFailCounts": {} + }, + { + "name": "SaveProduit bad (gratuit)", + "id": "55357aed-2e32-43b4-86bb-1cd7c1c12cb3", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 406, + "name": "Not Acceptable", + "detail": { + "name": "Not Acceptable", + "detail": "The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request." + } + }, + "testPassFailCounts": {} + }, + { + "name": "SaveProduit bad (toobigname)", + "id": "91cf9f25-0f81-4a91-95b4-547b39079b87", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 400, + "name": "Bad Request", + "detail": { + "name": "Bad Request", + "detail": "The request cannot be fulfilled due to bad syntax." + } + }, + "testPassFailCounts": {} + }, + { + "name": "listeProduits Copy", + "id": "6712c305-4f09-4368-9979-7858f0fed37f", + "url": "localhost:9090/Produits", + "time": "2018-12-13T21:58:56.902Z", + "responseCode": { + "code": 200, + "name": "OK", + "detail": { + "name": "OK", + "detail": "Standard response for successful HTTP requests. The actual response will depend on the request method used. In a GET request, the response will contain an entity corresponding to the requested resource. In a POST request the response will contain an entity describing or containing the result of the action." + } + }, + "testPassFailCounts": {} + } + ], + "synced": false +} \ No newline at end of file diff --git a/TestPostman/Screen Shot 2018-12-13 at 22.59.34.png b/TestPostman/Screen Shot 2018-12-13 at 22.59.34.png new file mode 100644 index 00000000..6ae25894 Binary files /dev/null and b/TestPostman/Screen Shot 2018-12-13 at 22.59.34.png differ diff --git a/src/main/java/com/ecommerce/microcommerce/dao/ProductDao.java b/src/main/java/com/ecommerce/microcommerce/dao/ProductDao.java index 6b272676..bb0093a9 100644 --- a/src/main/java/com/ecommerce/microcommerce/dao/ProductDao.java +++ b/src/main/java/com/ecommerce/microcommerce/dao/ProductDao.java @@ -19,4 +19,6 @@ public interface ProductDao extends JpaRepository { @Query("SELECT id, nom, prix FROM Product p WHERE p.prix > :prixLimit") List chercherUnProduitCher(@Param("prixLimit") int prix); + + List findByOrderByNom(); } diff --git a/src/main/java/com/ecommerce/microcommerce/model/Product.java b/src/main/java/com/ecommerce/microcommerce/model/Product.java index 4746a35a..09dc9cee 100644 --- a/src/main/java/com/ecommerce/microcommerce/model/Product.java +++ b/src/main/java/com/ecommerce/microcommerce/model/Product.java @@ -1,6 +1,8 @@ package com.ecommerce.microcommerce.model; import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; + import org.hibernate.validator.constraints.Length; import javax.persistence.Entity; @@ -19,10 +21,11 @@ public class Product { @Length(min=3, max=20, message = "Nom trop long ou trop court. Et oui messages sont plus stylés que ceux de Spring") private String nom; - @Min(value = 1) + @Min(value = 0) private int prix; //information que nous ne souhaitons pas exposer + @JsonIgnore private int prixAchat; //constructeur par défaut @@ -68,7 +71,11 @@ public int getPrixAchat() { public void setPrixAchat(int prixAchat) { this.prixAchat = prixAchat; } - + + public int getMarge() { + return this.prix-this.prixAchat; + } + @Override public String toString() { return "Product{" + diff --git a/src/main/java/com/ecommerce/microcommerce/web/controller/ProductController.java b/src/main/java/com/ecommerce/microcommerce/web/controller/ProductController.java index ffc59ba3..b693db98 100644 --- a/src/main/java/com/ecommerce/microcommerce/web/controller/ProductController.java +++ b/src/main/java/com/ecommerce/microcommerce/web/controller/ProductController.java @@ -2,6 +2,7 @@ import com.ecommerce.microcommerce.dao.ProductDao; import com.ecommerce.microcommerce.model.Product; +import com.ecommerce.microcommerce.web.exceptions.ProduitGratuitException; import com.ecommerce.microcommerce.web.exceptions.ProduitIntrouvableException; import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; @@ -16,18 +17,39 @@ import javax.validation.Valid; import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; -@Api( description="API pour es opérations CRUD sur les produits.") +@Api( description="API pour les opérations CRUD sur les produits.") @RestController public class ProductController { @Autowired private ProductDao productDao; + + @ApiOperation(value = "Récupère la liste des produits avec les marges réalisées par le vendeur") + @GetMapping(value = "/AdminProduits") + public Collection calculerMargeProduit() { + + Iterable produits = productDao.findAll(); + Collection output = new ArrayList<>(); + for (Product p : produits) { + output.add(p.toString() + " : " + p.getMarge()); + } + return output; + } + + @ApiOperation(value = "Récupère la liste des produits triés par ordre alphabétique") + @GetMapping(value = "/Produits/trierAlpha") + public Iterable trierProduitsParOrdreAlphabetique() { - + Iterable produits = productDao.findByOrderByNom(); + return produits; + } + //Récupérer la liste des produits @RequestMapping(value = "/Produits", method = RequestMethod.GET) @@ -68,7 +90,8 @@ public Product afficherUnProduit(@PathVariable int id) { @PostMapping(value = "/Produits") public ResponseEntity ajouterProduit(@Valid @RequestBody Product product) { - + if(product.getPrix()==0) + throw new ProduitGratuitException("Il est interdit de rendre un produit gratuit"); Product productAdded = productDao.save(product); if (productAdded == null) @@ -91,7 +114,8 @@ public void supprimerProduit(@PathVariable int id) { @PutMapping (value = "/Produits") public void updateProduit(@RequestBody Product product) { - + if(product.getPrix()==0) + throw new ProduitGratuitException("Il est interdit de rendre un produit gratuit"); productDao.save(product); } diff --git a/src/main/java/com/ecommerce/microcommerce/web/exceptions/ProduitGratuitException.java b/src/main/java/com/ecommerce/microcommerce/web/exceptions/ProduitGratuitException.java new file mode 100644 index 00000000..4d0b264a --- /dev/null +++ b/src/main/java/com/ecommerce/microcommerce/web/exceptions/ProduitGratuitException.java @@ -0,0 +1,15 @@ +package com.ecommerce.microcommerce.web.exceptions; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@ResponseStatus(HttpStatus.NOT_ACCEPTABLE) +public class ProduitGratuitException extends RuntimeException { + + public ProduitGratuitException(String string) { + super(string); + } + + + +}