From af94ff204967be9483564114c30744c1cd9b1931 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 18 Nov 2024 20:04:55 +0100 Subject: [PATCH] Extracted TestUtils --- .../codinux/invoicing/reader/EInvoiceReaderTest.kt | 5 ++--- .../kotlin/net/codinux/invoicing/test/TestUtils.kt | 14 ++++++++++++++ .../invoicing/validation/EInvoiceValidatorTest.kt | 5 ++--- 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/test/TestUtils.kt diff --git a/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/reader/EInvoiceReaderTest.kt b/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/reader/EInvoiceReaderTest.kt index 4f691a9..5c34df0 100644 --- a/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/reader/EInvoiceReaderTest.kt +++ b/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/reader/EInvoiceReaderTest.kt @@ -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) diff --git a/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/test/TestUtils.kt b/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/test/TestUtils.kt new file mode 100644 index 0000000..500e0bd --- /dev/null +++ b/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/test/TestUtils.kt @@ -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()) + +} \ No newline at end of file diff --git a/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/validation/EInvoiceValidatorTest.kt b/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/validation/EInvoiceValidatorTest.kt index 5ebf18f..a6c3be9 100644 --- a/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/validation/EInvoiceValidatorTest.kt +++ b/e-invoicing-domain/src/test/kotlin/net/codinux/invoicing/validation/EInvoiceValidatorTest.kt @@ -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) } \ No newline at end of file