@Test public void postFeedback() throws Exception { when(authorization.getUser("foo")).thenReturn(username); when(httpHeader.headers(CREATED)).thenReturn(responseBuilder); when(responseBuilder.build()).thenReturn(response); feedbackResource.postFeedback(userFeedback, "foo"); verify(authorization).getUser("foo"); verify(userFeedback).setUsername(username); verify(feedback).createUserFeedback(userFeedback); verify(httpHeader).headers(CREATED); verify(responseBuilder, times(0)).entity(anyObject()); verify(responseBuilder).build(); }
@POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Submit feedback") @Timed public Response postFeedback( @ApiParam(name = "userFeedback", value = "Please see model example", required = true) final UserFeedback userFeedback, @HeaderParam(AUTHORIZATION) @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true) final String authorizationHeader) { try { userFeedback.setUsername(authorization.getUser(authorizationHeader)); feedback.createUserFeedback(userFeedback); return httpHeader.headers(CREATED).build(); } catch (Exception exception) { LOGGER.error("postFeedback failed for userFeedback={} with error:", userFeedback, exception); throw exception; } }
FeedbackResource { @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Submit feedback") @Timed public Response postFeedback( @ApiParam(name = "userFeedback", value = "Please see model example", required = true) final UserFeedback userFeedback, @HeaderParam(AUTHORIZATION) @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true) final String authorizationHeader) { try { userFeedback.setUsername(authorization.getUser(authorizationHeader)); feedback.createUserFeedback(userFeedback); return httpHeader.headers(CREATED).build(); } catch (Exception exception) { LOGGER.error("postFeedback failed for userFeedback={} with error:", userFeedback, exception); throw exception; } } }
FeedbackResource { @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Submit feedback") @Timed public Response postFeedback( @ApiParam(name = "userFeedback", value = "Please see model example", required = true) final UserFeedback userFeedback, @HeaderParam(AUTHORIZATION) @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true) final String authorizationHeader) { try { userFeedback.setUsername(authorization.getUser(authorizationHeader)); feedback.createUserFeedback(userFeedback); return httpHeader.headers(CREATED).build(); } catch (Exception exception) { LOGGER.error("postFeedback failed for userFeedback={} with error:", userFeedback, exception); throw exception; } } @Inject  FeedbackResource(final Authorization authorization, final Feedback feedback, final HttpHeader httpHeader); }
FeedbackResource { @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Submit feedback") @Timed public Response postFeedback( @ApiParam(name = "userFeedback", value = "Please see model example", required = true) final UserFeedback userFeedback, @HeaderParam(AUTHORIZATION) @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true) final String authorizationHeader) { try { userFeedback.setUsername(authorization.getUser(authorizationHeader)); feedback.createUserFeedback(userFeedback); return httpHeader.headers(CREATED).build(); } catch (Exception exception) { LOGGER.error("postFeedback failed for userFeedback={} with error:", userFeedback, exception); throw exception; } } @Inject  FeedbackResource(final Authorization authorization, final Feedback feedback, final HttpHeader httpHeader); @GET @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Get all feedback") @Timed Response getAllUserFeedback(
            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Submit feedback") @Timed Response postFeedback(
            @ApiParam(name = "userFeedback", value = "Please see model example", required = true)
            final UserFeedback userFeedback,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("/users/{username}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Get single user feedback") @Timed Response getUserFeedback(
            @PathParam("username")
            @ApiParam(value = "User name")
            final UserInfo.Username username,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); }
FeedbackResource { @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Submit feedback") @Timed public Response postFeedback( @ApiParam(name = "userFeedback", value = "Please see model example", required = true) final UserFeedback userFeedback, @HeaderParam(AUTHORIZATION) @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true) final String authorizationHeader) { try { userFeedback.setUsername(authorization.getUser(authorizationHeader)); feedback.createUserFeedback(userFeedback); return httpHeader.headers(CREATED).build(); } catch (Exception exception) { LOGGER.error("postFeedback failed for userFeedback={} with error:", userFeedback, exception); throw exception; } } @Inject  FeedbackResource(final Authorization authorization, final Feedback feedback, final HttpHeader httpHeader); @GET @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Get all feedback") @Timed Response getAllUserFeedback(
            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @POST @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Submit feedback") @Timed Response postFeedback(
            @ApiParam(name = "userFeedback", value = "Please see model example", required = true)
            final UserFeedback userFeedback,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader); @GET @Path("/users/{username}") @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @ApiOperation(value = "Get single user feedback") @Timed Response getUserFeedback(
            @PathParam("username")
            @ApiParam(value = "User name")
            final UserInfo.Username username,

            @HeaderParam(AUTHORIZATION)
            @ApiParam(value = EXAMPLE_AUTHORIZATION_HEADER, required = true)
            final String authorizationHeader);  }