From 7774fb6ffb0290c4d5f4910309200f681624eee9 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Thu, 10 Nov 2011 15:07:47 +0000 Subject: [PATCH] Use asserNotNull(var) instead of if (var != null) and avoid subsequent NPE warnings git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1200365 13f79535-47bb-0310-9956-ffa450edef68 --- .../MillerUpdatingRegressionTest.java | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java b/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java index 521bdb054..7c9bcafc2 100644 --- a/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java +++ b/src/test/java/org/apache/commons/math/stat/regression/MillerUpdatingRegressionTest.java @@ -16,6 +16,8 @@ */ package org.apache.commons.math.stat.regression; +import junit.framework.Assert; + import org.apache.commons.math.linear.RealMatrix; import org.apache.commons.math.stat.correlation.PearsonsCorrelation; import org.apache.commons.math.TestUtils; @@ -178,9 +180,7 @@ public class MillerUpdatingRegressionTest { instance.addObservations(x, y); try { RegressionResults result = instance.regress(); - if (result == null) { - fail("The test case is a prototype."); - } + Assert.assertNotNull("The test case is a prototype.", result); TestUtils.assertEquals( new double[]{9.5169, 0.8827, 0.4540, -1.6275}, result.getParameterEstimates(), 1e-4); @@ -212,9 +212,7 @@ public class MillerUpdatingRegressionTest { instance.addObservations(x, y); try { RegressionResults result = instance.regress(); - if (result == null) { - fail("The test case is a prototype."); - } + Assert.assertNotNull("The test case is a prototype.", result); TestUtils.assertEquals( new double[]{9.5169, 0.8827, 0.4540, -1.6275}, result.getParameterEstimates(), 1e-4); @@ -783,15 +781,11 @@ public class MillerUpdatingRegressionTest { instance.addObservations(x, y); RegressionResults result = instance.regress(); - if (result == null) { - fail("Could not estimate initial regression"); - } + Assert.assertNotNull("Could not estimate initial regression", result); instance2.addObservations(x2, y); RegressionResults resultRedundant = instance2.regress(); - if (resultRedundant == null) { - fail("Could not estimate redundant regression"); - } + Assert.assertNotNull("Could not estimate redundant regression", resultRedundant); double[] beta = result.getParameterEstimates(); double[] betar = resultRedundant.getParameterEstimates(); double[] se = result.getStdErrorOfEstimates(); @@ -849,15 +843,11 @@ public class MillerUpdatingRegressionTest { instance.addObservations(x, y); RegressionResults result = instance.regress(); - if (result == null) { - fail("Could not estimate initial regression"); - } + Assert.assertNotNull("Could not estimate initial regression", result); instance2.addObservations(x2, y); RegressionResults resultRedundant = instance2.regress(); - if (resultRedundant == null) { - fail("Could not estimate redundant regression"); - } + Assert.assertNotNull("Could not estimate redundant regression", resultRedundant); double[] beta = result.getParameterEstimates(); double[] betar = resultRedundant.getParameterEstimates(); double[] se = result.getStdErrorOfEstimates();