@Test public void doesNotChangeWhenListPassedAsInputChanges() { final List<Price> prices = new ArrayList<>(4); prices.add(new Price(400)); prices.add(new Price(500)); prices.add(new Price(600)); prices.add(new Price(700)); final PriceLevels cut = new PriceLevels(prices); prices.set(1, new Price(1234)); assertThat(cut.get(1)).isEqualTo(new Price(500)); assertThat(cut.get(3)).isEqualTo(new Price(700)); }
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();  }