CombinedMaster implements AbstractMaster<D> { @Override public final List<UniqueId> replaceVersion(final UniqueId uniqueId, final List<D> replacementDocuments) { final String scheme = uniqueId.getScheme(); final M master = getMasterByScheme(scheme); if (master != null) { return master.replaceVersion(uniqueId, replacementDocuments); } return (new Try<List<UniqueId>>() { @Override public List<UniqueId> tryMaster(final M master) { return master.replaceVersion(uniqueId, replacementDocuments); } }).each(scheme); } protected  CombinedMaster(List<M> masterList); @Override D get(final UniqueId uniqueId); @Override D get(final ObjectIdentifiable objectId, final VersionCorrection versionCorrection); @Override D add(final D document); @Override D update(final D document); @Override void remove(final ObjectIdentifiable objectIdentifiable); @Override D correct(final D document); @Override final List<UniqueId> replaceVersion(final UniqueId uniqueId, final List<D> replacementDocuments); @Override final List<UniqueId> replaceAllVersions(final ObjectIdentifiable objectId, final List<D> replacementDocuments); @Override List<UniqueId> replaceVersions(final ObjectIdentifiable objectId, final List<D> replacementDocuments); @Override final void removeVersion(final UniqueId uniqueId); @Override final UniqueId replaceVersion(D replacementDocument); @Override final UniqueId addVersion(ObjectIdentifiable objectId, D documentToAdd); @Override Map<UniqueId, D> get(Collection<UniqueId> uniqueIds);  }
@Test public void replaceVersionUniqueIdListD() { cMaster.replaceVersion(u1, Lists.newArrayList(d1)); cMaster.replaceVersion(u1, Lists.newArrayList(d1)); verify(m1, times(2)).replaceVersion(u1, Lists.newArrayList(d1)); }
@Test public void replaceVersionD() { cMaster.replaceVersion(d1); cMaster.replaceVersion(d1); verify(m1, times(2)).replaceVersion(u1, Collections.singletonList(d1)); }