From 15cc605f680ee3f461d7aebc725a73fc12b3bf69 Mon Sep 17 00:00:00 2001 From: vteague Date: Sat, 10 Aug 2024 09:01:53 +1000 Subject: [PATCH] Improvements from @michelleblom's review. --- .../controller/ComparisonAuditController.java | 2 +- .../corla/endpoint/ACVRUploadTests.java | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/server/eclipse-project/src/main/java/us/freeandfair/corla/controller/ComparisonAuditController.java b/server/eclipse-project/src/main/java/us/freeandfair/corla/controller/ComparisonAuditController.java index ace90c2c..ef5b2f89 100644 --- a/server/eclipse-project/src/main/java/us/freeandfair/corla/controller/ComparisonAuditController.java +++ b/server/eclipse-project/src/main/java/us/freeandfair/corla/controller/ComparisonAuditController.java @@ -233,7 +233,7 @@ public static boolean reaudit(final CountyDashboard cdb, LOGGER.info("[reaudit] cvr: " + cvr.toString()); - // VT: If this cvr has not been audited before, I believe cai will be null. + // DemocracyDevelopers: If this cvr has not been audited before, cai will be null. final CVRAuditInfo cai = Persistence.getByID(cvr.id(), CVRAuditInfo.class); if (cai == null || cai.acvr() == null) { LOGGER.error("can't reaudit a cvr that hasn't been audited"); diff --git a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/endpoint/ACVRUploadTests.java b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/endpoint/ACVRUploadTests.java index b9eacb82..8abc6c55 100644 --- a/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/endpoint/ACVRUploadTests.java +++ b/server/eclipse-project/src/test/java/au/org/democracydevelopers/corla/endpoint/ACVRUploadTests.java @@ -407,11 +407,11 @@ public void initMocks() { * 5. a vote with invalid choices (names not in the list of choices for the contest), * 6. a vote that doesn't properly correspond to the IDs it should have, * 7. an unparseable vote (typos in json data), - * 8. a reaudit (which checks that the superseded upload is market REAUDITED), and - * 9. a second reaudit with the same data (which checks that the previous reaudit is also now marked REAUDITED and that - * there are now two revisions). - * We check that it is accepted and that the right records for CVR and CVRContestInfo are - * stored in the database. + * 8. a reaudit (which checks that the superseded upload is marked REAUDITED), and + * 9. a second reaudit with the same data (which checks that the previous reaudit is also now + * marked REAUDITED and that there are now two revisions). + * We check that it is accepted (or rejected if it should be) and that the right records for CVR + * and CVRContestInfo are stored in the database. */ @Test @Transactional @@ -470,16 +470,18 @@ void testACVRUploadAndStorage() { // cause an error. testErrorResponseAndNoMatchingCvr(240515L, IRVJsonDeserializationFail, malformedACVRMsg); - // Eighth test: upload a reaudit ballot. + // Eighth test: upload a reaudited ballot. // Check that the new data successfully replaces the prior upload. testSuccessResponse(240509L, "1-1-1", validIRVReauditAsJson, List.of("Alice","Chuan"), 3); - // Test that the previous upload, with a vote for Bob and Chuan (validIRVAsJson) is now tagged as REAUDITED. + // Test that the previous upload, with a vote for Bob and Chuan (validIRVAsJson) is now tagged + // as REAUDITED. testPreviousAreReaudited(240509L, "1-1-1", List.of("Bob","Chuan"), 1, 1); - // Ninth test: re-upload the same reaudit ballot, again. + // Ninth test: upload the same ballot being reaudited, again. // Check that the new data is identical (it replaces it, but it's the same). testSuccessResponse(240509L, "1-1-1", validIRVReauditAsJson, List.of("Alice","Chuan"), 3); - // Test that the previous upload (from test 8), with a vote for Alice and Chuan (validIRVReauditAsJson) is now tagged as REAUDITED. + // Test that the previous upload (from test 8), with a vote for Alice and Chuan + // (validIRVReauditAsJson) is now tagged as REAUDITED. // There should be two reaudited ballots now, and the max revision should be 2. testPreviousAreReaudited(240509L, "1-1-1", List.of("Alice","Chuan"), 2, 2); @@ -567,11 +569,12 @@ private void testPreviousAreReaudited(final long CvrId, final String expectedImp // Find the maximum revision; check that it matches the expected maximum revision (this should match the number of // reaudits). assertFalse(acvrs.isEmpty()); - OptionalLong maxRevision = acvrs.stream().mapToLong(CastVoteRecord::getRevision).max(); + final OptionalLong maxRevision = acvrs.stream().mapToLong(CastVoteRecord::getRevision).max(); assertEquals(maxRevision, OptionalLong.of(expectedMaxRevision)); // Check that there is one record with the expected revision and it has the expected vote choices. - List maxRevisionAcvrs = acvrs.stream().filter(a -> a.getRevision() == expectedMaxRevision).toList(); + final List maxRevisionAcvrs + = acvrs.stream().filter(a -> a.getRevision() == expectedMaxRevision).toList(); assertEquals(maxRevisionAcvrs.size(), 1); assertTrue(maxRevisionAcvrs.get(0).contestInfoForContestResult(tinyIRV).isPresent()); final List choices = maxRevisionAcvrs.get(0).contestInfoForContestResult(tinyIRV).get().choices();