Skip to content

Commit

Permalink
fix compile warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fhoeben committed Dec 17, 2024
1 parent 4cda8b2 commit 2bb2bf7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 44 deletions.
9 changes: 2 additions & 7 deletions src/test/java/nl/hsac/fitnesse/symbols/RandomStringTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package nl.hsac.fitnesse.symbols;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

/**
Expand All @@ -13,9 +12,6 @@
public class RandomStringTest {
private final RandomString stringLengthGenerator = new RandomString();

@Rule
public final ExpectedException exception = ExpectedException.none();

@Test
public void testLength() {
checkGeneratedLength("50", "", 50);
Expand Down Expand Up @@ -108,8 +104,7 @@ private void checkGeneratedLength(String lengthParam, String prefix, int expecte
* to test for the exceptions
*/
private void checkGeneratedLengthException(String lengthParam, String prefix) {
exception.expect(IllegalArgumentException.class);
stringLengthGenerator.getStringLength(lengthParam, prefix);
assertThrows(IllegalArgumentException.class, () -> stringLengthGenerator.getStringLength(lengthParam, prefix));
}

/**
Expand Down
20 changes: 7 additions & 13 deletions src/test/java/nl/hsac/fitnesse/util/RandomDomainTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package nl.hsac.fitnesse.util;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

/**
Expand All @@ -14,9 +13,6 @@ public class RandomDomainTest {
private final RandomDomain domain = new RandomDomain();
private final RandomUtil random = new RandomUtil();

@Rule
public final ExpectedException exception = ExpectedException.none();

/**
* Tests tld randomization.
*/
Expand Down Expand Up @@ -73,12 +69,10 @@ public void testGenerateFullDomain() {
*/
@Test
public void testDomainLengthException() {
exception.expect(IllegalArgumentException.class);
RandomDomain.generateFullDomain(domain, 4);
RandomDomain.generateFullDomain(domain, 3);
RandomDomain.generateFullDomain(domain, 2);
RandomDomain.generateFullDomain(domain, 1);
RandomDomain.generateFullDomain(domain, -1);
assertThrows(IllegalArgumentException.class, () -> RandomDomain.generateFullDomain(domain, 4));
assertThrows(IllegalArgumentException.class, () -> RandomDomain.generateFullDomain(domain, 3));
assertThrows(IllegalArgumentException.class, () -> RandomDomain.generateFullDomain(domain, 2));
assertThrows(IllegalArgumentException.class, () -> RandomDomain.generateFullDomain(domain, 1));
assertThrows(IllegalArgumentException.class, () -> RandomDomain.generateFullDomain(domain, -1));
}

}
}
14 changes: 3 additions & 11 deletions src/test/java/nl/hsac/fitnesse/util/RandomUtilTest.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package nl.hsac.fitnesse.util;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.util.Arrays;

import static org.junit.Assert.*;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

/**
* Tests RandomUtil.
*/
public class RandomUtilTest {
private final RandomUtil util = new RandomUtil();

@Rule
public final ExpectedException exception = ExpectedException.none();


/**
* Tests int generation.
*/
Expand Down Expand Up @@ -59,9 +54,6 @@ public void testRandomSplit() {
*/
@Test
public void testSplitLengthException() {
exception.expect(IllegalArgumentException.class);
util.getRandomSplit(1);
assertThrows(IllegalArgumentException.class, () -> util.getRandomSplit(1));
}


}
16 changes: 3 additions & 13 deletions src/test/java/nl/hsac/fitnesse/util/iban/IbanGeneratorTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package nl.hsac.fitnesse.util.iban;

import nl.hsac.fitnesse.util.RandomUtil;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

/**
Expand All @@ -16,12 +15,6 @@ public class IbanGeneratorTest {
private static final RandomUtil RANDOM_UTIL = new RandomUtil();
private final NLIbanGenerator generator = new NLIbanGenerator();

@Rule
public final ExpectedException exception = ExpectedException.none();

/**
* Tests random generation.
*/
@Test
public void testGenerate() {
for (int i = 0; i < 100; i++) {
Expand Down Expand Up @@ -59,8 +52,7 @@ public void testCountryBank() {
*/
@Test
public void testErrorCountryCode() {
exception.expect(IllegalArgumentException.class);
ibanGenerator.generateIban("ZZ", "");
assertThrows(IllegalArgumentException.class, () -> ibanGenerator.generateIban("ZZ", ""));
}

/**
Expand Down Expand Up @@ -107,8 +99,7 @@ public void testPaddingWithStartingZeros() {
*/
@Test
public void testErrorPaddingWithZeros() {
exception.expect(IllegalArgumentException.class);
ibanGenerator.padWithStartingZeros("ZZ", 1);
assertThrows(IllegalArgumentException.class, () -> ibanGenerator.padWithStartingZeros("ZZ", 1));
}

private void testPadWithStartingZeros(String string, int desiredLength) {
Expand All @@ -126,6 +117,5 @@ private void countrySelectTest(String countryCode, int expectedIbanLength) {
assertEquals("Got: " + result, expectedIbanLength, result.length());
assertTrue("Got: " + result, result.startsWith(countryCode));
}

}

0 comments on commit 2bb2bf7

Please sign in to comment.