@Test public void testFollowUser() throws Exception { assertFalse(alice.following.contains(bob)); final Response response = target("/bob/follow").request().cookie(aliceCookie).get(); assertNotNull(response); assertEquals(303, response.getStatus()); try (final MinijaxRequestContext ctx = createRequestContext()) { final Dao dao = ctx.getResource(Dao.class); assertTrue(dao.read(User.class, alice.getId()).following.contains(bob)); } }
@GET @Path("/{handle}/follow") @RolesAllowed("user") public Response followUser(@PathParam("handle") String handle) { security.getUserPrincipal().following.add(dao.readByHandle(User.class, handle)); dao.update(security.getUserPrincipal()); return Response.seeOther(URI.create("/")).build(); }
Minitwit { @GET @Path("/{handle}/follow") @RolesAllowed("user") public Response followUser(@PathParam("handle") String handle) { security.getUserPrincipal().following.add(dao.readByHandle(User.class, handle)); dao.update(security.getUserPrincipal()); return Response.seeOther(URI.create("/")).build(); } }
Minitwit { @GET @Path("/{handle}/follow") @RolesAllowed("user") public Response followUser(@PathParam("handle") String handle) { security.getUserPrincipal().following.add(dao.readByHandle(User.class, handle)); dao.update(security.getUserPrincipal()); return Response.seeOther(URI.create("/")).build(); }  }
Minitwit { @GET @Path("/{handle}/follow") @RolesAllowed("user") public Response followUser(@PathParam("handle") String handle) { security.getUserPrincipal().following.add(dao.readByHandle(User.class, handle)); dao.update(security.getUserPrincipal()); return Response.seeOther(URI.create("/")).build(); }  @GET Response timeline(); @GET @Path("/public") Response publicTimeline(); @GET @Path("/{handle}") Response userTimeline(@PathParam("handle") String handle); @GET @Path("/{handle}/follow") @RolesAllowed("user") Response followUser(@PathParam("handle") String handle); @POST @Path("/addmessage") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @RolesAllowed("user") Response addMessage(@FormParam("text") String text); @GET @Path("/login") View login(); @POST @Path("/login") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) Response login(
            @FormParam("email") String email,
            @FormParam("password") String password); @GET @Path("/logout") Response logout(); @GET @Path("/register") View register(); @POST @Path("/register") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) Response register(
            @FormParam("handle") String handle,
            @FormParam("email") String email,
            @FormParam("password") String password); static void main(String[] args); }
Minitwit { @GET @Path("/{handle}/follow") @RolesAllowed("user") public Response followUser(@PathParam("handle") String handle) { security.getUserPrincipal().following.add(dao.readByHandle(User.class, handle)); dao.update(security.getUserPrincipal()); return Response.seeOther(URI.create("/")).build(); }  @GET Response timeline(); @GET @Path("/public") Response publicTimeline(); @GET @Path("/{handle}") Response userTimeline(@PathParam("handle") String handle); @GET @Path("/{handle}/follow") @RolesAllowed("user") Response followUser(@PathParam("handle") String handle); @POST @Path("/addmessage") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @RolesAllowed("user") Response addMessage(@FormParam("text") String text); @GET @Path("/login") View login(); @POST @Path("/login") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) Response login(
            @FormParam("email") String email,
            @FormParam("password") String password); @GET @Path("/logout") Response logout(); @GET @Path("/register") View register(); @POST @Path("/register") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) Response register(
            @FormParam("handle") String handle,
            @FormParam("email") String email,
            @FormParam("password") String password); static void main(String[] args);  }