NotifierInfoCatalogResource { @GET @Path("/notifiers") @Timed public Response listNotifiers(@Context UriInfo uriInfo, @Context SecurityContext securityContext) { List<QueryParam> queryParams = new ArrayList<>(); MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); Collection<Notifier> notifiers; if (params.isEmpty()) { notifiers = catalogService.listNotifierInfos(); } else { queryParams = WSUtils.buildQueryParameters(params); notifiers = catalogService.listNotifierInfos(queryParams); } if (notifiers != null) { boolean notifierUser = SecurityUtil.hasRole(authorizer, securityContext, Roles.ROLE_NOTIFIER_USER); if (notifierUser) { LOG.debug("Returning all Notifiers since user has role: {}", Roles.ROLE_NOTIFIER_USER); } else { notifiers = SecurityUtil.filter(authorizer, securityContext, Notifier.NAMESPACE, notifiers, READ); } return WSUtils.respondEntities(notifiers, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); } NotifierInfoCatalogResource(StreamlineAuthorizer authorizer, StreamCatalogService catalogService, FileStorage fileStorage); @GET @Path("/notifiers") @Timed Response listNotifiers(@Context UriInfo uriInfo, @Context SecurityContext securityContext); @GET @Path("/notifiers/{id}") @Timed Response getNotifierById(@PathParam("id") Long id, @Context SecurityContext securityContext); @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/notifiers") @Timed Response addNotifier(@FormDataParam("notifierJarFile") final InputStream inputStream,
                                @FormDataParam("notifierJarFile") final FormDataContentDisposition contentDispositionHeader,
                                @FormDataParam("notifierConfig") final FormDataBodyPart notifierConfig,
                                @Context SecurityContext securityContext); @DELETE @Path("/notifiers/{id}") @Timed Response removeNotifierInfo(@PathParam("id") Long id, @Context SecurityContext securityContext); @PUT @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/notifiers/{id}") @Timed Response addOrUpdateNotifierInfo(@PathParam("id") Long id,
                                            @FormDataParam("notifierJarFile") final InputStream inputStream,
                                            @FormDataParam("notifierJarFile") final FormDataContentDisposition contentDispositionHeader,
                                            @FormDataParam("notifierConfig") final FormDataBodyPart notifierConfig,
                                            @Context SecurityContext securityContext); @Timed @GET @Produces({"application/java-archive", "application/json"}) @Path("/notifiers/download/{notifierId}") Response downloadNotifier(@PathParam("notifierId") Long notifierId, @Context SecurityContext securityContext);  }
@Test public void testListNotifiers() { final Notifier notifier = new Notifier(); final QueryParam expectedQp = new QueryParam("notifierName", "email_notifier_1"); multiValuedMap.putSingle("notifierName", "email_notifier_1"); new Expectations() { { mockUriInfo.getQueryParameters(); times = 1; result = multiValuedMap; mockCatalogService.listNotifierInfos(Arrays.asList(expectedQp));times=1; result = Arrays.asList(notifier); } }; CollectionResponse collectionResponse = (CollectionResponse) resource.listNotifiers(mockUriInfo, securityContext).getEntity(); assertEquals(1, collectionResponse .getEntities().size()); assertEquals(notifier, collectionResponse.getEntities().iterator().next()); }