129 lines
3.8 KiB
Kotlin
129 lines
3.8 KiB
Kotlin
package solutions.bitbadger.documents.integration.sqlite
|
|
|
|
import org.junit.jupiter.api.DisplayName
|
|
import org.junit.jupiter.api.assertThrows
|
|
import solutions.bitbadger.documents.DocumentException
|
|
import solutions.bitbadger.documents.integration.common.Find
|
|
import kotlin.test.Test
|
|
|
|
/**
|
|
* SQLite integration tests for the `Find` object / `find*` connection extension functions
|
|
*/
|
|
@DisplayName("SQLite - Find")
|
|
class FindIT {
|
|
|
|
@Test
|
|
@DisplayName("all retrieves all documents")
|
|
fun allDefault() =
|
|
SQLiteDB().use(Find::allDefault)
|
|
|
|
@Test
|
|
@DisplayName("all sorts data ascending")
|
|
fun allAscending() =
|
|
SQLiteDB().use(Find::allAscending)
|
|
|
|
@Test
|
|
@DisplayName("all sorts data descending")
|
|
fun allDescending() =
|
|
SQLiteDB().use(Find::allDescending)
|
|
|
|
@Test
|
|
@DisplayName("all sorts data numerically")
|
|
fun allNumOrder() =
|
|
SQLiteDB().use(Find::allNumOrder)
|
|
|
|
@Test
|
|
@DisplayName("all succeeds with an empty table")
|
|
fun allEmpty() =
|
|
SQLiteDB().use(Find::allEmpty)
|
|
|
|
@Test
|
|
@DisplayName("byId retrieves a document via a string ID")
|
|
fun byIdString() =
|
|
SQLiteDB().use(Find::byIdString)
|
|
|
|
@Test
|
|
@DisplayName("byId retrieves a document via a numeric ID")
|
|
fun byIdNumber() =
|
|
SQLiteDB().use(Find::byIdNumber)
|
|
|
|
@Test
|
|
@DisplayName("byId returns null when a matching ID is not found")
|
|
fun byIdNotFound() =
|
|
SQLiteDB().use(Find::byIdNotFound)
|
|
|
|
@Test
|
|
@DisplayName("byFields retrieves matching documents")
|
|
fun byFieldsMatch() =
|
|
SQLiteDB().use(Find::byFieldsMatch)
|
|
|
|
@Test
|
|
@DisplayName("byFields retrieves ordered matching documents")
|
|
fun byFieldsMatchOrdered() =
|
|
SQLiteDB().use(Find::byFieldsMatchOrdered)
|
|
|
|
@Test
|
|
@DisplayName("byFields retrieves matching documents with a numeric IN clause")
|
|
fun byFieldsMatchNumIn() =
|
|
SQLiteDB().use(Find::byFieldsMatchNumIn)
|
|
|
|
@Test
|
|
@DisplayName("byFields succeeds when no documents match")
|
|
fun byFieldsNoMatch() =
|
|
SQLiteDB().use(Find::byFieldsNoMatch)
|
|
|
|
@Test
|
|
@DisplayName("byFields retrieves matching documents with an IN_ARRAY comparison")
|
|
fun byFieldsMatchInArray() =
|
|
SQLiteDB().use(Find::byFieldsMatchInArray)
|
|
|
|
@Test
|
|
@DisplayName("byFields succeeds when no documents match an IN_ARRAY comparison")
|
|
fun byFieldsNoMatchInArray() =
|
|
SQLiteDB().use(Find::byFieldsNoMatchInArray)
|
|
|
|
@Test
|
|
@DisplayName("byContains fails")
|
|
fun byContainsFails() {
|
|
assertThrows<DocumentException> { SQLiteDB().use(Find::byContainsMatch) }
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("byJsonPath fails")
|
|
fun byJsonPathFails() {
|
|
assertThrows<DocumentException> { SQLiteDB().use(Find::byJsonPathMatch) }
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("firstByFields retrieves a matching document")
|
|
fun firstByFieldsMatchOne() =
|
|
SQLiteDB().use(Find::firstByFieldsMatchOne)
|
|
|
|
@Test
|
|
@DisplayName("firstByFields retrieves a matching document among many")
|
|
fun firstByFieldsMatchMany() =
|
|
SQLiteDB().use(Find::firstByFieldsMatchMany)
|
|
|
|
@Test
|
|
@DisplayName("firstByFields retrieves a matching document among many (ordered)")
|
|
fun firstByFieldsMatchOrdered() =
|
|
SQLiteDB().use(Find::firstByFieldsMatchOrdered)
|
|
|
|
@Test
|
|
@DisplayName("firstByFields returns null when no document matches")
|
|
fun firstByFieldsNoMatch() =
|
|
SQLiteDB().use(Find::firstByFieldsNoMatch)
|
|
|
|
@Test
|
|
@DisplayName("firstByContains fails")
|
|
fun firstByContainsFails() {
|
|
assertThrows<DocumentException> { SQLiteDB().use(Find::firstByContainsMatchOne) }
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("firstByJsonPath fails")
|
|
fun firstByJsonPathFails() {
|
|
assertThrows<DocumentException> { SQLiteDB().use(Find::firstByJsonPathMatchOne) }
|
|
}
|
|
}
|