@Test public void doesNotChangeWhenArrayPassedAsInputChanges() { final Price[] prices = new Price[] { new Price(0), new Price(1), new Price(2), new Price(3) }; final PriceLevels cut = new PriceLevels(prices); prices[2] = new Price(20); assertThat(cut.get(2)).isEqualTo(new Price(2)); }
public Price get(final int index) throws IndexOutOfBoundsException { return priceLevels[index]; }
PriceLevels { public Price get(final int index) throws IndexOutOfBoundsException { return priceLevels[index]; } }
PriceLevels { public Price get(final int index) throws IndexOutOfBoundsException { return priceLevels[index]; } PriceLevels(final Price... priceLevels);  PriceLevels(final List<Price> priceLevels); }
PriceLevels { public Price get(final int index) throws IndexOutOfBoundsException { return priceLevels[index]; } PriceLevels(final Price... priceLevels);  PriceLevels(final List<Price> priceLevels); Optional<Price> nextHigherLevel(final Price price); Optional<Price> nextLowerLevel(final Price price); int count(); Price get(final int index); boolean contains(final Price price); @Override String toString(); }
PriceLevels { public Price get(final int index) throws IndexOutOfBoundsException { return priceLevels[index]; } PriceLevels(final Price... priceLevels);  PriceLevels(final List<Price> priceLevels); Optional<Price> nextHigherLevel(final Price price); Optional<Price> nextLowerLevel(final Price price); int count(); Price get(final int index); boolean contains(final Price price); @Override String toString();  }