Skip to content

Commit c04a37b

Browse files
committed
Refactor Kotlin tests per SonarQube
1 parent 61d9357 commit c04a37b

File tree

6 files changed

+118
-134
lines changed

6 files changed

+118
-134
lines changed

src/test/kotlin/examples/kotlin/mybatis3/canonical/PersonMapperTest.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ class PersonMapperTest {
6363
or(occupation, isNull())
6464
}
6565

66-
assertThat(rows.size).isEqualTo(3)
66+
assertThat(rows).hasSize(3)
6767
}
6868
}
6969

@@ -74,7 +74,7 @@ class PersonMapperTest {
7474

7575
val rows = mapper.select { allRows() }
7676

77-
assertThat(rows.size).isEqualTo(6)
77+
assertThat(rows).hasSize(6)
7878
assertThat(rows[0].id).isEqualTo(1)
7979
assertThat(rows[5].id).isEqualTo(6)
8080
}
@@ -90,7 +90,7 @@ class PersonMapperTest {
9090
orderBy(lastName.descending(), firstName.descending())
9191
}
9292

93-
assertThat(rows.size).isEqualTo(6)
93+
assertThat(rows).hasSize(6)
9494
assertThat(rows[0].id).isEqualTo(5)
9595
assertThat(rows[5].id).isEqualTo(1)
9696
}
@@ -106,7 +106,7 @@ class PersonMapperTest {
106106
or(occupation, isNull())
107107
}
108108

109-
assertThat(rows.size).isEqualTo(5)
109+
assertThat(rows).hasSize(5)
110110
}
111111
}
112112

@@ -120,7 +120,7 @@ class PersonMapperTest {
120120
orderBy(id)
121121
}
122122

123-
assertThat(rows.size).isEqualTo(2)
123+
assertThat(rows).hasSize(2)
124124
assertThat(rows[0].id).isEqualTo(3)
125125
assertThat(rows[1].id).isEqualTo(6)
126126
}
@@ -145,7 +145,7 @@ class PersonMapperTest {
145145
where(firstName, isIn("Fred", "Barney"))
146146
}
147147

148-
assertThat(rows.size).isEqualTo(2)
148+
assertThat(rows).hasSize(2)
149149
assertThat(rows[0].lastName?.name).isEqualTo("Flintstone")
150150
assertThat(rows[1].lastName?.name).isEqualTo("Rubble")
151151
}
@@ -472,7 +472,7 @@ class PersonMapperTest {
472472
orderBy(id)
473473
}
474474

475-
assertThat(rows.size).isEqualTo(3)
475+
assertThat(rows).hasSize(3)
476476
assertThat(rows[0].firstName).isEqualTo("Fred")
477477
}
478478
}
@@ -487,7 +487,7 @@ class PersonMapperTest {
487487
orderBy(id)
488488
}
489489

490-
assertThat(rows.size).isEqualTo(3)
490+
assertThat(rows).hasSize(3)
491491
assertThat(rows[0].firstName).isEqualTo("Barney")
492492
}
493493
}
@@ -502,7 +502,7 @@ class PersonMapperTest {
502502
orderBy(id)
503503
}
504504

505-
assertThat(records.size).isEqualTo(6L)
505+
assertThat(records).hasSize(6)
506506
with(records[0]) {
507507
assertThat(id).isEqualTo(1)
508508
assertThat(employed).isTrue()
@@ -527,7 +527,7 @@ class PersonMapperTest {
527527
where(id, isEqualTo(1))
528528
}
529529

530-
assertThat(records.size).isEqualTo(1L)
530+
assertThat(records).hasSize(1)
531531
with(records[0]) {
532532
assertThat(id).isEqualTo(1)
533533
assertThat(employed).isTrue()

src/test/kotlin/examples/kotlin/mybatis3/canonical/ReusableWhereTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@ class ReusableWhereTest {
8787
orderBy(id)
8888
}
8989

90-
assertThat(rows.size).isEqualTo(3)
90+
assertThat(rows).hasSize(3)
9191
}
9292
}
9393

