diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvDotParserTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvDotParserTest.java index 0c1e4293f487247aa73a3721449579e2724f3031..5666fa11456d623ca7f35a5ffd950bf72b2cefa2 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvDotParserTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvDotParserTest.java @@ -28,7 +28,7 @@ public class CsvDotParserTest { try { parser = new CsvParser(csvReader, ',', '\"'); } catch (Exception e) { - + Assertions.fail(); } } @@ -36,58 +36,58 @@ public class CsvDotParserTest { @Test public void testHorizontalParsing() { PointListContainer<PointList> container = parser.parse(CsvType.DOTS, CsvOrientation.HORIZONTAL); - Iterator containerIt = container.iterator(); - PointList list_1 = (PointList) containerIt.next(); + Iterator<PointList> containerIt = container.iterator(); + PointList list_1 = containerIt.next(); Assertions.assertEquals(list_1.getName(), "Linie1"); - Iterator it = list_1.getListIterator(); + Iterator<Point2DDouble> it = list_1.getListIterator(); - Point2DDouble point = (Point2DDouble) it.next(); + Point2DDouble point = it.next(); Assertions.assertEquals(point.getX(), 1.0); Assertions.assertEquals(point.getY(), 1.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 7.0); Assertions.assertEquals(point.getY(), 2.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 9.0); Assertions.assertEquals(point.getY(), 5.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 2.0); Assertions.assertEquals(point.getY(), 4.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 10.0); Assertions.assertEquals(point.getY(), 10.0); - PointList list_2 = (PointList) containerIt.next(); + PointList list_2 = containerIt.next(); Assertions.assertEquals(list_2.getName(), "Linie2"); it = list_2.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 0.0); Assertions.assertEquals(point.getY(), 3.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 2.0); Assertions.assertEquals(point.getY(), 9.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 7.0); Assertions.assertEquals(point.getY(), 4.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 9.0); Assertions.assertEquals(point.getY(), 2.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 1.0); Assertions.assertEquals(point.getY(), 5.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 4.0); Assertions.assertEquals(point.getY(), 7.0); diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvParseAlgorithmTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvParseAlgorithmTest.java deleted file mode 100644 index 5565daba75cd3059289b72cf294eb068147694aa..0000000000000000000000000000000000000000 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvParseAlgorithmTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.tudresden.inf.mci.brailleplot.csvparser; - -/** - * @author Richard Schmidt - */ -public class CsvParseAlgorithmTest { -/* - public static CsvParseAlgorithm parser; - public static PointListContainer<PointList> container = new SimplePointListContainerImpl(); - public static Point2DDouble point; - public static int n; - public static PointList list; - - - @BeforeAll - public static void initialize() { - parser = new CsvDotParser(); - container.pushBack(new SimplePointListImpl()); - container.pushBack(new SimplePointListImpl()); - point = new Point2DDouble(2.0, 4.0); - n = 5; - } - - @Test - public void testAddPoint() { - parser.addPointToPointListList(container, n, point); - Iterator it = container.iterator(); - for (int i = 0; i < n; i++) { - list = (PointList) it.next(); - } - Assertions.assertEquals(list.getListIterator().next(), point); - } -*/ -} diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedCategoriesParserTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedCategoriesParserTest.java index c658520541b51f5cc65fbe947dda8b6779ec646b..10ce58b266d7595b8597f11e6bb5affa7ff36098 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedCategoriesParserTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedCategoriesParserTest.java @@ -2,7 +2,6 @@ package de.tudresden.inf.mci.brailleplot.csvparser; import de.tudresden.inf.mci.brailleplot.datacontainers.CategoricalPointListContainer; import de.tudresden.inf.mci.brailleplot.datacontainers.PointList; -import de.tudresden.inf.mci.brailleplot.datacontainers.PointListContainer; import de.tudresden.inf.mci.brailleplot.point.Point2DDouble; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -13,7 +12,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.Iterator; -import java.util.List; /** * @author Richard Schmidt @@ -30,7 +28,7 @@ public class CsvXAlignedCategoriesParserTest { try { parser = new CsvParser(csvReader, ',', '\"'); } catch (Exception e) { - + Assertions.fail(); } } @@ -43,88 +41,88 @@ public class CsvXAlignedCategoriesParserTest { Assertions.assertEquals(container.getCategory(3), " Reihe c "); Assertions.assertEquals(container.getCategory(4), " Reihe d"); - Iterator containerIt = container.iterator(); - PointList list_1 = (PointList) containerIt.next(); + Iterator<PointList> containerIt = container.iterator(); + PointList list_1 = containerIt.next(); Assertions.assertEquals(list_1.getName(), "Kat.1"); - Iterator it = list_1.getListIterator(); + Iterator<Point2DDouble> it = list_1.getListIterator(); - Point2DDouble point = (Point2DDouble) it.next(); + Point2DDouble point = it.next(); Assertions.assertEquals(point.getX(), 1.0); Assertions.assertEquals(point.getY(), 3.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 2.0); Assertions.assertEquals(point.getY(), 2.5); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 3.0); Assertions.assertEquals(point.getY(), 1.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 4.0); Assertions.assertEquals(point.getY(), 3.0); - PointList list_2 = (PointList) containerIt.next(); + PointList list_2 = containerIt.next(); Assertions.assertEquals(list_2.getName(), "Kat.2"); it = list_2.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 1.0); Assertions.assertEquals(point.getY(), 4.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 2.0); Assertions.assertEquals(point.getY(), 3.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 3.0); Assertions.assertEquals(point.getY(), 2.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 4.0); Assertions.assertEquals(point.getY(), 5.0); - PointList list_3 = (PointList) containerIt.next(); + PointList list_3 = containerIt.next(); Assertions.assertEquals(list_3.getName(), "Kat.3"); it = list_3.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 1.0); Assertions.assertEquals(point.getY(), 4.5); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 2.0); Assertions.assertEquals(point.getY(), 3.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 3.0); Assertions.assertEquals(point.getY(), 1.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 4.0); Assertions.assertEquals(point.getY(), 0.2); - PointList list_4 = (PointList) containerIt.next(); + PointList list_4 = containerIt.next(); Assertions.assertEquals(list_4.getName(), "Kat.4"); it = list_4.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 1.0); Assertions.assertEquals(point.getY(), 4.5); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 2.0); Assertions.assertEquals(point.getY(), 3.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 3.0); Assertions.assertEquals(point.getY(), 1.0); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 4.0); Assertions.assertEquals(point.getY(), 0.2); diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedParserTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedParserTest.java index cac89a88fafe46d49e5f35aa1bd053aebc4fbba2..5e989fce0672bf61705ceacaccb0529351173c3d 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedParserTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/csvparser/CsvXAlignedParserTest.java @@ -12,7 +12,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.Iterator; -import java.util.List; /** * @author Richard Schmidt @@ -29,7 +28,7 @@ public class CsvXAlignedParserTest { try { parser = new CsvParser(csvReader, ',', '\"'); } catch (Exception e) { - + Assertions.fail(); } } @@ -37,67 +36,67 @@ public class CsvXAlignedParserTest { @Test public void testVerticalParsing() { PointListContainer<PointList> container = parser.parse(CsvType.X_ALIGNED, CsvOrientation.VERTICAL); - Iterator containerIt = container.iterator(); - PointList list_1 = (PointList) containerIt.next(); + Iterator<PointList> containerIt = container.iterator(); + PointList list_1 = containerIt.next(); Assertions.assertEquals(list_1.getName(), "a"); - Iterator it = list_1.getListIterator(); + Iterator<Point2DDouble> it = list_1.getListIterator(); - Point2DDouble point = (Point2DDouble) it.next(); + Point2DDouble point = it.next(); Assertions.assertEquals(point.getX(), 0.0); Assertions.assertEquals(point.getY(), 1.0); - PointList list_2 = (PointList) containerIt.next(); + PointList list_2 = containerIt.next(); Assertions.assertEquals(list_2.getName(), "b"); it = list_2.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 0.0); Assertions.assertEquals(point.getY(), 2.2); - PointList list_3 = (PointList) containerIt.next(); + PointList list_3 = containerIt.next(); Assertions.assertEquals(list_3.getName(), "c"); it = list_3.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 0.0); Assertions.assertEquals(point.getY(), 3.0); - PointList list_4 = (PointList) containerIt.next(); + PointList list_4 = containerIt.next(); Assertions.assertEquals(list_4.getName(), "d"); it = list_4.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 0.0); Assertions.assertEquals(point.getY(), 4.4); - PointList list_5 = (PointList) containerIt.next(); + PointList list_5 = containerIt.next(); Assertions.assertEquals(list_5.getName(), "e"); it = list_5.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 0.0); Assertions.assertEquals(point.getY(), 5.0); - PointList list_6 = (PointList) containerIt.next(); + PointList list_6 = containerIt.next(); Assertions.assertEquals(list_6.getName(), "f"); it = list_6.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 0.0); Assertions.assertEquals(point.getY(), 6.0); - PointList list_7 = (PointList) containerIt.next(); + PointList list_7 = containerIt.next(); Assertions.assertEquals(list_7.getName(), "g"); it = list_7.getListIterator(); - point = (Point2DDouble) it.next(); + point = it.next(); Assertions.assertEquals(point.getX(), 0.0); Assertions.assertEquals(point.getY(), 7.0); diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/AbstractPointContainerTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/AbstractPointContainerTest.java index fa121f3f475aa11ec362f2e4161d86fe68949cdd..4aba65506a18aac8f8f4bbb4ef0f7e8b4eef6163 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/AbstractPointContainerTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/AbstractPointContainerTest.java @@ -30,16 +30,16 @@ public class AbstractPointContainerTest { container.pushBack(list_1); container.pushBack(list_2); - Iterator container_it = container.iterator(); - PointList list = (PointList) container_it.next(); - Iterator list_it = list.getListIterator(); - Point2DDouble point = (Point2DDouble) list_it.next(); + Iterator<PointList> container_it = container.iterator(); + PointList list = container_it.next(); + Iterator<Point2DDouble> list_it = list.getListIterator(); + Point2DDouble point = list_it.next(); Assertions.assertEquals(point.getX(), 1.0); Assertions.assertEquals(point.getY(), 2.0); - list = (PointList) container_it.next(); + list = container_it.next(); list_it = list.getListIterator(); - point = (Point2DDouble) list_it.next(); + point = list_it.next(); Assertions.assertEquals(point.getX(), 3.0); Assertions.assertEquals(point.getY(), 4.0); } diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimpleCategoricalPointListContainerImplTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimpleCategoricalPointListContainerImplTest.java index 7e3971567624cfa7bec8aaade2a85d604882f81c..1b8da50b05c8abcb4f584aed8536da57a4b4f050 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimpleCategoricalPointListContainerImplTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimpleCategoricalPointListContainerImplTest.java @@ -4,31 +4,22 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.util.Iterator; - /** * @author Richard Schmidt */ public class SimpleCategoricalPointListContainerImplTest { public static SimpleCategoricalPointListContainerImpl container; - public static NullPointerException e; - public static IndexOutOfBoundsException b; @BeforeAll public static void initialize() { container = new SimpleCategoricalPointListContainerImpl(); - e = new NullPointerException(); - b = new IndexOutOfBoundsException(); } @Test public void testPushBackCategory() { - try { - container.pushBackCategory(null);} - catch (Exception exc) { - Assertions.assertEquals(e.getCause(), exc.getCause()); - } + + Assertions.assertThrows(NullPointerException.class, () -> {container.pushBackCategory(null);}); int a = container.pushBackCategory("Kat. 1"); int b = container.pushBackCategory("Kat. 2"); @@ -42,18 +33,9 @@ public class SimpleCategoricalPointListContainerImplTest { @Test public void testGetCategory() { - try { - container.getCategory(-1);} - catch (Exception exc) { - Assertions.assertEquals(b.getCause(), exc.getCause()); - System.out.print("hier"); - } - - try { - container.getCategory(2);} - catch (Exception exc) { - Assertions.assertEquals(b.getCause(), exc.getCause()); - System.out.print("hier"); - } + + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> {container.getCategory(-1);}); + Assertions.assertThrows(IndexOutOfBoundsException.class, () -> {container.getCategory(2);}); + } } diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimplePointListContainerImplTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimplePointListContainerImplTest.java index 6c33f243b85bcca9110f1d8d0e003cb0cbb71de7..bc4f69eb68882fd294bbea97575a39b34442ad85 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimplePointListContainerImplTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimplePointListContainerImplTest.java @@ -28,8 +28,8 @@ public class SimplePointListContainerImplTest { @Test public void testSimplePointListContainerImpl() { SimplePointListContainerImpl container = new SimplePointListContainerImpl(elements); - Iterator it = container.iterator(); - PointList my_list = (PointList) it.next(); + Iterator<PointList> it = container.iterator(); + PointList my_list = it.next(); Assertions.assertEquals("test_list", my_list.getName()); } } diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimplePointListImplTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimplePointListImplTest.java index 57a890ba7b1167b1479249380910f72ea09e9c56..bb7f53ec0cda2200bf80940247a9013a21704eec 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimplePointListImplTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/datacontainers/SimplePointListImplTest.java @@ -19,7 +19,6 @@ public class SimplePointListImplTest { public static Point2DDouble point_1; public static Point2DDouble point_2; public static SimplePointListImpl plist; - public static NullPointerException e; @BeforeAll public static void initialize() { @@ -29,32 +28,23 @@ public class SimplePointListImplTest { point_2 = new Point2DDouble(4, 5); initial_elements.add(point_1); initial_elements.add(point_2); - e = new NullPointerException(); } @Test public void testSimplePointListImpl() { - try { - plist = new SimplePointListImpl(null, initial_elements); - } catch (Exception exc) { - Assertions.assertEquals(e.getCause(), exc.getCause()); - } - - try { - plist = new SimplePointListImpl(name, null); - } catch (Exception exc) { - Assertions.assertEquals(e.getCause(), exc.getCause()); - } - - SimplePointListImpl plist = new SimplePointListImpl(name, initial_elements); + + Assertions.assertThrows(NullPointerException.class, () -> {new SimplePointListImpl(null, initial_elements);}); + Assertions.assertThrows(NullPointerException.class, () -> {new SimplePointListImpl(name, null);}); + + plist = new SimplePointListImpl(name, initial_elements); Assertions.assertEquals(name, plist.getName()); - Iterator it = plist.getListIterator(); - Point2DDouble p = (Point2DDouble) it.next(); + Iterator<Point2DDouble> it = plist.getListIterator(); + Point2DDouble p = it.next(); Assertions.assertEquals(2, p.getX()); Assertions.assertEquals(3, p.getY()); - p = (Point2DDouble) it.next(); + p = it.next(); Assertions.assertEquals(4, p.getX()); Assertions.assertEquals(5, p.getY()); diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/diagrams/BarChartTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/diagrams/BarChartTest.java index cbee2d72843eac5c1aee8bf461b9a1ef745ef178..b54ea6d6c181bb84fca7e32353164094805a5768 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/diagrams/BarChartTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/diagrams/BarChartTest.java @@ -22,7 +22,7 @@ public class BarChartTest { @BeforeAll public static void initialize() { - outter_list = new LinkedList(); + outter_list = new LinkedList<>(); inner_list = new SimplePointListImpl(); point = new Point2DDouble(1, 2); inner_list.pushBack(point); @@ -33,7 +33,7 @@ public class BarChartTest { @Test public void testBarChart () { BarChart bar = new BarChart(container); - Point2DDouble p = (Point2DDouble) bar.getDataSet().iterator().next().getListIterator().next(); + Point2DDouble p = bar.getDataSet().iterator().next().getListIterator().next(); Assertions.assertEquals(1, p.getX()); Assertions.assertEquals(2, p.getY()); } diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/point/Point2DTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/point/Point2DTest.java index d80b923f3b352bfaf95f7ebb1904f63e26bd77a3..464ecdc39c1cecd09f8232ff39278bb35a64cb12 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/point/Point2DTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/point/Point2DTest.java @@ -1,7 +1,6 @@ package de.tudresden.inf.mci.brailleplot.point; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; /** @@ -9,30 +8,14 @@ import org.junit.jupiter.api.Test; */ public class Point2DTest { - public static NullPointerException e; - - @BeforeAll - public static void initialize() { - e = new NullPointerException(); - } - @Test public void testPoint2D () { int a = 1; int b = 2; Point2D p; - try { - p = new Point2D(null, b); - } catch (Exception exc) { - Assertions.assertEquals(e.getCause(), exc.getCause()); - } - - try { - p = new Point2D(a, null); - } catch (Exception exc) { - Assertions.assertEquals(e.getCause(), exc.getCause()); - } + Assertions.assertThrows(NullPointerException.class, () -> {new Point2D(null, b);}); + Assertions.assertThrows(NullPointerException.class, () -> {new Point2D(a, null);}); p = new Point2D(a, b); Assertions.assertEquals(a, p.getX()); diff --git a/src/test/java/de/tudresden/inf/mci/brailleplot/point/Point2DValuedTest.java b/src/test/java/de/tudresden/inf/mci/brailleplot/point/Point2DValuedTest.java index 623752d358a2954fe92f799cfdad08a0ed584a60..8d257f2890f9a2ce806169461cd9be855455d4c7 100644 --- a/src/test/java/de/tudresden/inf/mci/brailleplot/point/Point2DValuedTest.java +++ b/src/test/java/de/tudresden/inf/mci/brailleplot/point/Point2DValuedTest.java @@ -1,7 +1,6 @@ package de.tudresden.inf.mci.brailleplot.point; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; /** @@ -9,24 +8,13 @@ import org.junit.jupiter.api.Test; */ public class Point2DValuedTest { - public static NullPointerException e; - - @BeforeAll - public static void initialize() { - e = new NullPointerException(); - } - @Test public void testPoint2DValued () { int a = 1; int b = 2; int value = 3; - try { - Point2DValued point = new Point2DValued(a, b, null); - } catch (Exception exc) { - Assertions.assertEquals(e.getCause(), exc.getCause()); - } + Assertions.assertThrows(NullPointerException.class, () -> {new Point2DValued(a, b, null);}); Point2DValued point = new Point2DValued(a, b, value); Assertions.assertEquals(value, point.getVal());