-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* release_notes, move file loading to function with custom exception * Rename Yaml Loader to more generic File Loader * Made changes requested by prs
- Loading branch information
1 parent
71aac52
commit 08b7866
Showing
12 changed files
with
61 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ftl.util | ||
|
||
import java.io.Reader | ||
import java.nio.file.Files | ||
import java.nio.file.NoSuchFileException | ||
import java.nio.file.Path | ||
|
||
fun loadFile(filePath: Path): Reader = try { | ||
Files.newBufferedReader(filePath) | ||
} catch (fileNotFound: NoSuchFileException) { | ||
throw FlankFatalError("File not found: ${fileNotFound.message}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
test_runner/src/test/kotlin/ftl/args/yml/FileLoaderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ftl.args.yml | ||
|
||
import ftl.util.loadFile | ||
import ftl.test.util.TestHelper.getThrowable | ||
import ftl.util.FlankFatalError | ||
import org.junit.Assert | ||
import org.junit.Test | ||
import java.nio.file.Paths | ||
import java.util.UUID | ||
|
||
class FileLoaderTest { | ||
@Test(expected = FlankFatalError::class) | ||
fun `should throws FlankFatalError when file not found`() { | ||
val filePath = Paths.get("${UUID.randomUUID()}.yml") | ||
loadFile(filePath) | ||
} | ||
|
||
@Test | ||
fun `should throws FlankFatalError with specific message when file not found`() { | ||
val filePath = Paths.get("${UUID.randomUUID()}.yml") | ||
val thrownException = getThrowable { loadFile(filePath) } | ||
|
||
val expectedExceptionMessage = "File not found: $filePath" | ||
Assert.assertEquals(expectedExceptionMessage, thrownException.message) | ||
|
||
val expectedExceptionType = FlankFatalError::class | ||
Assert.assertEquals(expectedExceptionType, thrownException::class) | ||
} | ||
} |