DataExchangeMasterResource extends AbstractDataResource { @POST @Path("exchanges") public Response add(@Context UriInfo uriInfo, ExchangeDocument request) { ExchangeDocument result = getExchangeMaster().add(request); URI createdUri = (new DataExchangeResource()).uriVersion(uriInfo.getBaseUri(), result.getUniqueId()); return responseCreatedObject(createdUri, result); } DataExchangeMasterResource(final ExchangeMaster exchangeMaster); ExchangeMaster getExchangeMaster(); @GET Response getHateaos(@Context UriInfo uriInfo); @HEAD @Path("exchanges") Response status(); @POST @Path("exchangeSearches") Response search(ExchangeSearchRequest request); @POST @Path("exchanges") Response add(@Context UriInfo uriInfo, ExchangeDocument request); @Path("exchanges/{exchangeId}") DataExchangeResource findExchange(@PathParam("exchangeId") String idStr); static URI uriSearch(URI baseUri); static URI uriAdd(URI baseUri);  }
@Test public void testAddExchange() { final ManageableExchange target = new ManageableExchange(ExternalIdBundle.of("A", "B"), "Test", ExternalIdBundle.EMPTY, ZoneId.of("Europe/London")); final ExchangeDocument request = new ExchangeDocument(target); final ExchangeDocument result = new ExchangeDocument(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()); }