/
DanLiz456
/
current
Обзор
Документация
Войти
/
DanLiz456
/
current
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
server/src/test/resources/requests.http
150 строк
5 KB
DanLiz456
Initial commit: Реализация лайков
28 май 2026, 07:41
28 май 2026, 07:41
cdc1288
Код
Авторство
О чём код?
### Получение списка сообщений GET http://localhost:9999/api/posts > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); client.assert(response.contentType.mimeType === "application/json", "Expected 'application/json' but received '" + response.contentType.mimeType + "'"); }); %} ### Создание нового сообщения (id = 0) POST http://localhost:9999/api/posts Content-Type: application/json { "id": 0, "author": "Netology", "authorAvatar": "netology.jpg", "content": "New Post", "published": 0, "likedByMe": false, "likes": 0 } > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); client.assert(response.contentType.mimeType === "application/json", "Expected 'application/json' but received '" + response.contentType.mimeType + "'"); client.assert(response.body.id === 4, "Generated id not 4"); }); %} ### Получение сообщения по id GET http://localhost:9999/api/posts/4 > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); client.assert(response.contentType.mimeType === "application/json", "Expected 'application/json' but received '" + response.contentType.mimeType + "'"); client.assert(response.body.id === 4, "id not 4"); client.assert(response.body.content === "New Post", "Invalid content"); }); %} ### Обновление сообщения (id != 0) POST http://localhost:9999/api/posts Content-Type: application/json { "id": 4, "author": "Netology", "authorAvatar": "netology.jpg", "content": "New Post (UPDATED)", "published": 0, "likedByMe": false, "likes": 0 } > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); client.assert(response.contentType.mimeType === "application/json", "Expected 'application/json' but received '" + response.contentType.mimeType + "'"); client.assert(response.body.id === 4, "Id changed"); client.assert(response.body.content === "New Post (UPDATED)", "Content not updated"); }); %} ### Like сообщения POST http://localhost:9999/api/posts/4/likes > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); }); %} ### Получение сообщения по id GET http://localhost:9999/api/posts/4 > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); client.assert(response.contentType.mimeType === "application/json", "Expected 'application/json' but received '" + response.contentType.mimeType + "'"); client.assert(response.body.id === 4, "id not 4"); client.assert(response.body.likes === 1, "likes not incremented"); client.assert(response.body.likedByMe === true, "likedByMe didn't changed"); }); %} ### Дизлайк сообщения DELETE http://localhost:9999/api/posts/4/likes > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); }); %} ### Получение сообщения по id GET http://localhost:9999/api/posts/4 > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); client.assert(response.contentType.mimeType === "application/json", "Expected 'application/json' but received '" + response.contentType.mimeType + "'"); client.assert(response.body.id === 4, "id not 4"); client.assert(response.body.likes === 0, "likes decremented"); client.assert(response.body.likedByMe === false, "likedByMe didn't changed"); }); %} ### Удаление сообщения по id DELETE http://localhost:9999/api/posts/4 > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); }); %} ### Получение несуществующего сообщения GET http://localhost:9999/api/posts/4 > {% client.test("Request executed successfully", function() { client.assert(response.status === 404, "Response status is not 404"); }); %} ### Получение аватарки GET http://localhost:9999/avatars/sber.jpg > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); client.assert(response.contentType.mimeType === 'image/jpeg', "Invalid mime type"); }); %}