SlotResource { @Path("{slotId}") @GET @Produces(MediaType.APPLICATION_JSON) public Response getSlotStatus(@PathParam("slotId") UUID slotId, @Context UriInfo uriInfo) { Preconditions.checkNotNull(slotId, "slotId must not be null"); Slot slot = agent.getSlot(slotId); if (slot == null) { return Response.status(Response.Status.NOT_FOUND).build(); } SlotStatus slotStatus = slot.status(); return Response.ok(SlotStatusRepresentation.from(slotStatus)) .header(AIRSHIP_AGENT_VERSION_HEADER, agent.getAgentStatus().getVersion()) .header(AIRSHIP_SLOT_VERSION_HEADER, slotStatus.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 testGetSlotStatus() { SlotStatus slotStatus = agent.install(APPLE_INSTALLATION); URI requestUri = URI.create("http: Response response = resource.getSlotStatus(slotStatus.getId(), MockUriInfo.from(requestUri)); assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); assertEquals(response.getEntity(), SlotStatusRepresentation.from(slotStatus)); assertEquals(response.getMetadata().get(AIRSHIP_AGENT_VERSION_HEADER).get(0), agent.getAgentStatus().getVersion()); assertEquals(response.getMetadata().get(AIRSHIP_SLOT_VERSION_HEADER).get(0), slotStatus.getVersion()); assertNull(response.getMetadata().get("Content-Type")); }
@Test public void testGetSlotStatusUnknown() { Response response = resource.getSlotStatus(UUID.randomUUID(), MockUriInfo.from("http: assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); }
@Test(expectedExceptions = NullPointerException.class) public void testGetSlotStatusNull() { resource.getSlotStatus(null, MockUriInfo.from(URI.create("http: }