VmRestApi extends ApiBase implements VmApi { @Override public void performRestartOperationAsync(final String vmId, final FutureCallback<Task> responseCallback) throws IOException { String path = String.format("%s/%s/restart", getBasePath(), vmId); createObjectAsync(path, null, responseCallback); } VmRestApi(RestClient restClient); @Override String getBasePath(); @Override Vm getVm(String vmId); @Override void getVmAsync(final String vmId, final FutureCallback<Vm>
      responseCallback); @Override ResourceList<Task> getTasksForVm(String vmId); @Override void getTasksForVmAsync(final String vmId,
                                 final FutureCallback<ResourceList<Task>> responseCallback); @Override Task delete(String id); @Override void deleteAsync(final String id, final FutureCallback<Task> responseCallback); @Override Task addTagToVm(String vmId, Tag tag); @Override void addTagToVmAsync(final String vmId, Tag tag, final FutureCallback<Task> responseCallback); @Override Task performStartOperation(String vmId); @Override void performStartOperationAsync(final String vmId,
                                         final FutureCallback<Task> responseCallback); @Override Task performStopOperation(String vmId); @Override void performStopOperationAsync(final String vmId,
                                        final FutureCallback<Task> responseCallback); @Override Task performRestartOperation(String vmId); @Override void performRestartOperationAsync(final String vmId,
                                           final FutureCallback<Task> responseCallback); @Override Task performResumeOperation(String vmId); @Override void performResumeOperationAsync(final String vmId,
                                          final FutureCallback<Task> responseCallback); @Override Task performSuspendOperation(String vmId); @Override void performSuspendOperationAsync(final String vmId,
                                           final FutureCallback<Task> responseCallback); @Override Task attachDisk(String vmId, VmDiskOperation vmDiskOperation); @Override void attachDiskAsync(final String vmId, VmDiskOperation vmDiskOperation,
                              final FutureCallback<Task> responseCallback); @Override Task detachDisk(String vmId, VmDiskOperation vmDiskOperation); @Override void detachDiskAsync(final String vmId, VmDiskOperation vmDiskOperation,
                              final FutureCallback<Task> responseCallback); @Override Task uploadAndAttachIso(String vmId, String inputFileName); @Override Task detachIso(String vmId); @Override void detachIsoAsync(final String vmId, final FutureCallback<Task> responseCallback); @Override Task getNetworks(String vmId); @Override void getNetworksAsync(String vmId, FutureCallback<Task> responseCallback); static VmNetworks parseVmNetworksFromTask(Task task); @Override Task setMetadata(final String vmId, final VmMetadata metadata); @Override void setMetadataAsync(
      final String vmId,
      final VmMetadata metadata,
      final FutureCallback<Task> responseCallback);  }
@Test public void testPerformRestartOperationAsync() throws IOException, InterruptedException { final Task responseTask = new Task(); responseTask.setId("12345"); responseTask.setState("QUEUED"); responseTask.setQueuedTime(Date.from(Instant.now())); ObjectMapper mapper = new ObjectMapper(); String serializedTask = mapper.writeValueAsString(responseTask); setupMocks(serializedTask, HttpStatus.SC_CREATED); VmApi vmApi = new VmRestApi(restClient); final CountDownLatch latch = new CountDownLatch(1); vmApi.performRestartOperationAsync("foo", new FutureCallback<Task>() { @Override public void onSuccess(@Nullable Task result) { assertEquals(result, responseTask); latch.countDown(); } @Override public void onFailure(Throwable t) { fail(t.toString()); latch.countDown(); } }); assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true)); }