aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
diff options
context:
space:
mode:
authorMichael Foiani <sotech117@michaels-mbp-3.lan>2021-04-16 18:55:57 -0400
committerMichael Foiani <sotech117@michaels-mbp-3.lan>2021-04-16 18:55:57 -0400
commitee7dba2f399afa78275755c46b9b9c38906cc2b1 (patch)
tree59d569093bab1a478ce9201cb698a250aa5370c6 /src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
parent79cf63694077d0835a62b9833d31f3c263cdccd9 (diff)
parent3f7130d250eface87c94e436ca361eb0bf2a7104 (diff)
Merge branch 'master' of https://github.com/cs0320-2021/term-project-cohwille-jmccaul3-mfoiani-rhunt2
Merging with clark's test cases.
Diffstat (limited to 'src/test/java/edu/brown/cs/student/ProfitCalculationTest.java')
-rw-r--r--src/test/java/edu/brown/cs/student/ProfitCalculationTest.java37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java b/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
index 99500d0..974fff0 100644
--- a/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
+++ b/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
@@ -4,10 +4,16 @@ import edu.brown.cs.student.term.DatabaseQuerier;
import edu.brown.cs.student.term.hub.Holder;
import edu.brown.cs.student.term.hub.HubSearch;
import edu.brown.cs.student.term.hub.LinkMapper;
+import edu.brown.cs.student.term.profit.ProfitCalculation;
+import edu.brown.cs.student.term.profit.StockHolding;
+import edu.brown.cs.student.term.repl.commands.SetupCommand;
+import edu.brown.cs.student.term.trade.Trade;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import java.util.List;
+import java.sql.Date;
import java.time.Instant;
import java.util.Map;
@@ -16,7 +22,9 @@ import static org.junit.Assert.assertTrue;
public class ProfitCalculationTest {
- /** these should span the entire mock dataset */
+ /**
+ * these should span the entire mock dataset
+ */
//12 am on 3/11 in UTC
private Instant start = Instant.parse("2021-03-11T05:00:00.00Z");
//12 am on 3/28 in UTC
@@ -26,9 +34,9 @@ public class ProfitCalculationTest {
@Before
public void setUp() {
- try{
- db = new DatabaseQuerier("data/lil_mock.sqlite3");
- } catch(Exception e){
+ try {
+ db = new DatabaseQuerier("data/trades.sqlite3");
+ } catch (Exception e) {
System.out.println("DBQuerier Test, couldn't connect to db???");
}
}
@@ -39,18 +47,17 @@ public class ProfitCalculationTest {
}
@Test
- public void testEmptyDB(){
- try{
- db = new DatabaseQuerier("data/empty.sqlite3");
- } catch(Exception e){
- System.out.println("DBQuerier Test, couldn't connect to db???");
- }
- LinkMapper lm = new LinkMapper(db);
- HubSearch hub = new HubSearch(lm);
- Map<Holder, Double> hubRanks = hub.runHubSearch(start, end);
- assertTrue(hubRanks.isEmpty());
- tearDown();
+ public void testEmptyDB() {
+ setUp();
+ ProfitCalculation profitCalculation =
+ new ProfitCalculation(DatabaseQuerier.getConn(), "CAKEBREAD STEVEN", new Date(1518010558000l),
+ new Date(1718010556000l));
+ List<StockHolding> trade = profitCalculation.getHoldingsList();
+ double gain = trade.get(0).getUnrealizedGain();
+ assertEquals(294800.0, gain, .01);
+
}
+
} \ No newline at end of file