@Ignore @Test public void shouldReturn200WhenStartDateAndEndDateSupplied() throws BadRequestException { operationResponse.setExecutedOkay(true); accounts = new ArrayList<Integer>(); for (int i = 0; i < 10; i++) { accounts.add(i); } when(alertService.getByAccountId(Matchers.anyInt(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyString(), Matchers.anyString())).thenReturn(null); Response resp = alertsResource.retrieveByAccountIds(null, null, accounts, Calendar.getInstance().toString(), Calendar.getInstance().toString(), false); Assert.assertEquals(200, resp.getStatus()); }
@GET @Path("account") public Response retrieveByAccountIds(@QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit, @QueryParam("account") List<Integer> accounts, @QueryParam("startDate") String startDate, @QueryParam("endDate") String endDate, @QueryParam("showStackTrace") boolean showStackTrace) { if (!isUserInRole("cp,ops,support")) { return ResponseFactory.accessDenied(); } List<Alert> domainCls; Alerts apiModelCls = new Alerts(); try { for (int account : accounts) { domainCls = alertService.getByAccountId(marker, limit, account, startDate, endDate); for (Alert dAlert : domainCls) { if (showStackTrace) { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class)); } else { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class, "SIMPLE_ALERT")); } } } return Response.status(200).entity(apiModelCls).build(); } catch (Exception e) { return ResponseFactory.getErrorResponse(e, null, null); } }
AlertsResource extends ManagementDependencyProvider { @GET @Path("account") public Response retrieveByAccountIds(@QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit, @QueryParam("account") List<Integer> accounts, @QueryParam("startDate") String startDate, @QueryParam("endDate") String endDate, @QueryParam("showStackTrace") boolean showStackTrace) { if (!isUserInRole("cp,ops,support")) { return ResponseFactory.accessDenied(); } List<Alert> domainCls; Alerts apiModelCls = new Alerts(); try { for (int account : accounts) { domainCls = alertService.getByAccountId(marker, limit, account, startDate, endDate); for (Alert dAlert : domainCls) { if (showStackTrace) { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class)); } else { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class, "SIMPLE_ALERT")); } } } return Response.status(200).entity(apiModelCls).build(); } catch (Exception e) { return ResponseFactory.getErrorResponse(e, null, null); } } }
AlertsResource extends ManagementDependencyProvider { @GET @Path("account") public Response retrieveByAccountIds(@QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit, @QueryParam("account") List<Integer> accounts, @QueryParam("startDate") String startDate, @QueryParam("endDate") String endDate, @QueryParam("showStackTrace") boolean showStackTrace) { if (!isUserInRole("cp,ops,support")) { return ResponseFactory.accessDenied(); } List<Alert> domainCls; Alerts apiModelCls = new Alerts(); try { for (int account : accounts) { domainCls = alertService.getByAccountId(marker, limit, account, startDate, endDate); for (Alert dAlert : domainCls) { if (showStackTrace) { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class)); } else { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class, "SIMPLE_ALERT")); } } } return Response.status(200).entity(apiModelCls).build(); } catch (Exception e) { return ResponseFactory.getErrorResponse(e, null, null); } }  }
AlertsResource extends ManagementDependencyProvider { @GET @Path("account") public Response retrieveByAccountIds(@QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit, @QueryParam("account") List<Integer> accounts, @QueryParam("startDate") String startDate, @QueryParam("endDate") String endDate, @QueryParam("showStackTrace") boolean showStackTrace) { if (!isUserInRole("cp,ops,support")) { return ResponseFactory.accessDenied(); } List<Alert> domainCls; Alerts apiModelCls = new Alerts(); try { for (int account : accounts) { domainCls = alertService.getByAccountId(marker, limit, account, startDate, endDate); for (Alert dAlert : domainCls) { if (showStackTrace) { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class)); } else { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class, "SIMPLE_ALERT")); } } } return Response.status(200).entity(apiModelCls).build(); } catch (Exception e) { return ResponseFactory.getErrorResponse(e, null, null); } }  @Path("{id: [1-9][0-9]*}") AlertResource retrieveAlertResource(@PathParam("id") int id); @GET Response retrieveAll(@QueryParam("status") String status, @QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit); @GET @Path("byloadbalancerids") Response retrieveByLoadBalancerids(@QueryParam("id") List<Integer> ids,
                                              @QueryParam("startDate") String startDate,
                                              @QueryParam("endDate") String endDate); @GET @Path("account") Response retrieveByAccountIds(@QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit, @QueryParam("account") List<Integer> accounts, @QueryParam("startDate") String startDate, @QueryParam("endDate") String endDate, @QueryParam("showStackTrace") boolean showStackTrace); @GET @Path("account/{aid: [1-9][0-9]*}") Response retrieveByAccountId_(@PathParam("aid") int accountId,
                                         @QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit,
                                         @QueryParam("startDate") String startDate,
                                         @QueryParam("endDate") String endDate); @GET @Path("cluster/{cid: [1-9][0-9]*}") Response retrieveByClusterId(@PathParam("cid") int cid,
                                        @QueryParam("startDate") String startDate,
                                        @QueryParam("endDate") String endDate); @GET @Path("loadbalancer") Response retrieveByLoadBalancerId(@QueryParam("id") Integer id, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit); @GET @Path("unacknowledged") Response retrieveAllUnacknowledged(@QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit); @GET @Path("atomhopper") Response retrieveAllByAtomHopperUnacknowledged(@QueryParam("marker") Integer marker,
                                                          @QueryParam("messageName") String messageName,
                                                          @QueryParam("limit") Integer limit); void setAlertResource(AlertResource alertResource); @GET @Path("atomhopper/byloadbalancerids") Response retrieveByLoadBalanceridsForAtomHopper(@QueryParam("id") List<Integer> ids,
                                                           @QueryParam("messageName") String messageName,
                                                           @QueryParam("startDate") String startDate,
                                                           @QueryParam("endDate") String endDate); }
