mirror of
https://github.com/gotson/komga.git
synced 2025-12-24 17:35:03 +01:00
use Kotlin extension for MockMvc testing
This commit is contained in:
parent
713c602e8d
commit
9fff28e147
4 changed files with 121 additions and 114 deletions
|
|
@ -8,7 +8,6 @@ import org.gotson.komga.domain.model.makeSeries
|
|||
import org.gotson.komga.domain.persistence.LibraryRepository
|
||||
import org.gotson.komga.domain.persistence.SeriesRepository
|
||||
import org.gotson.komga.interfaces.web.WithMockCustomUser
|
||||
import org.hamcrest.CoreMatchers.equalTo
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
|
|
@ -25,8 +24,7 @@ import org.springframework.boot.test.context.SpringBootTest
|
|||
import org.springframework.jdbc.core.JdbcTemplate
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension
|
||||
import org.springframework.test.web.servlet.MockMvc
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
|
||||
import org.springframework.test.web.servlet.get
|
||||
import javax.sql.DataSource
|
||||
|
||||
@ExtendWith(SpringExtension::class)
|
||||
|
|
@ -85,10 +83,13 @@ class BookControllerTest(
|
|||
).also { it.library = otherLibrary }
|
||||
seriesRepository.save(otherSeries)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content.length()", equalTo(1)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].name", equalTo("1")))
|
||||
mockMvc.get("/api/v1/books")
|
||||
.andExpect {
|
||||
status { isOk }
|
||||
jsonPath("$.content.length()") { value(1) }
|
||||
jsonPath("\$.content[0].name") { value("1") }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -104,11 +105,11 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/books/${book.id}")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -121,11 +122,11 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}/thumbnail"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}/thumbnail")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}/thumbnail"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/books/${book.id}/thumbnail")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -138,11 +139,11 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}/file"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}/file")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}/file"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/books/${book.id}/file")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -155,11 +156,11 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}/pages"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}/pages")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}/pages"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/books/${book.id}/pages")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -172,11 +173,11 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}/pages/1"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}/pages/1")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}/pages/1"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/books/${book.id}/pages/1")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -192,11 +193,11 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}/thumbnail"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}/thumbnail")
|
||||
.andExpect { status { isNotFound } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}/thumbnail"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound)
|
||||
mockMvc.get("/api/v1/books/${book.id}/thumbnail")
|
||||
.andExpect { status { isNotFound } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -209,11 +210,11 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}/file"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}/file")
|
||||
.andExpect { status { isNotFound } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}/file"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound)
|
||||
mockMvc.get("/api/v1/books/${book.id}/file")
|
||||
.andExpect { status { isNotFound } }
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
|
@ -227,11 +228,11 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}/pages"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}/pages")
|
||||
.andExpect { status { isNotFound } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}/pages"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound)
|
||||
mockMvc.get("/api/v1/books/${book.id}/pages")
|
||||
.andExpect { status { isNotFound } }
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
|
@ -245,11 +246,11 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}/pages/1"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}/pages/1")
|
||||
.andExpect { status { isNotFound } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}/pages/1"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound)
|
||||
mockMvc.get("/api/v1/books/${book.id}/pages/1")
|
||||
.andExpect { status { isNotFound } }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -267,10 +268,10 @@ class BookControllerTest(
|
|||
seriesRepository.save(series)
|
||||
val book = series.books.first()
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books/${book.id}/pages/$page"))
|
||||
.andExpect(MockMvcResultMatchers.status().isBadRequest)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books/${book.id}/pages/$page")
|
||||
.andExpect { status { isBadRequest } }
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/books/${book.id}/pages/$page"))
|
||||
.andExpect(MockMvcResultMatchers.status().isBadRequest)
|
||||
mockMvc.get("/api/v1/books/${book.id}/pages/$page")
|
||||
.andExpect { status { isBadRequest } }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ import org.springframework.security.test.context.support.WithAnonymousUser
|
|||
import org.springframework.security.test.context.support.WithMockUser
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension
|
||||
import org.springframework.test.web.servlet.MockMvc
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
|
||||
import org.springframework.test.web.servlet.get
|
||||
import java.nio.file.Files
|
||||
|
||||
@ExtendWith(SpringExtension::class)
|
||||
|
|
@ -24,16 +23,16 @@ class FileSystemControllerTest(
|
|||
@Test
|
||||
@WithAnonymousUser
|
||||
fun `given anonymous user when getDirectoryListing then return unauthorized`() {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(route))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get(route)
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithMockUser(roles = ["USER"])
|
||||
fun `given relative path param when getDirectoryListing then return bad request`() {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(route)
|
||||
.param("path", "."))
|
||||
.andExpect(MockMvcResultMatchers.status().isBadRequest)
|
||||
mockMvc.get(route) {
|
||||
param("path", ".")
|
||||
}.andExpect { status { isBadRequest } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -42,8 +41,8 @@ class FileSystemControllerTest(
|
|||
val parent = Files.createTempDirectory(null)
|
||||
Files.delete(parent)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(route)
|
||||
.param("path", parent.toString()))
|
||||
.andExpect(MockMvcResultMatchers.status().isBadRequest)
|
||||
mockMvc.get(route) {
|
||||
param("path", parent.toString())
|
||||
}.andExpect { status { isBadRequest } }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.gotson.komga.interfaces.web.rest
|
||||
|
||||
import org.gotson.komga.interfaces.web.WithMockCustomUser
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.junit.jupiter.api.Nested
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
|
|
@ -13,8 +12,8 @@ import org.springframework.security.test.context.support.WithAnonymousUser
|
|||
import org.springframework.security.test.context.support.WithMockUser
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension
|
||||
import org.springframework.test.web.servlet.MockMvc
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
|
||||
import org.springframework.test.web.servlet.get
|
||||
import org.springframework.test.web.servlet.post
|
||||
|
||||
@ExtendWith(SpringExtension::class)
|
||||
@SpringBootTest
|
||||
|
|
@ -29,8 +28,8 @@ class LibraryControllerTest(
|
|||
@Test
|
||||
@WithAnonymousUser
|
||||
fun `given anonymous user when getAll then return unauthorized`() {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(route))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get(route)
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -38,10 +37,10 @@ class LibraryControllerTest(
|
|||
fun `given anonymous user when addOne then return unauthorized`() {
|
||||
val jsonString = """{"name":"test", "root": "C:\\Temp"}"""
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(route)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(jsonString))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.post(route) {
|
||||
contentType = MediaType.APPLICATION_JSON
|
||||
content = jsonString
|
||||
}.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,8 +49,8 @@ class LibraryControllerTest(
|
|||
@Test
|
||||
@WithMockCustomUser
|
||||
fun `given user with access to all libraries when getAll then return ok`() {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(route))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
mockMvc.get(route)
|
||||
.andExpect { status { isOk } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -59,10 +58,10 @@ class LibraryControllerTest(
|
|||
fun `given user with USER role when addOne then return forbidden`() {
|
||||
val jsonString = """{"name":"test", "root": "C:\\Temp"}"""
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.post(route)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(jsonString))
|
||||
.andExpect(MockMvcResultMatchers.status().isForbidden)
|
||||
mockMvc.post(route) {
|
||||
contentType = MediaType.APPLICATION_JSON
|
||||
content = jsonString
|
||||
}.andExpect { status { isForbidden } }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,10 +70,12 @@ class LibraryControllerTest(
|
|||
@Test
|
||||
@WithMockCustomUser(sharedAllLibraries = false, sharedLibraries = [1])
|
||||
fun `given user with access to a single library when getAll then only gets this library`() {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(route))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.length()", CoreMatchers.equalTo(1)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$[0].id", CoreMatchers.equalTo(1)))
|
||||
mockMvc.get(route)
|
||||
.andExpect {
|
||||
status { isOk }
|
||||
jsonPath("$.length()") { value(1) }
|
||||
jsonPath("$[0].id") { value(1) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import org.gotson.komga.domain.model.makeSeries
|
|||
import org.gotson.komga.domain.persistence.LibraryRepository
|
||||
import org.gotson.komga.domain.persistence.SeriesRepository
|
||||
import org.gotson.komga.interfaces.web.WithMockCustomUser
|
||||
import org.hamcrest.CoreMatchers.equalTo
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
|
|
@ -21,8 +20,7 @@ import org.springframework.boot.test.context.SpringBootTest
|
|||
import org.springframework.jdbc.core.JdbcTemplate
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension
|
||||
import org.springframework.test.web.servlet.MockMvc
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
|
||||
import org.springframework.test.web.servlet.get
|
||||
import javax.sql.DataSource
|
||||
|
||||
@ExtendWith(SpringExtension::class)
|
||||
|
|
@ -75,11 +73,13 @@ class SeriesControllerTest(
|
|||
series.books = series.books.toMutableList().also { it.add(makeBook("2")) }
|
||||
seriesRepository.save(series)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books?ready_only=false"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].name", equalTo("1")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[1].name", equalTo("2")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[2].name", equalTo("3")))
|
||||
mockMvc.get("/api/v1/series/${series.id}/books?ready_only=false")
|
||||
.andExpect {
|
||||
status { isOk }
|
||||
jsonPath("$.content[0].name") { value("1") }
|
||||
jsonPath("$.content[1].name") { value("2") }
|
||||
jsonPath("$.content[2].name") { value("3") }
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -94,15 +94,17 @@ class SeriesControllerTest(
|
|||
series.books = series.books.toMutableList().also { it.add(makeBook("2")) }
|
||||
seriesRepository.save(series)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books?ready_only=false"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].name", equalTo("1")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[1].name", equalTo("2")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[2].name", equalTo("3")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[3].name", equalTo("5")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.size", equalTo(20)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.first", equalTo(true)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.number", equalTo(0)))
|
||||
mockMvc.get("/api/v1/series/${series.id}/books?ready_only=false")
|
||||
.andExpect {
|
||||
status { isOk }
|
||||
jsonPath("$.content[0].name") { value("1") }
|
||||
jsonPath("$.content[1].name") { value("2") }
|
||||
jsonPath("$.content[2].name") { value("3") }
|
||||
jsonPath("$.content[3].name") { value("5") }
|
||||
jsonPath("$.size") { value(20) }
|
||||
jsonPath("$.first") { value(true) }
|
||||
jsonPath("$.number") { value(0) }
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -118,15 +120,17 @@ class SeriesControllerTest(
|
|||
series.books.forEach { it.metadata = BookMetadata(BookMetadata.Status.READY) }
|
||||
seriesRepository.save(series)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books?ready_only=true"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].name", equalTo("1")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[1].name", equalTo("2")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[2].name", equalTo("3")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[3].name", equalTo("5")))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.size", equalTo(20)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.first", equalTo(true)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.number", equalTo(0)))
|
||||
mockMvc.get("/api/v1/series/${series.id}/books?ready_only=true")
|
||||
.andExpect {
|
||||
status { isOk }
|
||||
jsonPath("$.content[0].name") { value("1") }
|
||||
jsonPath("$.content[1].name") { value("2") }
|
||||
jsonPath("$.content[2].name") { value("3") }
|
||||
jsonPath("$.content[3].name") { value("5") }
|
||||
jsonPath("$.size") { value(20) }
|
||||
jsonPath("$.first") { value(true) }
|
||||
jsonPath("$.number") { value(0) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,10 +154,12 @@ class SeriesControllerTest(
|
|||
).also { it.library = otherLibrary }
|
||||
seriesRepository.save(otherSeries)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content.length()", equalTo(1)))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.content[0].name", equalTo("series")))
|
||||
mockMvc.get("/api/v1/series")
|
||||
.andExpect {
|
||||
status { isOk }
|
||||
jsonPath("$.content.length()") { value(1) }
|
||||
jsonPath("$.content[0].name") { value("series") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,8 +174,8 @@ class SeriesControllerTest(
|
|||
).also { it.library = library }
|
||||
seriesRepository.save(series)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/series/${series.id}")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -181,8 +187,8 @@ class SeriesControllerTest(
|
|||
).also { it.library = library }
|
||||
seriesRepository.save(series)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/thumbnail"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/series/${series.id}/thumbnail")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -194,8 +200,8 @@ class SeriesControllerTest(
|
|||
).also { it.library = library }
|
||||
seriesRepository.save(series)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/books"))
|
||||
.andExpect(MockMvcResultMatchers.status().isUnauthorized)
|
||||
mockMvc.get("/api/v1/series/${series.id}/books")
|
||||
.andExpect { status { isUnauthorized } }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,8 +216,8 @@ class SeriesControllerTest(
|
|||
).also { it.library = library }
|
||||
seriesRepository.save(series)
|
||||
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/api/v1/series/${series.id}/thumbnail"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound)
|
||||
mockMvc.get("/api/v1/series/${series.id}/thumbnail")
|
||||
.andExpect { status { isNotFound } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue