### Question:
LaguerrePolynomialRealRootFinder implements Polynomial1DRootFinder<Double> { @Override public Double[] getRoots(RealPolynomialFunction1D function) { ArgChecker.notNull(function, "function"); try { Complex[] roots = ROOT_FINDER.solveAllComplex(function.getCoefficients(), 0); List<Double> realRoots = new ArrayList<>(); for (Complex c : roots) { if (DoubleMath.fuzzyEquals(c.getImaginary(), 0d, EPS)) { realRoots.add(c.getReal()); } } if (realRoots.isEmpty()) { throw new MathException("Could not find any real roots"); } return realRoots.toArray(new Double[realRoots.size()]); } catch (TooManyEvaluationsException e) { throw new MathException(e); } }  @Override Double[] getRoots(RealPolynomialFunction1D function);  }### Answer:
@Test public void testNullFunction() { assertThatIllegalArgumentException() .isThrownBy(() -> ROOT_FINDER.getRoots(null)); }
@Test public void testNoRealRoots() { assertThatExceptionOfType(MathException.class) .isThrownBy(() -> ROOT_FINDER.getRoots(NO_REAL_ROOTS)); }
@Test public void test() { Double[] result = ROOT_FINDER.getRoots(TWO_REAL_ROOTS); Arrays.sort(result); assertThat(result.length).isEqualTo(2); assertThat(result[0]).isCloseTo(-4, offset(EPS)); assertThat(result[1]).isCloseTo(-3, offset(EPS)); result = ROOT_FINDER.getRoots(ONE_REAL_ROOT); assertThat(result.length).isEqualTo(2); assertThat(result[0]).isCloseTo(3, offset(EPS)); assertThat(result[1]).isCloseTo(3, offset(EPS)); result = ROOT_FINDER.getRoots(CLOSE_ROOTS); Arrays.sort(result); assertThat(result.length).isEqualTo(2); assertThat(result[1] - result[0]).isCloseTo(1e-6, offset(1e-8)); }