This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See https://gitlab.nuiton.org/chorem/pollen.git commit 80d8262759f5306cf65a88dd62ee1b3b689d5876 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Mon Sep 25 17:18:43 2017 +0200 Corretion de la methode pour les votes alternatifs --- .../InstantRunoffVoteCountingStrategy.java | 6 ++--- .../InstantRunoffVoteCountingStrategyTest.java | 29 ++++++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategy.java b/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategy.java index ed08962a..5bb19870 100644 --- a/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategy.java +++ b/pollen-votecounting-instant-runoff/src/main/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategy.java @@ -164,7 +164,8 @@ public class InstantRunoffVoteCountingStrategy extends AbstractVoteCountingStrat // on remet à zero les scores pour les ids a conserver for (String id : idsToInclude) { - resultByChoice.get(id).setScoreValue(null); + resultByChoice.get(id).setScoreValue(BigDecimal.ZERO); + addRoundChoice(round, id, 0); } // on calcule les scores à partir des classements @@ -196,9 +197,6 @@ public class InstantRunoffVoteCountingStrategy extends AbstractVoteCountingStrat results.sort(Comparator.comparing(ChoiceScore::getScoreValue, Comparator.nullsFirst(Comparator.naturalOrder()))); - // on supprime tout score à 0 - results.removeIf(choiceScore -> choiceScore.getScoreValue() == null - || ZERO_D.equals(choiceScore.getScoreValue())); return results; } diff --git a/pollen-votecounting-instant-runoff/src/test/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategyTest.java b/pollen-votecounting-instant-runoff/src/test/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategyTest.java index f3ae2fed..8f3580d2 100644 --- a/pollen-votecounting-instant-runoff/src/test/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategyTest.java +++ b/pollen-votecounting-instant-runoff/src/test/java/org/chorem/pollen/votecounting/InstantRunoffVoteCountingStrategyTest.java @@ -116,10 +116,13 @@ public class InstantRunoffVoteCountingStrategyTest { @Test public void simpleVotecount0() throws Exception { - // Simple poll (all weight to 1) R1 - // 1 (a=1 b=2 c=null) a 2 - // 2 (a=3 b=2 c=1) b 1 - // 3 (a=1 b=null c=2) c - + // Simple poll + // a b c + // 1 1 2 + // 2 3 2 1 + // 3 1 2 + //-------------------- + // tour 1 2 0 1 Set<Voter> voters = new SimpleVoterBuilder(). newVoter("1", 1.). @@ -143,7 +146,7 @@ public class InstantRunoffVoteCountingStrategyTest { .isNotNull() .containsExactlyInAnyOrder( ChoiceScore.newScore(CHOICE_A, BigDecimal.valueOf(2.0), 0), - ChoiceScore.newScore(CHOICE_B, null, 2), + ChoiceScore.newScore(CHOICE_B, BigDecimal.ZERO, 2), ChoiceScore.newScore(CHOICE_C, BigDecimal.valueOf(1.0), 1)) .isSortedAccordingTo(ChoiceScore::compareTo); } @@ -151,10 +154,14 @@ public class InstantRunoffVoteCountingStrategyTest { @Test public void simpleVotecount2() throws Exception { - // Simple poll (all weight to 1) R1 - // 1 (a=1 b=2 c=null) a 2 - // 2 (a=1 b=2 c=1) b - - // 3 (a=null b=null c=2) c 2 + // Simple poll + // a b c + // 1 1 2 + // 2 1 2 1 + // 3 2 + //------------------- + // Tour 1 2 0 2 -> elimination B + // Tour 2 2 0 2 Set<Voter> voters = new SimpleVoterBuilder(). newVoter("1", 1.). @@ -178,7 +185,7 @@ public class InstantRunoffVoteCountingStrategyTest { .isNotNull() .containsExactlyInAnyOrder( ChoiceScore.newScore(CHOICE_A, BigDecimal.valueOf(2.0), 0), - ChoiceScore.newScore(CHOICE_B, null, 1), + ChoiceScore.newScore(CHOICE_B, BigDecimal.ZERO, 1), ChoiceScore.newScore(CHOICE_C, BigDecimal.valueOf(2.0), 0)) .isSortedAccordingTo(ChoiceScore::compareTo); } @@ -249,7 +256,7 @@ public class InstantRunoffVoteCountingStrategyTest { .containsExactlyInAnyOrder( ChoiceScore.newScore(CHOICE_A, BigDecimal.valueOf(2.0), 0), ChoiceScore.newScore(CHOICE_B, BigDecimal.valueOf(2.0), 0), - ChoiceScore.newScore(CHOICE_C, null, 1)) + ChoiceScore.newScore(CHOICE_C, BigDecimal.ZERO, 1)) .isSortedAccordingTo(ChoiceScore::compareTo); } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.