VariableNotionalProvider implements NotionalProvider { @Override public double getAmount(final LocalDate date) { if (_dates == null) { throw new IllegalArgumentException("date set is null"); } for (int i = 0; i < _dates.length; ++i) { if (_dates[i].equals(date)) { return _notionals[i]; } } throw new IllegalArgumentException("The date " + date + " is not found in the date set"); } VariableNotionalProvider(LocalDate[] dates, double[] notionals);  VariableNotionalProvider(double[] notionals); VariableNotionalProvider withZonedDateTime(List<ZonedDateTime> dateList); @Override double getAmount(final LocalDate date); double[] getNotionals(); LocalDate[] getDates();  }
@Test(expectedExceptions = IllegalArgumentException.class) public void missingDateSetTest() { double[] notionals = new double[] {100.0, 90.0 }; VariableNotionalProvider provider = new VariableNotionalProvider(notionals); provider.getAmount(LocalDate.of(2014, 11, 13)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void dateNotFoundTest() { LocalDate[] dates = new LocalDate[] {LocalDate.of(2014, 7, 18), LocalDate.of(2014, 9, 18) }; double[] notionals = new double[] {100.0, 200.0 }; VariableNotionalProvider provider = new VariableNotionalProvider(dates, notionals); provider.getAmount(LocalDate.of(2014, 8, 1)); }