package name.abuchen.portfolio.math;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import java.time.LocalDate;
import java.time.Month;
import java.util.ArrayList;
import java.util.Arrays;

import org.junit.Test;

public class NPVFunctionTest
{
    @Test(expected = NullPointerException.class)
    public void testNullArguments()
    {
        new NPVFunction(null, null);
    }

    @Test(expected = UnsupportedOperationException.class)
    public void testInvalidArguments()
    {
        new NPVFunction(Arrays.asList(LocalDate.now()), new ArrayList<Double>());
    }

    @Test(expected = UnsupportedOperationException.class)
    public void testEmptyArguments()
    {
        new NPVFunction(new ArrayList<LocalDate>(), new ArrayList<Double>());
    }

    @Test
    public void testSimple()
    {
        NPVFunction f = new NPVFunction(Arrays.asList( //
                        LocalDate.of(2010, Month.JANUARY, 1), //
                        LocalDate.of(2010, Month.DECEMBER, 31)), //
                        Arrays.asList(-200d, 210d));

        assertThat(f.compute(0.05d), is(3965.669635841685d));
    }

}

@@ -854,16 +854,23 @@
 nction f
+unction
  = new N
@@ -1088,44 +1088,124 @@
 ));%0A
-%0A        assertThat(f.compute(0.05d)
+        double doubleRate = 0.05d;%0A%0A        double result = function.compute(doubleRate);%0A%0A        assertThat(result
 , is
@@ -1233,11 +1233,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Improve readability of NPVFunctionTest