src/test/kotlin/examples/kotlin/mybatis3/general/GeneralKotlinTest.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,7 +35,6 @@ import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory
3535
import org.assertj.core.api.Assertions.assertThat
3636
import org.junit.jupiter.api.Test
3737
import org.mybatis.dynamic.sql.SqlBuilder.*
38-
import org.mybatis.dynamic.sql.util.kotlin.*
3938
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.*
4039
import org.mybatis.dynamic.sql.util.kotlin.mybatis3.from
4140
import java.io.InputStreamReader
@@ -318,7 +317,7 @@ class GeneralKotlinTest {
318317

319318
val rows = mapper.selectMany(selectStatement)
320319

321-
assertThat(rows.size).isEqualTo(2)
320+
assertThat(rows).hasSize(2)
322321
with(rows[0]) {
323322
assertThat(id).isEqualTo(1)
324323
assertThat(firstName).isEqualTo("Fred")
@@ -349,7 +348,7 @@ class GeneralKotlinTest {
349348

350349
val rows = mapper.selectMany(selectStatement)
351350

352-
assertThat(rows.size).isEqualTo(3)
351+
assertThat(rows).hasSize(3)
353352
with(rows[0]) {
354353
assertThat(id).isEqualTo(1)
355354
assertThat(firstName).isEqualTo("Fred")
@@ -386,7 +385,7 @@ class GeneralKotlinTest {
386385

387386
val rows = mapper.selectMany(selectStatement)
388387

389-
assertThat(rows.size).isEqualTo(1)
388+
assertThat(rows).hasSize(1)
390389
with(rows[0]) {
391390
assertThat(id).isEqualTo(1)
392391
assertThat(firstName).isEqualTo("Fred")
@@ -424,7 +423,7 @@ class GeneralKotlinTest {
424423

425424
val rows = mapper.selectMany(selectStatement)
426425

427-
assertThat(rows.size).isEqualTo(3)
426+
assertThat(rows).hasSize(3)
428427
with(rows[2]) {
429428
assertThat(id).isEqualTo(4)
430429
assertThat(firstName).isEqualTo("Barney")
@@ -468,7 +467,7 @@ class GeneralKotlinTest {
468467

469468
val rows = mapper.selectMany(selectStatement)
470469

471-
assertThat(rows.size).isEqualTo(1)
470+
assertThat(rows).hasSize(1)
472471
with(rows[0]) {
473472
assertThat(id).isEqualTo(1)
474473
assertThat(firstName).isEqualTo("Fred")
@@ -509,7 +508,7 @@ class GeneralKotlinTest {
509508

510509
val rows = mapper.selectMany(selectStatement)
511510

512-
assertThat(rows.size).isEqualTo(3)
511+
assertThat(rows).hasSize(3)
513512
with(rows[2]) {
514513
assertThat(id).isEqualTo(4)
515514
assertThat(firstName).isEqualTo("Barney")
@@ -534,7 +533,7 @@ class GeneralKotlinTest {
534533
offset(2)
535534
}
536535

537-
assertThat(rows.size).isEqualTo(3)
536+
assertThat(rows).hasSize(3)
538537
with(rows[0]) {
539538
assertThat(id).isEqualTo(3)
540539
assertThat(firstName).isEqualTo("Pebbles")
@@ -559,7 +558,7 @@ class GeneralKotlinTest {
559558
fetchFirst(3).rowsOnly()
560559
}
561560

562-
assertThat(rows.size).isEqualTo(3)
561+
assertThat(rows).hasSize(3)
563562
with(rows[0]) {
564563
assertThat(id).isEqualTo(3)
565564
assertThat(firstName).isEqualTo("Pebbles")

0 commit comments

Comments
 (0)