AdminResource implements Serializable { @PUT @Path("accounts") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated Account"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @ApiOperation(value = "Update account", response = AccountDTO.class) @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public AccountDTO updateAccount( @ApiParam(required = true, value = "Updated account") AccountDTO accountDTO) throws EntityNotFoundException, NotAllowedException { Account account = accountManager.updateAccount( accountDTO.getLogin(), accountDTO.getName(), accountDTO.getEmail(), accountDTO.getLanguage(), accountDTO.getNewPassword(), accountDTO.getTimeZone()); AccountDTO accountDToResult = mapper.map(account, AccountDTO.class); accountDToResult.setAdmin(UserGroupMapping.ADMIN_ROLE_ID .equals(accountManager.getUserGroupMapping(accountDTO.getLogin()).getGroupName())); return accountDToResult; } AdminResource(); @PostConstruct void init(); @GET @Path("disk-usage-stats") @ApiOperation(value = "Get disk usage stats", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of disk usage statistics"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) JsonObject getDiskSpaceUsageStats(); @GET @Path("users-stats") @ApiOperation(value = "Get users stats", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of user statistics"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) JsonObject getUsersStats(); @GET @Path("documents-stats") @ApiOperation(value = "Get documents stats", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of documents statistics"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) JsonObject getDocumentsStats(); @GET @Path("products-stats") @ApiOperation(value = "Get products stats", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of products statistics"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) JsonObject getProductsStats(); @GET @Path("parts-stats") @ApiOperation(value = "Get parts stats", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of parts statistics"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) JsonObject getPartsStats(); @PUT @ApiOperation(value = "Synchronize index for given workspace", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 202, message = "Accepted delete operation (asynchronous method)"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("index/{workspaceId}") Response indexWorkspaceData(
            @ApiParam(value = "Workspace id", required = true) @PathParam("workspaceId") String workspaceId); @PUT @ApiOperation(value = "Synchronize index for all workspaces", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 202, message = "Accepted delete operation (asynchronous method)"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("index-all") Response indexAllWorkspaces(); @GET @Path("platform-options") @ApiOperation(value = "Get platform options", response = PlatformOptionsDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of PlatformOptions"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) PlatformOptionsDTO getPlatformOptions(); @PUT @Path("platform-options") @ApiOperation(value = "Set platform options", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful update of PlatformOptions"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Response setPlatformOptions(
            @ApiParam("Options to set") PlatformOptionsDTO platformOptionsDTO); @PUT @ApiOperation(value = "Enable or disable workspace", response = WorkspaceDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated Workspace"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("workspace/{workspaceId}/enable") @Produces(MediaType.APPLICATION_JSON) WorkspaceDTO enableWorkspace(
            @ApiParam(value = "Workspace id", required = true) @PathParam("workspaceId") String workspaceId,
            @ApiParam(value = "Enabled", required = true) @QueryParam("enabled") boolean enabled); @PUT @ApiOperation(value = "Enable or disable account", response = AccountDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated Account"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("accounts/{login}/enable") @Produces(MediaType.APPLICATION_JSON) AccountDTO enableAccount(
            @ApiParam(value = "Workspace id", required = true) @PathParam("login") String login,
            @ApiParam(value = "Enabled", required = true) @QueryParam("enabled") boolean enabled); @GET @Path("accounts") @ApiOperation(value = "Get all registered accounts", response = AccountDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of Accounts"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) List<AccountDTO> getAccounts(); @PUT @Path("accounts") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated Account"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @ApiOperation(value = "Update account", response = AccountDTO.class) @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) AccountDTO updateAccount(
            @ApiParam(required = true, value = "Updated account") AccountDTO accountDTO); @GET @Path("providers") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of auth providers"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @ApiOperation(value = "Get detailed providers", response = OAuthProviderDTO.class, responseContainer = "List") @Produces(MediaType.APPLICATION_JSON) Response getDetailedProviders(); @GET @Path("providers/{id}") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of auth provider"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @ApiOperation(value = "Get detailed provider", response = OAuthProviderDTO.class) @Produces(MediaType.APPLICATION_JSON) OAuthProviderDTO getDetailedProvider(@ApiParam(value = "Provider id", required = true) @PathParam("id") int providerId); @POST @Path("providers") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful creation of auth provider"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @ApiOperation(value = "Create a new OAuth provider", response = OAuthProviderDTO.class) @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Response createProvider(@ApiParam(required = true, value = "Updated account") OAuthProviderDTO providerDTO); @PUT @Path("providers/{id}") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful update of auth provider"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @ApiOperation(value = "Update OAuth provider", response = OAuthProviderDTO.class) @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Response updateProvider(
            @ApiParam(value = "OAuthProvider id", required = true) @PathParam("id") int id,
            @ApiParam(required = true, value = "Updated provider") OAuthProviderDTO providerDTO); @DELETE @Path("providers/{id}") @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful removal of auth provider"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error")}) @ApiOperation(value = "Delete OAuth provider", response = Response.class) @Produces(MediaType.APPLICATION_JSON) Response removeProvider(
            @ApiParam(value = "OAuthProvider id", required = true) @PathParam("id") int id);  }
@Test public void updateAccount() throws EntityNotFoundException, NotAllowedException { Mockito.when(accountManager.updateAccount(accountDTO.getLogin(), accountDTO.getName(), accountDTO.getEmail(), accountDTO.getLanguage(), accountDTO.getNewPassword(), accountDTO.getTimeZone())).thenReturn(account); Mockito.when(accountManager.getUserGroupMapping(accountDTO.getLogin())).thenReturn(userGroupMapping); Mockito.when(accountManager.getUserGroupMapping(accountDTO.getLogin()).getGroupName()) .thenReturn(UserGroupMapping.ADMIN_ROLE_ID); AccountDTO accountDTOResult = adminResource.updateAccount(accountDTO); Assert.assertTrue(accountDTOResult.isAdmin()); }