PrivilegeApiResource extends PrivilegeApiResourceSupport implements Resource, PrivilegeApiResourceDoc { @Override @GET @RequiresAuthentication @RequiresPermissions("nexus:privileges:read") @Path("{privilegeId}") public ApiPrivilege getPrivilege(@PathParam("privilegeId") final String privilegeId) { try { return toApiPrivilege(getDefaultAuthorizationManager().getPrivilege(privilegeId)); } catch (NoSuchPrivilegeException e) { log.debug("Attempt to retrieve privilege '{}' failed, as it wasn't found in the system.", privilegeId, e); throw new WebApplicationMessageException(Status.NOT_FOUND, String.format(PRIV_NOT_FOUND, privilegeId), MediaType.APPLICATION_JSON); } } @Inject  PrivilegeApiResource(final SecuritySystem securitySystem,
                              final Map<String, PrivilegeDescriptor> privilegeDescriptors); @Override @GET @RequiresAuthentication @RequiresPermissions("nexus:privileges:read") List<ApiPrivilege> getPrivileges(); @Override @GET @RequiresAuthentication @RequiresPermissions("nexus:privileges:read") @Path("{privilegeId}") ApiPrivilege getPrivilege(@PathParam("privilegeId") final String privilegeId); @Override @DELETE @RequiresAuthentication @RequiresPermissions("nexus:privileges:delete") @Path("{privilegeId}") void deletePrivilege(@PathParam("privilegeId") final String privilegeId); @Override @POST @RequiresAuthentication @RequiresPermissions("nexus:privileges:create") @Path("application") Response createPrivilege(final ApiPrivilegeApplicationRequest privilege); @Override @PUT @RequiresAuthentication @RequiresPermissions("nexus:privileges:update") @Path("application/{privilegeId}") void updatePrivilege(@PathParam("privilegeId") final String privilegeId,
                              final ApiPrivilegeApplicationRequest privilege); @Override @POST @RequiresAuthentication @RequiresPermissions("nexus:privileges:create") @Path("wildcard") Response createPrivilege(final ApiPrivilegeWildcardRequest privilege); @Override @PUT @RequiresAuthentication @RequiresPermissions("nexus:privileges:update") @Path("wildcard/{privilegeId}") void updatePrivilege(@PathParam("privilegeId") final String privilegeId,
                              final ApiPrivilegeWildcardRequest privilege);  }
@Test public void testGetPrivilege_notFound() { when(authorizationManager.getPrivilege("priv")).thenThrow(new NoSuchPrivilegeException("priv")); try { underTest.getPrivilege("priv"); fail("exception should have been thrown for missing privilege"); } catch (WebApplicationMessageException e) { assertThat(e.getResponse().getStatus(), is(404)); assertThat(e.getResponse().getMediaType(), is(MediaType.APPLICATION_JSON_TYPE)); assertThat(e.getResponse().getEntity().toString(), is("\"Privilege 'priv' not found.\"")); } }