aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/edu/brown/cs/student/LinkMapperTest.java
diff options
context:
space:
mode:
authorMichael Foiani <sotech117@michaels-mbp-3.lan>2021-04-16 11:28:17 -0400
committerMichael Foiani <sotech117@michaels-mbp-3.lan>2021-04-16 11:28:17 -0400
commit250f5edc1ed502c74c398b5850a0bb7a7b01848c (patch)
tree56e41c692f5d1380eda69bc931e0d01feda0721b /src/test/java/edu/brown/cs/student/LinkMapperTest.java
parent939f748b5f0914fe1558d571fdf13962c46b4537 (diff)
parentb75b23ff59a71c9a54be43525189b678124ae3a3 (diff)
Big merge to supress the printstram and update the frontend server.
Diffstat (limited to 'src/test/java/edu/brown/cs/student/LinkMapperTest.java')
-rw-r--r--src/test/java/edu/brown/cs/student/LinkMapperTest.java59
1 files changed, 47 insertions, 12 deletions
diff --git a/src/test/java/edu/brown/cs/student/LinkMapperTest.java b/src/test/java/edu/brown/cs/student/LinkMapperTest.java
index 2683b90..3d4bedc 100644
--- a/src/test/java/edu/brown/cs/student/LinkMapperTest.java
+++ b/src/test/java/edu/brown/cs/student/LinkMapperTest.java
@@ -10,6 +10,10 @@ import org.junit.Test;
import java.time.Instant;
import java.util.Map;
+import java.util.Set;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
public class LinkMapperTest {
@@ -30,26 +34,57 @@ public class LinkMapperTest {
}
}
- /*
- * try{
-
- } catch(Exception e) {
- System.out.println("Error in test");
- }*/
-
@After
public void tearDown() {
db = null;
}
@Test
- public void testMapper(){
+ public void testBasicMapper(){
+ setUp();
+ LinkMapper lm = new LinkMapper(db);
+ Map<Holder, Set<Holder>> linkMap = lm.makeFollowerLinks(start, end);
+ //should be one for each person in little mock (6)
+ assertEquals(6, linkMap.keySet().size());
+
+ for(Holder h: linkMap.keySet()){
+ //didn't follow anyone elses trades
+ if(h.getName().equals("Don") || h.getName().equals("Jane")){
+ assertTrue(linkMap.get(h).isEmpty());
+ //biggest follower
+ } else if(h.getName().equals("Midge")){
+ assertEquals(4, linkMap.get(h).size());
+ } else if(h.getName().equals("Nancy") || h.getName().equals("Mitch")){
+ assertEquals(2, linkMap.get(h).size());
+ } else {
+ //should be Bob, only followed Mitch
+ assertEquals(1, linkMap.get(h).size());
+ }
+ }
+ tearDown();
+ }
+
+ @Test
+ public void testBadDate(){
setUp();
LinkMapper lm = new LinkMapper(db);
- lm.makeFollowerLinks(start, end);
- HubSearch hub = new HubSearch(lm);
- Map<Holder, Double> him = hub.runHubSearch(start, end);
- System.out.println(him);
+ Map<Holder, Set<Holder>> linkMap = lm.makeFollowerLinks(end, start);
+ assertTrue(linkMap.isEmpty());
+ tearDown();
+ }
+
+ @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);
+ Map<Holder, Set<Holder>> linkMap = lm.makeFollowerLinks(start, end);
+ //should be one for each person in little mock (6)
+ assertTrue(linkMap.isEmpty());
+
}
}