/
sasha.martian
/
quote-api
Обзор
Документация
Войти
/
sasha.martian
/
quote-api
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/test/java/com/example/quoteapi/QuoteApiMissingFileIntegrationTest.java
32 строки
1 KB
Galushkin Alexander
Улучшения, шаги 3-9
05 июл 2026, 12:44
05 июл 2026, 12:44
944c478
Код
Авторство
О чём код?
package com.example.quoteapi; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.MockMvc; @SpringBootTest @AutoConfigureMockMvc @TestPropertySource(properties = "quotes.file-path=classpath:missing-quotes.json") class QuoteApiMissingFileIntegrationTest { @Autowired private MockMvc mockMvc; @Test void returnsInternalServerErrorWhenFileIsMissing() throws Exception { mockMvc.perform(get("/api/quotes").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isInternalServerError()) .andExpect(jsonPath("$.status").value(500)) .andExpect(jsonPath("$.error").value("Internal Server Error")) .andExpect(jsonPath("$.message").value("Не удалось загрузить цитаты из файла classpath:missing-quotes.json")) .andExpect(jsonPath("$.timestamp").exists()); } }