/**
   * @param jobId
   * @throws InterruptedException
   */
  protected void jobStatus(String jobId) throws InterruptedException {
    System.out.println("Job ID : " + jobId);

    boolean jobContinue = true;
    do {
      AsyncJob<Object> asyncJob = client.getAsyncJobClient().getAsyncJob(jobId);
      AsyncJob.Status status = asyncJob.getStatus();

      switch (status) {
        case IN_PROGRESS:
          System.out.println("Job Status : IN_PROGRESS");
          break;
        case SUCCEEDED:
          jobContinue = false;
          System.out.println("Job Status : SUCCEDED");
          break;
        case FAILED:
          jobContinue = false;
          System.out.println("Job Status : FAILED");
          break;
        case UNKNOWN:
          jobContinue = false;
          System.out.println("Job Status : UNKNOWN");
          break;
      }

      Thread.sleep(5 * 1000);
    } while (jobContinue);
  }
  @Test
  public void testEnableDisableAccount() {
    skipIfNotGlobalAdmin();

    Account testAccount = null;
    try {
      testAccount = createTestAccount(globalAdminClient, prefix);

      AsyncCreateResponse response =
          domainAdminClient
              .getAccountClient()
              .disableAccount(testAccount.getName(), testAccount.getDomainId(), false);
      assertNotNull(response);
      assertTrue(jobComplete.apply(response.getJobId()));

      AsyncJob<Account> job =
          domainAdminClient.getAsyncJobClient().getAsyncJob(response.getJobId());
      assertEquals(job.getResult().getState(), Account.State.DISABLED);

      Account updated =
          domainAdminClient
              .getAccountClient()
              .enableAccount(testAccount.getName(), testAccount.getDomainId());
      assertNotNull(updated);
      assertEquals(updated.getState(), Account.State.ENABLED);

    } finally {
      if (testAccount != null) {
        globalAdminClient.getAccountClient().deleteAccount(testAccount.getId());
      }
    }
  }
Пример #3
0
  @Test(enabled = true, dependsOnMethods = "testRegisterTemplate")
  public void testExtractTemplate() throws Exception {
    // Initiate the extraction and wait for it to complete
    AsyncCreateResponse response =
        client
            .getTemplateClient()
            .extractTemplate(
                registeredTemplate.getId(),
                ExtractMode.HTTP_DOWNLOAD,
                registeredTemplate.getZoneId());
    assertTrue(jobComplete.apply(response.getJobId()), registeredTemplate.toString());

    // Get the result
    AsyncJob<TemplateExtraction> asyncJob =
        client.getAsyncJobClient().getAsyncJob(response.getJobId());
    TemplateExtraction extract = asyncJob.getResult();
    assertNotNull(extract);

    // Check that the URL can be retrieved
    String extractUrl = extract.getUrl();
    assertNotNull(extractUrl);
    URI uri = new URI(URLDecoder.decode(extractUrl, "utf-8"));
    assertTrue(context.utils().http().exists(uri), "does not exist: " + uri);
  }