JUnit5 assertThrows MapRankingTest (#215)
diff --git a/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/MapRankingTest.java b/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/MapRankingTest.java
index fb31a3c..6d1f9f4 100644
--- a/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/MapRankingTest.java
+++ b/commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/MapRankingTest.java
@@ -29,10 +29,13 @@
import org.apache.commons.math4.neuralnet.oned.NeuronString;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
/**
* Tests for {@link MapRanking} class.
*/
public class MapRankingTest {
+
/*
* Test assumes that the network is
*
@@ -94,15 +97,20 @@
Assert.assertEquals(3, allBest.size());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testRankPrecondition() {
final UniformRandomProvider rng = RandomSource.SPLIT_MIX_64.create();
final FeatureInitializer init
= new OffsetFeatureInitializer(FeatureInitializerFactory.uniform(rng, -0.1, 0.1));
final FeatureInitializer[] initArray = {init};
- new MapRanking(new NeuronString(3, false, initArray).getNetwork(),
- new EuclideanDistance()).rank(new double[] {-1}, 0);
+ final EuclideanDistance distance = new EuclideanDistance();
+ final Network network = new NeuronString(3, false, initArray).getNetwork();
+ final MapRanking mapRanking = new MapRanking(network, distance);
+
+ assertThrows(IllegalArgumentException.class, () ->
+ mapRanking.rank(new double[]{-1}, 0)
+ );
}
@Test
@@ -121,4 +129,5 @@
Assert.assertEquals(expected[i], sorted.get(i).getIdentifier());
}
}
+
}