InviteService extends Service { @GET @Path("/{domain}") @Produces(APPLICATION_JSON) @ApiOperation( value = "Get invites by instance", response = InviteDto.class, responseContainer = "list" ) @ApiResponses({ @ApiResponse(code = 200, message = "The invitations successfully fetched"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 500, message = "Internal server error occurred") }) public Response getInvites( @ApiParam(value = "Domain id") @PathParam("domain") String domain, @ApiParam(value = "Instance id", required = true) @QueryParam("instance") String instance, @ApiParam("Skip count") @QueryParam("skipCount") @DefaultValue("0") long skipCount, @ApiParam("Max items") @QueryParam("maxItems") @DefaultValue("30") int maxItems) throws BadRequestException, ServerException { checkArgument(maxItems >= 0, "The number of items to return can't be negative."); checkArgument(skipCount >= 0, "The number of items to skip can't be negative."); checkArgument(!isNullOrEmpty(instance), "Instance id required"); Page<? extends Invite> invitesPage = inviteManager.getInvites(domain, instance, skipCount, maxItems); return Response.ok() .entity(invitesPage.getItems().stream().map(DtoConverter::asDto).collect(toList())) .header("Link", createLinkHeader(invitesPage)) .build(); } @Inject  InviteService(EmailValidator emailValidator, InviteManager inviteManager); @POST @Consumes(APPLICATION_JSON) @ApiOperation( value = "Invite unregistered user by email " + "or update permissions for already invited user", notes = "Invited user will receive email notification only on invitation creation" ) @ApiResponses({ @ApiResponse(code = 204, message = "The invitation successfully created/updated"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 409, message = "User with specified email is already registered"), @ApiResponse(code = 500, message = "Internal server error occurred") }) void invite(@ApiParam(value = "The invite to store", required = true) InviteDto inviteDto); @GET @Path("/{domain}") @Produces(APPLICATION_JSON) @ApiOperation( value = "Get invites by instance", response = InviteDto.class, responseContainer = "list" ) @ApiResponses({ @ApiResponse(code = 200, message = "The invitations successfully fetched"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 500, message = "Internal server error occurred") }) Response getInvites(
      @ApiParam(value = "Domain id") @PathParam("domain") String domain,
      @ApiParam(value = "Instance id", required = true) @QueryParam("instance") String instance,
      @ApiParam("Skip count") @QueryParam("skipCount") @DefaultValue("0") long skipCount,
      @ApiParam("Max items") @QueryParam("maxItems") @DefaultValue("30") int maxItems); @DELETE @Path("/{domain}") @ApiOperation(value = "Remove invite") @ApiResponses({ @ApiResponse(code = 204, message = "The invitation successfully removed"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 500, message = "Internal server error occurred") }) void remove(
      @ApiParam("Domain id") @PathParam("domain") String domain,
      @ApiParam(value = "Instance id", required = true) @QueryParam("instance") String instance,
      @ApiParam(value = "User email", required = true) @QueryParam("email") String email);  }
@Test public void shouldReturnInvitesByInstance() throws Exception { InviteDto invite = createInvite(); doReturn(new Page<>(Collections.singletonList(invite), 2, 1, 3)) .when(inviteManager) .getInvites(anyString(), anyString(), anyLong(), anyInt()); Response response = given() .auth() .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD) .contentType("application/json") .when() .expect() .statusCode(200) .get(SECURE_PATH + "/invite/organization?instance=org123&skipCount=2&maxItems=1"); List<InviteDto> result = unwrapDtoList(response, InviteDto.class); assertEquals(result.size(), 1); assertEquals(result.get(0), invite); verify(inviteManager).getInvites("organization", "org123", 2, 1); }