DataPortfolioMasterResource extends AbstractDataResource { @POST @Path("portfolios") public Response add(@Context UriInfo uriInfo, PortfolioDocument request) { PortfolioDocument result = getPortfolioMaster().add(request); URI createdUri = (new DataPortfolioResource()).uriVersion(uriInfo.getBaseUri(), result.getUniqueId()); return responseCreatedObject(createdUri, result); } DataPortfolioMasterResource();  DataPortfolioMasterResource(final PortfolioMaster portfolioMaster); PortfolioMaster getPortfolioMaster(); @GET Response getHateaos(@Context UriInfo uriInfo); @HEAD @Path("portfolios") Response status(); @POST @Path("portfolioSearches") Response search(PortfolioSearchRequest request); @POST @Path("portfolios") Response add(@Context UriInfo uriInfo, PortfolioDocument request); @Path("nodes/{nodeId}") DataPortfolioNodeResource findPortfolioNode(@PathParam("nodeId") String idStr); @Path("portfolios/{portfolioId}") DataPortfolioResource findPortfolio(@PathParam("portfolioId") String idStr); @Path("portfolios/changeManager") DataChangeManagerResource getChangeManager(); static URI uriSearch(URI baseUri); static URI uriAdd(URI baseUri);  }
@Test public void testAddPortfolio() { final ManageablePortfolio target = new ManageablePortfolio("Portfolio A"); target.getRootNode().setName("RootNode"); target.getRootNode().addChildNode(new ManageablePortfolioNode("Child")); final PortfolioDocument request = new PortfolioDocument(target); final PortfolioDocument result = new PortfolioDocument(target); result.setUniqueId(UID); when(_underlying.add(same(request))).thenReturn(result); Response test = _resource.add(_uriInfo, request); assertEquals(Status.CREATED.getStatusCode(), test.getStatus()); assertSame(result, test.getEntity()); }