private void doTwoWayMatchingTest( MatchType matchType, int matchRatio, int fixedRatio, int parallel) throws Exception { Match g = new Match(); g.initMatch(matchType, 2); g.matchRatio = matchRatio; g.fixedRatio = fixedRatio; g.parallelMatchingMode = parallel; g.outfilePath = outfilePath; String infileName = "testing/match_test_2way.txt"; g.addMatchGroup("0"); g.addMatchGroup("1"); g.addPatients(infileName); g.run(); }
@Test public void testGetSetSeen() { Match match = new Match(5, "gNaam", "MgNaam", false, true); match.setSeen(true); assertTrue(match.isSeen()); }
@Test public void testFromToJSON() { Match match = create(); assertEquals(match, Match.fromJSON(match.toJSON())); }
@Test public void testGetMatchUsername() { Match match = new Match(5, "gNaam", null, true, true); match.setMatchUsername("MgNaam"); assertEquals("MgNaam", match.getMatchUsername()); }
@Test public void testEqualsNegative2() { Match test1 = create(); assertFalse(test1.equals(21)); }
@Test public void testEqualsNegative4() { Match test1 = new Match(-1, "username2", "username2", false, false); Match test2 = new Match(-1, "username1", "username2", false, false); assertFalse(test1.equals(test2)); }
@Test public void testConstructorApproved() { Match test = create(); assertEquals(false, test.isApproved()); }
@Test public void testEqualsPositive1() { Match test1 = create(); Match test2 = create(); assertTrue(test1.equals(test2)); }
@Test public void testConstructorSeen() { Match test = create(); assertEquals(false, test.isSeen()); }
@Test public void testConstructorMatchUsername() { Match test = create(); assertEquals("matchUsername", test.getMatchUsername()); }
@Test public void testGetRatingWrongOrder() { DatabaseCommunicator communicator = new DatabaseCommunicator("tempestasludi.com", "TI1216-test", "TI1216", "3t.uGmL365j2f7B"); Faculty f = new Faculty("EWI", "Elektrotechniek, Wiskunde en Informatica", new ArrayList<Program>()); Program p = new Program("TI", "Technische Informatica", f, new ArrayList<Course>()); new Course("C1", "Course 1", p); new Course("C2", "Course 2", p); new Course("C3", "Course 3", p); new Course("C4", "Course 4", p); new Course("C5", "Course 5", p); new Course("C6", "Course 6", p); new Course("C7", "Course 7", p); Grade g11 = new Grade("C1", 9); Grade g12 = new Grade("C2", 8); Grade g13 = new Grade("C3", 9); Grade g14 = new Grade("C4", 10); Grade g15 = new Grade("C5", 9); Grade g16 = new Grade("C6", 9); Grade g17 = new Grade("C7", 8); Grade g21 = new Grade("C1", 5); Grade g22 = new Grade("C2", 4); Grade g23 = new Grade("C3", 5); Grade g24 = new Grade("C4", 3); Grade g25 = new Grade("C5", 3); Grade g26 = new Grade("C6", 6); Grade g27 = new Grade("C7", 5); Grade g31 = new Grade("C1", 7); Grade g32 = new Grade("C2", 8); Grade g33 = new Grade("C3", 7); Grade g34 = new Grade("C4", 6); Grade g35 = new Grade("C5", 3); Grade g36 = new Grade("C6", 2); Grade g37 = new Grade("C7", 3); Grade g41 = new Grade("C1", 3); Grade g42 = new Grade("C2", 3); Grade g43 = new Grade("C3", 5); Grade g44 = new Grade("C4", 5); Grade g45 = new Grade("C5", 7); Grade g46 = new Grade("C6", 9); Grade g47 = new Grade("C7", 6); Grade[] l1 = new Grade[] {g15, g13, g12, g17, g11, g16, g14}; Grade[] l2 = new Grade[] {g22, g21, g25, g24, g23, g27, g26}; Grade[] l3 = new Grade[] {g37, g36, g34, g33, g35, g32, g31}; Grade[] l4 = new Grade[] {g43, g44, g41, g42, g46, g47, g45}; User u1 = new User("U1", "", "", l1, false); User u2 = new User("U2", "", "", l2, false); User u3 = new User("U3", "", "", l3, false); User u4 = new User("U4", "", "", l4, false); Credentials cr1 = new Credentials("U1", "P1"); Credentials cr2 = new Credentials("U2", "P2"); Credentials cr3 = new Credentials("U3", "P3"); Credentials cr4 = new Credentials("U4", "P4"); communicator.save(f); communicator.save(u1, cr1); communicator.save(u2, cr2); communicator.save(u3, cr3); communicator.save(u4, cr4); Match match12 = new Match(1, "U1", "U2", false, false); Match match13 = new Match(2, "U1", "U3", false, false); Match match14 = new Match(3, "U1", "U4", false, false); Match match21 = new Match(4, "U2", "U1", false, false); Match match23 = new Match(5, "U2", "U3", false, false); Match match24 = new Match(6, "U2", "U4", false, false); Match match31 = new Match(7, "U3", "U1", false, false); Match match32 = new Match(8, "U3", "U2", false, false); Match match34 = new Match(9, "U3", "U4", false, false); Match match41 = new Match(10, "U4", "U1", false, false); Match match42 = new Match(11, "U4", "U2", false, false); Match match43 = new Match(12, "U4", "U3", false, false); assertEquals(7, (int) match12.getRating(communicator)); assertEquals(14, (int) match13.getRating(communicator)); assertEquals(12, (int) match14.getRating(communicator)); assertEquals((int) match12.getRating(communicator), (int) match21.getRating(communicator)); assertEquals(15, (int) match23.getRating(communicator)); assertEquals(12, (int) match24.getRating(communicator)); assertEquals((int) match13.getRating(communicator), (int) match31.getRating(communicator)); assertEquals((int) match23.getRating(communicator), (int) match32.getRating(communicator)); assertEquals(25, (int) match34.getRating(communicator)); assertEquals((int) match14.getRating(communicator), (int) match41.getRating(communicator)); assertEquals((int) match24.getRating(communicator), (int) match42.getRating(communicator)); assertEquals((int) match34.getRating(communicator), (int) match43.getRating(communicator)); communicator.delete(f); }
@Test public void testConstructorId() { Match test = create(); assertEquals(-1, test.getId()); }
@Test public void testGetSetApproved() { Match match = new Match(5, "gNaam", "MgNaam", true, false); match.setApproved(true); assertTrue(match.isApproved()); }