InstancesResource { @POST @Consumes(APPLICATION_JSON) public Response launchInstances(List<Instance> instances) { instancesService.launchInstances(instances); return ok(); } @Autowired  InstancesResource(InstancesService instancesService); @GET @Path("/{instanceId}") Response getInstanceById(@PathParam("instanceId") String instanceId); @POST @Consumes(APPLICATION_JSON) Response launchInstances(List<Instance> instances); @PUT @Path("/start") @Consumes(APPLICATION_JSON) Response startInstances(List<String> instanceIds); @PUT @Path("/shutdown") @Consumes(APPLICATION_JSON) Response shutdownInstances(List<String> instanceIds); @PUT @Path("/pause") @Consumes(APPLICATION_JSON) Response pauseInstances(List<String> instanceIds); @PUT @Path("/resume") @Consumes(APPLICATION_JSON) Response resumeInstances(List<String> instanceIds); @PUT @Path("/suspend") @Consumes(APPLICATION_JSON) Response suspendInstances(List<String> instanceIds); @PUT @Path("/resize/{flavorId}") @Consumes(APPLICATION_JSON) Response resizeInstances(@PathParam("flavorId") String flavorId, List<String> instanceIds); @PUT @Path("/rebuild/{imageId}") @Consumes(APPLICATION_JSON) Response rebuildInstances(@PathParam("imageId") String imageId, List<String> instanceIds); @PUT @Path("/rename") @Consumes(APPLICATION_JSON) Response renameInstances(Map<String, String> newNames); @PUT @Path("/reboot") @Consumes(APPLICATION_JSON) Response rebootInstances(List<String> instanceIds); @PUT @Path("/hard-reboot") @Consumes(APPLICATION_JSON) Response hardRebootInstances(List<String> instanceIds); @POST @Path("/delete") @Consumes(APPLICATION_JSON) Response deleteInstances(List<String> instanceIds);  }
@Test public void testLaunchInstances() throws Exception { List<Instance> instances = new ArrayList<>(); Instance instance = EntityGenerator.getInstance(); instance.setId("another-id"); instances.add(instance); assertThat(instancesAware.getInstances(), hasSize(1)); Response<ResponseBody> response = getApi().launch(instances).execute(); assertThat(response.isSuccessful(), is(true)); assertThat(instancesAware.getInstances(), hasSize(2)); }