### Question:
JobService extends AbstractService { public Build getBuild(Job job, Long buildNumber) { checkArgumentNotNull(job, "Job cannot be null"); return getBuild(job.getName(), buildNumber); } 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 getBuild_WithNullJob_ThrowsException() throws Exception { service.getBuild((Job) null, new Long(76)); }
@Test(expected = IllegalArgumentException.class) public void getBuild_WithNullJobName_ThrowsException() throws Exception { service.getBuild(new Job(), new Long(76)); }
@Test(expected = IllegalArgumentException.class) public void getBuild_WithNullBuildNumber_ThrowsException() throws Exception { service.getBuild(new Job().setName("vacuum.my.room"), null); }
@Test public void getBuild() throws Exception { Job job = new Job().setName("vacuum.my.room"); Build someBuild = new Build(); when(client.getForObject("/job/vacuum.my.room/69/api/xml", Build.class)).thenReturn(someBuild); assertEquals(someBuild, service.getBuild(job, new Long(69))); }
@Test public void getBuild_With404Response_ReturnsNull() throws Exception { Job job = new Job().setName("open.the.window"); HttpClientErrorException notFoundError = new HttpClientErrorException(HttpStatus.NOT_FOUND); when(client.getForObject("/job/open.the.window/72/api/xml", Build.class)).thenThrow(notFoundError); assertNull(service.getBuild(job, new Long(72))); }
@Test public void getBuild_With403Response_ThrowsException() throws Exception { Job job = new Job().setName("close.the.window"); HttpClientErrorException forbiddenError = new HttpClientErrorException(HttpStatus.FORBIDDEN); when(client.getForObject("/job/close.the.window/77/api/xml", Build.class)).thenThrow(forbiddenError); try { service.getBuild(job, new Long(77)); } catch (HttpClientErrorException expected) { assertEquals(forbiddenError, expected); } }