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

Lagt til ny extension-metode for DokumentInfo og tester for denne #973

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -25,4 +25,6 @@ data class DokumentInfo(
Tema.KON -> erKontantstøtteSøknad()
else -> throw Error("Støtter ikke tema $tema")
}

fun harOriginalVariant(): Boolean = this.dokumentvarianter?.any { it.variantformat == Dokumentvariantformat.ORIGINAL } ?: false
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,64 @@ class DokumentInfoTest {
assertEquals("Støtter ikke tema ENF", error.message)
}
}

@Nested
inner class HarOriginalVariant {
@Test
fun `skal returnere true dersom dokumentvarianter inneholder original variant`() {
// Arrange
val dokumentInfo =
DokumentInfo(
dokumentInfoId = "1",
brevkode = Brevkoder.BARNETRYGD_ORDINÆR_SØKNAD,
dokumentvarianter =
listOf(
Dokumentvariant(Dokumentvariantformat.ORIGINAL, "Testfil", false),
),
)

// Act
val harOriginalVariant = dokumentInfo.harOriginalVariant()

// Assert
assertTrue(harOriginalVariant)
}

@Test
fun `skal returnere false dersom dokumentvarianter ikke inneholder original variant`() {
// Arrange
val dokumentInfo =
DokumentInfo(
dokumentInfoId = "1",
brevkode = Brevkoder.BARNETRYGD_ORDINÆR_SØKNAD,
dokumentvarianter =
listOf(
Dokumentvariant(Dokumentvariantformat.ARKIV, "Testfil", false),
),
)

// Act
val harOriginalVariant = dokumentInfo.harOriginalVariant()

// Assert
assertFalse(harOriginalVariant)
}

@Test
fun `skal returnere false dersom dokumentvarianter er en tom liste`() {
// Arrange
val dokumentInfo =
DokumentInfo(
dokumentInfoId = "1",
brevkode = Brevkoder.BARNETRYGD_ORDINÆR_SØKNAD,
dokumentvarianter = emptyList(),
)

// Act
val harOriginalVariant = dokumentInfo.harOriginalVariant()

// Assert
assertFalse(harOriginalVariant)
}
}
}
Loading