Skip to content

Commit

Permalink
Merge pull request #607 from scireum/feature/mbo/OX-10357-3
Browse files Browse the repository at this point in the history
JUnit: Migrates MangoTest and MangoNightlyTest to Kotlin
  • Loading branch information
mkeckmkeck authored Jan 30, 2024
2 parents e087aac + 9e3d975 commit 578e238
Show file tree
Hide file tree
Showing 4 changed files with 327 additions and 303 deletions.
55 changes: 0 additions & 55 deletions src/test/java/sirius/db/mongo/MangoNightlySpec.groovy

This file was deleted.

248 changes: 0 additions & 248 deletions src/test/java/sirius/db/mongo/MangoSpec.groovy

This file was deleted.

64 changes: 64 additions & 0 deletions src/test/kotlin/sirius/db/mongo/MangoNightlyTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/

package sirius.db.mongo

import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.extension.ExtendWith
import sirius.kernel.SiriusExtension
import sirius.kernel.Tags
import sirius.kernel.di.std.Part
import sirius.kernel.health.HandledException
import java.util.*
import kotlin.test.assertEquals

@Tag(Tags.NIGHTLY)
@ExtendWith(SiriusExtension::class)
class MangoNightlyTest {
@Test
fun `selecting over 1000 entities in queryList throws an exception`() {
mango.select(MangoListTestEntity::class.java).delete()
for (i in 0..1000) {
val entityToCreate = MangoListTestEntity()
entityToCreate.counter = i
mango.update(entityToCreate)
}

assertThrows<HandledException> { mango.select(MangoListTestEntity::class.java).queryList() }
}

@Test
fun `a timed out mongo count returns an empty optional`() {
mango.select(
MangoListTestEntity::class.java
).delete()

for (i in 0..99_999) {
val entityToCreate = MangoListTestEntity()
entityToCreate.counter = i
mango.update(entityToCreate)
}
val query = mango
.select(
MangoListTestEntity::class.java
)

assertEquals(
Optional.empty(), query.count(
true, 1
)
)
}

companion object {
@Part
private lateinit var mango: Mango
}
}
Loading

0 comments on commit 578e238

Please sign in to comment.