|
1 | 1 | package org.radarbase.output.path |
2 | 2 |
|
| 3 | +import org.hamcrest.MatcherAssert.assertThat |
| 4 | +import org.hamcrest.Matchers.instanceOf |
| 5 | +import org.hamcrest.Matchers.nullValue |
3 | 6 | import org.junit.jupiter.api.Assertions.assertEquals |
4 | 7 | import org.junit.jupiter.api.Test |
5 | 8 | import org.junit.jupiter.api.assertThrows |
| 9 | +import org.radarbase.output.path.FormattedPathFactory.Companion.toPathFormatterPlugin |
6 | 10 | import org.radarcns.kafka.ObservationKey |
7 | 11 | import org.radarcns.passive.phone.PhoneLight |
8 | 12 | import java.nio.file.Paths |
9 | 13 | import java.time.Instant |
| 14 | +import kotlin.reflect.jvm.jvmName |
10 | 15 |
|
11 | 16 | internal class FormattedPathFactoryTest { |
12 | 17 | @Test |
@@ -99,4 +104,25 @@ internal class FormattedPathFactoryTest { |
99 | 104 | ) |
100 | 105 | extension = ".csv.gz" |
101 | 106 | } |
| 107 | + |
| 108 | + @Test |
| 109 | + fun testNamedPluginCreate() { |
| 110 | + assertThat("fixed".toPathFormatterPlugin(), instanceOf(FixedPathFormatterPlugin::class.java)) |
| 111 | + assertThat("time".toPathFormatterPlugin(), instanceOf(TimePathFormatterPlugin::class.java)) |
| 112 | + assertThat("key".toPathFormatterPlugin(), instanceOf(KeyPathFormatterPlugin::class.java)) |
| 113 | + assertThat("value".toPathFormatterPlugin(), instanceOf(ValuePathFormatterPlugin::class.java)) |
| 114 | + } |
| 115 | + |
| 116 | + @Test |
| 117 | + fun testBadPluginCreate() { |
| 118 | + assertThat("unknown".toPathFormatterPlugin(), nullValue()) |
| 119 | + } |
| 120 | + |
| 121 | + @Test |
| 122 | + fun testClassPathPluginCreate() { |
| 123 | + assertThat( |
| 124 | + FixedPathFormatterPlugin::class.jvmName.toPathFormatterPlugin(), |
| 125 | + instanceOf(FixedPathFormatterPlugin::class.java), |
| 126 | + ) |
| 127 | + } |
102 | 128 | } |
0 commit comments