SimpleContainer implements Containerlike<T> { @Override public Collection<T> removeUnfit() { if (this.verifier == null) { return Collections.emptyList(); } Collection<T> unfit = new ArrayList<>(); ListIterator<T> iter = this.storage.listIterator(); while(iter.hasNext()) { T thing = iter.next(); if (!verifier.isSufficient(thing)) { unfit.add(thing); iter.remove(); } } return unfit; } SimpleContainer();  SimpleContainer(ThingTypeCheck<T> verifier);  SimpleContainer(ThingTypeCheck<T> verifier, int limit); @Override boolean canFit(T thing); @Override Collection<T> findSimilar(ThingTypeCheck<T>judge); @Override Collection<T> removeUnfit(); @Override boolean hasUnfit(); @Override void setVerifier(ThingTypeCheck<T> verifier); @Override ThingTypeCheck<T> getVerifier(); @Override boolean hasSizeLimit(); @Override int getSizeLimit(); @Override int setSizeLimit(int limit); @Override boolean add(T o); @Override boolean offer(T o); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<T> iterator(); @Override T[] toArray(); @Override T[] toArray(T[] a); @Override boolean remove(Object o); @Override boolean containsAll(Collection c); @Override boolean addAll(Collection c); @Override boolean removeAll(Collection c); @Override boolean retainAll(Collection c); @Override void clear(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test @Covers("public Collection<T> removeUnfit()") public void testRemoveUnfit() { SimpleContainer<Integer> instance = new SimpleContainer<>(); instance.add(42); Collection<Integer> unfit = instance.removeUnfit(); assertTrue(unfit.isEmpty()); assertFalse(instance.isEmpty()); SimpleIntegerCheck check = new SimpleIntegerCheck(1, 20); instance.setVerifier(check); unfit = instance.removeUnfit(); assertFalse(unfit.isEmpty()); assertTrue(instance.isEmpty()); }