Mname { @VisibleForTesting static Optional<Integer> getRedirectPort(IAssignedTask task) { Map<String, Integer> ports = task.getAssignedPorts(); for (String httpPortName : HTTP_PORT_NAMES) { Integer port = ports.get(httpPortName); if (port != null) { return Optional.of(port); } } return 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 testRedirectPort() { replayAndStart(); assertEquals(Optional.absent(), getRedirectPort(null)); assertEquals(Optional.absent(), getRedirectPort(ImmutableMap.of())); assertEquals(Optional.absent(), getRedirectPort(ImmutableMap.of("thrift", 5))); assertEquals(Optional.of(5), getRedirectPort(ImmutableMap.of("health", 5, "http", 6))); assertEquals(Optional.of(6), getRedirectPort(ImmutableMap.of("http", 6))); assertEquals(Optional.of(7), getRedirectPort(ImmutableMap.of("HTTP", 7))); assertEquals(Optional.of(8), getRedirectPort(ImmutableMap.of("web", 8))); assertEquals(Optional.of(9), getRedirectPort(ImmutableMap.of("admin", 9))); }