DataPositionSourceResource extends AbstractDataResource { @GET @Path("portfolios/{portfolioId}") public Response getPortfolio( @PathParam("portfolioId") String idStr, @QueryParam("version") String version, @QueryParam("versionAsOf") String versionAsOf, @QueryParam("correctedTo") String correctedTo) { final ObjectId objectId = ObjectId.parse(idStr); final VersionCorrection vc = VersionCorrection.parse(versionAsOf, correctedTo); if (version != null) { final Portfolio result = getPositionSource().getPortfolio(objectId.atVersion(version), vc); return responseOkObject(result); } else { final Portfolio result = getPositionSource().getPortfolio(objectId, vc); return responseOkObject(result); } } DataPositionSourceResource(final PositionSource positionSource); PositionSource getPositionSource(); @GET Response getHateaos(@Context UriInfo uriInfo); @GET @Path("portfolios/{portfolioId}") Response getPortfolio(
      @PathParam("portfolioId") String idStr,
      @QueryParam("version") String version,
      @QueryParam("versionAsOf") String versionAsOf,
      @QueryParam("correctedTo") String correctedTo); @GET @Path("nodes/{nodeId}") Response getNode(
      @PathParam("nodeId") String idStr,
      @QueryParam("version") String version,
      @QueryParam("versionAsOf") String versionAsOf,
      @QueryParam("correctedTo") String correctedTo); @GET @Path("positions/{positionId}") Response getPosition(
      @PathParam("positionId") String idStr,
      @QueryParam("version") String version,
      @QueryParam("versionAsOf") String versionAsOf,
      @QueryParam("correctedTo") String correctedTo); @GET @Path("trades/{tradeId}") Response getTrade(
      @PathParam("tradeId") String idStr,
      @QueryParam("version") String version); static URI uriGetPortfolio(URI baseUri, UniqueId uniqueId); static URI uriGetPortfolio(URI baseUri, ObjectId objectId, VersionCorrection vc); static URI uriGetNode(URI baseUri, UniqueId uniqueId); static URI uriGetPosition(URI baseUri, UniqueId uniqueId); static URI uriGetPosition(final URI baseUri, final ObjectId objectId, final VersionCorrection versionCorrection); static URI uriGetTrade(URI baseUri, UniqueId uniqueId);  }
@Test public void testGetPortfolioByUid() { final SimplePortfolio target = new SimplePortfolio("Test"); when(_underlying.getPortfolio(eq(UID), eq(VersionCorrection.LATEST))).thenReturn(target); final Response test = _resource.getPortfolio(OID.toString(), UID.getVersion(), null, null); assertEquals(Status.OK.getStatusCode(), test.getStatus()); assertSame(target, test.getEntity()); }
@Test public void testGetPortfolioByOid() { final SimplePortfolio target = new SimplePortfolio("Test"); when(_underlying.getPortfolio(eq(OID), eq(VC))).thenReturn(target); final Response test = _resource.getPortfolio(OID.toString(), null, VC.getVersionAsOfString(), VC.getCorrectedToString()); assertEquals(Status.OK.getStatusCode(), test.getStatus()); assertSame(target, test.getEntity()); }