-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed StockFileReader Added toString method to stock class Created test for CSVStockFileParser Fixed issue where CSVStockFileParser would only accept incorrect formats
- Loading branch information
Nikollai
committed
Apr 12, 2026
1 parent
764750a
commit 3acdb6a
Showing
4 changed files
with
56 additions
and
8 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
10 changes: 6 additions & 4 deletions
10
...roller/fileIO/StockInformationReader.java → ...ns/controller/fileIO/StockFileReader.java
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,40 @@ | ||
| package millions; | ||
|
|
||
| import millions.controller.fileIO.CSVStockFileParser; | ||
| import millions.controller.fileIO.StockFileReader; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
|
|
||
| public class CSVStockFileParserTest { | ||
| @TempDir | ||
| static Path tempDir; | ||
|
|
||
| static Path sharedFile; | ||
|
|
||
| @BeforeAll | ||
| public static void setUpTestFile() throws Exception { | ||
| sharedFile = Files.createFile(tempDir.resolve("file.csv")); | ||
| String string = "# Top 500 US Stocks by Market Cap\n"; | ||
| string += "# Ticker,Name,Price\n"; | ||
| string += "\n"; | ||
| string += "NVDA,Nvidia,191.27\n"; | ||
| string += "AAPL,Apple Inc.,276.43\n"; | ||
| string += "MSFT,Microsoft,404.68\n"; | ||
| Files.writeString(sharedFile, string); | ||
| } | ||
|
|
||
| @Test | ||
| public void parseStockFileTest(){ | ||
| StockFileReader stockFileReader = new StockFileReader(sharedFile); | ||
| stockFileReader.readFile().forEach(System.out::println); | ||
|
|
||
| CSVStockFileParser parser = new CSVStockFileParser(stockFileReader.readFile()); | ||
| parser.parse().forEach(s -> System.out.println(s.toString())); | ||
| } | ||
| } |