Mname { @GET @Path("/{role}/{env}/{job}/{instance}") public Response get( @PathParam("role") String role, @PathParam("env") String env, @PathParam("job") String job, @PathParam("instance") int instanceId, @Context UriInfo uriInfo) { return get(role, env, job, instanceId, uriInfo, Optional.absent()); } @Inject  Mname(Storage storage); @GET Response getUsage(); @GET @Path("/{role}/{env}/{job}/{instance}/{forward:.+}") Response getWithForwardRequest(
      @PathParam("role") String role,
      @PathParam("env") String env,
      @PathParam("job") String job,
      @PathParam("instance") int instanceId,
      @PathParam("forward") String forward,
      @Context UriInfo uriInfo); @PUT @Path("/{role}/{env}/{job}/{instance}/{forward:.+}") Response putWithForwardRequest(
      @PathParam("role") String role,
      @PathParam("env") String env,
      @PathParam("job") String job,
      @PathParam("instance") int instanceId,
      @PathParam("forward") String forward,
      @Context UriInfo uriInfo); @POST @Path("/{role}/{env}/{job}/{instance}/{forward:.+}") Response postWithForwardRequest(
      @PathParam("role") String role,
      @PathParam("env") String env,
      @PathParam("job") String job,
      @PathParam("instance") int instanceId,
      @PathParam("forward") String forward,
      @Context UriInfo uriInfo); @DELETE @Path("/{role}/{env}/{job}/{instance}/{forward:.+}") Response deleteWithForwardRequest(
      @PathParam("role") String role,
      @PathParam("env") String env,
      @PathParam("job") String job,
      @PathParam("instance") int instanceId,
      @PathParam("forward") String forward,
      @Context UriInfo uriInfo); @GET @Path("/{role}/{env}/{job}/{instance}") Response get(
      @PathParam("role") String role,
      @PathParam("env") String env,
      @PathParam("job") String job,
      @PathParam("instance") int instanceId,
      @Context UriInfo uriInfo); @PUT @Path("/{role}/{env}/{job}/{instance}") Response put(
      @PathParam("role") String role,
      @PathParam("env") String env,
      @PathParam("job") String job,
      @PathParam("instance") int instanceId,
      @Context UriInfo uriInfo); @POST @Path("/{role}/{env}/{job}/{instance}") Response post(
      @PathParam("role") String role,
      @PathParam("env") String env,
      @PathParam("job") String job,
      @PathParam("instance") int instanceId,
      @Context UriInfo uriInfo); @DELETE @Path("/{role}/{env}/{job}/{instance}") Response delete(
      @PathParam("role") String role,
      @PathParam("env") String env,
      @PathParam("job") String job,
      @PathParam("instance") int instanceId,
      @Context UriInfo uriInfo);  }
@Test public void testInstanceAbsent() { storage.expectOperations(); storage.expectTaskFetch(TASK_QUERY); replayAndStart(); ClientResponse response = getRequestBuilder("/mname/myrole/test/myjob/1") .get(ClientResponse.class); assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); }
@Test public void testInstanceNotRunning() { storage.expectOperations(); IScheduledTask pending = IScheduledTask.build(TASK.newBuilder().setStatus(ScheduleStatus.PENDING)); storage.expectTaskFetch(TASK_QUERY, pending); replayAndStart(); ClientResponse response = getRequestBuilder("/mname/myrole/test/myjob/1") .get(ClientResponse.class); assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); }
@Test public void testInstanceNoHttp() { storage.expectOperations(); ScheduledTask builder = TASK.newBuilder(); builder.getAssignedTask().setAssignedPorts(ImmutableMap.of("telnet", 80)); IScheduledTask noHttp = IScheduledTask.build(builder); storage.expectTaskFetch(TASK_QUERY, noHttp); replayAndStart(); ClientResponse response = getRequestBuilder("/mname/myrole/test/myjob/1") .get(ClientResponse.class); assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus()); }