Skip to content

Выполнить задание 9 спринта: добавить работу с http сервером - #6

Merged
milayadasha merged 2 commits into
mainfrom
sprint_9-solution-http-api
Nov 26, 2025
Merged

milayadasha merged 2 commits into
mainfrom
sprint_9-solution-http-api

Conversation

@milayadasha

Copy link
Copy Markdown
Owner
  1. Добавлен новый package c логикой работы http-сервера:
  • адаптеры для обработки LocalDateTime и Duration
  • классы для HttpHandler-ов
  • класс HttpTaskServer, который отвечает за работу сервера
  1. Добавлен новый класс NotFoundException
  2. Доработаны методы в InMemoryTaskManager. Теперь в случае невозможность добавить/изменить/удалить задачу выбрасывается исключение
  3. Обновлены существующие тесты из-за обновления в п.3
  4. Добавлены новые тесты, покрывающие функционал из п.1

@maks-avilow maks-avilow left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Привет Дарья! ТЗ выполнено - зачет. Удачи в следующих спринтах

@@ -0,0 +1,19 @@
package ru.yandex.javacourse.http;

public enum HttpStatusCode {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

хорошее решение вынести статус коды в енам. лайк!


public HttpTaskServer() {
taskManager = Managers.getDefault();
port = 8080;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

порт даже можно было вынести в константу, но твое решение корректно также

return Duration.ofMinutes(Long.parseLong(value));
} catch (Exception e) {
jsonReader.nextNull();
return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да корректно. но увлекаться возвратами null нужно очень аккуратно так как это может привести к скрытым багам npe

getAllSubtasks(exchange);
break;
case "POST":
processingRequestedSubtask(exchange, requestBody);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

молодец что вынесла код в методы и используешь тут в точке вызова в блоках case. очень хорошо!

processingRequestedSubtask(exchange, requestBody);
break;
default:
sendNotFound(exchange, "Некорректный метод");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

повтрояющиеся строки нужно не забывать выносить в константы

@Test
@DisplayName("Должен сохранять эпик в менеджер при отправке запроса в HttpServer")
public void test_AddEpic_WhenSendEpicWithId_ManagerShouldStore() throws IOException, InterruptedException {
//given

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спасибо за тесты и разметку given-when-then

@milayadasha
milayadasha merged commit 6fc34d8 into main Nov 26, 2025
1 check passed
@milayadasha
milayadasha deleted the sprint_9-solution-http-api branch November 26, 2025 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants