forked from cdos-rla/colorado-rla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
server/eclipse-project/src/test/java/us/freeandfair/corla/model/AdministratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
server/eclipse-project/src/test/java/us/freeandfair/corla/model/AuditBoardTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package us.freeandfair.corla.model; | ||
|
||
import org.testng.annotations.Test; | ||
import us.freeandfair.corla.util.TestClassWithDatabase; | ||
|
||
import java.lang.reflect.Array; | ||
import java.time.Instant; | ||
|
||
import java.util.ArrayList; | ||
|
||
import static org.testng.AssertJUnit.*; | ||
import static us.freeandfair.corla.util.EqualsHashcodeHelper.nullableHashCode; | ||
|
||
public class AuditBoardTest extends TestClassWithDatabase { | ||
|
||
@Test | ||
public static void testGettersAndSetters () { | ||
|
||
AuditBoard defaultAB = new AuditBoard(); | ||
assertEquals(new ArrayList<Elector>(), defaultAB.members()); | ||
assertNull(defaultAB.signInTime()); | ||
assertNull(defaultAB.signOutTime()); | ||
|
||
ArrayList<Elector> electors = new ArrayList<>(); | ||
|
||
electors.add(new Elector("firstname", "lastname", "party")); | ||
|
||
// TODO: do we want a stopped clock here too? | ||
Instant sign_in_time = Instant.now(); | ||
|
||
AuditBoard ab = new AuditBoard(electors, sign_in_time); | ||
|
||
assertEquals(electors, ab.members()); | ||
|
||
assertEquals(sign_in_time, ab.signInTime()); | ||
|
||
Instant sign_out_time = Instant.now(); | ||
|
||
ab.setSignOutTime(sign_out_time); | ||
assertEquals(sign_out_time, ab.signOutTime()); | ||
|
||
String expectedToString = "AuditBoard [members=" + electors + ", sign_in_time=" + | ||
sign_in_time + ", sign_out_time=" + sign_out_time + "]"; | ||
|
||
assertEquals(expectedToString, ab.toString()); | ||
|
||
assertEquals(nullableHashCode(sign_in_time), ab.hashCode()); | ||
|
||
assertFalse(ab.equals("Not an auditboard")); | ||
ArrayList<Elector> otherElectors = new ArrayList<>(); | ||
otherElectors.add(new Elector("otherfirstname", "otherlastname", "otherparty")); | ||
|
||
AuditBoard otherAB = new AuditBoard(otherElectors, sign_in_time); | ||
|
||
assertFalse(ab.equals(otherAB)); | ||
assertTrue(ab.equals(ab)); | ||
|
||
} | ||
} |