DataConventionSourceResource extends AbstractDataResource { @GET @Path("conventions/{conventionId}") public Response get( @PathParam("conventionId") String idStr, @QueryParam("version") String version, @QueryParam("versionAsOf") String versionAsOf, @QueryParam("correctedTo") String correctedTo) { final ObjectId objectId = ObjectId.parse(idStr); if (version != null) { final Convention result = getConventionSource().get(objectId.atVersion(version)); return responseOkObject(result); } else { final VersionCorrection vc = VersionCorrection.parse(versionAsOf, correctedTo); Convention result = getConventionSource().get(objectId, vc); return responseOkObject(result); } } DataConventionSourceResource(final ConventionSource conventionSource); ConventionSource getConventionSource(); @GET Response getHateaos(@Context UriInfo uriInfo); @GET @Path("conventions") Response search(
      @QueryParam("versionAsOf") String versionAsOf,
      @QueryParam("correctedTo") String correctedTo,
      @QueryParam("id") List<String> externalIdStrs); @GET @Path("conventions/{conventionId}") Response get(
      @PathParam("conventionId") String idStr,
      @QueryParam("version") String version,
      @QueryParam("versionAsOf") String versionAsOf,
      @QueryParam("correctedTo") String correctedTo); @GET @Path("conventionSearches/bulk") Response getBulk(
      @QueryParam("id") List<String> uniqueIdStrs); 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); static URI uriBulk(URI baseUri, Iterable<UniqueId> uniqueIds); @GET @Path("conventionSearches/list") Response searchList(@QueryParam("id") List<String> externalIdStrs); @GET @Path("conventionSearches/single") Response searchSingle(
      @QueryParam("id") List<String> externalIdStrs,
      @QueryParam("versionAsOf") String versionAsOf,
      @QueryParam("correctedTo") String correctedTo,
      @QueryParam("type") String typeStr); static URI uriSearchList(URI baseUri, ExternalIdBundle bundle); static URI uriSearchSingle(URI baseUri, ExternalIdBundle bundle, VersionCorrection vc); static URI uriSearchSingle(URI baseUri, ExternalIdBundle bundle, VersionCorrection vc, Class<?> type); @GET @Path("debugInfo") FudgeMsgEnvelope getDebugInfo();  }
@Test public void testGetConventionByUid() { final MockConvention target = new MockConvention("TEST"); 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 testGetConventionByOid() { final MockConvention target = new MockConvention("TEST"); 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()); }