Skip to content

Commit

Permalink
Feat: Renamed FileParser and FileManager to StockFileParser and Stock…
Browse files Browse the repository at this point in the history
…FileManager, respectively.
  • Loading branch information
tommyah committed May 25, 2026
1 parent 5fe81c2 commit 9dca303
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import edu.ntnu.idi.idatt2003.g40.mappe.engine.Exchange;
import edu.ntnu.idi.idatt2003.g40.mappe.model.Player;
import edu.ntnu.idi.idatt2003.g40.mappe.model.Stock;
import edu.ntnu.idi.idatt2003.g40.mappe.service.FileParser;
import edu.ntnu.idi.idatt2003.g40.mappe.service.FileManager;
import edu.ntnu.idi.idatt2003.g40.mappe.service.StockFileParser;
import edu.ntnu.idi.idatt2003.g40.mappe.service.StockFileManager;
import edu.ntnu.idi.idatt2003.g40.mappe.service.SaveGameService;
import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager;
import edu.ntnu.idi.idatt2003.g40.mappe.utils.ConfigValues;
Expand Down Expand Up @@ -86,9 +86,9 @@ public void start(final Stage stage) throws Exception {
ViewManager viewManager = new ViewManager(stage, eventManager);

List<Stock> stocksInFile;
FileManager parser1 = new FileManager("/sp500.csv");
StockFileManager parser1 = new StockFileManager("/sp500.csv");

FileParser converter1 = new FileParser();
StockFileParser converter1 = new StockFileParser();
stocksInFile = converter1.getStocksFromStrings(parser1.readFile());

Exchange exchange = new Exchange("Exchange", stocksInFile);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package edu.ntnu.idi.idatt2003.g40.mappe.service;

import edu.ntnu.idi.idatt2003.g40.mappe.model.SaveGame;

import java.io.IOException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
* to file, each stock separated by a line.</li>
* </ul>
*
* <p>Used with {@link FileParser}</p>
* <p>Used with {@link StockFileParser}</p>
*
* @see FileParser
* @see StockFileParser
* @author tohja
* @version 1.0.0
* */
public class FileManager {
public class StockFileManager {

/** The path name this parser is using.*/
private final String pathName;
Expand Down Expand Up @@ -102,7 +102,7 @@ private enum ParserRuleSet {
*
* @param pathName the file path name to read.
* */
public FileManager(final String pathName) {
public StockFileManager(final String pathName) {
this.pathName = pathName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* list of string elements.</li>
* </ul>
*
* <p>Used with {@link FileManager}</p>
* <p>Used with {@link StockFileManager}</p>
*
* @see FileManager
* @see StockFileManager
* @author tohja
* @version 1.0.0
* */
public class FileParser {
public class StockFileParser {

/**
* Turns a list of valid string representations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ private TransactionFactory() {
* @param transactionType the type of transaction to create.
* @param share the share this transaction is about.
* @param week the week this transaction takes place in.
* @param calculator the calculator to use when calculating the transaction.
*
* @return an implementation of {@link Transaction}.
* */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Contains classes providing modular functionality to the application,
* such as the {@link edu.ntnu.idi.idatt2003.g40.mappe.service.FileParser}.
* such as the {@link edu.ntnu.idi.idatt2003.g40.mappe.service.StockFileParser}.
* */
package edu.ntnu.idi.idatt2003.g40.mappe.service;
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

import static org.junit.jupiter.api.Assertions.*;

class FileManagerTest {
class StockFileManagerTest {

private final String testStockDataPath = "/testStockData.txt";

private final String absoluteTestStockDataPath = "src/main/resources/testStockData.txt";
FileManager fileManager;
StockFileManager stockFileManager;

private final String validStockFromFile = "NVID, Nvidida Corporation, 241.591";

Expand All @@ -30,11 +30,11 @@ class FileManagerTest {

@BeforeEach
void setUp() throws Exception {
fileManager = new FileManager(testStockDataPath);
stockFileManager = new StockFileManager(testStockDataPath);
Path path = Paths.get(absoluteTestStockDataPath);
allLines = Files.readAllLines(path);
try {
validStocks = fileManager.readFile();
validStocks = stockFileManager.readFile();
} catch (Exception _) {
throw new Exception("Test failed");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import java.util.ArrayList;
import java.util.List;

class FileParserTest {
class StockFileParserTest {

private FileParser converter;
private StockFileParser converter;

private String validStockAsString1;
private String validStockAsString2;
Expand All @@ -33,7 +33,7 @@ void setUp() {
allStocks.add(validStockAsString3);
allStocks.add(invalidStockAsString1);

converter = new FileParser();
converter = new StockFileParser();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -28,8 +29,19 @@ private enum TestEventTypes implements EventChannel {

}

/**
* Event manager used for testing.
* */
private EventManager testEventManager;

/**
* Example event subscriber 1.
* */
private SampleEventSubscriber sampleEventSubscriber1;

/**
* Example event subscriber 2.
* */
private SampleEventSubscriber sampleEventSubscriber2;

@BeforeEach
Expand Down

0 comments on commit 9dca303

Please sign in to comment.