コード例 #1
0
  @Override
  public void getHostConfig(AsyncMethodCallback<Host.AsyncClient.get_host_config_call> handler) {

    logger.info("Host get config complete invocation");

    if (null != getConfigFailure) {
      handler.onError(getConfigFailure);

    } else if (null != getConfigResultCode) {
      Host.AsyncClient.get_host_config_call getHostConfigCall =
          mock(Host.AsyncClient.get_host_config_call.class);
      GetConfigResponse getConfigResponse = new GetConfigResponse();
      getConfigResponse.setResult(getConfigResultCode);
      getConfigResponse.setHostConfig(hostConfig);

      try {
        when(getHostConfigCall.getResult()).thenReturn(getConfigResponse);
      } catch (TException e) {
        throw new RuntimeException("Failed to mock getHostConfigCall.getResult");
      }

      handler.onComplete(getHostConfigCall);

    } else {
      throw new IllegalStateException("No result or failure specified for getHostConfig");
    }
  }
コード例 #2
0
 @Override
 public void setHostMode(
     HostMode hostMode, AsyncMethodCallback<Host.AsyncClient.set_host_mode_call> callback) {
   if (this.setHostModeFailure != null) {
     callback.onError(this.setHostModeFailure);
   } else if (this.setHostModeResultCode != null) {
     Host.AsyncClient.set_host_mode_call call = mock(Host.AsyncClient.set_host_mode_call.class);
     SetHostModeResponse response = new SetHostModeResponse();
     response.setResult(this.setHostModeResultCode);
     try {
       when(call.getResult()).thenReturn(response);
     } catch (TException e) {
       throw new RuntimeException("Failed to mock setHostMode.getResult");
     }
     callback.onComplete(call);
   } else {
     throw new IllegalStateException("No result or failure specified for setHostMode");
   }
 }
コード例 #3
0
  @Override
  public void provision(
      String availabilityZone,
      List<String> datastores,
      Set<String> imageDatastoreNames,
      boolean usedForVMs,
      List<String> networks,
      String hostAddress,
      int hostPort,
      List<String> chairmanServerList,
      double memoryOvercommit,
      String loggingEndpoint,
      String logLevel,
      boolean managementOnly,
      String ntpEndpoint,
      String hostId,
      AsyncMethodCallback<Host.AsyncClient.provision_call> handler) {

    logger.info("Host provision complete invocation");

    if (null != provisionFailure) {
      handler.onError(provisionFailure);

    } else if (null != provisionResultCode) {
      Host.AsyncClient.provision_call provisionCall = mock(Host.AsyncClient.provision_call.class);
      ProvisionResponse provisionResponse = new ProvisionResponse();
      provisionResponse.setResult(provisionResultCode);

      try {
        when(provisionCall.getResult()).thenReturn(provisionResponse);
      } catch (TException e) {
        throw new RuntimeException("Failed to mock provisionCall.getResult");
      }

      handler.onComplete(provisionCall);

    } else {
      throw new IllegalStateException("No result or failure specified for provision");
    }
  }