### Question:
SimpleItemSupplier implements Supplier<List<PMO>> { @Override public List<PMO> get() { List<? extends MO> actualModelObjects = modelObjectSupplier.get(); requireNonNull(actualModelObjects, "modelObjectSupplier must supply a List of model objects (which may be empty)"); if (hasUnderlyingModelObjectListChanged(actualModelObjects)) { HashSet<? extends MO> actualModelObjectsSet = new HashSet<>(actualModelObjects); itemMap.keySet().removeIf(o -> !actualModelObjectsSet.contains(o)); items = new LinkedList<>(); actualModelObjects.forEach(mo -> items.add(applymo2pmoMapping(mo))); modelObjectsCopy = new ArrayList<>(actualModelObjects); } return items; } SimpleItemSupplier(Supplier<? extends List<? extends MO>> modelObjectSupplier,
            Function<MO, PMO> mo2pmoMapping); @Override List<PMO> get();  }### Answer:
@Test public void testCreateItemSupplierWithoutUnknownType() { Supplier<List<Integer>> supplier = () -> Arrays.asList(1); SimpleItemSupplier<Integer, Integer> itemSupplier2 = new SimpleItemSupplier<>(supplier, UnaryOperator.identity()); assertThat(itemSupplier2.get(), hasItem(1)); }
@Test public void testGet_shouldReturnEmptyList_ifUnderlyingListIsEmpty() { assertThat(itemSupplier.get(), hasSize(0)); }
@Test public void testGet_shouldReturnNewList_ifUnderlyingListHasCanged() { itemSupplier.get(); modelObjects.add(42); assertThat(itemSupplier.get(), hasSize(1)); SimplePmo pmo = itemSupplier.get().get(0); assertThat(pmo.getModelObject(), is(42)); modelObjects.add(43); assertThat(itemSupplier.get(), hasSize(2)); assertThat(itemSupplier.get().get(0), is(pmo)); assertThat(itemSupplier.get().get(1).getModelObject(), is(43)); }
@Test public void testGet_shouldReturnNewList_ifUnderlyingListHasCangedOrder() { modelObjects.add(0); modelObjects.add(1); assertThat(itemSupplier.get(), hasSize(2)); assertThat(itemSupplier, hasPmosForModelobjects(0, 1)); SimplePmo pmo2 = itemSupplier.get().get(1); modelObjects.set(0, 99); assertThat(itemSupplier.get(), hasSize(2)); assertThat(itemSupplier, hasPmosForModelobjects(99, 1)); assertThat(pmo2, is(itemSupplier.get().get(1))); }
@Test public void testGet_ShouldRemoveUnusedModelObjectMappings() { modelObjects.add(0); SimplePmo pmo1 = itemSupplier.get().get(0); modelObjects.set(0, 99); itemSupplier.get(); modelObjects.set(0, 0); assertThat(pmo1, is(not(itemSupplier.get().get(0)))); }
@Test public void testGet_shouldReturnSameList_ifUnderlyingListHasNotChanged() { modelObjects.add(42); List<SimplePmo> list = itemSupplier.get(); List<SimplePmo> list2 = itemSupplier.get(); assertThat(list == list2); }