Browse Source

fix: use another assertThrow that CI knows

master
Dominique Merle 1 year ago
parent
commit
a7aa8a82b5
  1. 7
      src/main/java/fr/mieuxvoter/mj/IncoherentTallyException.java
  2. 37
      src/test/java/fr/mieuxvoter/mj/MajorityJudgmentDeliberatorTest.java

7
src/main/java/fr/mieuxvoter/mj/IncoherentTallyException.java

@ -16,11 +16,4 @@ class IncoherentTallyException extends InvalidTallyException {
);
}
@Override
public String getLocalizedMessage() {
return super.getLocalizedMessage();
}
}

37
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");
}

Loading…
Cancel
Save