AlertsResource extends ManagementDependencyProvider { @GET @Path("account") public Response retrieveByAccountIds(@QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit, @QueryParam("account") List<Integer> accounts, @QueryParam("startDate") String startDate, @QueryParam("endDate") String endDate, @QueryParam("showStackTrace") boolean showStackTrace) { if (!isUserInRole("cp,ops,support")) { return ResponseFactory.accessDenied(); } List<Alert> domainCls; Alerts apiModelCls = new Alerts(); try { for (int account : accounts) { domainCls = alertService.getByAccountId(marker, limit, account, startDate, endDate); for (Alert dAlert : domainCls) { if (showStackTrace) { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class)); } else { apiModelCls.getAlerts().add(getDozerMapper().map(dAlert, org.openstack.atlas.docs.loadbalancers.api.management.v1.Alert.class, "SIMPLE_ALERT")); } } } return Response.status(200).entity(apiModelCls).build(); } catch (Exception e) { return ResponseFactory.getErrorResponse(e, null, null); } }  @Path("{id: [1-9][0-9]*}") AlertResource retrieveAlertResource(@PathParam("id") int id); @GET Response retrieveAll(@QueryParam("status") String status, @QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit); @GET @Path("byloadbalancerids") Response retrieveByLoadBalancerids(@QueryParam("id") List<Integer> ids,
                                              @QueryParam("startDate") String startDate,
                                              @QueryParam("endDate") String endDate); @GET @Path("account") Response retrieveByAccountIds(@QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit, @QueryParam("account") List<Integer> accounts, @QueryParam("startDate") String startDate, @QueryParam("endDate") String endDate, @QueryParam("showStackTrace") boolean showStackTrace); @GET @Path("account/{aid: [1-9][0-9]*}") Response retrieveByAccountId_(@PathParam("aid") int accountId,
                                         @QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit,
                                         @QueryParam("startDate") String startDate,
                                         @QueryParam("endDate") String endDate); @GET @Path("cluster/{cid: [1-9][0-9]*}") Response retrieveByClusterId(@PathParam("cid") int cid,
                                        @QueryParam("startDate") String startDate,
                                        @QueryParam("endDate") String endDate); @GET @Path("loadbalancer") Response retrieveByLoadBalancerId(@QueryParam("id") Integer id, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit); @GET @Path("unacknowledged") Response retrieveAllUnacknowledged(@QueryParam("marker") Integer marker, @QueryParam("limit") Integer limit); @GET @Path("atomhopper") Response retrieveAllByAtomHopperUnacknowledged(@QueryParam("marker") Integer marker,
                                                          @QueryParam("messageName") String messageName,
                                                          @QueryParam("limit") Integer limit); void setAlertResource(AlertResource alertResource); @GET @Path("atomhopper/byloadbalancerids") Response retrieveByLoadBalanceridsForAtomHopper(@QueryParam("id") List<Integer> ids,
                                                           @QueryParam("messageName") String messageName,
                                                           @QueryParam("startDate") String startDate,
                                                           @QueryParam("endDate") String endDate);  }