PriamInstanceResource { @GET public String getInstances() { StringBuilder response = new StringBuilder(); List<PriamInstance> allInstances = factory.getAllIds(config.getAppName()); for (PriamInstance node : allInstances) { response.append(node.toString()); response.append("\n"); } return response.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);  }
@Test public void getInstances( @Mocked final PriamInstance instance1, @Mocked final PriamInstance instance2, @Mocked final PriamInstance instance3) { new Expectations() { final List<PriamInstance> instances = ImmutableList.of(instance1, instance2, instance3); { config.getAppName(); result = APP_NAME; factory.getAllIds(APP_NAME); result = instances; instance1.toString(); result = "instance1"; instance2.toString(); result = "instance2"; instance3.toString(); result = "instance3"; } }; assertEquals("instance1\ninstance2\ninstance3\n", resource.getInstances()); }