DataSecurityMasterResource extends AbstractDataResource { @POST @Path("securities") public Response add(@Context UriInfo uriInfo, SecurityDocument request) { SecurityDocument result = getSecurityMaster().add(request); URI createdUri = (new DataSecurityResource()).uriVersion(uriInfo.getBaseUri(), result.getUniqueId()); return responseCreatedObject(createdUri, result); } DataSecurityMasterResource(final SecurityMaster securityMaster); SecurityMaster getSecurityMaster(); @GET Response getHateaos(@Context UriInfo uriInfo); @HEAD @Path("securities") Response status(); @GET @Path("metaData") Response metaData(@Context UriInfo uriInfo); @POST @Path("securitySearches") Response search(SecuritySearchRequest request); @POST @Path("securities") Response add(@Context UriInfo uriInfo, SecurityDocument request); @Path("securities/{securityId}") DataSecurityResource findSecurity(@PathParam("securityId") String idStr); static URI uriMetaData(URI baseUri, SecurityMetaDataRequest request); static URI uriSearch(URI baseUri); static URI uriAdd(URI baseUri);  }
@Test public void testAddSecurity() { final ManageableSecurity target = new ManageableSecurity(null, "Name", "Type", ExternalIdBundle.of("C", "D")); final SecurityDocument request = new SecurityDocument(target); final SecurityDocument result = new SecurityDocument(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()); }