Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Increase code coverage #284

Merged
merged 3 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ch.difty.kris.domain

import org.amshove.kluent.shouldContainAll
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class RisTagTest {
Expand Down Expand Up @@ -92,4 +93,134 @@
"End of Reference",
)
}


@Test
fun settingRisType() {
val rr = RisRecord()
RisTag.TY.setInto(rr, RisType.BOOK)
assertThat(rr.type).isEqualTo(RisType.BOOK)
}

@Test
fun settingMultipleAuthors_setsThemInOrder() {
val rr = RisRecord()
mapOf(
RisTag.A1 to RisRecord::firstAuthors,
RisTag.A2 to RisRecord::secondaryAuthors,
RisTag.A3 to RisRecord::tertiaryAuthors,
RisTag.A4 to RisRecord::subsidiaryAuthors,
RisTag.AU to RisRecord::authors,
).forEach { (risTag: RisTag, getter: (RisRecord) -> List<String>) ->
risTag.setInto(rr, "Bond, J.")
risTag.setInto(rr, "Duck, D.")
assertThat(getter(rr)).containsAll(listOf("Bond, J.", "Duck, D."))
}
}

@Test
fun settingStringValues() {
Fixed Show fixed Hide fixed
val rr = RisRecord()
mapOf(
RisTag.AB to RisRecord::abstr,
RisTag.AD to RisRecord::authorAddress,
RisTag.AN to RisRecord::accessionNumber,
RisTag.AV to RisRecord::archivesLocation,
RisTag.BT to RisRecord::bt,
RisTag.C1 to RisRecord::custom1,
RisTag.C2 to RisRecord::custom2,
RisTag.C3 to RisRecord::custom3,
RisTag.C4 to RisRecord::custom4,
RisTag.C5 to RisRecord::custom5,
RisTag.C6 to RisRecord::custom6,
RisTag.C7 to RisRecord::custom7,
RisTag.C8 to RisRecord::custom8,
RisTag.CA to RisRecord::caption,
RisTag.CN to RisRecord::callNumber,
RisTag.CP to RisRecord::cp,
RisTag.CT to RisRecord::unpublishedReferenceTitle,
RisTag.CY to RisRecord::placePublished,
RisTag.DA to RisRecord::date,
RisTag.DB to RisRecord::databaseName,
RisTag.DO to RisRecord::doi,
RisTag.DP to RisRecord::databaseProvider,
RisTag.ED to RisRecord::editor,
RisTag.EP to RisRecord::endPage,
RisTag.ET to RisRecord::edition,
RisTag.ID to RisRecord::referenceId,
RisTag.IS to RisRecord::issue,
RisTag.J1 to RisRecord::periodicalNameUserAbbrevation,
RisTag.J2 to RisRecord::alternativeTitle,
RisTag.JA to RisRecord::periodicalNameStandardAbbrevation,
RisTag.JF to RisRecord::periodicalNameFullFormatJF,
RisTag.JO to RisRecord::periodicalNameFullFormatJO,
RisTag.LA to RisRecord::language,
RisTag.LB to RisRecord::label,
RisTag.LK to RisRecord::websiteLink,
RisTag.M1 to RisRecord::miscellaneous1,
RisTag.M2 to RisRecord::miscellaneous2,
RisTag.M3 to RisRecord::miscellaneous3,
RisTag.N1 to RisRecord::notes,
RisTag.N2 to RisRecord::abstr2,
RisTag.NV to RisRecord::numberOfVolumes,
RisTag.PB to RisRecord::publisher,
RisTag.PP to RisRecord::publishingPlace,
RisTag.PY to RisRecord::publicationYear,
RisTag.RI to RisRecord::reviewedItem,
RisTag.RN to RisRecord::researchNotes,
RisTag.RP to RisRecord::reprintEdition,
RisTag.SE to RisRecord::section,
RisTag.SN to RisRecord::isbnIssn,
RisTag.SP to RisRecord::startPage,
RisTag.ST to RisRecord::shortTitle,
RisTag.T1 to RisRecord::primaryTitle,
RisTag.T2 to RisRecord::secondaryTitle,
RisTag.T3 to RisRecord::tertiaryTitle,
RisTag.TA to RisRecord::translatedAuthor,
RisTag.TI to RisRecord::title,
RisTag.TT to RisRecord::translatedTitle,
RisTag.U1 to RisRecord::userDefinable1,
RisTag.U2 to RisRecord::userDefinable2,
RisTag.U3 to RisRecord::userDefinable3,
RisTag.U4 to RisRecord::userDefinable4,
RisTag.U5 to RisRecord::userDefinable5,
RisTag.UR to RisRecord::url,
RisTag.VL to RisRecord::volumeNumber,
RisTag.VO to RisRecord::publisherStandardNumber,
RisTag.Y1 to RisRecord::primaryDate,
RisTag.Y2 to RisRecord::accessDate,
).forEach { (risTag: RisTag, getter: (RisRecord) -> String?) ->
risTag.setInto(rr, risTag.name)
assertThat(getter(rr)).isEqualTo(risTag.name)
}
}

@Test
fun settingMultipleKeywords_setsThemInOrder() {
val rr = RisRecord()
mapOf(
RisTag.KW to RisRecord::keywords,
RisTag.L1 to RisRecord::pdfLinks,
RisTag.L2 to RisRecord::fullTextLinks,
RisTag.L3 to RisRecord::relatedRecords,
RisTag.L4 to RisRecord::images,
).forEach { (risTag: RisTag, getter: (RisRecord) -> List<String>) ->
risTag.setInto(rr, "${risTag}1")
risTag.setInto(rr, "${risTag}2")
assertThat(getter(rr)).containsAll(listOf("${risTag}1", "${risTag}2"))
}
}

@Test
fun erShouldSetNothing() {
val rr = RisRecord()
RisTag.ER.setInto(rr, "Whatever")
assertThat(rr.toString()).isEqualTo(RisRecord().toString())
}

@Test
fun erShouldBeLastElement() {
assertThat(RisTag.entries.last()).isEqualTo(RisTag.ER)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ch.difty.kris

import io.kotest.matchers.shouldBe
import kotlinx.coroutines.Dispatchers
import org.junit.jupiter.api.Test

internal class DeafultDispatchProviderTest {

private val sut = DefaultDispatcherProvider

@Test
internal fun defaultProviderShouldBeDefault() {
sut.default shouldBe Dispatchers.Default
}

@Test
internal fun mainProviderShouldBeMain() {
sut.main shouldBe Dispatchers.Main
}

@Test
internal fun unconfinedProviderShouldBeUnconfined() {
sut.unconfined shouldBe Dispatchers.Unconfined
}

@Test
internal fun ioProviderShouldBeIo() {
sut.io shouldBe Dispatchers.IO
}
}
Loading