From 1bc55a1e72c15a4300cb0011e337969096530829 Mon Sep 17 00:00:00 2001 From: sciencesakura Date: Sun, 23 Jul 2023 04:50:20 +0900 Subject: [PATCH] Improve Kotlin test --- .../dbsetup/spreadsheet/ExcelTest.kt | 79 ++++++++---------- kotlin/src/test/resources/kt_test.xlsx | Bin 0 -> 6274 bytes kotlin/src/test/resources/testdata.xlsx | Bin 4764 -> 0 bytes 3 files changed, 33 insertions(+), 46 deletions(-) create mode 100644 kotlin/src/test/resources/kt_test.xlsx delete mode 100644 kotlin/src/test/resources/testdata.xlsx diff --git a/kotlin/src/test/kotlin/com/sciencesakura/dbsetup/spreadsheet/ExcelTest.kt b/kotlin/src/test/kotlin/com/sciencesakura/dbsetup/spreadsheet/ExcelTest.kt index 2155777..796d3ab 100644 --- a/kotlin/src/test/kotlin/com/sciencesakura/dbsetup/spreadsheet/ExcelTest.kt +++ b/kotlin/src/test/kotlin/com/sciencesakura/dbsetup/spreadsheet/ExcelTest.kt @@ -24,7 +24,6 @@ package com.sciencesakura.dbsetup.spreadsheet import com.ninja_squad.dbsetup.destination.DriverManagerDestination -import com.ninja_squad.dbsetup.generator.ValueGenerators import com.ninja_squad.dbsetup_kotlin.dbSetup import org.assertj.db.api.Assertions.assertThat import org.assertj.db.type.Changes @@ -32,69 +31,57 @@ import org.assertj.db.type.Source import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -private const val url = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1" -private const val username = "sa" -private val source = Source(url, username, null) -private val destination = DriverManagerDestination(url, username, null) -private val setUpQueries = arrayOf( - """ - create table if not exists table_1 ( - a integer primary key, - b integer, - c integer - ) - """, - "truncate table table_1", -) - class ExcelTest { + val url = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1" + + val username = "sa" + + val source = Source(url, username, null) + + val destination = DriverManagerDestination.with(url, username, null) + @BeforeEach fun setUp() { + val table_11 = """ + create table if not exists table_11 ( + id integer primary key, + name varchar(100) + ) + """.trimIndent() + val table_12 = """ + create table if not exists table_12 ( + id integer primary key, + name varchar(100) + ) + """.trimIndent() dbSetup(destination) { - sql(*setUpQueries) + sql(table_11, table_12) + truncate("table_11", "table_12") }.launch() } @Test - fun import_with_default_settings() { + fun import_excel() { val changes = Changes(source).setStartPointNow() dbSetup(destination) { - excel("testdata.xlsx") + excel("kt_test.xlsx") }.launch() - assertThat(changes.setEndPointNow()) - .hasNumberOfChanges(2) - .changeOfCreation() - .rowAtEndPoint() - .value("a").isEqualTo(10) - .value("b").isEqualTo(100) - .value("c").isNull - .changeOfCreation() - .rowAtEndPoint() - .value("a").isEqualTo(20) - .value("b").isEqualTo(200) - .value("c").isNull + assertThat(changes.setEndPointNow()).hasNumberOfChanges(2).changeOfCreationOnTable("table_11") + .rowAtEndPoint().value("id").isEqualTo(1).value("name").isEqualTo("Alice") + .changeOfCreationOnTable("table_12").rowAtEndPoint().value("id").isEqualTo(2).value("name") + .isEqualTo("Bob") } @Test - fun import_with_customized_settings() { + fun import_excel_with_configure() { val changes = Changes(source).setStartPointNow() dbSetup(destination) { - excel("testdata.xlsx") { - withGeneratedValue("table_1", "c", ValueGenerators.sequence()) + excel("kt_test.xlsx") { + exclude("table_12") } }.launch() - assertThat(changes.setEndPointNow()) - .hasNumberOfChanges(2) - .changeOfCreation() - .rowAtEndPoint() - .value("a").isEqualTo(10) - .value("b").isEqualTo(100) - .value("c").isEqualTo(1) - .changeOfCreation() - .rowAtEndPoint() - .value("a").isEqualTo(20) - .value("b").isEqualTo(200) - .value("c").isEqualTo(2) + assertThat(changes.setEndPointNow()).hasNumberOfChanges(1).changeOfCreationOnTable("table_11") + .rowAtEndPoint().value("id").isEqualTo(1).value("name").isEqualTo("Alice") } } diff --git a/kotlin/src/test/resources/kt_test.xlsx b/kotlin/src/test/resources/kt_test.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..c6368428f9c0fc7c69cb692549f804e637e829ee GIT binary patch literal 6274 zcmbVQWmuHm)&`^n>5>MK4jD>BLUL%3k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0t4W4Aubx2%2xWc?%ri>ZdN^9g2&HUpT9l1xnu}p5R5U|7bLZuH?Ah}5zvhb|{ z`^$_LR@_*1q{t(!JFMK` zi#!ovd*8e%U2xViCRdaDXG3O;SAD3FTnu&(3rKDAriSM6lO9^|Fw259Gn_RAVum`B zH@~CCi)ww+_!2^L!sPStWOrTgLg|j>-1g5|Fr&9auHW;SU+2b!NtBmK$hY1_e*U{U zLwIvuW=>AOCKam!MkZY7_8FOWR}FB@I!yg;waqk+%_E3)9fy)(?}QH0rEiZ12|t3d_w6ZzqC)Pk6C+nM+bJApVXIftNV*~QZAMQWP&sH>WBe(UCsnu~^ zzve@1dIxGOqe}Mj=}m!k;gr@%0vHot7q@Byr3EY|=N^RPAFwMwiO*QIVScwkyQw|X zT{Rhro_d81hi=M^%QCvmi<&4V+#7mk`c)f+u2a~KDOp`&Cw*>W{xn}Wzx55ANMxET zH$&Rzr^n!f%L1DB=Hx$v>O6-IE+vneq05pNgSLx1!IdMAyUr*GCn}_v%Z+LLNyNjI zR%^t(cHXJzitwx6mloL(*(uwUQcP{_Uc$d#D8M2U{dM9RVqOy*6^#_-w@!Ogn!MI& z|J`n=wtqU_RP3&m%iqR|9O}R8n19B(soGrYd%q2ctTV_sH`TsBoo}9uuZ5l87LESP z`M1pTr|Zp)_4U#Dw^?ERYux`hNdFn-X2bsXDCS5s|9<a) z1R2Hk&sP6ugqyYbx>5c%Ib`AbkGA=z`^^$~ov^=c3mNUV`@hQhp8;;xg6m58+q#Kw o1o*pd{^@;_p#MJn1@iX)s2=J{7)UOopxj1YJxH45lU?8a59@ZhA^-pY literal 0 HcmV?d00001 diff --git a/kotlin/src/test/resources/testdata.xlsx b/kotlin/src/test/resources/testdata.xlsx deleted file mode 100644 index f5f4ef68b7dd4fefc5775196741d5d292d4d458a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4764 zcmaJ_2|Sc-_r};|%a&0L$q+)kw#XXU*Q_BsV;PMt#!igMzVFEzqL?U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