DataConventionMasterResource extends AbstractDataResource { @POST @Path("conventions") public Response add(@Context UriInfo uriInfo, ConventionDocument request) { ConventionDocument result = getConventionMaster().add(request); URI createdUri = (new DataConventionResource()).uriVersion(uriInfo.getBaseUri(), result.getUniqueId()); return responseCreatedObject(createdUri, result); } DataConventionMasterResource(final ConventionMaster conventionMaster); ConventionMaster getConventionMaster(); @GET Response getHateaos(@Context UriInfo uriInfo); @HEAD @Path("conventions") Response status(); @GET @Path("metaData") Response metaData(@Context UriInfo uriInfo); @POST @Path("conventionSearches") Response search(ConventionSearchRequest request); @POST @Path("conventions") Response add(@Context UriInfo uriInfo, ConventionDocument request); @Path("conventions/{conventionId}") DataConventionResource findConvention(@PathParam("conventionId") String idStr); static URI uriMetaData(URI baseUri, ConventionMetaDataRequest request); static URI uriSearch(URI baseUri); static URI uriAdd(URI baseUri);  }
@Test public void testAddConvention() { final ManageableConvention target = new MockConvention("Test", ExternalIdBundle.of("A", "B"), Currency.GBP); final ConventionDocument request = new ConventionDocument(target); final ConventionDocument result = new ConventionDocument(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()); }