@Test public void getInstance_notFound() { new Expectations() { { config.getAppName(); result = APP_NAME; factory.getInstance(APP_NAME, instanceInfo.getRegion(), NODE_ID); result = null; } }; try { resource.getInstance(NODE_ID); fail("Expected WebApplicationException thrown"); } catch (WebApplicationException e) { assertEquals(404, e.getResponse().getStatus()); assertEquals( "No priam instance with id " + NODE_ID + " found", e.getResponse().getEntity()); } }
@GET @Path("{id}") public String getInstance(@PathParam("id") int id) { PriamInstance node = getByIdIfFound(id); return node.toString(); }
PriamInstanceResource { @GET @Path("{id}") public String getInstance(@PathParam("id") int id) { PriamInstance node = getByIdIfFound(id); return node.toString(); } }
PriamInstanceResource { @GET @Path("{id}") public String getInstance(@PathParam("id") int id) { PriamInstance node = getByIdIfFound(id); return node.toString(); } @Inject // Note: do not parameterize the generic type variable to an implementation as it confuses // Guice in the binding.  PriamInstanceResource(
            IConfiguration config, IPriamInstanceFactory factory, InstanceInfo instanceInfo); }
PriamInstanceResource { @GET @Path("{id}") public String getInstance(@PathParam("id") int id) { PriamInstance node = getByIdIfFound(id); return node.toString(); } @Inject // Note: do not parameterize the generic type variable to an implementation as it confuses // Guice in the binding.  PriamInstanceResource(
            IConfiguration config, IPriamInstanceFactory factory, InstanceInfo instanceInfo); @GET String getInstances(); @GET @Path("{id}") String getInstance(@PathParam("id") int id); @POST Response createInstance(
            @QueryParam("id") int id,
            @QueryParam("instanceID") String instanceID,
            @QueryParam("hostname") String hostname,
            @QueryParam("ip") String ip,
            @QueryParam("rack") String rack,
            @QueryParam("token") String token); @DELETE @Path("{id}") Response deleteInstance(@PathParam("id") int id); }
PriamInstanceResource { @GET @Path("{id}") public String getInstance(@PathParam("id") int id) { PriamInstance node = getByIdIfFound(id); return node.toString(); } @Inject // Note: do not parameterize the generic type variable to an implementation as it confuses // Guice in the binding.  PriamInstanceResource(
            IConfiguration config, IPriamInstanceFactory factory, InstanceInfo instanceInfo); @GET String getInstances(); @GET @Path("{id}") String getInstance(@PathParam("id") int id); @POST Response createInstance(
            @QueryParam("id") int id,
            @QueryParam("instanceID") String instanceID,
            @QueryParam("hostname") String hostname,
            @QueryParam("ip") String ip,
            @QueryParam("rack") String rack,
            @QueryParam("token") String token); @DELETE @Path("{id}") Response deleteInstance(@PathParam("id") int id);  }