Skip to content

Conversation

@AnanevKirill
Copy link

Файл README.md содержит описание работы с приложением

Файл README.md содержит описание работы с приложением
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.4.0</version>

Choose a reason for hiding this comment

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

все версии нужно выносить в секцию properties

import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@SpringBootApplication
@EnableJpaRepositories("ru.raiffeisen.soksapp.repositary")

Choose a reason for hiding this comment

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

ошибка в слове repository


private static final Logger log = LoggerFactory.getLogger(SocksController.class);

@Autowired

Choose a reason for hiding this comment

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

@Autowired на поле - плохая практика, тк отсутствует возможность внедрить сервис с ожидаемым поведением


try {
sockService.deleteSocks(sock);
} catch (NotEnoughSocsException e) {

Choose a reason for hiding this comment

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

обработка исключений в контроллере - плохая практика, для этого нужно создавать отдельный класс, который перехватывает и обрабатывает исключения приложения

log.error("Произошла ошибка при удалении носков", e);
return new ResponseEntity<>("Количество носков на складе меньше, чем в запросе", HttpStatus.BAD_REQUEST);
}
return ResponseEntity.ok().build();

Choose a reason for hiding this comment

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

также если обрабатывать исключения в другом классе можно пометить метод как void и навесить аннотацию @ResponseStatus


if (newQuantity == 0) {
log.info("Количество носков стало равным 0, удяляем запись с id: " + sockEntity.getId());
repository.deleteById(sockEntity.getId());

Choose a reason for hiding this comment

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

кажется излишним действием, ведь мы во время прихода носков всё равно лезем в базу и проверяем есть ли у нас такие

.sum();
}

throw new RuntimeException("Unsupported operation is passed: " + operation);

Choose a reason for hiding this comment

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

это должно быть внутри switch default case

.mapToInt(SockEntity::getQuantity)
.sum();

case MORE_THAN: // че-то

Choose a reason for hiding this comment

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

комментарии в коде должны быть на английском, если они и есть вообще

.post("/api/socks/income")
.getStatusCode();

Assertions.assertThat(statusCode)

Choose a reason for hiding this comment

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

к верхнему действию можно добавить .andExpect...


List<SockEntity> allSocks = socksRepository.findAll();

int newStatus = RestAssured.given()

Choose a reason for hiding this comment

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

два теста в одном тесте - плохая практика

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