@Test
 public void testGetChangesContainIssues() throws Exception {
   Job job = getJob();
   Build jobBuild = job.getBuild("lastCompletedBuild");
   ChangeSet buildChanges =
       client.getJobChanges(JenkinsClient.urlEncode(JENKINS_JOB), jobBuild.number);
   assertNotNull(buildChanges);
   for (ChangeSetItem changeItem : buildChanges.items) {
     assertNotNull(changeItem.issue);
   }
 }
  private Build buildJob(String jobPath)
      throws Exception, UnsupportedEncodingException, InterruptedException {
    Job job = null;
    AbstractNode result = client.execute(config.getUrl() + "/job/" + jobPath + "/build?delay=0sec");
    assertTrue(result instanceof ResetNode);
    for (int retryCount = 0;
        !(job = client.getJob(jobPath)).isBuilding() && retryCount < TEST_RETRY_COUNT;
        retryCount++) {
      Thread.sleep(TEST_RETRY_SLEEP);
    }

    return job.builds.get(0);
  }
  private Job getJobNotBuilding() throws Exception {
    Job job = null;
    for (int retryCount = 0;
        (job = client.getJob(JenkinsClient.urlEncode(JENKINS_JOB))).isBuilding()
            && retryCount < TEST_RETRY_COUNT;
        retryCount++) {
      Thread.sleep(TEST_RETRY_SLEEP);
    }

    if (job.isBuilding()) {
      throw new Exception("No jobs found in Jenkins Server");
    }

    return job;
  }
  @Test
  public void testCanStopBuild() throws Exception {
    Job job = getJobNotBuilding();
    Build build = buildJob(job.path);
    AbstractNode result =
        client.execute(config.getUrl() + "/job/" + job.path + "/" + build.number + "/stop");
    assertTrue(result instanceof ResetNode);
    for (int retryCount = 0;
        (job = client.getJob(job.path)).isBuilding() && retryCount < TEST_RETRY_COUNT;
        retryCount++) {
      Thread.sleep(TEST_RETRY_SLEEP);
    }

    assertEquals("aborted", job.builds.get(0).result.toLowerCase());
  }
 @Test
 public void testGetNotNullViewList() throws Exception {
   ViewList viewList = client.getViewList();
   assertNotNull(viewList);
   assertNotNull(viewList.getViews());
   assertNotNull(viewList.getPrimaryView());
 }
 private Build buildJob() throws UnsupportedEncodingException, InterruptedException, Exception {
   return buildJob(JenkinsClient.urlEncode(JENKINS_JOB));
 }
 @Test
 public void testCanTriggerBuildSuccessfully() throws Exception {
   JobName job = getJobNotBuilding();
   buildJob(job.path);
   assertTrue(client.getJob(job.path).isBuilding());
 }
 @Test
 public void testGetNotNullQueue() throws Exception {
   Queue queue = client.getQueue();
   assertNotNull(queue);
 }
 @Test
 public void testGetNotNullComputerList() throws Exception {
   ComputerList computerList = client.getComputerList();
   assertNotNull(computerList);
 }
 @Test
 public void testGetJobPath() throws Exception {
   Job job = getJob();
   assertNotNull(job);
   assertEquals(JenkinsClient.urlEncode(JENKINS_JOB), job.path);
 }
 private Job getJob() throws Exception {
   Job job = client.getJob(JenkinsClient.urlEncode(JENKINS_JOB));
   return job;
 }