|
|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
package data;
|
|
|
|
|
|
|
|
|
|
import data.WatchList;
|
|
|
|
|
import data.StypeMap;
|
|
|
|
|
import data.StockType;
|
|
|
|
|
import data.Nyse;
|
|
|
|
|
import data.exceptions.*;
|
|
|
|
|
import ui.Main;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
|
@ -9,6 +12,7 @@ import org.junit.jupiter.api.Test;
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.fail;
|
|
|
|
|
|
|
|
|
|
public class WatchListTest {
|
|
|
|
|
private WatchList watchlist;
|
|
|
|
|
@ -41,17 +45,35 @@ public class WatchListTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testDelStock() {
|
|
|
|
|
public void testDelStockNoThrow() {
|
|
|
|
|
StockType nyyyse = smap.getStype("Nyse");
|
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
|
watchlist.addStock(Integer.toString(i), nyyyse);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < 50; i++) {
|
|
|
|
|
try {
|
|
|
|
|
watchlist.delStock(Integer.toString(i));
|
|
|
|
|
} catch (WatchListExceptions e) {
|
|
|
|
|
fail();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
assertEquals(watchlist.size(), 50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testDelNotExistsStock() {
|
|
|
|
|
StockType nyyyse = smap.getStype("Nyse");
|
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
|
watchlist.addStock(Integer.toString(i), nyyyse);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
watchlist.delStock(Integer.toString(-1));
|
|
|
|
|
fail();
|
|
|
|
|
} catch (WatchListExceptions e) {
|
|
|
|
|
//expected to throw
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testSaveLoad() {
|
|
|
|
|
StockType nyyyse = smap.getStype("Nyse");
|