-
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.
Created CSVStockFileWriterTest Made some small changes to StockFileWriter and StockFileReaderTest
- Loading branch information
Nikollai
committed
Apr 13, 2026
1 parent
49ac7b1
commit 9f127ac
Showing
5 changed files
with
65 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
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 |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| package millions.controller.fileIO; | ||
|
|
||
| import java.nio.file.Path; | ||
|
|
||
| public interface StockFileWriter { | ||
| public void formatString(); | ||
| public boolean write(); | ||
| public boolean write(Path path); | ||
| } |
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,43 @@ | ||
| package millions; | ||
|
|
||
| import millions.controller.fileIO.CSVStockFileWriter; | ||
| import millions.controller.fileIO.StockFileReader; | ||
| import millions.model.Stock; | ||
|
|
||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import java.nio.file.Path; | ||
| import java.util.List; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| public class CSVStockFileWriterTest { | ||
| @TempDir | ||
| static Path tempDir; | ||
|
|
||
| List<Stock> stocks; | ||
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| Stock s1 = new Stock("PEAR", "Pear Inc.", BigDecimal.valueOf(300)); | ||
| Stock s2 = new Stock("DOGL", "DOOGLE Inc.", BigDecimal.valueOf(200.00)); | ||
| Stock s3 = new Stock("MSFT", "EpsteinSoft Inc.", BigDecimal.valueOf(0.02)); | ||
|
|
||
| this.stocks = List.of(s1, s2, s3); | ||
| } | ||
|
|
||
| @Test | ||
| public void testWrite() { | ||
| for(Stock stock : this.stocks) { | ||
| System.out.println(stock.toString()); | ||
| } | ||
| CSVStockFileWriter csvStockFileWriter = new CSVStockFileWriter(stocks); | ||
| csvStockFileWriter.write(tempDir.resolve("stocks.csv")); | ||
|
|
||
| StockFileReader stockFileReader = new StockFileReader(tempDir.resolve("stocks.csv")); | ||
| assertEquals(3, stockFileReader.readFile().size()); | ||
| } | ||
| } |
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