From ad5c4bcae653118cb9e8694cce9bccbf8bc63a5e Mon Sep 17 00:00:00 2001 From: Martin Vysny Date: Fri, 31 Jan 2025 11:57:17 +0200 Subject: [PATCH] Migrate tests from DynaTest to JUnit5 --- build.gradle.kts | 1 - .../com/github/vokorm/AbstractDbDaoTests.kt | 7 +- .../github/vokorm/AbstractDbMappingTest.kt | 3 +- .../com/github/vokorm/ConditionBuilderTest.kt | 10 +- src/test/kotlin/com/github/vokorm/DaoTest.kt | 233 ------------------ .../kotlin/com/github/vokorm/FiltersTest.kt | 119 --------- .../kotlin/com/github/vokorm/MappingTest.kt | 178 ------------- 7 files changed, 8 insertions(+), 543 deletions(-) delete mode 100644 src/test/kotlin/com/github/vokorm/DaoTest.kt delete mode 100644 src/test/kotlin/com/github/vokorm/FiltersTest.kt delete mode 100644 src/test/kotlin/com/github/vokorm/MappingTest.kt diff --git a/build.gradle.kts b/build.gradle.kts index bcdf162..db27bff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,7 +31,6 @@ dependencies { testImplementation(libs.bundles.hibernate.validator) // tests - testImplementation(libs.dynatest) testImplementation(kotlin("test")) testImplementation(libs.junit.jupiter.engine) testImplementation(libs.bundles.gson) diff --git a/src/test/kotlin/com/github/vokorm/AbstractDbDaoTests.kt b/src/test/kotlin/com/github/vokorm/AbstractDbDaoTests.kt index 63685c6..c34e840 100644 --- a/src/test/kotlin/com/github/vokorm/AbstractDbDaoTests.kt +++ b/src/test/kotlin/com/github/vokorm/AbstractDbDaoTests.kt @@ -1,8 +1,5 @@ package com.github.vokorm -import com.github.mvysny.dynatest.DynaNodeGroup -import com.github.mvysny.dynatest.DynaTestDsl -import com.github.mvysny.dynatest.expectThrows import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import java.time.Instant @@ -105,14 +102,14 @@ abstract class AbstractDbDaoTests { @Test fun `fails if there are two matching entities`() { repeat(2) { Person(name = "Albedo", age = 131).save() } - expectThrows(IllegalStateException::class, "too many rows matching Person: '(Test.name) = ") { + expectThrows("too many rows matching Person: '(Test.name) = ") { Person.findSingleBy { Person::name eq "Albedo" } } } @Test fun `fails if there are ten matching entities`() { repeat(10) { Person(name = "Albedo", age = 132).save() } - expectThrows(IllegalStateException::class, "too many rows matching Person: '(Test.name) = ") { + expectThrows("too many rows matching Person: '(Test.name) = ") { Person.findSingleBy { Person::name eq "Albedo" } } } diff --git a/src/test/kotlin/com/github/vokorm/AbstractDbMappingTest.kt b/src/test/kotlin/com/github/vokorm/AbstractDbMappingTest.kt index 4c57d7f..f87da36 100644 --- a/src/test/kotlin/com/github/vokorm/AbstractDbMappingTest.kt +++ b/src/test/kotlin/com/github/vokorm/AbstractDbMappingTest.kt @@ -2,7 +2,6 @@ package com.github.vokorm -import com.github.mvysny.dynatest.* import org.jdbi.v3.core.mapper.reflect.FieldMapper import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test @@ -59,7 +58,7 @@ abstract class AbstractDbMappingTests() { } @Test fun `updating non-existing row fails`() { val p = Person(id = 15, name = "Zaphod", age = 20, created = Date(1000), modified = Instant.ofEpochMilli(120398123)) - expectThrows(IllegalStateException::class, "We expected to update only one row but we updated 0 - perhaps there is no row with id 15?") { + expectThrows("We expected to update only one row but we updated 0 - perhaps there is no row with id 15?") { p.save() } } diff --git a/src/test/kotlin/com/github/vokorm/ConditionBuilderTest.kt b/src/test/kotlin/com/github/vokorm/ConditionBuilderTest.kt index ed7ca29..9bb5b24 100644 --- a/src/test/kotlin/com/github/vokorm/ConditionBuilderTest.kt +++ b/src/test/kotlin/com/github/vokorm/ConditionBuilderTest.kt @@ -1,16 +1,16 @@ package com.github.vokorm -import com.github.mvysny.dynatest.DynaTest +import org.junit.jupiter.api.Test import kotlin.test.expect -class ConditionBuilderTest : DynaTest({ - test("smoke API tests") { +class ConditionBuilderTest { + @Test fun `smoke API tests`() { buildCondition { Person::name eq "foo" } buildCondition { !(Person::name eq "foo") } buildCondition { (Person::name eq "foo") and (Person::id gt 25)} buildCondition { (Person::name eq "foo") or (Person::id gt 25)} } - test("produced condition") { + @Test fun `produced condition`() { expect("Person.name = foo") { buildCondition { Person::name eq "foo" } .toString() } @@ -24,4 +24,4 @@ class ConditionBuilderTest : DynaTest({ buildCondition { (Person::name eq "foo") or (Person::id gt 25)} .toString() } } -}) +} diff --git a/src/test/kotlin/com/github/vokorm/DaoTest.kt b/src/test/kotlin/com/github/vokorm/DaoTest.kt deleted file mode 100644 index 89c48fb..0000000 --- a/src/test/kotlin/com/github/vokorm/DaoTest.kt +++ /dev/null @@ -1,233 +0,0 @@ -package com.github.vokorm - -import com.github.mvysny.dynatest.DynaNodeGroup -import com.github.mvysny.dynatest.DynaTestDsl -import com.github.mvysny.dynatest.expectThrows -import java.time.Instant -import java.time.LocalDate -import java.util.* -import kotlin.test.expect - -@DynaTestDsl -fun DynaNodeGroup.dbDaoTests() { - group("Person") { - test("FindById") { - expect(null) { Person.findById(25) } - val p = Person(name = "Albedo", age = 121) - p.save() - expect(p) { Person.findById(p.id!!) } - } - test("GetById") { - val p = Person(name = "Albedo", age = 122) - p.save() - expect(p) { Person.getById(p.id!!) } - } - test("GetById fails if there is no such entity") { - expectThrows("There is no Person for id 25") { - Person.getById(25L) - } - } - group("singleBy() tests") { - test("succeeds if there is exactly one matching entity") { - val p = Person(name = "Albedo", age = 123) - p.save() - expect(p) { Person.singleBy { Person::name eq "Albedo" } } - } - - test("fails if there is no such entity") { - expectThrows("no row matching Person: '(Test.name) = ") { - Person.singleBy { Person::name eq "Albedo" } - } - } - - test("fails if there are two matching entities") { - repeat(2) { Person(name = "Albedo", age = 124).save() } - expectThrows("too many rows matching Person: '(Test.name) = ") { - Person.singleBy { Person::name eq "Albedo" } - } - } - - test("fails if there are ten matching entities") { - repeat(10) { Person(name = "Albedo", age = 125).save() } - expectThrows("too many rows matching Person: '(Test.name) = ") { - Person.singleBy { Person::name eq "Albedo" } - } - } - } - group("count") { - test("basic count") { - expect(0) { Person.count() } - listOf("Albedo", "Nigredo", "Rubedo").forEach { Person(name = it, age = 126).save() } - expect(3) { Person.count() } - } - test("count with filters") { - expect(0) { Person.count { Person::age gt 6 } } - listOf("Albedo", "Nigredo", "Rubedo").forEach { Person(name = it, age = it.length).save() } - expect(1) { Person.count { Person::age gt 6 } } - } - } - test("DeleteAll") { - listOf("Albedo", "Nigredo", "Rubedo").forEach { Person(name = it, age = 127).save() } - expect(3) { Person.count() } - Person.deleteAll() - expect(0) { Person.count() } - } - group("DeleteById") { - test("simple") { - listOf("Albedo", "Nigredo", "Rubedo").forEach { Person(name = it, age = 128).save() } - expect(3) { Person.count() } - Person.deleteById(Person.findAll().first { it.name == "Albedo" }.id!!) - expect(listOf("Nigredo", "Rubedo")) { Person.findAll().map { it.name } } - } - test("DoesNothingOnUnknownId") { - db { com.github.vokorm.Person.deleteById(25L) } - expect(listOf()) { Person.findAll() } - } - } - test("DeleteBy") { - listOf("Albedo", "Nigredo", "Rubedo").forEach { Person(name = it, age = 129).save() } - Person.deleteBy { "name = :name"("name" to "Albedo") } // raw sql where - expect(listOf("Nigredo", "Rubedo")) { Person.findAll().map { it.name } } - Person.deleteBy { Person::name eq "Rubedo" } // fancy type-safe criteria - expect(listOf("Nigredo")) { Person.findAll().map { it.name } } - } - group("findOneBy() tests") { - test("succeeds if there is exactly one matching entity") { - val p = Person(name = "Albedo", age = 130) - p.save() - expect(p) { Person.findSingleBy { Person::name eq "Albedo" } } - } - - test("returns null if there is no such entity") { - expect(null) { Person.findSingleBy { Person::name eq "Albedo" } } - } - - test("fails if there are two matching entities") { - repeat(2) { Person(name = "Albedo", age = 131).save() } - expectThrows(IllegalStateException::class, "too many rows matching Person: '(Test.name) = ") { - Person.findSingleBy { Person::name eq "Albedo" } - } - } - - test("fails if there are ten matching entities") { - repeat(10) { Person(name = "Albedo", age = 132).save() } - expectThrows(IllegalStateException::class, "too many rows matching Person: '(Test.name) = ") { - Person.findSingleBy { Person::name eq "Albedo" } - } - } - - test("test filter by date") { - val p = Person(name = "Albedo", age = 133, dateOfBirth = LocalDate.of(1980, 2, 2)) - p.save() - expect(p) { - Person.findSingleBy {Person::dateOfBirth eq LocalDate.of(1980, 2, 2) } - } - // here I don't care about whether it selects something or not, I'm only testing the database compatibility - Person.findSingleBy { Person::dateOfBirth eq Instant.now() } - Person.findSingleBy { Person::dateOfBirth eq Date() } - } - } - group("exists") { - test("returns false on empty table") { - expect(false) { Person.existsAny() } - expect(false) { Person.existsById(25) } - expect(false) { Person.existsBy { Person::age le 26 } } - } - test("returns true on matching entity") { - val p = Person(name = "Albedo", age = 134) - p.save() - expect(true) { Person.existsAny() } - expect(true) { Person.existsById(p.id!!) } - expect(true) { Person.existsBy { Person::age ge 26 } } - } - test("returns false on non-matching entity") { - val p = Person(name = "Albedo", age = 135) - p.save() - expect(true) { Person.existsAny() } - expect(false) { Person.existsById(p.id!! + 1) } - expect(false) { Person.existsBy { Person::age le 26 } } - } - } - test("findAll sorting") { - Person.findAll(Person::id.asc) - Person.findAll(Person::id.desc) - } - } - - // quick tests which test that DAO methods generally work with entities with aliased ID columns - group("EntityWithAliasedId") { - test("FindById") { - expect(null) { EntityWithAliasedId.findById(25) } - val p = EntityWithAliasedId(name = "Albedo") - p.save() - expect(p) { EntityWithAliasedId.findById(p.id!!) } - } - test("GetById") { - val p = EntityWithAliasedId(name = "Albedo") - p.save() - expect(p) { EntityWithAliasedId.getById(p.id!!) } - } - group("singleBy() tests") { - test("succeeds if there is exactly one matching entity") { - val p = EntityWithAliasedId(name = "Albedo") - p.save() - expect(p) { EntityWithAliasedId.singleBy { EntityWithAliasedId::name eq "Albedo" } } - } - } - group("count") { - test("basic count") { - expect(0) { EntityWithAliasedId.count() } - listOf("Albedo", "Nigredo", "Rubedo").forEach { EntityWithAliasedId(name = it).save() } - expect(3) { EntityWithAliasedId.count() } - } - test("count with filters") { - expect(0) { EntityWithAliasedId.count() } - listOf("Albedo", "Nigredo", "Rubedo").forEach { EntityWithAliasedId(name = it).save() } - expect(1) { EntityWithAliasedId.count { EntityWithAliasedId::name eq "Albedo" } } - val id = EntityWithAliasedId.findAll().first { it.name == "Albedo" }.id!! - } - } - test("DeleteAll") { - listOf("Albedo", "Nigredo", "Rubedo").forEach { EntityWithAliasedId(name = it).save() } - expect(3) { EntityWithAliasedId.count() } - EntityWithAliasedId.deleteAll() - expect(0) { EntityWithAliasedId.count() } - } - test("DeleteById") { - listOf("Albedo", "Nigredo", "Rubedo").forEach { EntityWithAliasedId(name = it).save() } - expect(3) { EntityWithAliasedId.count() } - EntityWithAliasedId.deleteById(EntityWithAliasedId.findAll().first { it.name == "Albedo" }.id!!) - expect(listOf("Nigredo", "Rubedo")) { EntityWithAliasedId.findAll().map { it.name } } - } - test("DeleteByIdDoesNothingOnUnknownId") { - db { EntityWithAliasedId.deleteById(25L) } - expect(listOf()) { EntityWithAliasedId.findAll() } - } - test("DeleteBy") { - listOf("Albedo", "Nigredo", "Rubedo").forEach { EntityWithAliasedId(name = it).save() } - EntityWithAliasedId.deleteBy { "name = :name"("name" to "Albedo") } // raw sql where - expect(listOf("Nigredo", "Rubedo")) { EntityWithAliasedId.findAll().map { it.name } } - } - group("findOneBy() tests") { - test("succeeds if there is exactly one matching entity") { - val p = EntityWithAliasedId(name = "Albedo") - p.save() - expect(p) { EntityWithAliasedId.findSingleBy { EntityWithAliasedId::name eq "Albedo" } } - } - } - group("exists") { - test("returns false on empty table") { - expect(false) { EntityWithAliasedId.existsAny() } - expect(false) { EntityWithAliasedId.existsById(25) } - expect(false) { EntityWithAliasedId.existsBy { EntityWithAliasedId::name le "a" } } - } - test("returns true on matching entity") { - val p = EntityWithAliasedId(name = "Albedo") - p.save() - expect(true) { EntityWithAliasedId.existsAny() } - expect(true) { EntityWithAliasedId.existsById(p.id!!) } - expect(true) { EntityWithAliasedId.existsBy { EntityWithAliasedId::name eq "Albedo" } } - } - } - } -} diff --git a/src/test/kotlin/com/github/vokorm/FiltersTest.kt b/src/test/kotlin/com/github/vokorm/FiltersTest.kt deleted file mode 100644 index 5a3d9f1..0000000 --- a/src/test/kotlin/com/github/vokorm/FiltersTest.kt +++ /dev/null @@ -1,119 +0,0 @@ -package com.github.vokorm - -import com.github.mvysny.dynatest.DynaNodeGroup -import com.github.mvysny.dynatest.DynaTestDsl - -@DynaTestDsl -fun DynaNodeGroup.dbFiltersTest(info: DatabaseInfo) { - test("api test") { - Person.findAll(Person::age.asc, Person::created.desc) - Person.findAllBy(Person::age.asc, Person::created.desc, condition = Person::age.exp.eq(5)) - } - - group("filter test") { - beforeEach { - // create a basic set of entities - Person(name = "Moby", age = 25).create() - Person(name = "Jerry", age = 26).create() - Person(name = "Paul", age = 27).create() - } - - test("eq filter test") { - expectList() { - Person.findAllBy { Person::age eq 40 }.map { it.name } - } - expectList("Jerry") { - Person.findAllBy { Person::age eq 26 }.map { it.name } - } - } - - test("ne filter test") { - expectList("Moby", "Jerry", "Paul") { - Person.findAllBy { Person::age ne 40 }.map { it.name } - } - expectList("Jerry", "Paul") { - Person.findAllBy { Person::age ne 25 }.map { it.name } - } - } - - test("le filter test") { - expectList("Moby", "Jerry", "Paul") { - Person.findAllBy { Person::age le 40 }.map { it.name } - } - expectList("Moby", "Jerry") { - Person.findAllBy { Person::age le 26 }.map { it.name } - } - } - - test("lt filter test") { - expectList("Moby", "Jerry", "Paul") { - Person.findAllBy { Person::age lt 40 }.map { it.name } - } - expectList("Moby") { - Person.findAllBy { Person::age lt 26 }.map { it.name } - } - } - - test("ge filter test") { - expectList() { - Person.findAllBy { Person::age ge 40 }.map { it.name } - } - expectList("Jerry", "Paul") { - Person.findAllBy { Person::age ge 26 }.map { it.name } - } - } - - test("gt filter test") { - expectList() { - Person.findAllBy { Person::age gt 40 }.map { it.name } - } - expectList("Paul") { - Person.findAllBy { Person::age gt 26 }.map { it.name } - } - } - - test("not filter test") { - expectList("Moby", "Paul") { - Person.findAllBy { !(Person::age eq 26) }.map { it.name } - } - } - - test("in filter test") { - expectList("Moby", "Jerry") { - Person.findAllBy { Person::age `in` listOf(25, 26, 28) }.map { it.name } - } - } - } - - group("full-text search") { - if (info.supportsFullText) { - test("smoke test") { - Person.findAllBy(Person::name.exp.fullTextMatches("")) - Person.findAllBy(Person::name.exp.fullTextMatches("a")) - Person.findAllBy(Person::name.exp.fullTextMatches("the")) - Person.findAllBy(Person::name.exp.fullTextMatches("Moby")) - } - - test("blank filter matches all records") { - val moby = Person(name = "Moby") - moby.create() - expectList(moby) { Person.findAllBy(Person::name.exp.fullTextMatches("")) } - } - - test("various queries matching/not matching Moby") { - val moby = Person(name = "Moby") - moby.create() - expectList() { Person.findAllBy(Person::name.exp.fullTextMatches("foo")) } - expectList(moby) { Person.findAllBy(Person::name.exp.fullTextMatches("Moby")) } - expectList() { Person.findAllBy(Person::name.exp.fullTextMatches("Jerry")) } - expectList() { Person.findAllBy(Person::name.exp.fullTextMatches("Jerry Moby")) } - } - - test("partial match") { - val moby = Person(name = "Moby") - moby.create() - expectList(moby) { Person.findAllBy(Person::name.exp.fullTextMatches("Mob")) } - } - } - } -} diff --git a/src/test/kotlin/com/github/vokorm/MappingTest.kt b/src/test/kotlin/com/github/vokorm/MappingTest.kt deleted file mode 100644 index 5d6d17b..0000000 --- a/src/test/kotlin/com/github/vokorm/MappingTest.kt +++ /dev/null @@ -1,178 +0,0 @@ -@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") - -package com.github.vokorm - -import com.github.mvysny.dynatest.* -import org.jdbi.v3.core.mapper.reflect.FieldMapper -import java.lang.IllegalStateException -import java.lang.Long -import java.time.Instant -import java.time.LocalDate -import java.util.* -import kotlin.test.expect - -@DynaTestDsl -fun DynaNodeGroup.dbMappingTests() { - test("FindAll") { - expectList() { Person.findAll() } - val p = Person(name = "Zaphod", age = 42, ignored2 = Object()) - p.save() - expect(true) { p.id != null } - p.ignored2 = null - expectList(p) { Person.findAll() } - } - group("Person") { - group("save") { - test("Save") { - val p = Person(name = "Albedo", age = 130) - p.save() - expectList("Albedo") { Person.findAll().map { it.name } } - p.name = "Rubedo" - p.save() - expectList("Rubedo") { Person.findAll().map { it.name } } - Person(name = "Nigredo", age = 130).save() - expectList("Rubedo", "Nigredo") { Person.findAll().map { it.name } } - } - test("SaveEnum") { - val p = Person(name = "Zaphod", age = 42, maritalStatus = MaritalStatus.Divorced) - p.save() - expectList("Divorced") { - db { - handle.createQuery("select maritalStatus from Test").map(FieldMapper.of(Foo::class.java)).list().map { it.maritalStatus } - } - } - expect(p) { db { Person.findAll()[0] } } - } - test("SaveLocalDate") { - val p = Person(name = "Zaphod", age = 42, dateOfBirth = LocalDate.of(1990, 1, 14)) - p.save() - expect(LocalDate.of(1990, 1, 14)) { db { Person.findAll()[0].dateOfBirth!! } } - } - test("save date and instant") { - val p = Person(name = "Zaphod", age = 20, created = Date(1000), modified = Instant.ofEpochMilli(120398123)) - p.save() - expect(1000) { db { Person.findAll()[0].created!!.time } } - expect(Instant.ofEpochMilli(120398123)) { db { Person.findAll()[0].modified!! } } - } - test("updating non-existing row fails") { - val p = Person(id = 15, name = "Zaphod", age = 20, created = Date(1000), modified = Instant.ofEpochMilli(120398123)) - expectThrows(IllegalStateException::class, "We expected to update only one row but we updated 0 - perhaps there is no row with id 15?") { - p.save() - } - } - } - test("delete") { - val p = Person(name = "Albedo", age = 130) - p.save() - p.delete() - expectList() { Person.findAll() } - } - test("JsonSerializationIgnoresMeta") { - expect("""{"name":"Zaphod","age":42}""") { gson.toJson(Person(name = "Zaphod", age = 42)) } - } - test("Meta") { - val meta = Person.meta - expect("Test") { meta.databaseTableName } // since Person is annotated with @Entity("Test") - expect("Test.id") { meta.idProperty[0].dbName.qualifiedName } - expect(Person::class.java) { meta.entityClass } - expect(Long::class.java) { meta.idProperty[0].valueType } - expect( - setOf( - "id", - "name", - "age", - "dateOfBirth", - "created", - "alive", - "maritalStatus", - "modified" - ) - ) { meta.persistedFieldDbNames.map { it.unqualifiedName } .toSet() } - } - } - group("EntityWithAliasedId") { - test("Save") { - val p = EntityWithAliasedId(name = "Albedo") - p.save() - expectList("Albedo") { EntityWithAliasedId.findAll().map { it.name } } - p.name = "Rubedo" - p.save() - expectList("Rubedo") { EntityWithAliasedId.findAll().map { it.name } } - EntityWithAliasedId(name = "Nigredo").save() - expectList("Rubedo", "Nigredo") { EntityWithAliasedId.findAll().map { it.name } } - } - test("delete") { - val p = EntityWithAliasedId(name = "Albedo") - p.save() - p.delete() - expect(listOf()) { EntityWithAliasedId.findAll() } - } - test("JsonSerializationIgnoresMeta") { - expect("""{"name":"Zaphod"}""") { gson.toJson(EntityWithAliasedId(name = "Zaphod")) } - } - test("Meta") { - val meta = EntityWithAliasedId.meta - expect("EntityWithAliasedId") { meta.databaseTableName } - expect("myid") { meta.idProperty[0].dbName.unqualifiedName } - expect(EntityWithAliasedId::class.java) { meta.entityClass } - expect(Long::class.java) { meta.idProperty[0].valueType } - expect(setOf("myid", "name")) { meta.persistedFieldDbNames.map { it.unqualifiedName } .toSet() } - } - } - group("NaturalPerson") { - test("save fails") { - val p = NaturalPerson(id = "12345678", name = "Albedo", bytes = byteArrayOf(5)) - expectThrows("We expected to update only one row but we updated 0 - perhaps there is no row with id 12345678?") { - p.save() - } - } - test("Save") { - val p = NaturalPerson(id = "12345678", name = "Albedo", bytes = byteArrayOf(5)) - p.create() - expectList("Albedo") { NaturalPerson.findAll().map { it.name } } - p.name = "Rubedo" - p.save() - expectList("Rubedo") { NaturalPerson.findAll().map { it.name } } - NaturalPerson(id = "aaa", name = "Nigredo", bytes = byteArrayOf(5)).create() - expectList("Rubedo", "Nigredo") { NaturalPerson.findAll().map { it.name } } - } - test("delete") { - val p = NaturalPerson(id = "foo", name = "Albedo", bytes = byteArrayOf(5)) - p.create() - p.delete() - expectList() { NaturalPerson.findAll() } - } - } - group("LogRecord") { - test("save succeeds since create() auto-generates ID") { - val p = LogRecord(text = "foo") - p.save() - expectList("foo") { LogRecord.findAll().map { it.text } } - } - test("Save") { - val p = LogRecord(text = "Albedo") - p.save() - expectList("Albedo") { LogRecord.findAll().map { it.text } } - p.text = "Rubedo" - p.save() - expectList("Rubedo") { LogRecord.findAll().map { it.text } } - LogRecord(text = "Nigredo").save() - expect(setOf("Rubedo", "Nigredo")) { LogRecord.findAll().map { it.text } .toSet() } - } - test("delete") { - val p = LogRecord(text = "foo") - p.save() - p.delete() - expectList() { LogRecord.findAll() } - } - } - group("TypeMapping") { - test("java enum to native db enum") { - for (it in MaritalStatus.entries.plusNull) { - val id: kotlin.Long? = TypeMappingEntity(enumTest = it).run { save(); id } - val loaded = TypeMappingEntity.findById(id!!)!! - expect(it) { loaded.enumTest } - } - } - } -}