-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #607 from scireum/feature/mbo/OX-10357-3
JUnit: Migrates MangoTest and MangoNightlyTest to Kotlin
- Loading branch information
Showing
4 changed files
with
327 additions
and
303 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.