diff options
author | clarkohw <66530369+clarkohw@users.noreply.github.com> | 2021-04-16 18:46:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-16 18:46:14 -0400 |
commit | 3f7130d250eface87c94e436ca361eb0bf2a7104 (patch) | |
tree | 168c3759bbcabc75f21aa59015d04715508aab44 /src/test/java/edu/brown/cs/student/ProfitCalculationTest.java | |
parent | 868c250d5c9ab45be1c5a478d2ff5cd82ec60f2d (diff) | |
parent | b51a24d0eecec9015434d7d0bf660138d5d98100 (diff) |
Merge pull request #11 from cs0320-2021/profit-testing
Profit testing
Diffstat (limited to 'src/test/java/edu/brown/cs/student/ProfitCalculationTest.java')
-rw-r--r-- | src/test/java/edu/brown/cs/student/ProfitCalculationTest.java | 37 |
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 |