@Override protected User createInstance() throws Exception { return new User(""); }
@Override public User to(UriInfo uriInfo, UserRepresentation representation) { // TODO: figure out difference between /{id} and handle in representation return update(uriInfo, representation, new User(representation.getHandle())); }
@Override protected User createNewDomainObject() { return new User(UUID.randomUUID().toString()).setBio("Bio"); }
@Override protected User createDomainObject() { return new User(UUID.randomUUID().toString()) .setName("Name") .setBio("Bio"); }
@Test public void shouldReponseSeeOtherWhenUserFound() throws Exception { final URL whoAmIURL = createTestURL(); Warp.initiate(new Activity() { @Override public void perform() { given(). redirects(). follow(false). then(). statusCode(Status.SEE_OTHER.getStatusCode()). when(). get(whoAmIURL.toExternalForm()); } }).inspect(new SetupAuth(new User("testuser"))); }
@Test public void shouldContainStateChangingMethodsForAuthorizedAccess() throws Exception { final URL testURL = createTestURL(); Warp.initiate(new Activity() { @Override public void perform() { given(). then(). statusCode(Status.OK.getStatusCode()). header("Allow", allOf( containsString("GET"), containsString("OPTIONS"), containsString("POST"), containsString("PUT"), containsString("DELETE"), containsString("PATCH"))). when(). options(testURL.toExternalForm()); } }).inspect(new SetupAuth(new User("testuser"))); }
public void registerUser(@Observes SuccessfulAuthentication event) { TwitterProfile profile = (TwitterProfile)event.getProfile(); User user = repository.get(profile.getScreenName()); if(user == null) { user = new User(profile.getScreenName()); } user.setName(profile.getFullName()); user.setBio(profile.getDescription()); user.setAvatarUrl(profile.getProfileImageUrl()); OAuthToken token = event.getToken(); user.setAccessToken(token.getSecret() + "|" + token.getToken()); if(user.getApiToken() == null) { user.setApiToken(UUID.randomUUID().toString()); } repository.store(user); } }