DataPositionMasterResource extends AbstractDataResource { @POST @Path("positions") public Response add(@Context UriInfo uriInfo, PositionDocument request) { PositionDocument result = getPositionMaster().add(request); URI createdUri = (new DataPositionResource()).uriVersion(uriInfo.getBaseUri(), result.getUniqueId()); return responseCreatedObject(createdUri, result); } DataPositionMasterResource(final PositionMaster positionMaster); PositionMaster getPositionMaster(); @GET Response getHateaos(@Context UriInfo uriInfo); @HEAD @Path("positions") Response status(); @POST @Path("positionSearches") Response search(PositionSearchRequest request); @POST @Path("positions") Response add(@Context UriInfo uriInfo, PositionDocument request); @Path("positions/{positionId}") DataPositionResource findPosition(@PathParam("positionId") String idStr); @Path("trades/{tradeId}") DataTradeResource findTrade(@PathParam("tradeId") String idStr); static URI uriSearch(URI baseUri); static URI uriAdd(URI baseUri);  }
@Test public void testAddPosition() { final ManageablePosition target = new ManageablePosition(); target.setQuantity(BigDecimal.ONE); final PositionDocument request = new PositionDocument(target); final PositionDocument result = new PositionDocument(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()); }