DataRegionSourceResource extends AbstractDataResource { @GET @Path("regions/{regionId}") public Response get( @PathParam("regionId") String idStr, @QueryParam("version") String version, @QueryParam("versionAsOf") String versionAsOf, @QueryParam("correctedTo") String correctedTo) { final ObjectId objectId = ObjectId.parse(idStr); if (version != null) { final Region result = getRegionSource().get(objectId.atVersion(version)); return responseOkObject(result); } else { final VersionCorrection vc = VersionCorrection.parse(versionAsOf, correctedTo); Region result = getRegionSource().get(objectId, vc); return responseOkObject(result); } } DataRegionSourceResource(final RegionSource regionSource); RegionSource getRegionSource(); @GET Response getHateaos(@Context UriInfo uriInfo); @GET @Path("regions") Response search(
      @QueryParam("versionAsOf") String versionAsOf,
      @QueryParam("correctedTo") String correctedTo,
      @QueryParam("id") List<String> externalIdStrs); @GET @Path("regions/{regionId}") Response get(
      @PathParam("regionId") String idStr,
      @QueryParam("version") String version,
      @QueryParam("versionAsOf") String versionAsOf,
      @QueryParam("correctedTo") String correctedTo); static URI uriSearch(URI baseUri, VersionCorrection vc, ExternalIdBundle bundle); static URI uriGet(URI baseUri, UniqueId uniqueId); static URI uriGet(URI baseUri, ObjectId objectId, VersionCorrection vc); @GET @Path("regionSearches/highest") Response searchHighest(@QueryParam("id") List<String> externalIdStrs); static URI uriSearchHighest(URI baseUri, ExternalIdBundle bundle);  }
@Test public void testGetRegionByUid() { final SimpleRegion target = new SimpleRegion(); target.setExternalIdBundle(BUNDLE); target.setName("Test"); when(_underlying.get(eq(UID))).thenReturn(target); Response test = _resource.get(OID.toString(), UID.getVersion(), "", ""); assertEquals(Status.OK.getStatusCode(), test.getStatus()); assertSame(target, test.getEntity()); }
@Test public void testGetRegionByOid() { final SimpleRegion target = new SimpleRegion(); target.setExternalIdBundle(BUNDLE); target.setName("Test"); when(_underlying.get(eq(OID), eq(VC))).thenReturn(target); Response test = _resource.get(OID.toString(), null, VC.getVersionAsOfString(), VC.getCorrectedToString()); assertEquals(Status.OK.getStatusCode(), test.getStatus()); assertSame(target, test.getEntity()); }