MasterRegionSource extends AbstractMasterSource<Region, RegionDocument, RegionMaster> implements RegionSource { @SuppressWarnings({"unchecked", "rawtypes" }) @Override public Collection<Region> get(ExternalIdBundle bundle, VersionCorrection versionCorrection) { RegionSearchRequest request = new RegionSearchRequest(bundle); request.setVersionCorrection(versionCorrection); return (List) getMaster().search(request).getRegions(); } MasterRegionSource(final RegionMaster master); @SuppressWarnings({"unchecked", "rawtypes" }) @Override Collection<Region> get(ExternalIdBundle bundle, VersionCorrection versionCorrection); @Override ManageableRegion getHighestLevelRegion(ExternalId regionId); @Override ManageableRegion getHighestLevelRegion(ExternalIdBundle regionIds); @Override Map<ExternalIdBundle, Collection<Region>> getAll(Collection<ExternalIdBundle> bundles, VersionCorrection versionCorrection); @Override Collection<Region> get(ExternalIdBundle bundle); @Override Region getSingle(ExternalIdBundle bundle); @Override Region getSingle(ExternalIdBundle bundle, VersionCorrection versionCorrection); @Override Map<ExternalIdBundle, Region> getSingle(Collection<ExternalIdBundle> bundles, VersionCorrection versionCorrection);  }
@Test(expectedExceptions = DataNotFoundException.class) public void test_getRegion_UniqueId_notFound() throws Exception { RegionMaster mock = mock(RegionMaster.class); when(mock.get(UID)).thenThrow(new DataNotFoundException("")); MasterRegionSource test = new MasterRegionSource(mock); try { test.get(UID); } finally { verify(mock, times(1)).get(UID); } }
@Test(expectedExceptions = DataNotFoundException.class) public void test_getRegion_ObjectId_notFound() throws Exception { RegionMaster mock = mock(RegionMaster.class); when(mock.get(OID, VC)).thenThrow(new DataNotFoundException("")); MasterRegionSource test = new MasterRegionSource(mock); try { test.get(OID, VC); } finally { verify(mock, times(1)).get(OID, VC); } }