### Question:
JobService extends AbstractService { public Long triggerBuild(Job job) { checkArgumentNotNull(job, "Job cannot be null"); checkArgumentNotNull(job.getName(), "Job.name cannot be null"); client().postForLocation(SEGMENT_JOB + "/" + job.getName() + "/build", null); return job.getNextBuildNumber(); } 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 triggerBuild_WithNullJob_ThrowsException() throws Exception { service.triggerBuild(null); }
@Test(expected = IllegalArgumentException.class) public void triggerbuild_WithNullJobName_ThrowsException() throws Exception { service.triggerBuild(new Job()); }
@Test public void triggerBuild() throws Exception { Job job = new Job().setName("vacuum.my.room").setNextBuildNumber(new Long(23)); Long buildNumber = service.triggerBuild(job); verify(client).postForLocation("/job/vacuum.my.room/build", null); assertEquals(new Long(23), buildNumber); }
@Test(expected = IllegalArgumentException.class) public void triggerParameterizedBuild_withNullJob_throwsException() throws Exception { service.triggerBuild(null, new HashMap<String, Object>()); }
@Test(expected = IllegalArgumentException.class) public void triggerParameterizedBuild_withNullJobName_throwsException() throws Exception { service.triggerBuild(new Job(), new HashMap<String, Object>()); }
@Test(expected = IllegalArgumentException.class) public void triggerParameterizedBuild_withNullParameters_throwsException() throws Exception { service.triggerBuild(new Job().setName("vacuum.my.room"), null); }
@Test public void triggerParameterizedBuild() throws Exception { Job job = new Job().setName("vacuum.my.room").setNextBuildNumber(new Long(69)); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("param1", "value1"); parameters.put("param2", "value 2"); parameters.put("param3", true); parameters.put("param4", 69); parameters.put("param5", "The string ü@foo-bar"); Long buildNumber = service.triggerBuild(job, parameters); verify(client) .postForLocation( "/job/vacuum.my.room/buildWithParameters?param1=value1&param2=value+2&param3=true&param4=69&param5=The+string+%C3%BC%40foo-bar", null); assertEquals(new Long(69), buildNumber); }