DataRegionMasterResource extends AbstractDataResource { @POST @Path("regions") public Response add(@Context UriInfo uriInfo, RegionDocument request) { RegionDocument result = getRegionMaster().add(request); URI createdUri = (new DataRegionResource()).uriVersion(uriInfo.getBaseUri(), result.getUniqueId()); return responseCreatedObject(createdUri, result); } DataRegionMasterResource(final RegionMaster regionMaster); RegionMaster getRegionMaster(); @GET Response getHateaos(@Context UriInfo uriInfo); @HEAD @Path("regions") Response status(); @POST @Path("regionSearches") Response search(RegionSearchRequest request); @POST @Path("regions") Response add(@Context UriInfo uriInfo, RegionDocument request); @Path("regions/{regionId}") DataRegionResource findRegion(@PathParam("regionId") String idStr); static URI uriSearch(URI baseUri); static URI uriAdd(URI baseUri);  }
@Test public void testAddRegion() { final ManageableRegion target = new ManageableRegion(); target.setFullName("Bananaville"); final RegionDocument request = new RegionDocument(target); final RegionDocument result = new RegionDocument(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()); }