/
sasha.martian
/
quote-api
Обзор
Документация
Войти
/
sasha.martian
/
quote-api
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/test/java/com/example/quoteapi/QuoteApiIntegrationTest.java
30 строк
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.web.servlet.MockMvc; @SpringBootTest @AutoConfigureMockMvc class QuoteApiIntegrationTest { @Autowired private MockMvc mockMvc; @Test void returnsAllQuotesFromClasspath() throws Exception { mockMvc.perform(get("/api/quotes").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$.length()").value(3)) .andExpect(jsonPath("$[0].id").value(1)) .andExpect(jsonPath("$[0].text").value("Жизнь — это то, что с тобой происходит, пока ты строишь планы.")) .andExpect(jsonPath("$[0].author").value("Джон Леннон")); } }