SlotResource { @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response installSlot(@HeaderParam(AIRSHIP_AGENT_VERSION_HEADER) String agentVersion, InstallationRepresentation installation, @Context UriInfo uriInfo) { Preconditions.checkNotNull(installation, "installation must not be null"); checkAgentVersion(agent.getAgentStatus(), agentVersion); SlotStatus slotStatus = agent.install(installation.toInstallation()); return Response .created(getSelfUri(slotStatus.getId(), uriInfo.getBaseUri())) .entity(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 testInstallSlot() { assertInstallSlot(agent.getAgentStatus().getVersion()); }
@Test public void testInstallInvalidVersion() { try { resource.installSlot("invalid-version", InstallationRepresentation.from(APPLE_INSTALLATION), uriInfo); fail("Expected WebApplicationException"); } catch (VersionConflictException e) { assertEquals(e.getName(), AIRSHIP_AGENT_VERSION_HEADER); assertEquals(e.getVersion(), agent.getAgentStatus().getVersion()); } }
@Test(expectedExceptions = NullPointerException.class) public void testInstallNullDeployment() { resource.installSlot(null, null, uriInfo); }