Skip to content

Commit

Permalink
[api]: Remove Kotest in favor of JUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Jul 19, 2024
1 parent ac4d68b commit 1c45794
Show file tree
Hide file tree
Showing 126 changed files with 9,863 additions and 8,576 deletions.
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ updates:
apache:
patterns:
- "org.apache*"
junit:
patterns:
- "org.junit*"

- package-ecosystem: "npm"
directory: "/desktop"
Expand Down
219 changes: 0 additions & 219 deletions api/src/test/kotlin/APITest.kt

This file was deleted.

130 changes: 68 additions & 62 deletions api/src/test/kotlin/CalibrationFrameRepositoryTest.kt
Original file line number Diff line number Diff line change
@@ -1,89 +1,95 @@
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.collections.shouldBeEmpty
import io.kotest.matchers.collections.shouldHaveSize
import io.objectbox.kotlin.boxFor
import nebulosa.api.calibration.CalibrationFrameEntity
import nebulosa.api.calibration.CalibrationFrameRepository
import nebulosa.api.database.MyObjectBox
import nebulosa.indi.device.camera.FrameType
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Test
import java.util.*

class CalibrationFrameRepositoryTest : StringSpec() {
class CalibrationFrameRepositoryTest {

init {
val boxStore = MyObjectBox.builder()
.inMemory(UUID.randomUUID().toString())
.build()

afterSpec {
boxStore.close()
}
@Test
fun findAll() {
REPOSITORY.findAll().shouldHaveSize(17)
}

val box = boxStore.boxFor<CalibrationFrameEntity>()
val repository = CalibrationFrameRepository(box)
@Test
fun findDarks() {
REPOSITORY.darkFrames(NAME, 1280, 1024, 1, 1L, 0.0).shouldHaveSize(1)
REPOSITORY.darkFrames(NAME, 1280, 1024, 1, 60L, 0.0).shouldHaveSize(4)
REPOSITORY.darkFrames(NAME, 1280, 1024, 1, 60L, 100.0).shouldHaveSize(2)
REPOSITORY.darkFrames(NAME, 1280, 1024, 1, 60L, 50.0).shouldBeEmpty()
REPOSITORY.darkFrames(NAME, 1280, 1024, 2, 60L, 100.0).shouldBeEmpty()
REPOSITORY.darkFrames(NAME, 4092, 2800, 1, 60L, 100.0).shouldBeEmpty()
REPOSITORY.darkFrames("ZW", 1280, 1024, 1, 1L, 0.0).shouldBeEmpty()
}

repository.save(FrameType.DARK, 1L)
repository.save(FrameType.DARK, 2L)
repository.save(FrameType.DARK, 5L)
repository.save(FrameType.DARK, 10L)
repository.save(FrameType.DARK, 30L)
repository.save(FrameType.DARK, 60L)
repository.save(FrameType.DARK, 60L, gain = 100.0)
repository.save(FrameType.DARK, 10L, temperature = -10.0)
repository.save(FrameType.DARK, 30L, temperature = -10.0)
repository.save(FrameType.DARK, 60L, temperature = -10.0)
repository.save(FrameType.DARK, 60L, temperature = -10.0, gain = 100.0)
repository.save(FrameType.BIAS, 0L)
repository.save(FrameType.BIAS, 0L, gain = 100.0)
repository.save(FrameType.FLAT, 0L, filter = "RED")
repository.save(FrameType.FLAT, 0L, filter = "GREEN")
repository.save(FrameType.FLAT, 0L, filter = "BLUE")
repository.save(FrameType.FLAT, 0L, filter = null)
@Test
fun findBias() {
REPOSITORY.biasFrames(NAME, 1280, 1024, 1, 0.0).shouldHaveSize(2)
REPOSITORY.biasFrames(NAME, 1280, 1024, 1, 100.0).shouldHaveSize(1)
REPOSITORY.biasFrames(NAME, 1280, 1024, 1, 50.0).shouldBeEmpty()
REPOSITORY.biasFrames(NAME, 1280, 1024, 2, 0.0).shouldBeEmpty()
REPOSITORY.biasFrames(NAME, 4092, 2800, 1, 0.0).shouldBeEmpty()
REPOSITORY.biasFrames("ZW", 1280, 1024, 2, 0.0).shouldBeEmpty()
}

"find all" {
repository.findAll().shouldHaveSize(17)
}
"find darks" {
repository.darkFrames(NAME, 1280, 1024, 1, 1L, 0.0).shouldHaveSize(1)
repository.darkFrames(NAME, 1280, 1024, 1, 60L, 0.0).shouldHaveSize(4)
repository.darkFrames(NAME, 1280, 1024, 1, 60L, 100.0).shouldHaveSize(2)
repository.darkFrames(NAME, 1280, 1024, 1, 60L, 50.0).shouldBeEmpty()
repository.darkFrames(NAME, 1280, 1024, 2, 60L, 100.0).shouldBeEmpty()
repository.darkFrames(NAME, 4092, 2800, 1, 60L, 100.0).shouldBeEmpty()
repository.darkFrames("ZW", 1280, 1024, 1, 1L, 0.0).shouldBeEmpty()
}
"find bias" {
repository.biasFrames(NAME, 1280, 1024, 1, 0.0).shouldHaveSize(2)
repository.biasFrames(NAME, 1280, 1024, 1, 100.0).shouldHaveSize(1)
repository.biasFrames(NAME, 1280, 1024, 1, 50.0).shouldBeEmpty()
repository.biasFrames(NAME, 1280, 1024, 2, 0.0).shouldBeEmpty()
repository.biasFrames(NAME, 4092, 2800, 1, 0.0).shouldBeEmpty()
repository.biasFrames("ZW", 1280, 1024, 2, 0.0).shouldBeEmpty()
}
"find flats" {
repository.flatFrames(NAME, null, 1280, 1024, 1).shouldHaveSize(1)
repository.flatFrames(NAME, "RED", 1280, 1024, 1).shouldHaveSize(1)
repository.flatFrames(NAME, "green", 1280, 1024, 1).shouldHaveSize(1)
repository.flatFrames(NAME, "BLUE", 1280, 1024, 1).shouldHaveSize(1)
repository.flatFrames(NAME, "RED", 1280, 1024, 2).shouldBeEmpty()
repository.flatFrames(NAME, "RED", 4092, 2800, 2).shouldBeEmpty()
repository.flatFrames(NAME, "HA", 1280, 1024, 2).shouldBeEmpty()
repository.flatFrames("ZW", "RED", 1280, 1024, 2).shouldBeEmpty()
}
@Test
fun findFlats() {
REPOSITORY.flatFrames(NAME, null, 1280, 1024, 1).shouldHaveSize(1)
REPOSITORY.flatFrames(NAME, "RED", 1280, 1024, 1).shouldHaveSize(1)
REPOSITORY.flatFrames(NAME, "green", 1280, 1024, 1).shouldHaveSize(1)
REPOSITORY.flatFrames(NAME, "BLUE", 1280, 1024, 1).shouldHaveSize(1)
REPOSITORY.flatFrames(NAME, "RED", 1280, 1024, 2).shouldBeEmpty()
REPOSITORY.flatFrames(NAME, "RED", 4092, 2800, 2).shouldBeEmpty()
REPOSITORY.flatFrames(NAME, "HA", 1280, 1024, 2).shouldBeEmpty()
REPOSITORY.flatFrames("ZW", "RED", 1280, 1024, 2).shouldBeEmpty()
}

companion object {

private const val NAME = "CCD Simulator"

@JvmStatic private val BOX_STORE = MyObjectBox.builder()
.inMemory(UUID.randomUUID().toString())
.build()

@AfterAll
@JvmStatic
fun closeBoxStore() {
BOX_STORE.close()
}

@JvmStatic private val BOX = BOX_STORE.boxFor<CalibrationFrameEntity>()
@JvmStatic private val REPOSITORY = CalibrationFrameRepository(BOX).apply {
save(FrameType.DARK, 1L)
save(FrameType.DARK, 2L)
save(FrameType.DARK, 5L)
save(FrameType.DARK, 10L)
save(FrameType.DARK, 30L)
save(FrameType.DARK, 60L)
save(FrameType.DARK, 60L, gain = 100.0)
save(FrameType.DARK, 10L, temperature = -10.0)
save(FrameType.DARK, 30L, temperature = -10.0)
save(FrameType.DARK, 60L, temperature = -10.0)
save(FrameType.DARK, 60L, temperature = -10.0, gain = 100.0)
save(FrameType.BIAS, 0L)
save(FrameType.BIAS, 0L, gain = 100.0)
save(FrameType.FLAT, 0L, filter = "RED")
save(FrameType.FLAT, 0L, filter = "GREEN")
save(FrameType.FLAT, 0L, filter = "BLUE")
save(FrameType.FLAT, 0L, filter = null)
}

@JvmStatic
internal fun CalibrationFrameRepository.save(
type: FrameType, exposureTime: Long,
temperature: Double = 25.0, width: Int = 1280, height: Int = 1024,
bin: Int = 1, gain: Double = 0.0,
filter: String? = null,
) {
save(CalibrationFrameEntity(0L, type, NAME, filter, exposureTime, temperature, width, height, bin, bin, gain))
}
) = save(CalibrationFrameEntity(0L, type, NAME, filter, exposureTime, temperature, width, height, bin, bin, gain))
}
}
Loading

0 comments on commit 1c45794

Please sign in to comment.