summaryrefslogtreecommitdiff
path: root/opendc-trace/opendc-trace-wfformat/src/test
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-20 22:04:23 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-20 22:04:23 +0200
commitc7fff03408ee3109d0a39a96c043584a2d8f67ca (patch)
tree8c4a877e0f00f14a9091f9c26fdb0e85cad94904 /opendc-trace/opendc-trace-wfformat/src/test
parent140aafdaa711b0fdeacf99b9c7e70b706b8490f4 (diff)
refactor(trace): Simplify TraceFormat SPI interface
This change simplifies the TraceFormat SPI interface by reducing the number of interfaces that implementors need to implement to only TraceFormat.
Diffstat (limited to 'opendc-trace/opendc-trace-wfformat/src/test')
-rw-r--r--opendc-trace/opendc-trace-wfformat/src/test/kotlin/org/opendc/trace/wfformat/WfFormatTraceFormatTest.kt58
1 files changed, 13 insertions, 45 deletions
diff --git a/opendc-trace/opendc-trace-wfformat/src/test/kotlin/org/opendc/trace/wfformat/WfFormatTraceFormatTest.kt b/opendc-trace/opendc-trace-wfformat/src/test/kotlin/org/opendc/trace/wfformat/WfFormatTraceFormatTest.kt
index 0bfc8840..217b175d 100644
--- a/opendc-trace/opendc-trace-wfformat/src/test/kotlin/org/opendc/trace/wfformat/WfFormatTraceFormatTest.kt
+++ b/opendc-trace/opendc-trace-wfformat/src/test/kotlin/org/opendc/trace/wfformat/WfFormatTraceFormatTest.kt
@@ -22,59 +22,38 @@
package org.opendc.trace.wfformat
+import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows
import org.opendc.trace.*
-import java.io.File
-import java.net.URL
+import java.nio.file.Paths
/**
* Test suite for the [WfFormatTraceFormat] class.
*/
class WfFormatTraceFormatTest {
- @Test
- fun testTraceExists() {
- val input = File("src/test/resources/trace.json").toURI().toURL()
- val format = WfFormatTraceFormat()
- assertDoesNotThrow { format.open(input) }
- }
-
- @Test
- fun testTraceDoesNotExists() {
- val input = File("src/test/resources/trace.json").toURI().toURL()
- val format = WfFormatTraceFormat()
- assertThrows<IllegalArgumentException> { format.open(URL(input.toString() + "help")) }
- }
+ private val format = WfFormatTraceFormat()
@Test
fun testTables() {
- val input = File("src/test/resources/trace.json").toURI().toURL()
- val format = WfFormatTraceFormat()
- val trace = format.open(input)
+ val path = Paths.get("src/test/resources/trace.json")
- assertEquals(listOf(TABLE_TASKS), trace.tables)
+ assertEquals(listOf(TABLE_TASKS), format.getTables(path))
}
@Test
fun testTableExists() {
- val input = File("src/test/resources/trace.json").toURI().toURL()
- val format = WfFormatTraceFormat()
- val table = format.open(input).getTable(TABLE_TASKS)
-
- assertNotNull(table)
- assertDoesNotThrow { table!!.newReader() }
+ val path = Paths.get("src/test/resources/trace.json")
+ Assertions.assertDoesNotThrow { format.getDetails(path, TABLE_TASKS) }
}
@Test
fun testTableDoesNotExist() {
- val input = File("src/test/resources/trace.json").toURI().toURL()
- val format = WfFormatTraceFormat()
- val trace = format.open(input)
+ val path = Paths.get("src/test/resources/trace.json")
- assertFalse(trace.containsTable("test"))
- assertNull(trace.getTable("test"))
+ assertThrows<IllegalArgumentException> { format.getDetails(path, "test") }
}
/**
@@ -82,9 +61,8 @@ class WfFormatTraceFormatTest {
*/
@Test
fun testTableReader() {
- val input = File("src/test/resources/trace.json").toURI().toURL()
- val trace = WfFormatTraceFormat().open(input)
- val reader = trace.getTable(TABLE_TASKS)!!.newReader()
+ val path = Paths.get("src/test/resources/trace.json")
+ val reader = format.newReader(path, TABLE_TASKS)
assertAll(
{ assertTrue(reader.nextRow()) },
@@ -110,9 +88,8 @@ class WfFormatTraceFormatTest {
*/
@Test
fun testTableReaderFull() {
- val input = File("src/test/resources/trace.json").toURI().toURL()
- val trace = WfFormatTraceFormat().open(input)
- val reader = trace.getTable(TABLE_TASKS)!!.newReader()
+ val path = Paths.get("src/test/resources/trace.json")
+ val reader = format.newReader(path, TABLE_TASKS)
assertDoesNotThrow {
while (reader.nextRow()) {
@@ -121,13 +98,4 @@ class WfFormatTraceFormatTest {
reader.close()
}
}
-
- @Test
- fun testTableReaderPartition() {
- val input = File("src/test/resources/trace.json").toURI().toURL()
- val format = WfFormatTraceFormat()
- val table = format.open(input).getTable(TABLE_TASKS)!!
-
- assertThrows<IllegalArgumentException> { table.newReader("test") }
- }
}