DataUserMasterResource extends AbstractDataResource { @POST @Path("users") public Response add(@Context UriInfo uriInfo, ManageableUser user) { UniqueId result = getUserMaster().add(user); URI createdUri = uriUserById(uriInfo.getBaseUri(), result); return responseCreatedObject(createdUri, result); } DataUserMasterResource(final UserMaster userMaster); UserMaster getUserMaster(); @GET Response getHateaos(@Context UriInfo uriInfo); @HEAD @Path("users") Response status(); @POST @Path("userSearches") Response search(UserSearchRequest request); @POST @Path("users") Response add(@Context UriInfo uriInfo, ManageableUser user); @GET @Path("users/{objectId}") Response getById(@PathParam("objectId") String idStr); @PUT @Path("users/{objectId}") Response updateById(@Context UriInfo uriInfo, @PathParam("objectId") String idStr, ManageableUser user); @DELETE @Path("users/{objectId}") void removeById(@PathParam("objectId") String idStr); @GET @Path("users/{objectId}/eventHistory") Response eventHistoryById(@PathParam("objectId") String idStr); @GET @Path("users/exists/{userName}") Response nameExists(@PathParam("userName") String userName); @GET @Path("users/name/{userName}") Response getByName(@PathParam("userName") String userName); @PUT @Path("users/name/{userName}") Response updateByName(@Context UriInfo uriInfo, @PathParam("userName") String userName, ManageableUser user); @DELETE @Path("users/name/{userName}") void removeByName(@PathParam("userName") String userName); @GET @Path("users/name/{userName}/eventHistory") Response eventHistoryByName(@PathParam("userName") String userName); @GET @Path("users/name/{userName}/account") Response accountByName(@PathParam("userName") String userName); static URI uriSearch(URI baseUri); static URI uriAdd(URI baseUri); static URI uriUserById(URI baseUri, ObjectIdentifiable objectId); static URI uriUserByName(URI baseUri, String userName); static URI uriNameExists(URI baseUri, String userName); static URI uriEventHistory(URI baseUri, UserEventHistoryRequest request); static URI uriUserAccountByName(URI baseUri, String userName);  }
@Test public void testAddUser() { final ManageableUser input = new ManageableUser("bob"); input.setAlternateIds(ExternalIdBundle.of("A", "B")); input.setEmailAddress("bob@bob.com"); input.getProfile().setDisplayName("Test"); input.getProfile().setZone(ZoneId.of("Europe/London")); when(_underlying.add(input)).thenReturn(UID); Response test = _resource.add(_uriInfo, input); assertEquals(Status.CREATED.getStatusCode(), test.getStatus()); assertEquals(UID, FudgeResponse.unwrap(test.getEntity())); }