diff --git a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertion.java b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertion.java index b190f00a..c85814b9 100644 --- a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertion.java +++ b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertion.java @@ -83,7 +83,7 @@ else if(loser_index != -1 && (winner_index == -1 || loser_index < winner_index)) * {@inheritDoc} */ public String getDescription(){ - return String.format("%s NEB %s: oneOver = %d; two Over = %d; oneUnder = %d, twoUnder = %d; " + + return String.format("%s NEB %s: oneOver = %d; twoOver = %d; oneUnder = %d, twoUnder = %d; " + "other = %d; optimistic = %d; estimated = %d; risk %f.", winner, loser, oneVoteOverCount, twoVoteOverCount, oneVoteUnderCount, twoVoteUnderCount, otherCount, optimisticSamplesToAudit, estimatedSamplesToAudit, currentRisk); diff --git a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/NENAssertion.java b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/NENAssertion.java index e3298a6c..bad58ec9 100644 --- a/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/NENAssertion.java +++ b/server/eclipse-project/src/main/java/au/org/democracydevelopers/corla/model/assertion/NENAssertion.java @@ -85,7 +85,7 @@ else if (choices_left.get(0).equals(loser)) { * {@inheritDoc} */ public String getDescription(){ - return String.format("%s NEN %s assuming (%s) are continuing: oneOver = %d; two Over = %d; " + + return String.format("%s NEN %s assuming (%s) are continuing: oneOver = %d; twoOver = %d; " + "oneUnder = %d, twoUnder = %d; other = %d; optimistic = %d; estimated = %d; risk %f.", winner, loser, assumedContinuing, oneVoteOverCount, twoVoteOverCount, oneVoteUnderCount, twoVoteUnderCount, otherCount, optimisticSamplesToAudit, estimatedSamplesToAudit, currentRisk); diff --git a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/IRVComparisonAuditTests.java b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/IRVComparisonAuditTests.java index e5fef60f..c96052d0 100644 --- a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/IRVComparisonAuditTests.java +++ b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/IRVComparisonAuditTests.java @@ -467,7 +467,7 @@ public void testInitialOptimisticSampleSizeMixedAssertions(){ * Two CastVoteRecord's with a blank vote will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testComputeDiscrepancyNone1(RecordType auditedType){ + public void testComputeDiscrepancyNone1(final RecordType auditedType){ testComputeDiscrepancyNone(blank, auditedType, "Mixed Contest"); } @@ -475,7 +475,7 @@ public void testComputeDiscrepancyNone1(RecordType auditedType){ * Two CastVoteRecord's with a single vote for "A" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testComputeDiscrepancyNone2(RecordType auditedType){ + public void testComputeDiscrepancyNone2(final RecordType auditedType){ testComputeDiscrepancyNone(A, auditedType, "Mixed Contest"); } @@ -483,7 +483,7 @@ public void testComputeDiscrepancyNone2(RecordType auditedType){ * Two CastVoteRecord's with a single vote for "B" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testComputeDiscrepancyNone3(RecordType auditedType){ + public void testComputeDiscrepancyNone3(final RecordType auditedType){ testComputeDiscrepancyNone(B, auditedType, "Mixed Contest"); } @@ -491,7 +491,7 @@ public void testComputeDiscrepancyNone3(RecordType auditedType){ * Two CastVoteRecord's with a vote for "A", "B", "C", "D" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNone4(RecordType auditedType){ + public void testNENComputeDiscrepancyNone4(final RecordType auditedType){ testComputeDiscrepancyNone(ABCD, auditedType, "Mixed Contest"); } @@ -499,7 +499,7 @@ public void testNENComputeDiscrepancyNone4(RecordType auditedType){ * Two CastVoteRecord's with a vote for "B", "A", "C", "D" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNone5(RecordType auditedType){ + public void testNENComputeDiscrepancyNone5(final RecordType auditedType){ testComputeDiscrepancyNone(BACD, auditedType, "Mixed Contest"); } @@ -509,7 +509,7 @@ public void testNENComputeDiscrepancyNone5(RecordType auditedType){ */ @Test(dataProvider = "DiscrepancyTypes", dataProviderClass = AssertionTests.class, expectedExceptions = IllegalArgumentException.class) - public void testNENRecordNoDiscrepancy(int theType){ + public void testNENRecordNoDiscrepancy(final int theType){ IRVComparisonAudit ca = testComputeDiscrepancyNone(BACD, RecordType.AUDITOR_ENTERED, "Mixed Contest"); @@ -587,7 +587,7 @@ public void testRemoveNullAuditInfoCVR(){ * The maximum discrepancy is 0. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testComputeDiscrepancyCVR_A_ACVR_ABCD(RecordType auditedType){ + public void testComputeDiscrepancyCVR_A_ACVR_ABCD(final RecordType auditedType){ log(LOGGER, String.format("testComputeDiscrepancyCVR_A_ACVR_ABCD[%s]", auditedType)); resetMocks(A, ABCD, RecordType.UPLOADED, ConsensusValue.YES, auditedType, "Mixed Contest"); IRVComparisonAudit ca = createIRVComparisonAuditMixed(); @@ -630,7 +630,7 @@ public void testRecordWrongDiscrepancy(){ * risk measurement before and after the removal of the recorded discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testComputeRecordRemoveDiscrepancyCVR_ABCD_ACVR_BACD(RecordType auditedType){ + public void testComputeRecordRemoveDiscrepancyCVR_ABCD_ACVR_BACD(final RecordType auditedType){ log(LOGGER, String.format("testComputeRecordRemoveDiscrepancyCVR_ABCD_ACVR_BACD[%s]", auditedType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, auditedType, "Mixed Contest"); IRVComparisonAudit ca = createIRVComparisonAuditMixed(); @@ -689,7 +689,7 @@ private void riskMeasurementCheck(IRVComparisonAudit audit, final List cvrDiscrepancy, double dilutedMargin){ + final int oneOver, final int twoOver, final int oneUnder, final int twoUnder, final int other, + final int optimistic, final int estimated, final double risk, final Map cvrDiscrepancy, + final double dilutedMargin){ assert(a instanceof NEBAssertion); - final String expected = String.format("%s NEB %s: oneOver = %d; two Over = %d; oneUnder = %d, " + + final String expected = String.format("%s NEB %s: oneOver = %d; twoOver = %d; oneUnder = %d, " + "twoUnder = %d; other = %d; optimistic = %d; estimated = %d; risk %f.", winner, loser, oneOver, twoOver, oneUnder, twoUnder, other, optimistic, estimated, BigDecimal.valueOf(risk).setScale(Assertion.RISK_DECIMALS, RoundingMode.HALF_UP)); @@ -1188,13 +1190,14 @@ private void checkNEBAssertion(final Assertion a, final String winner, final Str * @param dilutedMargin Expected diluted margin. */ private void checkNENAssertion(final Assertion a, final String winner, final String loser, - final List continuing, int oneOver, int twoOver, int oneUnder, int twoUnder, int other, - int optimistic, int estimated, double risk, final Map cvrDiscrepancy, double dilutedMargin){ + final List continuing, final int oneOver, final int twoOver, final int oneUnder, + final int twoUnder, final int other, final int optimistic, final int estimated, final double risk, + final Map cvrDiscrepancy, final double dilutedMargin){ assert(a instanceof NENAssertion); final String expected = String.format("%s NEN %s assuming (%s) are continuing: oneOver = %d; " + - "two Over = %d; oneUnder = %d, twoUnder = %d; other = %d; optimistic = %d; estimated = %d; " + + "twoOver = %d; oneUnder = %d, twoUnder = %d; other = %d; optimistic = %d; estimated = %d; " + "risk %f.", winner, loser, continuing, oneOver, twoOver, oneUnder, twoUnder, other, optimistic, estimated, BigDecimal.valueOf(risk).setScale(Assertion.RISK_DECIMALS, RoundingMode.HALF_UP)); diff --git a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/AssertionTests.java b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/AssertionTests.java index 5c41c5b7..32d9a174 100644 --- a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/AssertionTests.java +++ b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/AssertionTests.java @@ -223,8 +223,9 @@ public void initMocks() { * @param acvrRecType Record type for the audited ballot. * @param contestName Name of the contest whose votes we are encoding. */ - protected void resetMocks(CVRContestInfo cvrInfo, CVRContestInfo acvrInfo, RecordType cvrRecType, - ConsensusValue acvrConsensus, RecordType acvrRecType, final String contestName){ + protected void resetMocks(final CVRContestInfo cvrInfo, CVRContestInfo acvrInfo, + final RecordType cvrRecType, final ConsensusValue acvrConsensus, final RecordType acvrRecType, + final String contestName){ when(cvr.contestInfoForContestResult(contestName)).thenReturn(Optional.of(cvrInfo)); when(auditedCvr.contestInfoForContestResult(contestName)).thenReturn(Optional.of(acvrInfo)); @@ -519,10 +520,11 @@ public static Object[][] parametersVaryingSamples(){ * @param twoVoteUnder Number of two vote understatements to associate with the assertion. * @param other Number of other discrepancies to associate with the assertion. */ - public static void populateAssertion(Assertion a, String winner, String loser, String contestName, - List continuing, int rawMargin, double dilutedMargin, double difficulty, - Map cvrDiscrepancy, int oneVoteOver, int oneVoteUnder, int twoVoteOver, - int twoVoteUnder, int other){ + public static void populateAssertion(Assertion a, final String winner, final String loser, + final String contestName, final List continuing, final int rawMargin, + final double dilutedMargin, final double difficulty, final Map cvrDiscrepancy, + final int oneVoteOver, final int oneVoteUnder, final int twoVoteOver, + final int twoVoteUnder, final int other){ a.winner = winner; a.loser = loser; @@ -553,8 +555,8 @@ public static void populateAssertion(Assertion a, String winner, String loser, S * @return the optimistic number of ballots to sample when auditing the assertion with * the given characteristics. */ - public static int optimistic(BigDecimal riskLimit, double dilutedMargin, int o1, int o2, - int u1, int u2, BigDecimal gamma){ + public static int optimistic(final BigDecimal riskLimit, final double dilutedMargin, final int o1, + final int o2, final int u1, final int u2, final BigDecimal gamma){ final double dgamma = gamma.doubleValue(); final double oneOnOneGamma = 1/dgamma; @@ -585,8 +587,8 @@ public static int optimistic(BigDecimal riskLimit, double dilutedMargin, int o1, * the given characteristics, under the assumption that overstatements will continue at * the current rate, */ - public static int estimated(BigDecimal riskLimit, double dilutedMargin, int o1, int o2, - int u1, int u2, BigDecimal gamma, int auditedSamples){ + public static int estimated(final BigDecimal riskLimit, final double dilutedMargin, final int o1, + final int o2, final int u1, final int u2, final BigDecimal gamma, final int auditedSamples){ final int optimistic = optimistic(riskLimit, dilutedMargin, o1, o2, u1, u2, gamma); if(auditedSamples == 0){ @@ -606,7 +608,8 @@ public static int estimated(BigDecimal riskLimit, double dilutedMargin, int o1, * @param o Number of other discrepancies. * @return True if the assertion has the specified discrepancy counts */ - public static boolean countsEqual(Assertion a, int o1, int o2, int u1, int u2, int o){ + public static boolean countsEqual(final Assertion a, final int o1, final int o2, final int u1, + final int u2, final int o){ return a.otherCount == o && a.oneVoteOverCount == o1 && a.oneVoteUnderCount == u1 && a.twoVoteOverCount == o2 && a.twoVoteUnderCount == u2; } @@ -627,9 +630,9 @@ public static boolean countsEqual(Assertion a, int o1, int o2, int u1, int u2, i * @param u2 Expected two vote understatement count after discrepancy computation. * @param o Expected "other" discrepancy count after discrepancy computation. */ - public static void checkComputeDiscrepancy(CastVoteRecord cvr, CastVoteRecord auditedCvr, - List assertions, int dType, Map cvrDiscrepancies, int o1, int o2, - int u1, int u2, int o) + public static void checkComputeDiscrepancy(final CastVoteRecord cvr, final CastVoteRecord auditedCvr, + List assertions, final int dType, final Map cvrDiscrepancies, + final int o1, final int o2, final int u1, final int u2, final int o) { for(Assertion a : assertions){ OptionalInt d = a.computeDiscrepancy(cvr, auditedCvr); @@ -651,8 +654,9 @@ public static void checkComputeDiscrepancy(CastVoteRecord cvr, CastVoteRecord au * @param other Expected number of other discrepancies. * @param cvrDiscrepancy Expected internal map of CVR ID to discrepancy type. */ - public static void checkCountsDiscrepancyMap(final Assertion a, int oneOver, int oneUnder, - int twoOver, int twoUnder, int other, final Map cvrDiscrepancy){ + public static void checkCountsDiscrepancyMap(final Assertion a, final int oneOver, + final int oneUnder, final int twoOver, final int twoUnder, final int other, + final Map cvrDiscrepancy){ assertEquals(a.oneVoteOverCount.intValue(), oneOver); assertEquals(a.oneVoteUnderCount.intValue(), oneUnder); diff --git a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertionTests.java b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertionTests.java index 724a340f..05a48fec 100644 --- a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertionTests.java +++ b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NEBAssertionTests.java @@ -28,7 +28,6 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -import au.org.democracydevelopers.corla.util.testUtils; import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -83,9 +82,10 @@ public class NEBAssertionTests extends AssertionTests { * @param other Number of other discrepancies related to the assertion. */ @Test(dataProvider = "SampleParameters", dataProviderClass = AssertionTests.class) - public void testNEBOptimistic(BigDecimal riskLimit, Integer rawMargin, BigDecimal dilutedMargin, - BigDecimal difficulty, Map cvrDiscrepancies, Integer oneVoteOver, Integer oneVoteUnder, - Integer twoVoteOver, Integer twoVoteUnder, Integer other){ + public void testNEBOptimistic(final BigDecimal riskLimit, final Integer rawMargin, + final BigDecimal dilutedMargin, final BigDecimal difficulty, final Map cvrDiscrepancies, + final Integer oneVoteOver, final Integer oneVoteUnder, final Integer twoVoteOver, + final Integer twoVoteUnder, final Integer other){ log(LOGGER, String.format("testNEBOptimistic[%f;%f;%d;%d:%d;%d;%d]", riskLimit, dilutedMargin, oneVoteOver, oneVoteUnder, twoVoteOver, twoVoteUnder, other)); @@ -118,10 +118,10 @@ public void testNEBOptimistic(BigDecimal riskLimit, Integer rawMargin, BigDecima * @param other Number of other discrepancies related to the assertion. */ @Test(dataProvider = "ParametersVaryingSamples", dataProviderClass = AssertionTests.class) - public void testNEBEstimatedVaryingSamples(Integer auditedSamples, BigDecimal riskLimit, - Integer rawMargin, BigDecimal dilutedMargin, BigDecimal difficulty, - Map cvrDiscrepancies, Integer oneVoteOver, Integer oneVoteUnder, - Integer twoVoteOver, Integer twoVoteUnder, Integer other) + public void testNEBEstimatedVaryingSamples(final Integer auditedSamples, final BigDecimal riskLimit, + final Integer rawMargin, final BigDecimal dilutedMargin, final BigDecimal difficulty, + final Map cvrDiscrepancies, final Integer oneVoteOver, final Integer oneVoteUnder, + final Integer twoVoteOver, final Integer twoVoteUnder, final Integer other) { log(LOGGER, String.format("testNEBEstimatedVaryingSamples[%d;%f;%f;%d;%d:%d;%d;%d]", auditedSamples, riskLimit, dilutedMargin, oneVoteOver, oneVoteUnder, twoVoteOver, @@ -771,7 +771,7 @@ public void testNEBScoreMinusOne3() { * Two CastVoteRecord's with a blank vote will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNone1(RecordType auditedType){ + public void testNEBComputeDiscrepancyNone1(final RecordType auditedType){ testNEBComputeDiscrepancyNone(blank, auditedType); } @@ -779,7 +779,7 @@ public void testNEBComputeDiscrepancyNone1(RecordType auditedType){ * Two CastVoteRecord's with a single vote for "A" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNone2(RecordType auditedType){ + public void testNEBComputeDiscrepancyNone2(final RecordType auditedType){ testNEBComputeDiscrepancyNone(A, auditedType); } @@ -787,7 +787,7 @@ public void testNEBComputeDiscrepancyNone2(RecordType auditedType){ * Two CastVoteRecord's with a single vote for "B" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNone3(RecordType auditedType){ + public void testNEBComputeDiscrepancyNone3(final RecordType auditedType){ testNEBComputeDiscrepancyNone(B, auditedType); } @@ -795,7 +795,7 @@ public void testNEBComputeDiscrepancyNone3(RecordType auditedType){ * Two CastVoteRecord's with a vote for "A", "B", "C", "D" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNone4(RecordType auditedType){ + public void testNEBComputeDiscrepancyNone4(final RecordType auditedType){ testNEBComputeDiscrepancyNone(ABCD, auditedType); } @@ -803,7 +803,7 @@ public void testNEBComputeDiscrepancyNone4(RecordType auditedType){ * Two CastVoteRecord's with a vote for "B", "A", "C", "D" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNone5(RecordType auditedType){ + public void testNEBComputeDiscrepancyNone5(final RecordType auditedType){ testNEBComputeDiscrepancyNone(BACD, auditedType); } @@ -813,7 +813,7 @@ public void testNEBComputeDiscrepancyNone5(RecordType auditedType){ * field in the CVR and audited ballot CastVoteRecords. * @param info A vote configuration. */ - public void testNEBComputeDiscrepancyNone(CVRContestInfo info, RecordType auditedType){ + public void testNEBComputeDiscrepancyNone(final CVRContestInfo info, final RecordType auditedType){ log(LOGGER, String.format("testNEBComputeDiscrepancyNone[%s;%s]", info.choices(), auditedType)); resetMocks(info, info, RecordType.UPLOADED, ConsensusValue.YES, auditedType, TC); @@ -858,7 +858,7 @@ public void testNEBComputeDiscrepancyNone(CVRContestInfo info, RecordType audite * vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyOneOver1(RecordType recordType){ + public void testNEBComputeDiscrepancyOneOver1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyOneOver1[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -874,7 +874,7 @@ public void testNEBComputeDiscrepancyOneOver1(RecordType recordType){ * is computed for the assertions A NEB C. (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyOneOver2(RecordType recordType){ + public void testNEBComputeDiscrepancyOneOver2(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyOneOver2[%s]", recordType)); resetMocks(A, B, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -891,7 +891,7 @@ public void testNEBComputeDiscrepancyOneOver2(RecordType recordType){ * is computed for the assertions A NEB B. (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyOneOver3(RecordType recordType){ + public void testNEBComputeDiscrepancyOneOver3(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyOneOver3[%s]", recordType)); resetMocks(A, blank, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -908,7 +908,7 @@ public void testNEBComputeDiscrepancyOneOver3(RecordType recordType){ * is computed for the assertions A NEB B. (In this case, a two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyTwoOver1(RecordType recordType){ + public void testNEBComputeDiscrepancyTwoOver1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyTwoOver1[%s]", recordType)); resetMocks(A, B, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -925,7 +925,7 @@ public void testNEBComputeDiscrepancyTwoOver1(RecordType recordType){ * two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyTwoOver2(RecordType recordType){ + public void testNEBComputeDiscrepancyTwoOver2(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyTwoOver2[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -942,7 +942,7 @@ public void testNEBComputeDiscrepancyTwoOver2(RecordType recordType){ * one vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyOneUnder1(RecordType recordType){ + public void testNEBComputeDiscrepancyOneUnder1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyOneUnder1[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -959,7 +959,7 @@ public void testNEBComputeDiscrepancyOneUnder1(RecordType recordType){ * one vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyOneUnder2(RecordType recordType){ + public void testNEBComputeDiscrepancyOneUnder2(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyOneUnder2[%s]", recordType)); resetMocks(blank, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -976,7 +976,7 @@ public void testNEBComputeDiscrepancyOneUnder2(RecordType recordType){ * discrepancy is computed for the assertion A NEB C. (In this case, a one vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyOneUnder3(RecordType recordType){ + public void testNEBComputeDiscrepancyOneUnder3(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyOneUnder3[%s]", recordType)); resetMocks(B, A, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -993,7 +993,7 @@ public void testNEBComputeDiscrepancyOneUnder3(RecordType recordType){ * discrepancy is computed for the assertion A NEB B. (In this case, a two vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyTwoUnder1(RecordType recordType){ + public void testNEBComputeDiscrepancyTwoUnder1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyTwoUnder1[%s]", recordType)); resetMocks(B, A, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1010,7 +1010,7 @@ public void testNEBComputeDiscrepancyTwoUnder1(RecordType recordType){ * vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyTwoUnder2(RecordType recordType){ + public void testNEBComputeDiscrepancyTwoUnder2(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyTwoUnder2[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1028,7 +1028,7 @@ public void testNEBComputeDiscrepancyTwoUnder2(RecordType recordType){ * "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyOther1(RecordType recordType){ + public void testNEBComputeDiscrepancyOther1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyOther1[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1045,7 +1045,7 @@ public void testNEBComputeDiscrepancyOther1(RecordType recordType){ * discrepancy is computed for the assertion C NEB D. (In this case, an "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyOther2(RecordType recordType){ + public void testNEBComputeDiscrepancyOther2(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyOther2[%s]", recordType)); resetMocks(A, B, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1061,7 +1061,7 @@ public void testNEBComputeDiscrepancyOther2(RecordType recordType){ * discrepancy is computed for the assertion C NEB D. (In this case, an "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyOther3(RecordType recordType){ + public void testNEBComputeDiscrepancyOther3(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyOther3[%s]", recordType)); resetMocks(A, blank, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1077,7 +1077,7 @@ public void testNEBComputeDiscrepancyOther3(RecordType recordType){ * discrepancy is computed for the assertion A NEB B. (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyPhantomRecordOneOver1(RecordType recordType){ + public void testNEBComputeDiscrepancyPhantomRecordOneOver1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyPhantomRecordOneOver1[%s]", recordType)); resetMocks(blank, blank, RecordType.PHANTOM_RECORD, ConsensusValue.YES, recordType, TC); @@ -1093,7 +1093,7 @@ public void testNEBComputeDiscrepancyPhantomRecordOneOver1(RecordType recordType * discrepancy is computed for the assertion F NEB G. (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyPhantomRecordOneOver2(RecordType recordType){ + public void testNEBComputeDiscrepancyPhantomRecordOneOver2(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyPhantomRecordOneOver2[%s]", recordType)); resetMocks(blank, ABCD, RecordType.PHANTOM_RECORD, ConsensusValue.YES, recordType, TC); @@ -1109,7 +1109,7 @@ public void testNEBComputeDiscrepancyPhantomRecordOneOver2(RecordType recordType * discrepancy is computed for the assertion A NEB B. (In this case, an "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyPhantomRecordOther1(RecordType recordType){ + public void testNEBComputeDiscrepancyPhantomRecordOther1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyPhantomRecordOther1[%s]", recordType)); resetMocks(blank, ABCD, RecordType.PHANTOM_RECORD, ConsensusValue.YES, recordType, TC); @@ -1125,7 +1125,7 @@ public void testNEBComputeDiscrepancyPhantomRecordOther1(RecordType recordType){ * discrepancy is computed for the assertion B NEB A. (In this case, a two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyPhantomRecordTwoOver1(RecordType recordType){ + public void testNEBComputeDiscrepancyPhantomRecordTwoOver1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyPhantomRecordTwoOver1[%s]", recordType)); resetMocks(blank, ABCD, RecordType.PHANTOM_RECORD, ConsensusValue.YES, recordType, TC); @@ -1141,7 +1141,7 @@ public void testNEBComputeDiscrepancyPhantomRecordTwoOver1(RecordType recordType * the right discrepancy is computed for any NEB assertion. (A two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyPhantomRecordNoConsensus1(RecordType recordType){ + public void testNEBComputeDiscrepancyPhantomRecordNoConsensus1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyPhantomRecordNoConsensus1[%s]", recordType)); resetMocks(blank, ABCD, RecordType.PHANTOM_RECORD, ConsensusValue.NO, recordType, TC); @@ -1161,7 +1161,7 @@ public void testNEBComputeDiscrepancyPhantomRecordNoConsensus1(RecordType record * the right discrepancy is computed for any NEB assertion. (A two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyPhantomRecordNoConsensus2(RecordType recordType){ + public void testNEBComputeDiscrepancyPhantomRecordNoConsensus2(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyPhantomRecordNoConsensus2[%s]", recordType)); resetMocks(blank, blank, RecordType.PHANTOM_RECORD, ConsensusValue.NO, recordType, TC); @@ -1275,7 +1275,7 @@ public void testNEBComputeDiscrepancyPhantomBallotNormalCVR4(){ * the right discrepancy is computed for assertions A NEB F, and A NEB C. (A two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNoConsensusNormalCVR1(RecordType recordType){ + public void testNEBComputeDiscrepancyNoConsensusNormalCVR1(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyNoConsensusNormalCVR1[%s]", recordType)); resetMocks(ABCD, ABCD, RecordType.UPLOADED, ConsensusValue.NO, recordType, TC); @@ -1293,7 +1293,7 @@ public void testNEBComputeDiscrepancyNoConsensusNormalCVR1(RecordType recordType * the right discrepancy is computed for assertions F NEB A, and D NEB A. (An "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNoConsensusNormalCVR2(RecordType recordType){ + public void testNEBComputeDiscrepancyNoConsensusNormalCVR2(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyNoConsensusNormalCVR2[%s]", recordType)); resetMocks(ABCD, ABCD, RecordType.UPLOADED, ConsensusValue.NO, recordType, TC); @@ -1311,7 +1311,7 @@ public void testNEBComputeDiscrepancyNoConsensusNormalCVR2(RecordType recordType * the right discrepancy is computed for assertions B NEB C, and B NEB D. (A one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNoConsensusNormalCVR3(RecordType recordType){ + public void testNEBComputeDiscrepancyNoConsensusNormalCVR3(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyNoConsensusNormalCVR3[%s]", recordType)); resetMocks(ABCD, blank, RecordType.UPLOADED, ConsensusValue.NO, recordType, TC); @@ -1329,7 +1329,7 @@ public void testNEBComputeDiscrepancyNoConsensusNormalCVR3(RecordType recordType * discrepancy is computed for any NEB assertion. (A one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNoConsensusNormalCVR4(RecordType recordType){ + public void testNEBComputeDiscrepancyNoConsensusNormalCVR4(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyNoConsensusNormalCVR4[%s]", recordType)); resetMocks(blank, ABCD, RecordType.UPLOADED, ConsensusValue.NO, recordType, TC); @@ -1349,7 +1349,7 @@ public void testNEBComputeDiscrepancyNoConsensusNormalCVR4(RecordType recordType * no discrepancy results for any NEB assertion. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBNoContestOnCVRAuditedBallot(RecordType recordType){ + public void testNEBNoContestOnCVRAuditedBallot(final RecordType recordType){ log(LOGGER, String.format("testNEBNoContestOnCVRAuditedBallot[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -1412,7 +1412,7 @@ public void testNEBComputeDiscrepancyCVRNoContestPhantomBallot(){ * results (for any NEB assertion). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyPhantomCVRBallotNoContest(RecordType recordType){ + public void testNEBComputeDiscrepancyPhantomCVRBallotNoContest(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyPhantomCVRBallotNoContest[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(blank)); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -1437,7 +1437,7 @@ public void testNEBComputeDiscrepancyPhantomCVRBallotNoContest(RecordType record * 1 (a one vote overstatement) results (for any NEB assertion). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyCVRNoContestBallotNoConsensus(RecordType recordType){ + public void testNEBComputeDiscrepancyCVRNoContestBallotNoConsensus(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyCVRNoContestBallotNoConsensus[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); @@ -1464,7 +1464,7 @@ public void testNEBComputeDiscrepancyCVRNoContestBallotNoConsensus(RecordType re * for all the tested assertions. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyCVRNoContestBallotScoreOfZero(RecordType recordType){ + public void testNEBComputeDiscrepancyCVRNoContestBallotScoreOfZero(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyCVRNoContestBallotScoreOfZero[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(A)); @@ -1490,7 +1490,7 @@ public void testNEBComputeDiscrepancyCVRNoContestBallotScoreOfZero(RecordType re * of the audited ballot score). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyCVRNoContestBallotScoreOfMinusOne(RecordType recordType){ + public void testNEBComputeDiscrepancyCVRNoContestBallotScoreOfMinusOne(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyCVRNoContestBallotScoreOfMinusOne[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); @@ -1516,7 +1516,7 @@ public void testNEBComputeDiscrepancyCVRNoContestBallotScoreOfMinusOne(RecordTyp * of the audited ballot score). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyCVRNoContestBallotScoreOfOne(RecordType recordType){ + public void testNEBComputeDiscrepancyCVRNoContestBallotScoreOfOne(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyCVRNoContestBallotScoreOfOne[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); @@ -1541,7 +1541,7 @@ public void testNEBComputeDiscrepancyCVRNoContestBallotScoreOfOne(RecordType rec * discrepancy) for all the tested assertions. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNormalCVRBallotNoContestZero(RecordType recordType){ + public void testNEBComputeDiscrepancyNormalCVRBallotNoContestZero(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyNormalCVRBallotNoContestZero[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(A)); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -1566,7 +1566,7 @@ public void testNEBComputeDiscrepancyNormalCVRBallotNoContestZero(RecordType rec * overstatement) for all the tested assertions. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNormalCVRBallotNoContestOne(RecordType recordType){ + public void testNEBComputeDiscrepancyNormalCVRBallotNoContestOne(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyNormalCVRBallotNoContestOne[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(A)); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -1591,7 +1591,7 @@ public void testNEBComputeDiscrepancyNormalCVRBallotNoContestOne(RecordType reco * understatement) for all the tested assertions. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNEBComputeDiscrepancyNormalCVRBallotNoContestMinusOne(RecordType recordType){ + public void testNEBComputeDiscrepancyNormalCVRBallotNoContestMinusOne(final RecordType recordType){ log(LOGGER, String.format("testNEBComputeDiscrepancyNormalCVRBallotNoContestMinusOne[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -1909,7 +1909,7 @@ public void computeOptimisticSamplesToAudit(){ * with varying diluted margins, discrepancies, and current audited sample count. */ @Test(dataProvider = "AuditSampleNumbers", dataProviderClass = AssertionTests.class) - public void computeEstimatedSamplesToAudit(int auditedSampleCount){ + public void computeEstimatedSamplesToAudit(final int auditedSampleCount){ Assertion a1 = createNEBAssertion("A", "B", TC, 100, 0.01, 100, Map.of(), 0, 0, 0, 0, 0); @@ -2009,9 +2009,10 @@ public void computeEstimatedSamplesToAudit(int auditedSampleCount){ * @param other Number of other discrepancies to associate with the assertion. * @return an NEB assertion with the given specification. */ - private static Assertion createNEBAssertion(String winner, String loser, String contestName, - int rawMargin, double dilutedMargin, double difficulty, Map cvrDiscrepancy, - int oneVoteOver, int oneVoteUnder, int twoVoteOver, int twoVoteUnder, int other){ + private static Assertion createNEBAssertion(final String winner, final String loser, + final String contestName, final int rawMargin, final double dilutedMargin, final double difficulty, + final Map cvrDiscrepancy, final int oneVoteOver, final int oneVoteUnder, + final int twoVoteOver, final int twoVoteUnder, final int other){ Assertion a = new NEBAssertion(); AssertionTests.populateAssertion(a, winner, loser, contestName, List.of(), rawMargin, diff --git a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NENAssertionTests.java b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NENAssertionTests.java index d31d066b..31dafaaa 100644 --- a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NENAssertionTests.java +++ b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/model/assertion/NENAssertionTests.java @@ -90,9 +90,10 @@ public class NENAssertionTests extends AssertionTests { * @param other Number of other discrepancies related to the assertion. */ @Test(dataProvider = "SampleParameters", dataProviderClass = AssertionTests.class) - public void testNENOptimistic(BigDecimal riskLimit, Integer rawMargin, BigDecimal dilutedMargin, - BigDecimal difficulty, Map cvrDiscrepancies, Integer oneVoteOver, - Integer oneVoteUnder, Integer twoVoteOver, Integer twoVoteUnder, Integer other) + public void testNENOptimistic(final BigDecimal riskLimit, final Integer rawMargin, + final BigDecimal dilutedMargin, final BigDecimal difficulty, final Map cvrDiscrepancies, + final Integer oneVoteOver, final Integer oneVoteUnder, final Integer twoVoteOver, + final Integer twoVoteUnder, final Integer other) { log(LOGGER, String.format("testNENOptimistic[%f;%f;%d;%d:%d;%d;%d]", riskLimit, dilutedMargin, oneVoteOver, oneVoteUnder, twoVoteOver, twoVoteUnder, other)); @@ -125,10 +126,10 @@ public void testNENOptimistic(BigDecimal riskLimit, Integer rawMargin, BigDecima * @param other Number of other discrepancies related to the assertion. */ @Test(dataProvider = "ParametersVaryingSamples", dataProviderClass = AssertionTests.class) - public void testNENEstimatedVaryingSamples(Integer auditedSamples, BigDecimal riskLimit, - Integer rawMargin, BigDecimal dilutedMargin, BigDecimal difficulty, - Map cvrDiscrepancies, Integer oneVoteOver, Integer oneVoteUnder, - Integer twoVoteOver, Integer twoVoteUnder, Integer other) + public void testNENEstimatedVaryingSamples(final Integer auditedSamples, final BigDecimal riskLimit, + final Integer rawMargin, final BigDecimal dilutedMargin, final BigDecimal difficulty, + final Map cvrDiscrepancies, final Integer oneVoteOver, final Integer oneVoteUnder, + final Integer twoVoteOver, final Integer twoVoteUnder, final Integer other) { log(LOGGER, String.format("testNENEstimatedVaryingSamples[%d;%f;%f;%d;%d:%d;%d;%d]", auditedSamples, riskLimit, dilutedMargin, oneVoteOver, oneVoteUnder, twoVoteOver, @@ -867,7 +868,7 @@ public void testNENScoreMinusOne4() { * Two CastVoteRecord's with a blank vote will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNone1(RecordType auditedType){ + public void testNENComputeDiscrepancyNone1(final RecordType auditedType){ testNENComputeDiscrepancyNone(blank, auditedType); } @@ -875,7 +876,7 @@ public void testNENComputeDiscrepancyNone1(RecordType auditedType){ * Two CastVoteRecord's with a single vote for "A" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNone2(RecordType auditedType){ + public void testNENComputeDiscrepancyNone2(final RecordType auditedType){ testNENComputeDiscrepancyNone(A, auditedType); } @@ -883,7 +884,7 @@ public void testNENComputeDiscrepancyNone2(RecordType auditedType){ * Two CastVoteRecord's with a single vote for "B" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNone3(RecordType auditedType){ + public void testNENComputeDiscrepancyNone3(final RecordType auditedType){ testNENComputeDiscrepancyNone(B, auditedType); } @@ -891,7 +892,7 @@ public void testNENComputeDiscrepancyNone3(RecordType auditedType){ * Two CastVoteRecord's with a vote for "A", "B", "C", "D" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNone4(RecordType auditedType){ + public void testNENComputeDiscrepancyNone4(final RecordType auditedType){ testNENComputeDiscrepancyNone(ABCD, auditedType); } @@ -899,7 +900,7 @@ public void testNENComputeDiscrepancyNone4(RecordType auditedType){ * Two CastVoteRecord's with a vote for "B", "A", "C", "D" will not trigger a discrepancy. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNone5(RecordType auditedType){ + public void testNENComputeDiscrepancyNone5(final RecordType auditedType){ testNENComputeDiscrepancyNone(BACD, auditedType); } @@ -909,7 +910,7 @@ public void testNENComputeDiscrepancyNone5(RecordType auditedType){ * field in the CVR and audited ballot CastVoteRecords. * @param info A vote configuration. */ - public void testNENComputeDiscrepancyNone(CVRContestInfo info, RecordType auditedType){ + public void testNENComputeDiscrepancyNone(final CVRContestInfo info, final RecordType auditedType){ log(LOGGER, String.format("testNENComputeDiscrepancyNone[%s;%s]", info.choices(), auditedType)); resetMocks(info, info, RecordType.UPLOADED, ConsensusValue.YES, auditedType, TC); @@ -951,7 +952,7 @@ public void testNENComputeDiscrepancyNone(CVRContestInfo info, RecordType audite * "C" are continuing candidates. (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOneOver1(RecordType recordType){ + public void testNENComputeDiscrepancyOneOver1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOneOver1[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -969,7 +970,7 @@ public void testNENComputeDiscrepancyOneOver1(RecordType recordType){ * (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOneOver2(RecordType recordType){ + public void testNENComputeDiscrepancyOneOver2(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOneOver2[%s]", recordType)); resetMocks(A, B, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -987,7 +988,7 @@ public void testNENComputeDiscrepancyOneOver2(RecordType recordType){ * (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOneOver3(RecordType recordType){ + public void testNENComputeDiscrepancyOneOver3(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOneOver3[%s]", recordType)); resetMocks(A, blank, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1005,7 +1006,7 @@ public void testNENComputeDiscrepancyOneOver3(RecordType recordType){ * "D" are continuing candidates. (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOneOver4(RecordType recordType){ + public void testNENComputeDiscrepancyOneOver4(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOneOver4[%s]", recordType)); resetMocks(ABCD, DABC, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1023,7 +1024,7 @@ public void testNENComputeDiscrepancyOneOver4(RecordType recordType){ * are continuing. (In this case, a two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyTwoOver1(RecordType recordType){ + public void testNENComputeDiscrepancyTwoOver1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyTwoOver1[%s]", recordType)); resetMocks(A, B, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1044,7 +1045,7 @@ public void testNENComputeDiscrepancyTwoOver1(RecordType recordType){ * and "D" are continuing. (In this case, a two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyTwoOver2(RecordType recordType){ + public void testNENComputeDiscrepancyTwoOver2(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyTwoOver2[%s]", recordType)); resetMocks(ABCD, DABC, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1063,7 +1064,7 @@ public void testNENComputeDiscrepancyTwoOver2(RecordType recordType){ * (In this case, a two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyTwoOver3(RecordType recordType){ + public void testNENComputeDiscrepancyTwoOver3(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyTwoOver2[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1084,7 +1085,7 @@ public void testNENComputeDiscrepancyTwoOver3(RecordType recordType){ * and "D" are continuing. (In this case, a one vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOneUnder1(RecordType recordType){ + public void testNENComputeDiscrepancyOneUnder1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOneUnder1[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1102,7 +1103,7 @@ public void testNENComputeDiscrepancyOneUnder1(RecordType recordType){ * are continuing. (In this case, a one vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOneUnder2(RecordType recordType){ + public void testNENComputeDiscrepancyOneUnder2(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOneUnder2[%s]", recordType)); resetMocks(blank, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1120,7 +1121,7 @@ public void testNENComputeDiscrepancyOneUnder2(RecordType recordType){ * (In this case, a one vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOneUnder3(RecordType recordType){ + public void testNENComputeDiscrepancyOneUnder3(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOneUnder3[%s]", recordType)); resetMocks(B, A, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1138,7 +1139,7 @@ public void testNENComputeDiscrepancyOneUnder3(RecordType recordType){ * (In this case, a one vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOneUnder4(RecordType recordType){ + public void testNENComputeDiscrepancyOneUnder4(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOneUnder4[%s]", recordType)); resetMocks(B, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1156,7 +1157,7 @@ public void testNENComputeDiscrepancyOneUnder4(RecordType recordType){ * (In this case, a two vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyTwoUnder1(RecordType recordType){ + public void testNENComputeDiscrepancyTwoUnder1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyTwoUnder1[%s]", recordType)); resetMocks(B, A, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1175,7 +1176,7 @@ public void testNENComputeDiscrepancyTwoUnder1(RecordType recordType){ * (In this case, a two vote understatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyTwoUnder2(RecordType recordType){ + public void testNENComputeDiscrepancyTwoUnder2(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyTwoUnder2[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1197,7 +1198,7 @@ public void testNENComputeDiscrepancyTwoUnder2(RecordType recordType){ * (In this case, an "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOther1(RecordType recordType){ + public void testNENComputeDiscrepancyOther1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOther1[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1218,7 +1219,7 @@ public void testNENComputeDiscrepancyOther1(RecordType recordType){ * (In this case, an "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOther2(RecordType recordType){ + public void testNENComputeDiscrepancyOther2(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOther2[%s]", recordType)); resetMocks(A, B, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1236,7 +1237,7 @@ public void testNENComputeDiscrepancyOther2(RecordType recordType){ * continuing. (In this case, an "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOther3(RecordType recordType){ + public void testNENComputeDiscrepancyOther3(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOther3[%s]", recordType)); resetMocks(A, blank, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1254,7 +1255,7 @@ public void testNENComputeDiscrepancyOther3(RecordType recordType){ * continuing. (In this case, an "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOther4(RecordType recordType){ + public void testNENComputeDiscrepancyOther4(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOther4[%s]", recordType)); resetMocks(A, BACD, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1273,7 +1274,7 @@ public void testNENComputeDiscrepancyOther4(RecordType recordType){ * (In this case, an "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyOther5(RecordType recordType){ + public void testNENComputeDiscrepancyOther5(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyOther5[%s]", recordType)); resetMocks(blank, BA, RecordType.UPLOADED, ConsensusValue.YES, recordType, TC); @@ -1294,7 +1295,7 @@ public void testNENComputeDiscrepancyOther5(RecordType recordType){ * C NEN A given A, B, C, and D are continuing. (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyPhantomRecordOneOver1(RecordType recordType){ + public void testNENComputeDiscrepancyPhantomRecordOneOver1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyPhantomRecordOneOver1[%s]", recordType)); resetMocks(blank, blank, RecordType.PHANTOM_RECORD, ConsensusValue.YES, recordType, TC); @@ -1316,7 +1317,7 @@ public void testNENComputeDiscrepancyPhantomRecordOneOver1(RecordType recordType * (In this case, a one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyPhantomRecordOneOver2(RecordType recordType){ + public void testNENComputeDiscrepancyPhantomRecordOneOver2(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyPhantomRecordOneOver2[%s]", recordType)); resetMocks(blank, ABCD, RecordType.PHANTOM_RECORD, ConsensusValue.YES, recordType, TC); @@ -1339,7 +1340,7 @@ public void testNENComputeDiscrepancyPhantomRecordOneOver2(RecordType recordType * continuing. (In this case, an "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyPhantomRecordOther1(RecordType recordType){ + public void testNENComputeDiscrepancyPhantomRecordOther1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyPhantomRecordOther1[%s]", recordType)); resetMocks(blank, ABCD, RecordType.PHANTOM_RECORD, ConsensusValue.YES, recordType, TC); @@ -1363,7 +1364,7 @@ public void testNENComputeDiscrepancyPhantomRecordOther1(RecordType recordType){ * and D NEN C assuming only "C" and "D" are continuing. (In this case, a two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyPhantomRecordTwoOver1(RecordType recordType){ + public void testNENComputeDiscrepancyPhantomRecordTwoOver1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyPhantomRecordTwoOver1[%s]", recordType)); resetMocks(blank, ABCD, RecordType.PHANTOM_RECORD, ConsensusValue.YES, recordType, TC); @@ -1383,7 +1384,7 @@ public void testNENComputeDiscrepancyPhantomRecordTwoOver1(RecordType recordType * the right discrepancy is computed for any NEN assertion. (A two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyPhantomRecordNoConsensus1(RecordType recordType){ + public void testNENComputeDiscrepancyPhantomRecordNoConsensus1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyPhantomRecordNoConsensus1[%s]", recordType)); resetMocks(blank, ABCD, RecordType.PHANTOM_RECORD, ConsensusValue.NO, recordType, TC); @@ -1397,7 +1398,7 @@ public void testNENComputeDiscrepancyPhantomRecordNoConsensus1(RecordType record * the right discrepancy is computed for any NEN assertion. (A two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyPhantomRecordNoConsensus2(RecordType recordType){ + public void testNENComputeDiscrepancyPhantomRecordNoConsensus2(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyPhantomRecordNoConsensus2[%s]", recordType)); resetMocks(blank, blank, RecordType.PHANTOM_RECORD, ConsensusValue.NO, recordType, TC); @@ -1513,7 +1514,7 @@ public void testNENComputeDiscrepancyPhantomBallotNormalCVR4(){ * continuing. (A two vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNoConsensusNormalCVR1(RecordType recordType){ + public void testNENComputeDiscrepancyNoConsensusNormalCVR1(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyNoConsensusNormalCVR1[%s]", recordType)); resetMocks(ABCD, BACD, RecordType.UPLOADED, ConsensusValue.NO, recordType, TC); @@ -1536,7 +1537,7 @@ public void testNENComputeDiscrepancyNoConsensusNormalCVR1(RecordType recordType * is computed for assertion F NEN A given "A" and "F" are continuing. (An "other" discrepancy). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNoConsensusNormalCVR2(RecordType recordType){ + public void testNENComputeDiscrepancyNoConsensusNormalCVR2(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyNoConsensusNormalCVR2[%s]", recordType)); resetMocks(ABCD, A, RecordType.UPLOADED, ConsensusValue.NO, recordType, TC); @@ -1554,7 +1555,7 @@ public void testNENComputeDiscrepancyNoConsensusNormalCVR2(RecordType recordType * continuing, and C NEN D given "B", "C", and "D" are continuing. (A one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNoConsensusNormalCVR3(RecordType recordType){ + public void testNENComputeDiscrepancyNoConsensusNormalCVR3(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyNoConsensusNormalCVR3[%s]", recordType)); resetMocks(ABCD, blank, RecordType.UPLOADED, ConsensusValue.NO, recordType, TC); @@ -1574,7 +1575,7 @@ public void testNENComputeDiscrepancyNoConsensusNormalCVR3(RecordType recordType * discrepancy is computed for any NEN assertion. (A one vote overstatement). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNoConsensusNormalCVR4(RecordType recordType){ + public void testNENComputeDiscrepancyNoConsensusNormalCVR4(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyNoConsensusNormalCVR4[%s]", recordType)); resetMocks(blank, ABCD, RecordType.UPLOADED, ConsensusValue.NO, recordType, TC); @@ -1588,7 +1589,7 @@ public void testNENComputeDiscrepancyNoConsensusNormalCVR4(RecordType recordType * no discrepancy results for any NEN assertion. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENNoContestOnCVRAuditedBallot(RecordType recordType){ + public void testNENNoContestOnCVRAuditedBallot(final RecordType recordType){ log(LOGGER, String.format("testNENNoContestOnCVRAuditedBallot[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -1637,7 +1638,7 @@ public void testNENComputeDiscrepancyCVRNoContestPhantomBallot(){ * results (for any NEN assertion). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyPhantomCVRBallotNoContest(RecordType recordType){ + public void testNENComputeDiscrepancyPhantomCVRBallotNoContest(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyPhantomCVRBallotNoContest[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(blank)); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -1661,7 +1662,7 @@ public void testNENComputeDiscrepancyPhantomCVRBallotNoContest(RecordType record * 1 (a one vote overstatement) results (for any NEN assertion). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyCVRNoContestBallotNoConsensus(RecordType recordType){ + public void testNENComputeDiscrepancyCVRNoContestBallotNoConsensus(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyCVRNoContestBallotNoConsensus[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); @@ -1687,7 +1688,7 @@ public void testNENComputeDiscrepancyCVRNoContestBallotNoConsensus(RecordType re * for all the tested assertions. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyCVRNoContestBallotScoreOfZero(RecordType recordType){ + public void testNENComputeDiscrepancyCVRNoContestBallotScoreOfZero(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyCVRNoContestBallotScoreOfZero[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); @@ -1718,7 +1719,7 @@ public void testNENComputeDiscrepancyCVRNoContestBallotScoreOfZero(RecordType re * of the audited ballot score). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyCVRNoContestBallotScoreOfMinusOne(RecordType recordType){ + public void testNENComputeDiscrepancyCVRNoContestBallotScoreOfMinusOne(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyCVRNoContestBallotScoreOfMinusOne[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); @@ -1749,7 +1750,7 @@ public void testNENComputeDiscrepancyCVRNoContestBallotScoreOfMinusOne(RecordTyp * of the audited ballot score). */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyCVRNoContestBallotScoreOfOne(RecordType recordType){ + public void testNENComputeDiscrepancyCVRNoContestBallotScoreOfOne(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyCVRNoContestBallotScoreOfOne[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); @@ -1779,7 +1780,7 @@ public void testNENComputeDiscrepancyCVRNoContestBallotScoreOfOne(RecordType rec * discrepancy) for all the tested assertions. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNormalCVRBallotNoContestZero(RecordType recordType){ + public void testNENComputeDiscrepancyNormalCVRBallotNoContestZero(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyNormalCVRBallotNoContestZero[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(A)); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -1809,7 +1810,7 @@ public void testNENComputeDiscrepancyNormalCVRBallotNoContestZero(RecordType rec * overstatement) for all the tested assertions. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNormalCVRBallotNoContestOne(RecordType recordType){ + public void testNENComputeDiscrepancyNormalCVRBallotNoContestOne(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyNormalCVRBallotNoContestOne[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -1839,7 +1840,7 @@ public void testNENComputeDiscrepancyNormalCVRBallotNoContestOne(RecordType reco * understatement) for all the tested assertions. */ @Test(dataProvider = "AuditedRecordTypes", dataProviderClass = AssertionTests.class) - public void testNENComputeDiscrepancyNormalCVRBallotNoContestMinusOne(RecordType recordType){ + public void testNENComputeDiscrepancyNormalCVRBallotNoContestMinusOne(final RecordType recordType){ log(LOGGER, String.format("testNENComputeDiscrepancyNormalCVRBallotNoContestMinusOne[%s]", recordType)); when(cvr.contestInfoForContestResult(TC)).thenReturn(Optional.of(ABCD)); when(auditedCvr.contestInfoForContestResult(TC)).thenReturn(Optional.empty()); @@ -2165,7 +2166,7 @@ public void computeOptimisticSamplesToAudit(){ * with varying diluted margins, discrepancies, and current audited sample count. */ @Test(dataProvider = "AuditSampleNumbers", dataProviderClass = AssertionTests.class) - public void computeEstimatedSamplesToAudit(int auditedSampleCount){ + public void computeEstimatedSamplesToAudit(final int auditedSampleCount){ log(LOGGER, String.format("computeEstimatedSamplesToAudit[%d]",auditedSampleCount)); Assertion a1 = createNENAssertion("A", "B", TC, List.of("A","B"),100, 0.01, 100, Map.of(), 0, 0, 0, @@ -2269,10 +2270,11 @@ public void computeEstimatedSamplesToAudit(int auditedSampleCount){ * @param other Number of other discrepancies to associate with the assertion. * @return an NEN assertion with the given specification. */ - private static Assertion createNENAssertion(String winner, String loser, String contestName, - List continuing, int rawMargin, double dilutedMargin, double difficulty, - Map cvrDiscrepancy, int oneVoteOver, int oneVoteUnder, int twoVoteOver, - int twoVoteUnder, int other){ + private static Assertion createNENAssertion(final String winner, final String loser, + final String contestName, final List continuing, final int rawMargin, + final double dilutedMargin, final double difficulty, + final Map cvrDiscrepancy, final int oneVoteOver, final int oneVoteUnder, + final int twoVoteOver, final int twoVoteUnder, final int other){ Assertion a = new NENAssertion(); AssertionTests.populateAssertion(a, winner, loser, contestName, continuing, rawMargin, diff --git a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/query/AssertionQueriesTests.java b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/query/AssertionQueriesTests.java new file mode 100644 index 00000000..f16c06d3 --- /dev/null +++ b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/query/AssertionQueriesTests.java @@ -0,0 +1,293 @@ +/* +Democracy Developers IRV extensions to colorado-rla. + +@copyright 2024 Colorado Department of State + +These IRV extensions are designed to connect to a running instance of the raire +service (https://github.com/DemocracyDevelopers/raire-service), in order to +generate assertions that can be audited using colorado-rla. + +The colorado-rla IRV extensions are free software: you can redistribute it and/or modify it under the terms +of the GNU Affero General Public License as published by the Free Software Foundation, either +version 3 of the License, or (at your option) any later version. + +The colorado-rla IRV extensions are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License along with +raire-service. If not, see . +*/ + +package au.org.democracydevelopers.corla.query; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import au.org.democracydevelopers.corla.model.assertion.Assertion; +import au.org.democracydevelopers.corla.model.assertion.NEBAssertion; +import au.org.democracydevelopers.corla.model.assertion.NENAssertion; +import au.org.democracydevelopers.corla.util.TestClassWithDatabase; +import au.org.democracydevelopers.corla.util.testUtils; +import java.util.List; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.ext.ScriptUtils; +import org.testcontainers.jdbc.JdbcDatabaseDelegate; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import us.freeandfair.corla.persistence.Persistence; + +/** + * This test class tests the functionality in the DemocracyDevelopers version of AssertionQueries. + * At the time of writing these tests, this class contains one method for collecting all assertions + * that belong to a specific contest, identified by contest name. + */ +public class AssertionQueriesTests extends TestClassWithDatabase { + + private static final Logger LOGGER = LogManager.getLogger(AssertionQueriesTests.class); + + /** + * Container for the mock-up database. + */ + protected static PostgreSQLContainer postgres = createTestContainer(); + + /** + * Start the test container and establish persistence properties before the first test. + */ + @BeforeClass + public static void beforeAll() { + postgres.start(); + Persistence.setProperties(createHibernateProperties(postgres)); + + var containerDelegate = new JdbcDatabaseDelegate(postgres, ""); + ScriptUtils.runInitScript(containerDelegate, "SQL/co-counties.sql"); + ScriptUtils.runInitScript(containerDelegate, "SQL/simple-assertions.sql"); + } + + /** + * After all test have run, stop the test container. + */ + @AfterClass + public static void afterAll() { + postgres.stop(); + } + + /** + * Check that an empty list is returned for a non-existent contest. + */ + @Test + public void testNonExistentContest(){ + testUtils.log(LOGGER, "testNonExistentContest"); + final List assertions = AssertionQueries.matching("Contest Number 9"); + + assertTrue(assertions.isEmpty()); + } + + /** + * Check that an empty list is returned for a existent contest with no assertions. + */ + @Test + public void testExistentContestNoAssertions(){ + testUtils.log(LOGGER, "testExistentContestNoAssertions"); + final List assertions = AssertionQueries.matching("No Assertions"); + + assertTrue(assertions.isEmpty()); + } + + /** + * Check that the correct assertions are returned for a contest with one NEB assertion. + */ + @Test + public void testOneNEBContest(){ + testUtils.log(LOGGER, "testOneNEBContest"); + final List assertions = AssertionQueries.matching("One NEB Assertion Contest"); + + assertEquals(assertions.size(), 1); + + final Assertion a = assertions.get(0); + + assertTrue(a instanceof NEBAssertion); + assertTrue(a.getDescription().startsWith( + "Alice NEB Bob: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + } + + /** + * Check that the correct assertions are returned for a contest with one NEN assertion. + */ + @Test + public void testOneNENContest(){ + testUtils.log(LOGGER, "testOneNENContest"); + final List assertions = AssertionQueries.matching("One NEN Assertion Contest"); + + assertEquals(assertions.size(), 1); + + final Assertion a = assertions.get(0); + + assertTrue(a instanceof NENAssertion); + assertTrue(a.getDescription().startsWith( + "Alice NEN Charlie assuming ([Alice, Charlie, Diego, Bob]) are continuing: oneOver = 0; " + + "twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + } + + /** + * Check that the correct assertions are returned for a contest with one NEN and one NEB assertion. + */ + @Test + public void testOneNENNEBContest(){ + testUtils.log(LOGGER, "testOneNENNEBContest"); + final List assertions = AssertionQueries.matching("One NEN NEB Assertion Contest"); + + assertEquals(assertions.size(), 2); + + final Assertion a1 = assertions.get(0); + assertTrue(a1 instanceof NEBAssertion); + assertTrue(a1.getDescription().startsWith( + "Amanda NEB Liesl: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a2 = assertions.get(1); + assertTrue(a2 instanceof NENAssertion); + assertTrue(a2.getDescription().startsWith( + "Amanda NEN Wendell assuming ([Liesl, Wendell, Amanda]) are continuing: oneOver = 0; " + + "twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + } + + /** + * Check that the correct assertions are returned for a multi-county contest. + */ + @Test + public void testMultiCountyContest(){ + testUtils.log(LOGGER, "testMultiCountyContest"); + final List assertions = AssertionQueries.matching("Multi-County Contest 1"); + + assertEquals(assertions.size(), 3); + + final Assertion a1 = assertions.get(0); + assertTrue(a1 instanceof NEBAssertion); + assertTrue(a1.getDescription().startsWith( + "Charlie C. Chaplin NEB Alice P. Mangrove: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a2 = assertions.get(1); + assertTrue(a2 instanceof NEBAssertion); + assertTrue(a2.getDescription().startsWith( + "Alice P. Mangrove NEB Al (Bob) Jones: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a3 = assertions.get(2); + assertTrue(a3 instanceof NENAssertion); + assertTrue(a3.getDescription().startsWith( + "Alice P. Mangrove NEN West W. Westerson assuming ([West W. Westerson, Alice P. Mangrove]) are " + + "continuing: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + } + + /** + * Check that the correct assertions are returned for a mixed assertion contest where some of + * the assertions have discrepancies. + */ + @Test + public void testMixedAssertionsWithDiscrepancies1(){ + testUtils.log(LOGGER, "testMixedAssertionsWithDiscrepancies1"); + final List assertions = AssertionQueries.matching("Test Estimation Mixed Assertions"); + + assertEquals(assertions.size(), 8); + + final Assertion a1 = assertions.get(0); + assertTrue(a1 instanceof NEBAssertion); + assertTrue(a1.getDescription().startsWith( + "A NEB B: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a2 = assertions.get(1); + assertTrue(a2 instanceof NEBAssertion); + assertTrue(a2.getDescription().startsWith( + "B NEB C: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a3 = assertions.get(2); + assertTrue(a3 instanceof NEBAssertion); + assertTrue(a3.getDescription().startsWith( + "F NEB G: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 1; other = 0" + )); + + final Assertion a4 = assertions.get(3); + assertTrue(a4 instanceof NEBAssertion); + assertTrue(a4.getDescription().startsWith( + "H NEB I: oneOver = 1; twoOver = 1; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a5 = assertions.get(4); + assertTrue(a5 instanceof NENAssertion); + assertTrue(a5.getDescription().startsWith( + "A NEN B assuming ([A, B]) are continuing: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a6 = assertions.get(5); + assertTrue(a6 instanceof NENAssertion); + assertTrue(a6.getDescription().startsWith( + "B NEN C assuming ([B, C]) are continuing: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a7 = assertions.get(6); + assertTrue(a7 instanceof NENAssertion); + assertTrue(a7.getDescription().startsWith( + "F NEN G assuming ([F, G]) are continuing: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 1; other = 0" + )); + + final Assertion a8 = assertions.get(7); + assertTrue(a8 instanceof NENAssertion); + assertTrue(a8.getDescription().startsWith( + "H NEN I assuming ([H, I]) are continuing: oneOver = 1; twoOver = 1; oneUnder = 0, twoUnder = 0; other = 0" + )); + } + + /** + * Check that the correct assertions are returned for a mixed assertion contest where all of + * the assertions have discrepancies, with more than one of the same type.. + */ + @Test + public void testMixedAssertionsWithDiscrepancies2(){ + testUtils.log(LOGGER, "testMixedAssertionsWithDiscrepancies2"); + final List assertions = AssertionQueries.matching("Mixed Assertions With Discrepancies"); + + assertEquals(assertions.size(), 5); + + final Assertion a1 = assertions.get(0); + assertTrue(a1 instanceof NEBAssertion); + assertTrue(a1.getDescription().startsWith( + "B NEB C: oneOver = 0; twoOver = 0; oneUnder = 0, twoUnder = 2; other = 0" + )); + + final Assertion a2 = assertions.get(1); + assertTrue(a2 instanceof NEBAssertion); + assertTrue(a2.getDescription().startsWith( + "F NEB G: oneOver = 0; twoOver = 0; oneUnder = 2, twoUnder = 0; other = 1" + )); + + final Assertion a3 = assertions.get(2); + assertTrue(a3 instanceof NEBAssertion); + assertTrue(a3.getDescription().startsWith( + "H NEB I: oneOver = 0; twoOver = 2; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a4 = assertions.get(3); + assertTrue(a4 instanceof NENAssertion); + assertTrue(a4.getDescription().startsWith( + "A NEN B assuming ([A, B]) are continuing: oneOver = 2; twoOver = 0; oneUnder = 0, twoUnder = 0; other = 0" + )); + + final Assertion a5 = assertions.get(4); + assertTrue(a5 instanceof NENAssertion); + assertTrue(a5.getDescription().startsWith( + "F NEN G assuming ([F, G]) are continuing: oneOver = 0; twoOver = 0; oneUnder = 1, twoUnder = 0; other = 2" + )); + } + +} diff --git a/server/eclipse-project/src/test/resources/SQL/simple-assertions.sql b/server/eclipse-project/src/test/resources/SQL/simple-assertions.sql index 35a44437..de8fab30 100644 --- a/server/eclipse-project/src/test/resources/SQL/simple-assertions.sql +++ b/server/eclipse-project/src/test/resources/SQL/simple-assertions.sql @@ -125,4 +125,33 @@ INSERT INTO contest (county_id, id, version, description, name, sequence_number, INSERT INTO assertion (assertion_type, contest_name, difficulty, diluted_margin, loser, margin, current_risk, estimated_samples_to_audit, one_vote_over_count, one_vote_under_count, optimistic_samples_to_audit, other_count, two_vote_over_count, two_vote_under_count, version, winner) values ('NEN', 'Simple Contest 4', 200, 0.07, 'B', 200, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'F'); INSERT INTO assertion_assumed_continuing values (32, 'A'); INSERT INTO assertion_assumed_continuing values (32, 'B'); -INSERT INTO assertion_assumed_continuing values (32, 'F'); \ No newline at end of file +INSERT INTO assertion_assumed_continuing values (32, 'F'); + +INSERT INTO contest (county_id, id, version, description, name, sequence_number, votes_allowed, winners_allowed) VALUES (4,13,0,'IRV','Mixed Assertions With Discrepancies',13,4,1); +INSERT INTO assertion (assertion_type, contest_name, difficulty, diluted_margin, loser, margin, current_risk, estimated_samples_to_audit, one_vote_over_count, one_vote_under_count, optimistic_samples_to_audit, other_count, two_vote_over_count, two_vote_under_count, version, winner) values ('NEB', 'Mixed Assertions With Discrepancies', 159, 0.0159, 'C', 159, 1, 0, 0, 0, 0, 0, 0, 2, 0, 'B'); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (33, -2, 1); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (33, -2, 2); + +INSERT INTO assertion (assertion_type, contest_name, difficulty, diluted_margin, loser, margin, current_risk, estimated_samples_to_audit, one_vote_over_count, one_vote_under_count, optimistic_samples_to_audit, other_count, two_vote_over_count, two_vote_under_count, version, winner) values ('NEB', 'Mixed Assertions With Discrepancies', 50, 0.12345, 'G', 1235, 1, 0, 0, 2, 0, 1, 0, 0, 0, 'F'); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (34, 0, 1); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (34, -1, 2); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (34, -1, 3); + +INSERT INTO assertion (assertion_type, contest_name, difficulty, diluted_margin, loser, margin, current_risk, estimated_samples_to_audit, one_vote_over_count, one_vote_under_count, optimistic_samples_to_audit, other_count, two_vote_over_count, two_vote_under_count, version, winner) values ('NEB', 'Mixed Assertions With Discrepancies', 17, 0.33247528, 'I', 3325, 1, 0, 0, 0, 0, 0, 2, 0, 0, 'H'); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (35, 2, 1); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (35, 2, 2); + +INSERT INTO assertion (assertion_type, contest_name, difficulty, diluted_margin, loser, margin, current_risk, estimated_samples_to_audit, one_vote_over_count, one_vote_under_count, optimistic_samples_to_audit, other_count, two_vote_over_count, two_vote_under_count, version, winner) values ('NEN', 'Mixed Assertions With Discrepancies', 100, 0.01, 'B', 100, 1, 0, 2, 0, 0, 0, 0, 0, 0, 'A'); +INSERT INTO assertion_assumed_continuing values (36, 'A'); +INSERT INTO assertion_assumed_continuing values (36, 'B'); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (36, 1, 1); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (36, 1, 2); + +INSERT INTO assertion (assertion_type, contest_name, difficulty, diluted_margin, loser, margin, current_risk, estimated_samples_to_audit, one_vote_over_count, one_vote_under_count, optimistic_samples_to_audit, other_count, two_vote_over_count, two_vote_under_count, version, winner) values ('NEN', 'Mixed Assertions With Discrepancies', 50, 0.12345, 'G', 1235, 1, 0, 0, 1, 0, 2, 0, 0, 0, 'F'); +INSERT INTO assertion_assumed_continuing values (37, 'F'); +INSERT INTO assertion_assumed_continuing values (37, 'G'); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (37, -1, 1); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (37, 0, 2); +INSERT INTO assertion_discrepancies (id, discrepancy, cvr_id) values (37, 0, 3); + +INSERT INTO contest (county_id, id, version, description, name, sequence_number, votes_allowed, winners_allowed) VALUES (4,14,0,'IRV','No Assertions',14,4,1);