/
DanLiz456
/
threads
Обзор
Документация
Войти
/
DanLiz456
/
threads
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
server/src/test/resources/requests.http
137 строк
4 KB
DanLiz456
Initial commit: Threads project setup
27 май 2026, 09:23
27 май 2026, 09:23
80f911c
Код
Авторство
О чём код?
### Получение списка сообщений 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", "content": "First 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 === 1, "Generated id not 1"); }); %} ### Получение сообщения по id GET http://localhost:9999/api/posts/1 > {% 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 === 1, "id not 1"); client.assert(response.body.content === "First Post", "id not 1"); }); %} ### Обновление сообщения (id != 0) POST http://localhost:9999/api/posts Content-Type: application/json { "id": 1, "author": "Netology", "content": "First 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 === 1, "Id changed"); client.assert(response.body.content === "First Post (UPDATED)", "Content not updated"); }); %} ### Like сообщения POST http://localhost:9999/api/posts/1/likes > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); }); %} ### Получение сообщения по id GET http://localhost:9999/api/posts/1 > {% 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 === 1, "id not 1"); 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/1/likes > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); }); %} ### Получение сообщения по id GET http://localhost:9999/api/posts/1 > {% 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 === 1, "id not 1"); 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/1 > {% client.test("Request executed successfully", function() { client.assert(response.status === 200, "Response status is not 200"); }); %} ### Получение несуществующего сообщения GET http://localhost:9999/api/posts/1 > {% client.test("Request executed successfully", function() { client.assert(response.status === 404, "Response status is not 404"); }); %}