CombinedMaster implements AbstractMaster<D> { @Override public D get(final UniqueId uniqueId) { final M master = getMasterByScheme(uniqueId.getScheme()); if (master != null) { return master.get(uniqueId); } return (new Try<D>() { @Override public D tryMaster(final M master) { return master.get(uniqueId); } }).each(uniqueId.getScheme()); } 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 getUniqueId() { when(m1.get(u1)).thenReturn(d1); cMaster.get(u1); cMaster.get(u1); verify(m1, times(2)).get(u1); }
@Test public void getObjectIdentifiableVersionCorrection() { VersionCorrection vc = VersionCorrection.LATEST; when(m1.get(o1, vc)).thenReturn(d1); cMaster.get(o1, vc); cMaster.get(o1, vc); verify(m1, times(2)).get(o1, vc); }
@Test public void get() { ArrayList<UniqueId> getList = Lists.newArrayList(u1, u2); when(m1.get(u2)).thenThrow(new IllegalArgumentException()); cMaster.get(getList); cMaster.get(getList); verify(m1, times(2)).get(u1); verify(m2, times(2)).get(u2); }