aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
blob: 99500d07b0b101a5bd01b6a9a0efe790818df0e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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 org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.time.Instant;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class ProfitCalculationTest {

  /** 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
  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 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();
  }


}