@Test public void createInstance(@Mocked final PriamInstance instance) { final String instanceID = "i-abc123"; final String hostname = "dom.com"; final String ip = "123.123.123.123"; final String rack = "us-east-1a"; final String token = "1234567890"; new Expectations() { { config.getAppName(); result = APP_NAME; factory.create(APP_NAME, NODE_ID, instanceID, hostname, ip, rack, null, token); result = instance; instance.getId(); result = NODE_ID; } }; Response response = resource.createInstance(NODE_ID, instanceID, hostname, ip, rack, token); assertEquals(201, response.getStatus()); assertEquals("/" + NODE_ID, response.getMetadata().getFirst("location").toString()); }
@POST public 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) { log.info( "Creating instance [id={}, instanceId={}, hostname={}, ip={}, rack={}, token={}", id, instanceID, hostname, ip, rack, token); PriamInstance instance = factory.create( config.getAppName(), id, instanceID, hostname, ip, rack, null, token); URI uri = UriBuilder.fromPath("/{id}").build(instance.getId()); return Response.created(uri).build(); }
PriamInstanceResource { @POST public 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) { log.info( "Creating instance [id={}, instanceId={}, hostname={}, ip={}, rack={}, token={}", id, instanceID, hostname, ip, rack, token); PriamInstance instance = factory.create( config.getAppName(), id, instanceID, hostname, ip, rack, null, token); URI uri = UriBuilder.fromPath("/{id}").build(instance.getId()); return Response.created(uri).build(); } }
PriamInstanceResource { @POST public 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) { log.info( "Creating instance [id={}, instanceId={}, hostname={}, ip={}, rack={}, token={}", id, instanceID, hostname, ip, rack, token); PriamInstance instance = factory.create( config.getAppName(), id, instanceID, hostname, ip, rack, null, token); URI uri = UriBuilder.fromPath("/{id}").build(instance.getId()); return Response.created(uri).build(); } @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 { @POST public 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) { log.info( "Creating instance [id={}, instanceId={}, hostname={}, ip={}, rack={}, token={}", id, instanceID, hostname, ip, rack, token); PriamInstance instance = factory.create( config.getAppName(), id, instanceID, hostname, ip, rack, null, token); URI uri = UriBuilder.fromPath("/{id}").build(instance.getId()); return Response.created(uri).build(); } @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 { @POST public 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) { log.info( "Creating instance [id={}, instanceId={}, hostname={}, ip={}, rack={}, token={}", id, instanceID, hostname, ip, rack, token); PriamInstance instance = factory.create( config.getAppName(), id, instanceID, hostname, ip, rack, null, token); URI uri = UriBuilder.fromPath("/{id}").build(instance.getId()); return Response.created(uri).build(); } @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);  }