aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/edu/brown/cs/student/LinkMapperTest.java
diff options
context:
space:
mode:
authorclarkohw <66530369+clarkohw@users.noreply.github.com>2021-04-15 23:57:32 -0400
committerGitHub <noreply@github.com>2021-04-15 23:57:32 -0400
commit8f731c741de79fc6963bb4b33050378341fe2f39 (patch)
tree81dbcc51f36ed651fe4c47fe376989bc1aed30b5 /src/test/java/edu/brown/cs/student/LinkMapperTest.java
parent1301a143b3b0e89180883c9948b13a1700f8821f (diff)
parentf42119ece5f132ef473d7c2ee5a7cfd64d83f132 (diff)
Merge branch 'master' into endpoint-proifit-query
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());
+
}
}