Extracted TestUtils

This commit is contained in:
dankito 2024-11-18 20:04:55 +01:00
parent f6a0022b24
commit af94ff2049
3 changed files with 18 additions and 6 deletions

View File

@ -2,7 +2,7 @@ package net.codinux.invoicing.reader
import net.codinux.invoicing.model.Invoice
import net.codinux.invoicing.test.InvoiceAsserter
import java.io.InputStream
import net.codinux.invoicing.test.TestUtils
import kotlin.test.Test
class EInvoiceReaderTest {
@ -32,8 +32,7 @@ class EInvoiceReaderTest {
}
private fun getTestFile(filename: String): InputStream =
this.javaClass.classLoader.getResourceAsStream("files/$filename")!!
private fun getTestFile(filename: String) = TestUtils.getTestFileAsStream(filename)
private fun assertInvoice(invoice: Invoice?) {
InvoiceAsserter.assertInvoice(invoice)

View File

@ -0,0 +1,14 @@
package net.codinux.invoicing.test
import java.io.File
import java.io.InputStream
object TestUtils {
fun getTestFileAsStream(filename: String): InputStream =
this.javaClass.classLoader.getResourceAsStream("files/$filename")!!
fun getTestFile(filename: String): File =
File(this.javaClass.classLoader.getResource("files/$filename")!!.toURI())
}

View File

@ -2,7 +2,7 @@ package net.codinux.invoicing.validation
import assertk.assertThat
import assertk.assertions.*
import java.io.File
import net.codinux.invoicing.test.TestUtils
import kotlin.test.Test
class EInvoiceValidatorTest {
@ -54,7 +54,6 @@ class EInvoiceValidatorTest {
}
private fun getTestFile(filename: String): File =
File(this.javaClass.classLoader.getResource("files/$filename")!!.toURI())
private fun getTestFile(filename: String) = TestUtils.getTestFile(filename)
}