package edu.brown.cs.student; 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.hub.SuspicionRanker; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.time.Instant; import java.util.Comparator; import java.util.List; import java.util.Map; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class SuspicionRankerTest { // ./cs32-test tests/student/hub/*.test //friday april 9th //private Instant start = Instant.ofEpochMilli(1618004180000L); //saturday april 10th //private Instant end = Instant.ofEpochMilli(1618019436000L); //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 private Instant end = Instant.parse("2021-03-28T05:00:00.00Z"); private DatabaseQuerier db; @Before public void setUp() { try{ db = new DatabaseQuerier("data/lil_mock.sqlite3"); } catch(Exception e){ System.out.println("DBQuerier Test, couldn't connect to db???"); } } @After public void tearDown() { db = null; } @Test public void testSuspicionRanksOnMockData(){ setUp(); SuspicionRanker r = new SuspicionRanker(db); List him = r.getSuspicionScoreList(start, end); assertEquals(6, him.size()); for(Holder p: him){ System.out.println(p.toTestString()); } tearDown(); } @Test public void testSusRankEmptyDB(){ try{ db = new DatabaseQuerier("data/testing/empty.sqlite3"); } catch(Exception e){ System.out.println("DBQuerier Test, couldn't connect to db???"); } SuspicionRanker r = new SuspicionRanker(db); List vals = r.getSuspicionScoreList(start, end); assertTrue(vals.isEmpty()); tearDown(); } @Test public void testBadDates(){ setUp(); SuspicionRanker r = new SuspicionRanker(db); List vals = r.getSuspicionScoreList(end, start); assertTrue(vals.isEmpty()); tearDown(); } //TODO: Test special case for all the profit = 0 //TODO: Test special case for all the profit is negative }