### Question:
JobService extends AbstractService { public Job getJob(String name) { checkArgumentNotNull(name, "Name cannot be null"); try { return client().getForObject(SEGMENT_JOB + "/" + name + SEGMENT_API_XML, Job.class); } catch (HttpClientErrorException e) { if (HttpStatus.NOT_FOUND == e.getStatusCode()) { return null; } throw e; } } JobService();  JobService(JenkinsClient client); List<Job> getJobs(); Job createJob(String name, JobConfiguration configuration); Job updateJob(String name, JobConfiguration configuration); Job updateJob(Job job, JobConfiguration configuration); void deleteJob(String name); void deleteJob(Job job); Job getJob(String name); JobConfiguration getJobConfiguration(Job job); JobConfiguration getJobConfiguration(String name); Long triggerBuild(Job job); Long triggerBuild(Job job, Map<String, Object> parameters); Build getBuild(Job job, Long buildNumber); Build getBuild(String name, Long buildNumber); Build triggerBuildAndWait(Job job); Build triggerBuildAndWait(Job job, Map<String, Object> parameters);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void getJob_WithNullName_ThrowsException() throws Exception { service.getJob(null); }
@Test public void getJob() throws Exception { Job job = new Job().setName("commit.your.changes"); when(client.getForObject("/job/commit.your.changes/api/xml", Job.class)).thenReturn(job); assertEquals(job, service.getJob("commit.your.changes")); }
@Test public void getJob_With404Response_ReturnsNull() throws Exception { HttpClientErrorException notFoundError = new HttpClientErrorException(HttpStatus.NOT_FOUND); when(client.getForObject("/job/paint.the.wall/api/xml", Job.class)).thenThrow(notFoundError); assertNull(service.getJob("paint.the.wall")); }
@Test public void getJob_With403Response_ThrowsException() throws Exception { HttpClientErrorException forbiddenError = new HttpClientErrorException(HttpStatus.FORBIDDEN); when(client.getForObject("/job/paint.the.wall/api/xml", Job.class)).thenThrow(forbiddenError); try { service.getJob("paint.the.wall"); } catch (HttpClientErrorException expected) { assertEquals(forbiddenError, expected); } }