### Question:
HashBag implements MutableBag<T> { @Override public boolean removeOccurrences(T element, int occurrences) { int sizeBefore = size; Integer existing = this.backingMap.get(element); if (existing != null) { Integer newCount = existing - occurrences; if (newCount <= 0) { this.backingMap.remove(element); size = size - existing; } else { this.backingMap.put(element, newCount); size = size - occurrences; } } return sizeBefore != size; }  @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer); @Override T1[] toArray(T1[] array); @Override boolean add(T element); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override Iterator<T> iterator(); @Override int getOccurrences(T element); @Override boolean addOccurrence(T element); @Override boolean addOccurrences(T element, int occurrences); @Override boolean removeOccurrence(T element); @Override boolean removeOccurrences(T element, int occurrences); @Override void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer); @Override void forEach(Consumer<? super T> consumer); @Override int hashCode(); @Override boolean equals(Object other);  }### Answer:
@Test public void removeOccurrences() { Assert.assertFalse(this.testObj.removeOccurrences("1", 1)); Assert.assertEquals(MutableBag.empty(), this.testObj); this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertTrue(this.testObj.removeOccurrences("1", 2)); Assert.assertEquals(MutableBag.of("2", "2", "3", "3", "3"), this.testObj); Assert.assertEquals(5, this.testObj.size()); Assert.assertTrue(this.testObj.removeOccurrences("2", 2)); Assert.assertEquals(MutableBag.of("3", "3", "3"), this.testObj); Assert.assertFalse(this.testObj.removeOccurrences("2", 2)); }