From a7aa8a82b5c30e4fdcfbc93ca1f924907628e6aa Mon Sep 17 00:00:00 2001 From: domi41 Date: Thu, 17 Jun 2021 10:26:22 +0200 Subject: [PATCH] fix: use another assertThrow that CI knows --- .../mj/IncoherentTallyException.java | 7 ---- .../mj/MajorityJudgmentDeliberatorTest.java | 37 ++++++++++++++----- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/main/java/fr/mieuxvoter/mj/IncoherentTallyException.java b/src/main/java/fr/mieuxvoter/mj/IncoherentTallyException.java index e89bbd5..acb0a76 100644 --- a/src/main/java/fr/mieuxvoter/mj/IncoherentTallyException.java +++ b/src/main/java/fr/mieuxvoter/mj/IncoherentTallyException.java @@ -16,11 +16,4 @@ class IncoherentTallyException extends InvalidTallyException { ); } - @Override - public String getLocalizedMessage() { - return super.getLocalizedMessage(); - } - - - } \ No newline at end of file diff --git a/src/test/java/fr/mieuxvoter/mj/MajorityJudgmentDeliberatorTest.java b/src/test/java/fr/mieuxvoter/mj/MajorityJudgmentDeliberatorTest.java index 3dffee7..372b6b5 100644 --- a/src/test/java/fr/mieuxvoter/mj/MajorityJudgmentDeliberatorTest.java +++ b/src/test/java/fr/mieuxvoter/mj/MajorityJudgmentDeliberatorTest.java @@ -1,6 +1,5 @@ package fr.mieuxvoter.mj; -import static org.junit.Assert.assertThrows; import static org.junit.jupiter.api.Assertions.*; import java.math.BigInteger; @@ -12,6 +11,7 @@ import javax.json.JsonValue; import org.junit.function.ThrowingRunnable; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import net.joshka.junit.json.params.JsonFileSource; @@ -378,16 +378,26 @@ class MajorityJudgmentDeliberatorTest { new ProposalTally(new Integer[]{ 2, 0, 0 }), }, amountOfJudges); +// assertThrows(null, null, null); assertThrows( - "An exception is raised", UnbalancedTallyException.class, - new ThrowingRunnable() { + new Executable() { @Override - public void run() throws Throwable { + public void execute() throws Throwable { mj.deliberate(tally); } - } + }, + "An exception is raised" ); + + boolean caught = false; + try { + mj.deliberate(tally); + } catch (UnbalancedTallyException e) { + caught = true; + assertNotNull(e.getLocalizedMessage()); + } + assertTrue(caught, "An exception is raised"); } @Test @@ -401,15 +411,24 @@ class MajorityJudgmentDeliberatorTest { }, amountOfJudges); assertThrows( - "An exception is raised", IncoherentTallyException.class, - new ThrowingRunnable() { + new Executable() { @Override - public void run() throws Throwable { + public void execute() throws Throwable { mj.deliberate(tally); } - } + }, + "An exception is raised" ); + + boolean caught = false; + try { + mj.deliberate(tally); + } catch (IncoherentTallyException e) { + caught = true; + assertNotNull(e.getLocalizedMessage()); + } + assertTrue(caught, "An exception is raised"); }