SlotResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response getAllSlotsStatus(@Context UriInfo uriInfo) { List<SlotStatusRepresentation> representations = Lists.newArrayList(); for (Slot slot : agent.getAllSlots()) { SlotStatus slotStatus = slot.status(); representations.add(SlotStatusRepresentation.from(slotStatus)); } return Response.ok(representations) .header(AIRSHIP_AGENT_VERSION_HEADER, agent.getAgentStatus().getVersion()) .build(); } @Inject  SlotResource(Agent agent); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response installSlot(@HeaderParam(AIRSHIP_AGENT_VERSION_HEADER) String agentVersion, InstallationRepresentation installation, @Context UriInfo uriInfo); @Path("{slotId}") @DELETE Response terminateSlot(@HeaderParam(AIRSHIP_AGENT_VERSION_HEADER) String agentVersion,
            @HeaderParam(AIRSHIP_SLOT_VERSION_HEADER) String slotVersion,
            @PathParam("slotId") UUID slotId); @Path("{slotId}") @GET @Produces(MediaType.APPLICATION_JSON) Response getSlotStatus(@PathParam("slotId") UUID slotId, @Context UriInfo uriInfo); @GET @Produces(MediaType.APPLICATION_JSON) Response getAllSlotsStatus(@Context UriInfo uriInfo);  }
@Test public void testGetAllSlotStatusEmpty() { Response response = resource.getAllSlotsStatus(uriInfo); assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); assertInstanceOf(response.getEntity(), Collection.class); assertEquals((Collection<?>) response.getEntity(), newArrayList()); assertEquals(response.getMetadata().get(AIRSHIP_AGENT_VERSION_HEADER).get(0), agent.getAgentStatus().getVersion()); }
@Test public void testGetAllSlotStatus() { SlotStatus slotStatus1 = agent.install(APPLE_INSTALLATION); SlotStatus slotStatus2 = agent.install(APPLE_INSTALLATION); Response response = resource.getAllSlotsStatus(uriInfo); assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); assertInstanceOf(response.getEntity(), Collection.class); assertEqualsNoOrder((Collection<?>) response.getEntity(), ImmutableMultiset.of( SlotStatusRepresentation.from(slotStatus1), SlotStatusRepresentation.from(slotStatus2) )); assertEquals(response.getMetadata().get(AIRSHIP_AGENT_VERSION_HEADER).get(0), agent.getAgentStatus().getVersion()); }